implement new conversation list

This patch is an implementation of the conversation list using the
conversation model recently introduced in LRC.
 - Unused HistoryVC and PersonsVC are removed from the code base as we
   are switching to a one list design.
 - Setting a conversation model on SmartListVC switches the displayed
   list.
 - Actions such as selecting a conversation, double clicking, call
   button and searching are also implemented (from the LRC point of
   view which may not yet be visible for user as of this patch).
 - As the new view is based on NSTableView rather than NSOutlineView,
   a RingTableView class is introduced based on RingOutlineView code.
 - The call button at the right of the search field is removed.

Change-Id: I668f102f435048d3c85efd22d1ab31b395139215
Reviewed-by: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
diff --git a/src/views/HoverTableRowView.h b/src/views/HoverTableRowView.h
index e477087..e89471b 100644
--- a/src/views/HoverTableRowView.h
+++ b/src/views/HoverTableRowView.h
@@ -57,5 +57,5 @@
 
 @end
 
-// Used by the HoverTableRowView and the RingOutlineView
+// Used by the HoverTableRowView and the RingTableView
 void DrawSeparatorInRect(NSRect rect);
diff --git a/src/views/RingTableView.h b/src/views/RingTableView.h
new file mode 100644
index 0000000..96d4a35
--- /dev/null
+++ b/src/views/RingTableView.h
@@ -0,0 +1,48 @@
+/*
+ *  Copyright (C) 2015-2016 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.
+ */
+
+#import <Cocoa/Cocoa.h>
+
+@protocol ContextMenuDelegate;
+@protocol ContextMenuDelegate
+
+@required
+
+- (NSMenu*) contextualMenuForIndex:(NSTreeNode*) path;
+
+@end
+
+@protocol KeyboardShortcutDelegate;
+@protocol KeyboardShortcutDelegate
+
+@optional
+
+/**
+ *  This shortcut has to respond to cmd (⌘) + a
+ */
+- (void) onAddShortcut;
+
+@end
+
+@interface RingTableView : NSTableView
+
+@property (nonatomic,weak) id <ContextMenuDelegate>         contextMenuDelegate;
+@property (nonatomic,weak) id <KeyboardShortcutDelegate>    shortcutsDelegate;
+
+@end
diff --git a/src/views/RingTableView.mm b/src/views/RingTableView.mm
new file mode 100644
index 0000000..6363b00
--- /dev/null
+++ b/src/views/RingTableView.mm
@@ -0,0 +1,99 @@
+/*
+ *  Copyright (C) 2015-2016 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.
+ */
+
+#import "RingTableView.h"
+
+#import "HoverTableRowView.h" // For the grid drawing shared code
+
+@implementation RingTableView
+
+- (NSMenu*)menuForEvent:(NSEvent*)evt
+{
+    // TODO : Reimplement without outlineView itemAtRow: method
+//    NSPoint pt = [self convertPoint:[evt locationInWindow] fromView:nil];
+//    int rowIdx = [self rowAtPoint:pt];
+//    if (self.contextMenuDelegate && rowIdx >= 0) {
+//        return [self.contextMenuDelegate contextualMenuForIndex:[self itemAtRow:rowIdx]];
+//    }
+    return nil;
+}
+
+- (void)keyDown:(NSEvent *)theEvent
+{
+    // Handle the Tab key
+    if ([[theEvent characters] characterAtIndex:0] == NSTabCharacter) {
+        if (([theEvent modifierFlags] & NSShiftKeyMask) != NSShiftKeyMask) {
+            [[self window] selectKeyViewFollowingView:self];
+        } else {
+            [[self window] selectKeyViewPrecedingView:self];
+        }
+    }
+    else if (([theEvent modifierFlags] & NSCommandKeyMask) == NSCommandKeyMask) {
+        if (self.shortcutsDelegate) {
+            if ([[theEvent characters] characterAtIndex:0] == 'a') {
+                [self.shortcutsDelegate onAddShortcut];
+            }
+        }
+    } else
+        [super keyDown:theEvent];
+}
+
+- (CGFloat)yPositionPastLastRow {
+    // Only draw the grid past the last visible row
+    NSInteger numberOfRows = self.numberOfRows;
+    CGFloat yStart = 0;
+    if (numberOfRows > 0) {
+        yStart = NSMaxY([self rectOfRow:numberOfRows - 1]);
+    }
+    return yStart;
+}
+
+- (void)drawGridInClipRect:(NSRect)clipRect {
+    // Only draw the grid past the last visible row
+    CGFloat yStart = [self yPositionPastLastRow];
+    // Draw the first separator one row past the last row
+    yStart += self.rowHeight;
+
+    // One thing to do is smarter clip testing to see if we actually need to draw!
+    NSRect boundsToDraw = self.bounds;
+    NSRect separatorRect = boundsToDraw;
+    separatorRect.size.height = 1;
+    while (yStart < NSMaxY(boundsToDraw)) {
+        separatorRect.origin.y = yStart;
+        DrawSeparatorInRect(separatorRect);
+        yStart += self.rowHeight;
+    }
+}
+
+- (void)setFrameSize:(NSSize)size {
+    [super setFrameSize:size];
+    // We need to invalidate more things when live-resizing since we fill with a gradient and stroke
+    if ([self inLiveResize]) {
+        CGFloat yStart = [self yPositionPastLastRow];
+        if (NSHeight(self.bounds) > yStart) {
+            // Redraw our horizontal grid lines
+            NSRect boundsPastY = self.bounds;
+            boundsPastY.size.height -= yStart;
+            boundsPastY.origin.y = yStart;
+            [self setNeedsDisplayInRect:boundsPastY];
+        }
+    }
+}
+
+@end