Commit d431155b authored by Olivier Soldano's avatar Olivier Soldano Committed by Kateryna Kostiuk

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's avatarKateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
parent 49cb2918
......@@ -130,10 +130,6 @@ SET(ringclient_CONTROLLERS
src/VideoPrefsVC.mm
src/VideoPrefsVC.h
src/GeneralPrefsVC.h
src/HistoryVC.mm
src/HistoryVC.h
src/PersonsVC.mm
src/PersonsVC.h
src/ChatVC.mm
src/ChatVC.h
src/PersonLinkerVC.mm
......@@ -190,6 +186,8 @@ SET(ringclient_VIEWS
src/views/ITProgressIndicator.h
src/views/RingOutlineView.mm
src/views/RingOutlineView.h
src/views/RingTableView.mm
src/views/RingTableView.h
src/views/RingIDField.mm
src/views/RingIDField.h
src/views/HoverTableRowView.mm
......@@ -230,7 +228,8 @@ SET(ringclient_OTHERS
src/delegates/ImageManipulationDelegate.mm
src/delegates/ImageManipulationDelegate.h
src/AccountSelectionManager.h
src/AccountSelectionManager.mm)
src/AccountSelectionManager.mm
src/utils.h)
SET(ringclient_XIBS
......
This diff is collapsed.
This diff is collapsed.
......@@ -17,7 +17,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import <Cocoa/Cocoa.h>
#import "HistoryVC.h"
@interface RingWindowController : NSWindowController <NSSharingServicePickerDelegate> {
IBOutlet NSView *currentView;
......
......@@ -48,7 +48,6 @@
#import "views/BackgroundView.h"
#import "ChooseAccountVC.h"
#import "ContactRequestVC.h"
#import "PersonsVC.h"
@interface RingWindowController () <MigrateRingAccountsDelegate, NSToolbarDelegate>
......@@ -70,7 +69,6 @@
PreferencesWC* preferencesWC;
IBOutlet SmartViewVC* smartViewVC;
IBOutlet PersonsVC* personsVC;
CurrentCallVC* currentCallVC;
ConversationVC* offlineVC;
......@@ -106,6 +104,7 @@ NSString* const kTrustRequestMenuItemIdentifier = @"TrustRequestMenuItemIde
[currentCallVC initFrame];
[offlineVC initFrame];
[smartViewVC setConversationModel: [chooseAccountVC selectedAccount].conversationModel.get()];
// Fresh run, we need to make sure RingID appears
[shareButton sendActionOn:NSLeftMouseDownMask];
......@@ -306,9 +305,6 @@ NSString* const kTrustRequestMenuItemIdentifier = @"TrustRequestMenuItemIde
case 0:
[smartViewVC startCallForRow:sender];
break;
case 2:
[personsVC startCallForRow:sender];
break;
default:
break;
}
......
......@@ -19,10 +19,18 @@
#import <Cocoa/Cocoa.h>
namespace lrc {
namespace api {
class ConversationModel;
}
}
@interface SmartViewVC : NSViewController <NSTextFieldDelegate>
@property (unsafe_unretained) IBOutlet NSTabView* tabbar;
@property lrc::api::ConversationModel* conversationModel;
- (void)startCallForRow:(id)sender;
@end
This diff is collapsed.
/*
* Copyright (C) 2015-2016 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
* Copyright (C) 2017 Savoir-faire Linux Inc.
* Author: Anthony Léonard <anthony.leonard@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
......@@ -16,12 +16,28 @@
* 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>
#import "views/RingOutlineView.h"
#import <Foundation/Foundation.h>
#import <api/conversation.h>
#import <api/conversationmodel.h>
#import <api/account.h>
#import <api/contactmodel.h>
#import <api/contact.h>
@interface PersonsVC : NSViewController <NSOutlineViewDelegate, ContextMenuDelegate>
static inline NSString* bestIDForConversation(const lrc::api::conversation::Info& conv, const lrc::api::ConversationModel& model)
{
auto contact = model.owner.contactModel->getContact(conv.participants[0]);
if (!contact.registeredName.empty())
return @(contact.registeredName.c_str());
else
return @(contact.profileInfo.uri.c_str());
}
- (void)startCallForRow:(id)sender;
@end
static inline NSString* bestNameForConversation(const lrc::api::conversation::Info& conv, const lrc::api::ConversationModel& model)
{
auto contact = model.owner.contactModel->getContact(conv.participants[0]);
if (!contact.profileInfo.alias.empty())
return @(contact.profileInfo.alias.c_str());
else
return bestIDForConversation(conv, model);
}
......@@ -57,5 +57,5 @@
@end
// Used by the HoverTableRowView and the RingOutlineView
// Used by the HoverTableRowView and the RingTableView
void DrawSeparatorInRect(NSRect rect);
......@@ -17,11 +17,32 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import <Cocoa/Cocoa.h>
#import "views/RingOutlineView.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
@interface HistoryVC : NSViewController <NSOutlineViewDelegate, ContextMenuDelegate>
@property (nonatomic,weak) id <ContextMenuDelegate> contextMenuDelegate;
@property (nonatomic,weak) id <KeyboardShortcutDelegate> shortcutsDelegate;
@end
/*
* 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
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment