Commit 9dd759cd authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

Smart View: contextual menu for not selected row

Contextual menu item - "add contact" works only when row is selected.
This patch change it and now contact could be added regardless of row
selection.

Change-Id: I1f0ec195c478faf46de031c8b4ac38a0469116ba
Reviewed-by: default avatarAnthony Léonard <anthony.leonard@savoirfairelinux.com>
parent b90f92af
......@@ -230,10 +230,12 @@ NSInteger const PHOTO_TAG = 400;
if (!contactmethod->contact() || contactmethod->contact()->isPlaceHolder()) {
NSMenu *theMenu = [[NSMenu alloc]
initWithTitle:@""];
[theMenu insertItemWithTitle:NSLocalizedString(@"Add to contacts", @"Contextual menu action")
action:@selector(addToContact)
keyEquivalent:@"a"
atIndex:0];
NSMenuItem* addContactItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Add to contacts", @"Contextual menu action")
action:@selector(addContactForRow:)
keyEquivalent:@""];
[addContactItem setRepresentedObject:item];
[theMenu addItem:addContactItem];
return theMenu;
}
}
......@@ -272,6 +274,16 @@ NSInteger const PHOTO_TAG = 400;
}
}
- (void) addContactForRow:(id) sender
{
NSInteger row = [historyView rowForItem:[sender representedObject]];
if(row < 0) {
return;
}
[historyView selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO];
[self addToContact];
}
#pragma mark - NSPopOverDelegate
- (void)popoverDidClose:(NSNotification *)notification
......
......@@ -477,6 +477,16 @@ NSInteger const PRESENCE_TAG = 800;
}
}
- (void) addContactForRow:(id) sender
{
NSInteger row = [smartView rowForItem:[sender representedObject]];
if(row < 0) {
return;
}
[smartView selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO];
[self addToContact];
}
/**
Copy a NSString in the general Pasteboard
......@@ -572,10 +582,11 @@ NSInteger const PRESENCE_TAG = 800;
&& !contactmethods.first()->contact()
|| contactmethods.first()->contact()->isPlaceHolder()) {
[theMenu insertItemWithTitle:NSLocalizedString(@"Add to contacts", @"Contextual menu action")
action:@selector(addToContact)
keyEquivalent:@"a"
atIndex:theMenu.itemArray.count];
NSMenuItem* addContactItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Add to contacts", @"Contextual menu action")
action:@selector(addContactForRow:)
keyEquivalent:@""];
[addContactItem setRepresentedObject:item];
[theMenu addItem:addContactItem];
} else if (auto person = contactmethods.first()->contact()) {
NSMenuItem* copyNameItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Copy name", @"Contextual menu action")
action:@selector(copyStringToPasteboard:)
......
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