Add delete action to Open Favorites

This only works for Recent Projects (not Favorites).

Also, the key equivalent for this is ⌘⌫. The Edit → Delete menu item will not work (as it’s being sent to the input field).
This commit is contained in:
Allan Odgaard
2014-02-07 19:52:56 +07:00
parent 6ab6c3f43b
commit 48e3796f87

View File

@@ -2,6 +2,7 @@
#import <OakFilterList/OakAbbreviations.h>
#import <OakAppKit/OakUIConstructionFunctions.h>
#import <OakAppKit/OakScopeBarView.h>
#import <OakAppKit/OakSound.h>
#import <OakFoundation/NSString Additions.h>
#import <OakSystem/application.h>
#import <text/ranker.h>
@@ -223,6 +224,29 @@ static NSUInteger const kOakSourceIndexFavorites = 1;
[super accept:sender];
}
- (void)delete:(id)sender
{
NSArray* items = self.selectedItems;
if(!items.count)
return;
for(NSDictionary* item in items)
{
NSString* path = item[@"path"];
if(self.sourceIndex == kOakSourceIndexRecentProjects)
{
KVDB* db = [self sharedProjectStateDB];
[db removeObjectForKey:path];
}
else if(self.sourceIndex == kOakSourceIndexFavorites)
{
NSLog(@"%s %@", sel_getName(_cmd), path);
}
}
[self loadItems:self];
OakPlayUISound(OakSoundDidTrashItemUISound);
}
- (void)takeSourceIndexFrom:(id)sender
{
if([sender respondsToSelector:@selector(tag)])