Context bar display now works again. Search is still broken

This commit is contained in:
michael starke
2014-02-27 01:40:50 +01:00
parent 61310d2300
commit ffabda0242
7 changed files with 58 additions and 54 deletions

2
HNHUi

Submodule HNHUi updated: b915d2b150...05245dc6a6

View File

@@ -102,7 +102,6 @@
4C46E09E17673A0A00DA62E8 /* HNHShadowBox.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C46E09D17673A0A00DA62E8 /* HNHShadowBox.m */; }; 4C46E09E17673A0A00DA62E8 /* HNHShadowBox.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C46E09D17673A0A00DA62E8 /* HNHShadowBox.m */; };
4C473A7F18AFD6340073FD2E /* KPKTestReference.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C473A7E18AFD6340073FD2E /* KPKTestReference.m */; }; 4C473A7F18AFD6340073FD2E /* KPKTestReference.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C473A7E18AFD6340073FD2E /* KPKTestReference.m */; };
4C473A8718AFD85B0073FD2E /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C473A8518AFD7250073FD2E /* XCTest.framework */; }; 4C473A8718AFD85B0073FD2E /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C473A8518AFD7250073FD2E /* XCTest.framework */; };
4C48A56218BE932100278A2D /* HNHCommon.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C48A56118BE932100278A2D /* HNHCommon.m */; };
4C4A100F176286FD00BBF2CA /* MPTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C4A100E176286FD00BBF2CA /* MPTableView.m */; }; 4C4A100F176286FD00BBF2CA /* MPTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C4A100E176286FD00BBF2CA /* MPTableView.m */; };
4C4B7EE917A45EC6000234C7 /* MPDatePickingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C4B7EE717A45EC5000234C7 /* MPDatePickingViewController.m */; }; 4C4B7EE917A45EC6000234C7 /* MPDatePickingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C4B7EE717A45EC5000234C7 /* MPDatePickingViewController.m */; };
4C4B7EEA17A45EC6000234C7 /* DatePickingView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C4B7EE817A45EC5000234C7 /* DatePickingView.xib */; }; 4C4B7EEA17A45EC6000234C7 /* DatePickingView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C4B7EE817A45EC5000234C7 /* DatePickingView.xib */; };
@@ -521,7 +520,6 @@
4C473A7E18AFD6340073FD2E /* KPKTestReference.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKTestReference.m; sourceTree = "<group>"; }; 4C473A7E18AFD6340073FD2E /* KPKTestReference.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKTestReference.m; sourceTree = "<group>"; };
4C473A8518AFD7250073FD2E /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 4C473A8518AFD7250073FD2E /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
4C48A56018BE932100278A2D /* HNHCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HNHCommon.h; sourceTree = "<group>"; }; 4C48A56018BE932100278A2D /* HNHCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HNHCommon.h; sourceTree = "<group>"; };
4C48A56118BE932100278A2D /* HNHCommon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HNHCommon.m; sourceTree = "<group>"; };
4C4A100D176286FD00BBF2CA /* MPTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPTableView.h; sourceTree = "<group>"; }; 4C4A100D176286FD00BBF2CA /* MPTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPTableView.h; sourceTree = "<group>"; };
4C4A100E176286FD00BBF2CA /* MPTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPTableView.m; sourceTree = "<group>"; }; 4C4A100E176286FD00BBF2CA /* MPTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPTableView.m; sourceTree = "<group>"; };
4C4B7EE617A45EC5000234C7 /* MPDatePickingViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPDatePickingViewController.h; sourceTree = "<group>"; }; 4C4B7EE617A45EC5000234C7 /* MPDatePickingViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPDatePickingViewController.h; sourceTree = "<group>"; };
@@ -1593,7 +1591,6 @@
4CFDDDE7185E92A600A9E7F1 /* HNHTextView.h */, 4CFDDDE7185E92A600A9E7F1 /* HNHTextView.h */,
4CFDDDE8185E92A600A9E7F1 /* HNHTextView.m */, 4CFDDDE8185E92A600A9E7F1 /* HNHTextView.m */,
4C48A56018BE932100278A2D /* HNHCommon.h */, 4C48A56018BE932100278A2D /* HNHCommon.h */,
4C48A56118BE932100278A2D /* HNHCommon.m */,
); );
path = HNHUi; path = HNHUi;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -2123,7 +2120,6 @@
4C888C9316EB6F5E003D34A1 /* MPToolbarItem.m in Sources */, 4C888C9316EB6F5E003D34A1 /* MPToolbarItem.m in Sources */,
4C888C9716EB754B003D34A1 /* MPActionHelper.m in Sources */, 4C888C9716EB754B003D34A1 /* MPActionHelper.m in Sources */,
4C811C8316ECD06E00C4BAC6 /* MPKeyfilePathControlDelegate.m in Sources */, 4C811C8316ECD06E00C4BAC6 /* MPKeyfilePathControlDelegate.m in Sources */,
4C48A56218BE932100278A2D /* HNHCommon.m in Sources */,
4CE39ABF16ECE34A000FE29D /* MPIconSelectViewController.m in Sources */, 4CE39ABF16ECE34A000FE29D /* MPIconSelectViewController.m in Sources */,
4CE39AC416ECE4F7000FE29D /* MPPopupImageView.m in Sources */, 4CE39AC416ECE4F7000FE29D /* MPPopupImageView.m in Sources */,
4C46B88517063A070046109A /* NSString+MPPasswordCreation.m in Sources */, 4C46B88517063A070046109A /* NSString+MPPasswordCreation.m in Sources */,

View File

@@ -12,6 +12,8 @@ typedef NS_ENUM(NSUInteger, MPActionType) {
MPUnkownAction, // Neutral element to be used for returns MPUnkownAction, // Neutral element to be used for returns
MPActionAddEntry, // Add an new entry MPActionAddEntry, // Add an new entry
MPActionAddGroup, // Add a new group MPActionAddGroup, // Add a new group
MPActionCloneEntry, // Simply clone an entry (inlcuding history)
MPActionCloneEntryWithOptions, // Request user inptu what clone
MPActionDelete, // Delete entry or group MPActionDelete, // Delete entry or group
MPActionCopyUsername, // copy username to pasteboard MPActionCopyUsername, // copy username to pasteboard
MPActionCopyPassword, // copy password to pasteboard MPActionCopyPassword, // copy password to pasteboard

View File

@@ -15,21 +15,22 @@
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
actionDict = @{ actionDict = @{
@(MPActionAddEntry) : @"createEntry:", @(MPActionAddEntry): @"createEntry:",
@(MPActionAddGroup) : @"createGroup:", @(MPActionAddGroup): @"createGroup:",
@(MPActionCopyPassword) : @"copyPassword:", @(MPActionCloneEntry): @"cloneEntry:",
@(MPActionCopyURL) : @"copyURL:", @(MPActionCopyPassword): @"copyPassword:",
@(MPActionCopyUsername) : @"copyUsername:", @(MPActionCopyURL): @"copyURL:",
@(MPActionDelete) : @"delete:", @(MPActionCopyUsername): @"copyUsername:",
@(MPActionEditPassword) : @"editPassword:", @(MPActionDelete): @"delete:",
@(MPActionOpenURL) : @"openURL:", @(MPActionEditPassword): @"editPassword:",
@(MPActionToggleInspector) : @"toggleInspector:", @(MPActionOpenURL): @"openURL:",
@(MPActionLock) : @"lock:", @(MPActionToggleInspector): @"toggleInspector:",
@(MPActionEmptyTrash) : @"emptyTrash:", @(MPActionLock): @"lock:",
@(MPActionDatabaseSettings) : @"showDatabaseSettings:", @(MPActionEmptyTrash): @"emptyTrash:",
@(MPActionEditTemplateGroup) : @"editTemplateGroup:", @(MPActionDatabaseSettings): @"showDatabaseSettings:",
@(MPActionExportXML) : @"exportAsXML", @(MPActionEditTemplateGroup): @"editTemplateGroup:",
@(MPActionImportXML) : @"importFromXMl", @(MPActionExportXML): @"exportAsXML",
@(MPActionImportXML): @"importFromXMl",
}; };
}); });
return actionDict; return actionDict;

View File

@@ -44,6 +44,7 @@ typedef NS_ENUM(NSUInteger, MPContextTab) {
@implementation MPContextBarViewController @implementation MPContextBarViewController
#pragma mark Livecycle
- (instancetype)init { - (instancetype)init {
self = [self initWithNibName:@"ContextBar" bundle:nil]; self = [self initWithNibName:@"ContextBar" bundle:nil];
return self; return self;
@@ -76,7 +77,13 @@ typedef NS_ENUM(NSUInteger, MPContextTab) {
[self _updateFilterButtons]; [self _updateFilterButtons];
} }
#pragma mark Properties #pragma mark MPDocument Notifications
- (void)registerNotificationsForDocument:(MPDocument *)document {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_updateFilterButtons) name:MPDocumentDidChangeSearchFlags object:document];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didEnterSearch:) name:MPDocumentDidEnterSearchNotification object:document];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didEnterHistory:) name:MPDocumentDidEnterHistoryNotification object:document];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didChangeCurrentItem:) name:MPDocumentCurrentItemChangedNotification object:document];
}
- (void)_didEnterSearch:(NSNotification *)notification { - (void)_didEnterSearch:(NSNotification *)notification {
/* Select text if already visible */ /* Select text if already visible */
@@ -89,15 +96,13 @@ typedef NS_ENUM(NSUInteger, MPContextTab) {
[self _updateBindings]; [self _updateBindings];
} }
- (void)_showTrash { - (void)_didChangeCurrentItem:(NSNotification *)notification {
self.activeTab = MPContextTabTrash; MPDocument *document = [notification object];
[self _updateBindings]; BOOL showTrash = document.useTrash && (document.selectedGroup == document.trash || [document isItemTrashed:document.selectedItem]);
} if(showTrash) {
self.activeTab = MPContextTabTrash;
- (void)registerNotificationsForDocument:(MPDocument *)document { [self _updateBindings];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_updateFilterButtons) name:MPDocumentDidChangeSearchFlags object:document]; }
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didEnterSearch:) name:MPDocumentDidEnterSearchNotification object:document];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didEnterHistory:) name:MPDocumentDidEnterHistoryNotification object:document];
} }
/* /*
@@ -109,6 +114,7 @@ typedef NS_ENUM(NSUInteger, MPContextTab) {
} }
*/ */
#pragma mark UI Helper #pragma mark UI Helper
- (void)_updateBindings { - (void)_updateBindings {
// only the entry view has to be bound, the rest not // only the entry view has to be bound, the rest not

View File

@@ -9,13 +9,22 @@
#import "MPContextMenuHelper.h" #import "MPContextMenuHelper.h"
#import "MPActionHelper.h" #import "MPActionHelper.h"
#import "MPFlagsHelper.h"
static void MPContextmenuHelperBeginSection(NSMutableArray *items) {
if([items count] > 0) {
[items addObject:[NSMenuItem separatorItem]];
}
}
@implementation MPContextMenuHelper @implementation MPContextMenuHelper
+ (NSArray *)contextMenuItemsWithItems:(MPContextMenuItemsFlags)flags { + (NSArray *)contextMenuItemsWithItems:(MPContextMenuItemsFlags)flags {
BOOL insertCreate = (0 != (flags & MPContextMenuCreate));
BOOL insertDelete = (0 != (flags & MPContextMenuDelete)); BOOL const insertCreate = MPTestFlagInOptions(MPContextMenuCreate, flags);
BOOL insertCopy = (0 != (flags & MPContextMenuCopy)); BOOL const insertDelete = MPTestFlagInOptions(MPContextMenuDelete, flags);
BOOL insertTrash = (0 != (flags & MPContextMenuTrash)); BOOL const insertCopy = MPTestFlagInOptions(MPContextMenuCopy, flags);
BOOL const insertTrash = MPTestFlagInOptions(MPContextMenuTrash, flags);
NSMutableArray *items = [NSMutableArray arrayWithCapacity:10]; NSMutableArray *items = [NSMutableArray arrayWithCapacity:10];
if(insertCreate) { if(insertCreate) {
@@ -30,27 +39,27 @@
[items addObjectsFromArray:@[ newGroup, newEntry ]]; [items addObjectsFromArray:@[ newGroup, newEntry ]];
} }
if(insertDelete || insertTrash) { if(insertDelete || insertTrash) {
[self _beginSection:items]; MPContextmenuHelperBeginSection(items);
if(insertDelete) { if(insertDelete) {
NSMenuItem *delete = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"DELETE", @"") NSMenuItem *delete = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"DELETE", @"")
action:[MPActionHelper actionOfType:MPActionDelete] action:[MPActionHelper actionOfType:MPActionDelete]
keyEquivalent:@""]; keyEquivalent:@""];
[items addObject:delete]; [items addObject:delete];
} }
if(insertTrash) { if(insertTrash) {
NSMenuItem *emptyTrash = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"EMPTY_TRASH", @"") NSMenuItem *emptyTrash = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"EMPTY_TRASH", @"")
action:[MPActionHelper actionOfType:MPActionEmptyTrash] action:[MPActionHelper actionOfType:MPActionEmptyTrash]
keyEquivalent:@""]; keyEquivalent:@""];
[emptyTrash setKeyEquivalentModifierMask:(NSShiftKeyMask | NSCommandKeyMask)]; [emptyTrash setKeyEquivalentModifierMask:(NSShiftKeyMask | NSCommandKeyMask)];
unichar backSpace = NSBackspaceCharacter; unichar backSpace = NSBackspaceCharacter;
[emptyTrash setKeyEquivalent:[NSString stringWithCharacters:&backSpace length:1]]; [emptyTrash setKeyEquivalent:[NSString stringWithCharacters:&backSpace length:1]];
[items addObject:emptyTrash]; [items addObject:emptyTrash];
} }
} }
if(insertCopy) { if(insertCopy) {
[self _beginSection:items]; MPContextmenuHelperBeginSection(items);
NSMenuItem *copyUsername = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"COPY_USERNAME", @"") NSMenuItem *copyUsername = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"COPY_USERNAME", @"")
action:[MPActionHelper actionOfType:MPActionCopyUsername] action:[MPActionHelper actionOfType:MPActionCopyUsername]
keyEquivalent:@"C"]; keyEquivalent:@"C"];
@@ -79,10 +88,4 @@
return items; return items;
} }
+ (void)_beginSection:(NSMutableArray *)items {
if([items count] > 0) {
[items addObject:[NSMenuItem separatorItem]];
}
}
@end @end

View File

@@ -206,7 +206,7 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_updateContextBar) selector:@selector(_didExitSearch:)
name:MPDocumentDidExitSearchNotification name:MPDocumentDidExitSearchNotification
object:document]; object:document];
@@ -355,8 +355,8 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
}); });
} }
#pragma mark MPContextBarDelegate #pragma mark NSDocument+Search Notifications
- (void)contextBarDidExitFilter { - (void)_didExitSearch:(NSNotification *)notification {
[[self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier] setHidden:YES]; [[self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier] setHidden:YES];
MPDocument *document = [[self windowController] document]; MPDocument *document = [[self windowController] document];
document.selectedItem = document.selectedGroup; document.selectedItem = document.selectedGroup;
@@ -368,16 +368,12 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
} }
#pragma mark ContextBar #pragma mark ContextBar
- (void)_showTrashBar {
[self _showContextBar];
}
- (void)_updateContextBar { - (void)_updateContextBar {
MPDocument *document = [[self windowController] document]; MPDocument *document = [[self windowController] document];
if(!document.hasSearch) { if(!document.hasSearch) {
BOOL showTrash = document.useTrash && (document.selectedGroup == document.trash || [document isItemTrashed:document.selectedItem]); BOOL showTrash = document.useTrash && (document.selectedGroup == document.trash || [document isItemTrashed:document.selectedItem]);
if(showTrash) { if(showTrash) {
[self _showTrashBar]; [self _showContextBar];
} }
else { else {
[self _hideContextBar]; [self _hideContextBar];