fixed #62 application now shows a welcome screen if no other window is opened

fixed #79 modification data can be used as table column
fixed #74 added group sorting in search results
This commit is contained in:
michael starke
2013-08-16 04:00:08 +02:00
parent dcef431c5c
commit f335825c44
7 changed files with 51 additions and 12 deletions

View File

@@ -7,6 +7,8 @@
// //
#import "KdbEntry+Undo.h" #import "KdbEntry+Undo.h"
#import "Kdb4Node.h"
#import "KdbGroup+Undo.h" #import "KdbGroup+Undo.h"
#import "KdbGroup+KVOAdditions.h" #import "KdbGroup+KVOAdditions.h"
#import "KdbGroup+MPTreeTools.h" #import "KdbGroup+MPTreeTools.h"
@@ -48,7 +50,7 @@ if(![[self undoManager] isUndoing]) {\
[[self undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.title]; [[self undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.title];
MPSetActionName(@"SET_TITLE", ""); MPSetActionName(@"SET_TITLE", "");
[self setLastModificationTime:[NSDate date]]; [self _touchModifcationDate];
[self setTitle:title]; [self setTitle:title];
} }
@@ -56,7 +58,7 @@ if(![[self undoManager] isUndoing]) {\
[[self undoManager] registerUndoWithTarget:self selector:@selector(setUsernameUndoable:) object:self.username]; [[self undoManager] registerUndoWithTarget:self selector:@selector(setUsernameUndoable:) object:self.username];
MPSetActionName(@"SET_USERNAME", ""); MPSetActionName(@"SET_USERNAME", "");
[self setLastModificationTime:[NSDate date]]; [self _touchModifcationDate];
[self setUsername:username]; [self setUsername:username];
} }
@@ -64,7 +66,7 @@ if(![[self undoManager] isUndoing]) {\
[[self undoManager] registerUndoWithTarget:self selector:@selector(setPasswordUndoable:) object:self.password]; [[self undoManager] registerUndoWithTarget:self selector:@selector(setPasswordUndoable:) object:self.password];
MPSetActionName(@"SET_PASSWORT", "Undo set password"); MPSetActionName(@"SET_PASSWORT", "Undo set password");
[self setLastModificationTime:[NSDate date]]; [self _touchModifcationDate];
[self setPassword:password]; [self setPassword:password];
} }
@@ -72,7 +74,7 @@ if(![[self undoManager] isUndoing]) {\
[[self undoManager] registerUndoWithTarget:self selector:@selector(setUrlUndoable:) object:self.url]; [[self undoManager] registerUndoWithTarget:self selector:@selector(setUrlUndoable:) object:self.url];
MPSetActionName(@"SET_URL", "Undo set URL"); MPSetActionName(@"SET_URL", "Undo set URL");
[self setLastModificationTime:[NSDate date]]; [self _touchModifcationDate];
[self setUrl:url]; [self setUrl:url];
} }
@@ -80,7 +82,7 @@ if(![[self undoManager] isUndoing]) {\
[[self undoManager] registerUndoWithTarget:self selector:@selector(setNotesUndoable:) object:self.notes]; [[self undoManager] registerUndoWithTarget:self selector:@selector(setNotesUndoable:) object:self.notes];
MPSetActionName(@"SET_NOTES", "Set Notes"); MPSetActionName(@"SET_NOTES", "Set Notes");
[self setLastModificationTime:[NSDate date]]; [self _touchModifcationDate];
[self setNotes:notes]; [self setNotes:notes];
} }
@@ -124,8 +126,14 @@ if(![[self undoManager] isUndoing]) {\
// Old indices might be wrong, correct them if necessary // Old indices might be wrong, correct them if necessary
index = MIN(index, [group.entries count]); index = MIN(index, [group.entries count]);
[group insertObject:self inEntriesAtIndex:index]; [group insertObject:self inEntriesAtIndex:index];
if([self respondsToSelector:@selector(setLocationChanged:)]) {
id entry = self;
[entry setLocationChanged:[NSDate date]];
}
} }
- (void)_touchModifcationDate {
self.lastModificationTime = [NSDate date];
}
@end @end

View File

@@ -48,6 +48,14 @@
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver:self];
} }
- (BOOL)applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)flag {
if(!flag) {
[self _loadWelcomeWindow];
[self.welcomeWindow orderFront:self];
}
return YES;
}
- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender { - (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender {
return [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyOpenEmptyDatabaseOnLaunch]; return [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyOpenEmptyDatabaseOnLaunch];
} }
@@ -101,8 +109,7 @@
} }
else { else {
NSArray *topLevelObject; [self _loadWelcomeWindow];
[[NSBundle mainBundle] loadNibNamed:@"WelcomeWindow" owner:self topLevelObjects:&topLevelObject];
[self.welcomeWindow orderFront:self]; [self.welcomeWindow orderFront:self];
} }
} }
@@ -159,4 +166,12 @@
_restoredWindows = [documents count] > 0; _restoredWindows = [documents count] > 0;
} }
- (void)_loadWelcomeWindow {
if(!_welcomeWindow) {
NSArray *topLevelObject;
[[NSBundle mainBundle] loadNibNamed:@"WelcomeWindow" owner:self topLevelObjects:&topLevelObject];
//CFRelease((__bridge CFTypeRef)_welcomeWindow);
}
}
@end @end

View File

@@ -57,6 +57,7 @@ NSString *const MPEntryTableParentColumnIdentifier = @"MPParentColumnIdentifier"
NSString *const MPEntryTableURLColumnIdentifier = @"MPEntryTableURLColumnIdentifier"; NSString *const MPEntryTableURLColumnIdentifier = @"MPEntryTableURLColumnIdentifier";
NSString *const MPEntryTableNotesColumnIdentifier = @"MPEntryTableNotesColumnIdentifier"; NSString *const MPEntryTableNotesColumnIdentifier = @"MPEntryTableNotesColumnIdentifier";
NSString *const MPEntryTableAttachmentColumnIdentifier = @"MPEntryTableAttachmentColumnIdentifier"; NSString *const MPEntryTableAttachmentColumnIdentifier = @"MPEntryTableAttachmentColumnIdentifier";
NSString *const MPEntryTableModfiedColumnIdentifier = @"MPEntryTableModfiedColumnIdentifier";
NSString *const _MPTableImageCellView = @"ImageCell"; NSString *const _MPTableImageCellView = @"ImageCell";
NSString *const _MPTableStringCellView = @"StringCell"; NSString *const _MPTableStringCellView = @"StringCell";
@@ -153,8 +154,10 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
NSTableColumn *urlColumn = [self.entryTable tableColumns][4]; NSTableColumn *urlColumn = [self.entryTable tableColumns][4];
NSTableColumn *attachmentsColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableAttachmentColumnIdentifier]; NSTableColumn *attachmentsColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableAttachmentColumnIdentifier];
NSTableColumn *notesColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableNotesColumnIdentifier]; NSTableColumn *notesColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableNotesColumnIdentifier];
NSTableColumn *modifiedColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableModfiedColumnIdentifier];
[self.entryTable addTableColumn:notesColumn]; [self.entryTable addTableColumn:notesColumn];
[self.entryTable addTableColumn:attachmentsColumn]; [self.entryTable addTableColumn:attachmentsColumn];
[self.entryTable addTableColumn:modifiedColumn];
[parentColumn setIdentifier:MPEntryTableParentColumnIdentifier]; [parentColumn setIdentifier:MPEntryTableParentColumnIdentifier];
[titleColumn setIdentifier:MPEntryTableTitleColumnIdentifier]; [titleColumn setIdentifier:MPEntryTableTitleColumnIdentifier];
@@ -168,10 +171,14 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
NSSortDescriptor *titleColumSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"title" ascending:YES selector:@selector(compare:)]; NSSortDescriptor *titleColumSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"title" ascending:YES selector:@selector(compare:)];
NSSortDescriptor *userNameSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"username" ascending:YES selector:@selector(compare:)]; NSSortDescriptor *userNameSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"username" ascending:YES selector:@selector(compare:)];
NSSortDescriptor *urlSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"url" ascending:YES selector:@selector(compare:)]; NSSortDescriptor *urlSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"url" ascending:YES selector:@selector(compare:)];
NSSortDescriptor *groupnameSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"parent.name" ascending:YES selector:@selector(compare:)];
NSSortDescriptor *dateSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"lastModificationTime" ascending:YES selector:@selector(compare:)];
[titleColumn setSortDescriptorPrototype:titleColumSortDescriptor]; [titleColumn setSortDescriptorPrototype:titleColumSortDescriptor];
[userNameColumn setSortDescriptorPrototype:userNameSortDescriptor]; [userNameColumn setSortDescriptorPrototype:userNameSortDescriptor];
[urlColumn setSortDescriptorPrototype:urlSortDescriptor]; [urlColumn setSortDescriptorPrototype:urlSortDescriptor];
[parentColumn setSortDescriptorPrototype:groupnameSortDescriptor];
[modifiedColumn setSortDescriptorPrototype:dateSortDescriptor];
[[parentColumn headerCell] setStringValue:NSLocalizedString(@"GROUP", "")]; [[parentColumn headerCell] setStringValue:NSLocalizedString(@"GROUP", "")];
[[titleColumn headerCell] setStringValue:NSLocalizedString(@"TITLE", "")]; [[titleColumn headerCell] setStringValue:NSLocalizedString(@"TITLE", "")];
@@ -180,6 +187,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
[[urlColumn headerCell] setStringValue:NSLocalizedString(@"URL", "")]; [[urlColumn headerCell] setStringValue:NSLocalizedString(@"URL", "")];
[[notesColumn headerCell] setStringValue:NSLocalizedString(@"NOTES", "")]; [[notesColumn headerCell] setStringValue:NSLocalizedString(@"NOTES", "")];
[[attachmentsColumn headerCell] setStringValue:NSLocalizedString(@"ATTACHMENTS", "")]; [[attachmentsColumn headerCell] setStringValue:NSLocalizedString(@"ATTACHMENTS", "")];
[[modifiedColumn headerCell] setStringValue:NSLocalizedString(@"MODIFIED", "")];
[self.entryTable bind:NSContentBinding toObject:self.entryArrayController withKeyPath:@"arrangedObjects" options:nil]; [self.entryTable bind:NSContentBinding toObject:self.entryArrayController withKeyPath:@"arrangedObjects" options:nil];
[self.entryTable bind:NSSortDescriptorsBinding toObject:self.entryArrayController withKeyPath:@"sortDescriptors" options:nil]; [self.entryTable bind:NSSortDescriptorsBinding toObject:self.entryArrayController withKeyPath:@"sortDescriptors" options:nil];
@@ -209,6 +217,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
BOOL isURLColumn = [[tableColumn identifier] isEqualToString:MPEntryTableURLColumnIdentifier]; BOOL isURLColumn = [[tableColumn identifier] isEqualToString:MPEntryTableURLColumnIdentifier];
BOOL isAttachmentColumn = [[tableColumn identifier] isEqualToString:MPEntryTableAttachmentColumnIdentifier]; BOOL isAttachmentColumn = [[tableColumn identifier] isEqualToString:MPEntryTableAttachmentColumnIdentifier];
BOOL isNotesColumn = [[tableColumn identifier] isEqualToString:MPEntryTableNotesColumnIdentifier]; BOOL isNotesColumn = [[tableColumn identifier] isEqualToString:MPEntryTableNotesColumnIdentifier];
BOOL isModifedColumn = [[tableColumn identifier] isEqualToString:MPEntryTableModfiedColumnIdentifier];
NSTableCellView *view = nil; NSTableCellView *view = nil;
if(isTitleColumn || isGroupColumn) { if(isTitleColumn || isGroupColumn) {
@@ -244,6 +253,13 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
[[view textField] setStringValue:@""]; [[view textField] setStringValue:@""];
//[[view textField] bind:NSValueBinding toObject:entry withKeyPath:@"countOfBinaries" options:nil]; //[[view textField] bind:NSValueBinding toObject:entry withKeyPath:@"countOfBinaries" options:nil];
} }
else if( isModifedColumn ) {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterMediumStyle];
[formatter setTimeStyle:NSDateFormatterMediumStyle];
[[view textField] setFormatter:formatter];
[[view textField] bind:NSValueBinding toObject:entry withKeyPath:@"lastModificationTime" options:nil];
}
} }
return view; return view;
@@ -556,13 +572,15 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
[headerMenu addItemWithTitle:NSLocalizedString(@"URL", "") action:NULL keyEquivalent:@""]; [headerMenu addItemWithTitle:NSLocalizedString(@"URL", "") action:NULL keyEquivalent:@""];
[headerMenu addItemWithTitle:NSLocalizedString(@"NOTES", "") action:NULL keyEquivalent:@""]; [headerMenu addItemWithTitle:NSLocalizedString(@"NOTES", "") action:NULL keyEquivalent:@""];
[headerMenu addItemWithTitle:NSLocalizedString(@"ATTACHMENTS", "") action:NULL keyEquivalent:@""]; [headerMenu addItemWithTitle:NSLocalizedString(@"ATTACHMENTS", "") action:NULL keyEquivalent:@""];
[headerMenu addItemWithTitle:NSLocalizedString(@"MODIFIED", "") action:NULL keyEquivalent:@""];
NSArray *identifier = @[ MPEntryTableTitleColumnIdentifier, NSArray *identifier = @[ MPEntryTableTitleColumnIdentifier,
MPEntryTableUserNameColumnIdentifier, MPEntryTableUserNameColumnIdentifier,
MPEntryTablePasswordColumnIdentifier, MPEntryTablePasswordColumnIdentifier,
MPEntryTableURLColumnIdentifier, MPEntryTableURLColumnIdentifier,
MPEntryTableNotesColumnIdentifier, MPEntryTableNotesColumnIdentifier,
MPEntryTableAttachmentColumnIdentifier ]; MPEntryTableAttachmentColumnIdentifier,
MPEntryTableModfiedColumnIdentifier ];
NSDictionary *options = @{ NSValueTransformerNameBindingOption : NSNegateBooleanTransformerName }; NSDictionary *options = @{ NSValueTransformerNameBindingOption : NSNegateBooleanTransformerName };
for(NSMenuItem *item in [headerMenu itemArray]) { for(NSMenuItem *item in [headerMenu itemArray]) {

View File

@@ -90,7 +90,6 @@
validTarget &= index != [self.draggedGroup.parent.groups indexOfObject:self.draggedGroup]; validTarget &= index != [self.draggedGroup.parent.groups indexOfObject:self.draggedGroup];
} }
BOOL isAnchesor = [self.draggedGroup isAnchestorOfGroup:targetGroup]; BOOL isAnchesor = [self.draggedGroup isAnchestorOfGroup:targetGroup];
NSLog(@"DraggedGroup:%@ isAnchestor:%d ofTargetGroup:%@", self.draggedGroup.name, isAnchesor, targetGroup.name);
validTarget &= !isAnchesor; validTarget &= !isAnchesor;
} }
else if(self.draggedEntry) { else if(self.draggedEntry) {

View File

@@ -43,7 +43,7 @@
<int key="NSWindowStyleMask">7</int> <int key="NSWindowStyleMask">7</int>
<int key="NSWindowBacking">2</int> <int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{196, 240}, {448, 255}}</string> <string key="NSWindowRect">{{196, 240}, {448, 255}}</string>
<int key="NSWTFlags">544735232</int> <int key="NSWTFlags">1618477056</int>
<string key="NSWindowTitle">Welcome</string> <string key="NSWindowTitle">Welcome</string>
<string key="NSWindowClass">NSWindow</string> <string key="NSWindowClass">NSWindow</string>
<nil key="NSViewClass"/> <nil key="NSViewClass"/>
@@ -186,7 +186,6 @@
<string key="NSFrame">{{372, 18}, {56, 25}}</string> <string key="NSFrame">{{372, 18}, {56, 25}}</string>
<reference key="NSSuperview" ref="1006"/> <reference key="NSSuperview" ref="1006"/>
<reference key="NSWindow"/> <reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:22</string> <string key="NSReuseIdentifierKey">_NS:22</string>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="138204662"> <object class="NSButtonCell" key="NSCell" id="138204662">

Binary file not shown.

Binary file not shown.