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
diff --git a/src/PersonsVC.mm b/src/PersonsVC.mm
index 4523620..182bc00 100644
--- a/src/PersonsVC.mm
+++ b/src/PersonsVC.mm
@@ -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 @@
};
-@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 @@
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 @@
if(m){
Call* c = CallModel::instance()->dialingCall();
- c->setDialNumber(m);
+ c->setPeerContactMethod(m);
c << Call::Action::ACCEPT;
}
}
@@ -152,26 +143,6 @@
}
// -------------------------------------------------------------------------------
-// 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
// -------------------------------------------------------------------------------
- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor
@@ -197,30 +168,43 @@
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 @@
- (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