Commit 4dfcafc0 authored by Alexandre Lision's avatar Alexandre Lision

smartview: refactor left panel

Major rewrite of the main left panel UI

- remove the ongoing calls treeview
- default to smartview treeview
- remove call field from toolbar and display it on top of left panel
- add access to alphabetical contacts treeview
- add access to history

Issue: #79398
Change-Id: Iac36b6f4ace30cdb70c4dcf619d64cd91b84c95c
parent 004ccbb5
......@@ -77,8 +77,6 @@ SET(ringclient_CONTROLLERS
src/RingWizardWC.h
src/RingWindowController.mm
src/RingWindowController.h
src/ConversationsVC.mm
src/ConversationsVC.h
src/PreferencesVC.mm
src/PreferencesVC.h
src/AccGeneralVC.mm
......@@ -111,7 +109,9 @@ SET(ringclient_CONTROLLERS
src/ChatVC.mm
src/ChatVC.h
src/PersonLinkerVC.mm
src/PersonLinkerVC.h)
src/PersonLinkerVC.h
src/SmartViewVC.mm
src/SmartViewVC.h)
SET(ringclient_BACKENDS
src/backends/AddressBookBackend.mm
......@@ -122,8 +122,6 @@ SET(ringclient_VIEWS
src/views/CallView.h
src/views/ITProgressIndicator.mm
src/views/ITProgressIndicator.h
src/views/PersonCell.mm
src/views/PersonCell.h
src/views/RingOutlineView.mm
src/views/RingOutlineView.h
src/views/RingIDField.mm
......@@ -175,9 +173,14 @@ ${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_mute_audio.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_chat.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_search.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_quality.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_call_received.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_call_missed.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_call_made.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ancrage.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/audio.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_person_add.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_persons.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_history.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/general.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/video.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_video.png)
......
/*
* Copyright (C) 2004-2015 Savoir-Faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef CONVERSATIONSVC_H
#define CONVERSATIONSVC_H
#import <Cocoa/Cocoa.h>
#import "QNSTreeController.h"
@interface ConversationsVC : NSViewController <NSOutlineViewDelegate> {
}
@end
#endif // CONVERSATIONSVC_H
/*
* Copyright (C) 2004-2015 Savoir-Faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#import "ConversationsVC.h"
#import <callmodel.h>
#import <QtCore/qitemselectionmodel.h>
#define COLUMNID_CONVERSATIONS @"ConversationsColumn" // the single column name in our outline view
@interface ConversationsVC ()
@property QNSTreeController *treeController;
@property (assign) IBOutlet NSOutlineView *conversationsView;
@end
@implementation ConversationsVC
@synthesize conversationsView;
@synthesize treeController;
- (void)awakeFromNib
{
NSLog(@"INIT Conversations VC");
treeController = [[QNSTreeController alloc] initWithQModel:CallModel::instance()];
[treeController setAvoidsEmptySelection:NO];
[treeController setChildrenKeyPath:@"children"];
[self.conversationsView bind:@"content" toObject:treeController withKeyPath:@"arrangedObjects" options:nil];
[self.conversationsView bind:@"sortDescriptors" toObject:treeController withKeyPath:@"sortDescriptors" options:nil];
[self.conversationsView bind:@"selectionIndexPaths" toObject:treeController withKeyPath:@"selectionIndexPaths" options:nil];
NSInteger idx = [conversationsView columnWithIdentifier:COLUMNID_CONVERSATIONS];
[[[[self.conversationsView tableColumns] objectAtIndex:idx] headerCell] setStringValue:@"Conversations"];
QObject::connect(CallModel::instance(),
&QAbstractItemModel::dataChanged,
[=](const QModelIndex &topLeft, const QModelIndex &bottomRight) {
[conversationsView reloadDataForRowIndexes:
[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(topLeft.row(), bottomRight.row() + 1)]
columnIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, conversationsView.tableColumns.count)]];
});
}
#pragma mark - NSOutlineViewDelegate methods
// -------------------------------------------------------------------------------
// shouldSelectItem:item
// -------------------------------------------------------------------------------
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item;
{
return YES;
}
// -------------------------------------------------------------------------------
// dataCellForTableColumn:tableColumn:item
// -------------------------------------------------------------------------------
- (NSCell *)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
NSCell *returnCell = [tableColumn dataCell];
if(item == nil)
return returnCell;
return returnCell;
}
// -------------------------------------------------------------------------------
// textShouldEndEditing:fieldEditor
// -------------------------------------------------------------------------------
- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor
{
if ([[fieldEditor string] length] == 0)
{
// don't allow empty node names
return NO;
}
else
{
return YES;
}
}
// -------------------------------------------------------------------------------
// shouldEditTableColumn:tableColumn:item
//
// Decide to allow the edit of the given outline view "item".
// -------------------------------------------------------------------------------
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
return NO;
}
// -------------------------------------------------------------------------------
// outlineView:willDisplayCell:forTableColumn:item
// -------------------------------------------------------------------------------
- (void)outlineView:(NSOutlineView *)olv willDisplayCell:(NSCell*)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
if ([[tableColumn identifier] isEqualToString:COLUMNID_CONVERSATIONS])
{
QModelIndex qIdx = [treeController toQIdx:((NSTreeNode*)item)];
if(qIdx.isValid())
cell.title = CallModel::instance()->data(qIdx, Qt::DisplayRole).toString().toNSString();
}
}
// -------------------------------------------------------------------------------
// outlineViewSelectionDidChange:notification
// -------------------------------------------------------------------------------
- (void)outlineViewSelectionDidChange:(NSNotification *)notification
{
// ask the tree controller for the current selection
if([[treeController selectedNodes] count] > 0) {
QModelIndex qIdx = [treeController toQIdx:[treeController selectedNodes][0]];
//Update details view by changing selection
CallModel::instance()->selectionModel()->setCurrentIndex(qIdx, QItemSelectionModel::ClearAndSelect);
} else {
CallModel::instance()->selectionModel()->clearCurrentIndex();
}
}
@end
/*
* Copyright (C) 2004-2015 Savoir-Faire Linux Inc.
* Copyright (C) 2015 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
......@@ -15,20 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef CURRENTCALLVC_H
#define CURRENTCALLVC_H
#import <Cocoa/Cocoa.h>
......@@ -43,5 +30,3 @@ class Call;
- (void) initFrame;
@end
#endif // CURRENTCALLVC_H
\ No newline at end of file
/*
* Copyright (C) 2004-2015 Savoir-Faire Linux Inc.
* Copyright (C) 2015 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
......@@ -15,17 +15,6 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#import "CurrentCallVC.h"
......@@ -436,6 +425,8 @@
[self connectVideoSignals];
/* check if text media is already present */
if(!CallModel::instance()->selectedCall())
return;
if (CallModel::instance()->selectedCall()->hasMedia(Media::Media::Type::TEXT, Media::Media::Direction::IN)) {
Media::Text *text = CallModel::instance()->selectedCall()->firstMedia<Media::Text>(Media::Media::Direction::IN);
[self monitorIncomingTextMessages:text];
......
/*
* Copyright (C) 2004-2015 Savoir-Faire Linux Inc.
* Copyright (C) 2015 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
......@@ -15,28 +15,10 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef HISTORYVIEWCONTROLLER_H
#define HISTORYVIEWCONTROLLER_H
#import <Cocoa/Cocoa.h>
#import "views/RingOutlineView.h"
@interface HistoryVC : NSViewController <NSOutlineViewDelegate, ContextMenuDelegate> {
}
@interface HistoryVC : NSViewController <NSOutlineViewDelegate, ContextMenuDelegate>
@end
#endif // HISTORYVIEWCONTROLLER_H
This diff is collapsed.
......@@ -15,17 +15,6 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#import <Cocoa/Cocoa.h>
......
......@@ -15,17 +15,6 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#import "PersonLinkerVC.h"
......@@ -43,12 +32,6 @@
#import "QNSTreeController.h"
#import "delegates/ImageManipulationDelegate.h"
#import "views/PersonCell.h"
#define FIRSTNAME_TAG 1
#define LASTNAME_TAG 2
#define COLUMNID_NAME @"NameColumn"
class OnlyPersonProxyModel : public QSortFilterProxyModel
{
......@@ -65,31 +48,31 @@ public:
}
};
@interface PersonLinkerVC () <NSTextFieldDelegate, NSComboBoxDelegate, NSComboBoxDataSource>
@interface PersonLinkerVC () <NSTextFieldDelegate, NSComboBoxDelegate, NSComboBoxDataSource> {
@property QSortFilterProxyModel* contactProxyModel;
@property QNSTreeController* treeController;
@property (unsafe_unretained) IBOutlet NSTextField *contactMethodLabel;
@property (unsafe_unretained) IBOutlet NSOutlineView *personsView;
@property (unsafe_unretained) IBOutlet NSTextField *firstNameField;
@property (unsafe_unretained) IBOutlet NSTextField *lastNameField;
@property (unsafe_unretained) IBOutlet NSButton *createNewContactButton;
@property (unsafe_unretained) IBOutlet NSComboBox *categoryComboBox;
@property (strong) IBOutlet NSView *createContactSubview;
@property (unsafe_unretained) IBOutlet NSView *linkToExistingSubview;
__unsafe_unretained IBOutlet NSTextField *contactMethodLabel;
__unsafe_unretained IBOutlet NSOutlineView *personsView;
__unsafe_unretained IBOutlet NSTextField *firstNameField;
__unsafe_unretained IBOutlet NSTextField *lastNameField;
__unsafe_unretained IBOutlet NSButton *createNewContactButton;
__unsafe_unretained IBOutlet NSComboBox *categoryComboBox;
__unsafe_unretained IBOutlet NSView *linkToExistingSubview;
QSortFilterProxyModel* contactProxyModel;
QNSTreeController* treeController;
IBOutlet NSView *createContactSubview;
}
@end
@implementation PersonLinkerVC
@synthesize treeController;
@synthesize personsView;
@synthesize contactProxyModel;
@synthesize contactMethodLabel;
@synthesize categoryComboBox, firstNameField, lastNameField;
@synthesize createContactSubview, linkToExistingSubview, createNewContactButton;
// Tags for views
NSInteger const FIRSTNAME_TAG = 1;
NSInteger const LASTNAME_TAG = 2;
NSInteger const IMAGE_TAG = 100;
NSInteger const DISPLAYNAME_TAG = 200;
NSInteger const DETAILS_TAG = 300;
-(void) awakeFromNib
{
......@@ -196,24 +179,7 @@ public:
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item;
{
QModelIndex qIdx = [treeController toQIdx:((NSTreeNode*)item)];
if(!qIdx.isValid())
return NO;
if(qIdx.parent().isValid()) {
return NO;
} else {
return YES;
}
}
// -------------------------------------------------------------------------------
// dataCellForTableColumn:tableColumn:item
// -------------------------------------------------------------------------------
- (NSCell *)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
QModelIndex qIdx = [treeController toQIdx:((NSTreeNode*)item)];
PersonCell *returnCell = [tableColumn dataCell];
return returnCell;
return qIdx.isValid();
}
// -------------------------------------------------------------------------------
......@@ -226,31 +192,34 @@ public:
return NO;
}
// -------------------------------------------------------------------------------
// outlineView:willDisplayCell:forTableColumn:item
// -------------------------------------------------------------------------------
- (void)outlineView:(NSOutlineView *)olv willDisplayCell:(NSCell*)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
/* View Based OutlineView: See the delegate method -tableView:viewForTableColumn:row: in NSTableView.
*/
- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
QModelIndex qIdx = [treeController toQIdx:((NSTreeNode*)item)];
if(!qIdx.isValid()) {
[((PersonCell *)cell) setPersonImage:nil];
return;
}
if ([[tableColumn identifier] isEqualToString:COLUMNID_NAME])
{
PersonCell *pCell = (PersonCell *)cell;
[pCell setPersonImage:nil];
if(!qIdx.parent().isValid()) {
pCell.title = qIdx.data(Qt::DisplayRole).toString().toNSString();
Person* p = qvariant_cast<Person*>(qIdx.data((int)Person::Role::Object));
QVariant photo = GlobalInstances::pixmapManipulator().contactPhoto(p, QSize(35,35));
[pCell setPersonImage:QtMac::toNSImage(qvariant_cast<QPixmap>(photo))];
} else {
pCell.title = qIdx.data(Qt::DisplayRole).toString().toNSString();
NSTableCellView *result = [outlineView makeViewWithIdentifier:@"MainCell" owner:outlineView];
NSImageView* photoView = [result viewWithTag:IMAGE_TAG];
NSTextField* displayName = [result viewWithTag:DISPLAYNAME_TAG];
}
if (!qIdx.isValid()) {
[photoView setImage:nil];
[displayName setStringValue:qIdx.data(Qt::DisplayRole).toString().toNSString()];
return result;
}
if (auto p = qvariant_cast<Person*>(qIdx.data((int)Person::Role::Object))) {
QVariant photo = GlobalInstances::pixmapManipulator().contactPhoto(p, QSize(35,35));
[photoView setImage:QtMac::toNSImage(qvariant_cast<QPixmap>(photo))];
} else {
QVariant photo = GlobalInstances::pixmapManipulator().contactPhoto(nil, QSize(35,35));
[photoView setImage:QtMac::toNSImage(qvariant_cast<QPixmap>(photo))];
}
[displayName setStringValue:qIdx.data(Qt::DisplayRole).toString().toNSString()];
return result;
}
// -------------------------------------------------------------------------------
......@@ -259,7 +228,7 @@ public:
- (CGFloat)outlineView:(NSOutlineView *)outlineView heightOfRowByItem:(id)item
{
return 45.0;
return 60.0;
}
#pragma mark - NSTextFieldDelegate
......
/*
* Copyright (C) 2004-2015 Savoir-Faire Linux Inc.
* Copyright (C) 2015 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
......@@ -15,17 +15,6 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#import <Cocoa/Cocoa.h>
......
......@@ -15,17 +15,6 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#import "PersonsVC.h"
......@@ -47,9 +36,6 @@
#import "backends/AddressBookBackend.h"
#import "QNSTreeController.h"
#import "delegates/ImageManipulationDelegate.h"
#import "views/PersonCell.h"
#define COLUMNID_NAME @"NameColumn"
class ReachablePersonModel : public QSortFilterProxyModel
{
......@@ -65,18 +51,23 @@ public:
};
@interface PersonsVC ()
@interface PersonsVC () {
@property QNSTreeController *treeController;
@property (assign) IBOutlet NSOutlineView *personsView;
@property QSortFilterProxyModel *contactProxyModel;
QNSTreeController *treeController;
__unsafe_unretained IBOutlet NSOutlineView *personsView;
QSortFilterProxyModel *contactProxyModel;
}
@end
@implementation PersonsVC
@synthesize treeController;
@synthesize personsView;
@synthesize contactProxyModel;
// Tags for views
NSInteger const IMAGE_TAG = 100;
NSInteger const DISPLAYNAME_TAG = 200;
NSInteger const DETAILS_TAG = 300;
NSInteger const CALL_BUTTON_TAG = 400;
-(void) awakeFromNib
{
......@@ -113,7 +104,7 @@ public:
QVariant var = qIdx.data((int)Person::Role::Object);
if (var.isValid()) {
Person *c = var.value<Person*>();
if (c->phoneNumbers().size() == 1) {
if (c->phoneNumbers().size() > 0) {
m = c->phoneNumbers().first();
}
}
......@@ -127,7 +118,7 @@ public:
if(m){
Call* c = CallModel::instance()->dialingCall();
c->setDialNumber(m);
c->setPeerContactMethod(m);
c << Call::Action::ACCEPT;
}
}
......@@ -151,26 +142,6 @@ public:
}
}
// -------------------------------------------------------------------------------
// dataCellForTableColumn:tableColumn:item
// -------------------------------------------------------------------------------
- (NSCell *)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
QModelIndex qIdx = [treeController toQIdx:((NSTreeNode*)item)];
PersonCell *returnCell = [tableColumn dataCell];
if(!qIdx.isValid())
return returnCell;
if(!qIdx.parent().isValid()) {
[returnCell setDrawsBackground:YES];
[returnCell setBackgroundColor:[NSColor selectedControlColor]];
} else {
[returnCell setDrawsBackground:NO];
}
return returnCell;
}
// -------------------------------------------------------------------------------
// textShouldEndEditing:fieldEditor
// -------------------------------------------------------------------------------
......@@ -197,30 +168,43 @@ public:
return NO;
}
// -------------------------------------------------------------------------------
// outlineView:willDisplayCell:forTableColumn:item
// -------------------------------------------------------------------------------
- (void)outlineView:(NSOutlineView *)olv willDisplayCell:(NSCell*)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
/* View Based OutlineView: See the delegate method -tableView:viewForTableColumn:row: in NSTableView.
*/
- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
QModelIndex qIdx = [treeController toQIdx:((NSTreeNode*)item)];
if(!qIdx.isValid())
return;
if ([[tableColumn identifier] isEqualToString:COLUMNID_NAME])
{
PersonCell *pCell = (PersonCell *)cell;
[pCell setPersonImage:nil];
if(!qIdx.parent().isValid()) {
pCell.title = qIdx.data(Qt::DisplayRole).toString().toNSString();
} else {
pCell.title = qIdx.data(Qt::DisplayRole).toString().toNSString();
if(((NSTreeNode*)item).indexPath.length == 2) {
Person* p = qvariant_cast<Person*>(qIdx.data((int)Person::Role::Object));
QVariant photo = GlobalInstances::pixmapManipulator().contactPhoto(p, QSize(35,35));
[pCell setPersonImage:QtMac::toNSImage(qvariant_cast<QPixmap>(photo))];
}
}
NSTableCellView *result;
if(!qIdx.parent().isValid()) {
result = [outlineView makeViewWithIdentifier:@"LetterCell" owner:outlineView];
[result setWantsLayer:YES];
[result setLayer:[CALayer layer]];
[result.layer setBackgroundColor:[NSColor selectedControlColor].CGColor];
} else if(((NSTreeNode*)item).indexPath.length == 2) {
result = [outlineView makeViewWithIdentifier:@"MainCell" owner:outlineView];
NSImageView* photoView = [result viewWithTag:IMAGE_TAG];
Person* p = qvariant_cast<Person*>(qIdx.data((int)Person::Role::Object));
QVariant photo = GlobalInstances::pixmapManipulator().contactPhoto(p, QSize(35,35));
[photoView setImage:QtMac::toNSImage(qvariant_cast<QPixmap>(photo))];
NSTextField* details = [result viewWithTag:DETAILS_TAG];
if (p && p->phoneNumbers().size() > 0)
[details setStringValue:p->phoneNumbers().first()->uri().toNSString()];
} else {
result = [outlineView makeViewWithIdentifier:@"ContactMethodCell" owner:outlineView];
}
NSTextField* displayName = [result viewWithTag:DISPLAYNAME_TAG];
[displayName setStringValue:qIdx.data(Qt::DisplayRole).toString().toNSString()];
return result;
}
- (IBAction)callClickedAtRow:(id)sender {
NSInteger row = [personsView rowForView:sender];
[personsView selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO];
[self callContact:nil];
}
// -------------------------------------------------------------------------------
......@@ -234,11 +218,7 @@ public:
- (CGFloat)outlineView:(NSOutlineView *)outlineView heightOfRowByItem:(id)item
{
QModelIndex qIdx = [treeController toQIdx:((NSTreeNode*)item)];
if(!qIdx.parent().isValid()) {
return 20.0;
} else {
return 45.0;
}
return (((NSTreeNode*)item).indexPath.length == 2) ? 60.0 : 20.0;
}
@end
/*
* Copyright (C) 2004-2015 Savoir-Faire Linux Inc.
* Copyright (C) 2015 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
......@@ -15,20 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef QNSTREECONTROLLER_H
#define QNSTREECONTROLLER_H
#import <Cocoa/Cocoa.h>
#import <qabstractitemmodel.h>
......@@ -43,5 +30,3 @@
- (QModelIndex) indexPathtoQIdx:(NSIndexPath*) path;
@end
#endif // QNSTREECONTROLLER_H
\ No newline at end of file
/*
* Copyright (C) 2004-2015 Savoir-Faire Linux Inc.