Switch to native frameworks
We now build a Cocoa application built on LibRingClient.
Qt bindings are working (need stabilization)
Refs #64818
diff --git a/ConversationsViewController.mm b/ConversationsViewController.mm
new file mode 100644
index 0000000..8581ce3
--- /dev/null
+++ b/ConversationsViewController.mm
@@ -0,0 +1,146 @@
+//
+// ConversationsViewController.m
+// Ring
+//
+// Created by Alexandre Lision on 2015-02-02.
+//
+//
+
+#import "ConversationsViewController.h"
+#import <callmodel.h>
+
+#define COLUMNID_CONVERSATIONS @"ConversationsColumn" // the single column name in our outline view
+
+@interface ConversationsViewController ()
+
+@end
+
+@implementation ConversationsViewController
+@synthesize conversationsView;
+@synthesize treeController;
+
+- (id)initWithCoder:(NSCoder *)aDecoder
+{
+ if (self = [super initWithCoder:aDecoder]) {
+ NSLog(@"INIT Conversations VC");
+ }
+ return self;
+}
+
+
+
+- (void)awakeFromNib
+{
+ NSLog(@"awakeFromNib");
+
+ 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"];
+}
+
+#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;
+ if ([[tableColumn identifier] isEqualToString:COLUMNID_CONVERSATIONS])
+ {
+
+ NSIndexPath* idx = ((NSTreeNode*)item).indexPath;
+ NSUInteger myArray[[idx length]];
+ [idx getIndexes:myArray];
+
+ NSLog(@"dataCellForTableColumn, indexPath: %lu", (unsigned long)myArray[0]);
+
+ QModelIndex qIdx = CallModel::instance()->index(myArray[0], 0);
+
+ QVariant test = CallModel::instance()->data(qIdx, Qt::DisplayRole);
+ }
+
+ 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])
+ {
+ NSIndexPath* idx = ((NSTreeNode*)item).indexPath;
+ NSUInteger myArray[[idx length]];
+ [idx getIndexes:myArray];
+ NSLog(@"array:%@", idx);
+
+ QModelIndex qIdx;
+ if(idx.length == 2)
+ qIdx = CallModel::instance()->index(myArray[1], 0, CallModel::instance()->index(myArray[0], 0));
+ else
+ qIdx = CallModel::instance()->index(myArray[0], 0);
+
+
+ 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
+ NSLog(@"outlineViewSelectionDidChange!!");
+}
+
+
+@end