From 96c54d7af3f14fe278cd9522a1875426c80cd771 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Sun, 30 Jun 2013 15:35:57 +0200 Subject: [PATCH] More work on #24 Deleted Entries, Groups are moved to Bin if enabled Undo/Redo stack is broken with trash Empty-Trash action missing --- MacPass/Base.lproj/InspectorView.xib | 462 ++++++++------------------- MacPass/KdbGroup+MPTreeTools.m | 1 + MacPass/MPDocument.m | 42 ++- MacPass/MPInspectorViewController.m | 17 +- MacPass/MacPass-Info.plist | 2 +- MacPass/de.lproj/Localizable.strings | Bin 6092 -> 6224 bytes MacPass/en.lproj/Localizable.strings | Bin 5906 -> 6028 bytes 7 files changed, 179 insertions(+), 345 deletions(-) diff --git a/MacPass/Base.lproj/InspectorView.xib b/MacPass/Base.lproj/InspectorView.xib index 2641ec93..f84423f0 100644 --- a/MacPass/Base.lproj/InspectorView.xib +++ b/MacPass/Base.lproj/InspectorView.xib @@ -68,7 +68,6 @@ {{20, 461}, {48, 48}} - _NS:9 YES @@ -93,7 +92,6 @@ 268 {{73, 477}, {203, 17}} - _NS:1535 {200, 750} @@ -136,7 +134,6 @@ {293, 30} - _NS:9 HNHGradientView @@ -145,7 +142,6 @@ 268 {{64, 429}, {165, 25}} - _NS:9 YES @@ -200,7 +196,7 @@ 12 {{0, 31}, {293, 399}} - + _NS:9 @@ -632,7 +628,6 @@ 256 {{236, 1}, {16, 332}} - _NS:83 NO @@ -837,7 +832,12 @@ 3 2 - + + 6 + System + alternateSelectedControlTextColor + + 6 System @@ -847,7 +847,7 @@ MC41AA - 17 + 36 -700448768 @@ -865,7 +865,7 @@ _NS:11 - 4 + 2 @@ -901,7 +901,7 @@ - QSAAAEEgAABBmAAAQZgAAA + QSAAAEEgAABCGAAAQhgAAA 0.25 4 1 @@ -924,7 +924,6 @@ 268 {{241, 362}, {32, 19}} - _NS:9 YES @@ -953,7 +952,6 @@ 268 {{17, 365}, {80, 14}} - _NS:1535 YES @@ -983,7 +981,6 @@ {259, 333} - _NS:13 YES @@ -1046,7 +1043,6 @@ {{1, 1}, {259, 333}} - _NS:11 @@ -1058,7 +1054,6 @@ -2147483392 {{224, 17}, {15, 102}} - _NS:58 NO @@ -1071,7 +1066,6 @@ -2147483392 {{1, 119}, {223, 15}} - _NS:60 NO @@ -1083,7 +1077,6 @@ {{16, 20}, {261, 335}} - _NS:9 133681 @@ -1098,7 +1091,6 @@ {293, 399} - Fields @@ -1118,7 +1110,6 @@ {293, 529} - _NS:11 @@ -1303,7 +1294,7 @@ NeXT Encapsulated PostScript v1.2 pasteboard type NeXT TIFF v4.0 pasteboard type - {{3, 0}, {17, 17}} + {{3, 2}, {32, 32}} _NS:11 @@ -1327,7 +1318,7 @@ 266 - {{25, 0}, {223, 17}} + {{40, 10}, {208, 17}} _NS:20 @@ -1346,7 +1337,7 @@ NO - {{1, 1}, {248, 17}} + {{1, 1}, {248, 36}} _NS:9 @@ -1378,8 +1369,8 @@ _NS:9 YES - -1804599231 - 272630784 + -1805647871 + 272629760 Value @@ -3363,54 +3354,6 @@ 1565 - - - 5 - 0 - - 5 - 1 - - 3 - - 1000 - - 8 - 29 - 3 - - - - 3 - 0 - - 3 - 1 - - 0.0 - - 1000 - - 6 - 24 - 2 - - - - 4 - 0 - - 4 - 1 - - 0.0 - - 1000 - - 6 - 24 - 2 - 5 @@ -3443,8 +3386,24 @@ 29 3 + + + 10 + 0 + + 10 + 1 + + 0.0 + + 1000 + + 6 + 24 + 2 + - + 10 0 @@ -3459,6 +3418,22 @@ 22 2 + + + 5 + 0 + + 5 + 1 + + 3 + + 1000 + + 8 + 29 + 3 + @@ -3474,31 +3449,11 @@ - - 1573 - - - - - 1574 - - - - - 1576 - - - 1577 - - 1578 - - - 1567 @@ -3511,7 +3466,23 @@ 1566 - + + + 8 + 0 + + 0 + 1 + + 32 + + 1000 + + 3 + 9 + 1 + + 7 0 @@ -3519,7 +3490,7 @@ 0 1 - 17 + 32 1000 @@ -3531,11 +3502,6 @@ - - 1572 - - - 1569 @@ -3902,8 +3868,8 @@ 1000 - 6 - 24 + 9 + 40 3 @@ -3922,6 +3888,22 @@ 40 3 + + + 3 + 0 + + 3 + 1 + + 0.0 + + 1000 + + 9 + 40 + 3 + 6 @@ -3973,7 +3955,7 @@ 0 1 - 100 + 80 1000 @@ -3984,7 +3966,7 @@ 8 - 0 + 1 0 1 @@ -4183,6 +4165,36 @@ + + 2180 + + + + + 2181 + + + + + 2182 + + + + + 2183 + + + + + 2184 + + + + + 2185 + + + @@ -4287,6 +4299,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + HNHScrollView com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -4327,15 +4340,15 @@ com.apple.InterfaceBuilder.CocoaPlugin - - - - + + + com.apple.InterfaceBuilder.CocoaPlugin - + + com.apple.InterfaceBuilder.CocoaPlugin @@ -4343,13 +4356,8 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -4472,6 +4480,7 @@ + @@ -4480,7 +4489,7 @@ com.apple.InterfaceBuilder.CocoaPlugin - + @@ -4522,6 +4531,12 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin @@ -4568,222 +4583,9 @@ - 2175 - - - - - HNHGradientView - NSView - - IBProjectSource - ./Classes/HNHGradientView.h - - - - HNHLevelIndicatorCell - NSLevelIndicatorCell - - IBProjectSource - ./Classes/HNHLevelIndicatorCell.h - - - - HNHRoundedSecureTextFieldCell - HNHRoundedTextFieldCell - - IBProjectSource - ./Classes/HNHRoundedSecureTextFieldCell.h - - - - HNHRoundedTextField - NSTextField - - IBProjectSource - ./Classes/HNHRoundedTextField.h - - - - HNHRoundedTextFieldCell - NSTextFieldCell - - IBProjectSource - ./Classes/HNHRoundedTextFieldCell.h - - - - HNHScrollView - NSScrollView - - IBProjectSource - ./Classes/HNHScrollView.h - - - - MPCustomFieldTableCellView - NSTableCellView - - NSTextField - NSButton - NSTextField - - - - labelTextField - NSTextField - - - removeButton - NSButton - - - valueTextField - NSTextField - - - - IBProjectSource - ./Classes/MPCustomFieldTableCellView.h - - - - MPInspectorViewController - MPViewController - - id - id - - - - addCustomField: - id - - - removeCustomField: - id - - - - NSTextField - NSTableView - HNHGradientView - NSTextField - NSTableView - NSTextField - NSButton - NSSegmentedControl - MPPopupImageView - NSTextField - NSTextField - NSTextView - NSTextField - NSTabView - NSTextField - NSTextField - NSTextField - - - - URLTextField - NSTextField - - - attachmentTableView - NSTableView - - - bottomBar - HNHGradientView - - - createdTextField - NSTextField - - - customFieldsTableView - NSTableView - - - customFieldsTextField - NSTextField - - - generatePasswordButton - NSButton - - - infoTabControl - NSSegmentedControl - - - itemImageView - MPPopupImageView - - - itemNameTextfield - NSTextField - - - modifiedTextField - NSTextField - - - notesTextView - NSTextView - - - passwordTextField - NSTextField - - - tabView - NSTabView - - - titleOrNameLabel - NSTextField - - - titleTextField - NSTextField - - - usernameTextField - NSTextField - - - - IBProjectSource - ./Classes/MPInspectorViewController.h - - - - MPPopupImageView - NSImageView - - IBProjectSource - ./Classes/MPPopupImageView.h - - - - MPViewController - NSViewController - - IBProjectSource - ./Classes/MPViewController.h - - - - NSLayoutConstraint - NSObject - - IBProjectSource - ./Classes/NSLayoutConstraint.h - - - + 2189 + 0 IBCocoaFramework YES diff --git a/MacPass/KdbGroup+MPTreeTools.m b/MacPass/KdbGroup+MPTreeTools.m index 5f7e8a29..4853e5e1 100644 --- a/MacPass/KdbGroup+MPTreeTools.m +++ b/MacPass/KdbGroup+MPTreeTools.m @@ -14,6 +14,7 @@ - (NSArray *)childGroups { NSMutableArray *childGroups = [NSMutableArray arrayWithCapacity:[self.groups count]]; + [childGroups addObjectsFromArray:self.groups]; for(KdbGroup *childGroup in self.groups) { [childGroups addObjectsFromArray:[childGroup childGroups]]; } diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 586e1bf0..5009ed60 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -8,14 +8,15 @@ #import "MPDocument.h" #import "MPDocumentWindowController.h" + +#import "MPDatabaseVersion.h" +#import "MPRootAdapter.h" +#import "MPIconHelper.h" + #import "KdbLib.h" #import "Kdb3Node.h" #import "Kdb4Node.h" #import "KdbPassword.h" - -#import "MPDatabaseVersion.h" -#import "MPRootAdapter.h" - #import "KdbGroup+Undo.h" #import "KdbGroup+KVOAdditions.h" #import "Kdb4Entry+KVOAdditions.h" @@ -265,8 +266,12 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey"; } - (KdbGroup *)recyleBin { + static KdbGroup *_recycleBin; if(self.useRecylceBin) { - return [self findGroup:self.treeV4.recycleBinUuid]; + if(!_recycleBin) { + _recycleBin = [self findGroup:self.treeV4.recycleBinUuid]; + } + return _recycleBin; } return nil; } @@ -318,7 +323,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey"; } [[[self undoManager] prepareWithInvocationTarget:self] moveGroup:group toGroup:group.parent index:oldIndex]; if(self.recyleBin == target) { - [[self undoManager] setActionName:@"DELETE_GROUP"]; + [[self undoManager] setActionName:@"UNDO_DELETE_GROUP"]; } else { [[self undoManager] setActionName:@"MOVE_GROUP"]; @@ -353,7 +358,12 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey"; return; // No changes } [[[self undoManager] prepareWithInvocationTarget:self] moveEntry:entry toGroup:entry.parent index:oldIndex]; - [[self undoManager] setActionName:@"MOVE_ENTRY"]; + if(self.recyleBin == target || self.recyleBin == entry.parent) { + [[self undoManager] setActionName:@"UNDO_DELETE_ENTRY"]; + } + else { + [[self undoManager] setActionName:@"MOVE_ENTRY"]; + } [entry.parent removeObjectFromEntriesAtIndex:oldIndex]; if(index < 0 || index > [target.groups count] ) { index = [target.groups count]; @@ -378,6 +388,13 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey"; if(NSNotFound == index) { return; // No object found; } + if(self.useRecylceBin) { + if(!self.recyleBin) { + [self _createRecylceBin]; + } + [self moveEntry:entry toGroup:self.recyleBin index:[self.recyleBin.entries count]]; + return; + } [[[self undoManager] prepareWithInvocationTarget:self] group:group addEntry:entry atIndex:index]; [[self undoManager] setActionName:NSLocalizedString(@"UNDO_DELETE_ENTRY", "Undo deleting of entry")]; [group removeObjectFromEntriesAtIndex:index]; @@ -396,7 +413,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey"; if(!self.recyleBin) { [self _createRecylceBin]; } - [self moveGroup:group toGroup:self.recyleBin index:[self.recyleBin.groups count]]; + [self moveGroup:aGroup toGroup:self.recyleBin index:[self.recyleBin.groups count]]; return; // Done! } [[[self undoManager] prepareWithInvocationTarget:self] group:group addGroup:aGroup atIndex:index]; @@ -430,13 +447,18 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey"; } - (void)_createRecylceBin { + /* Maybe push the stuff to the Tree? */ if(self.version == MPDatabaseVersion3) { - // create backup? } else if(self.version == MPDatabaseVersion4) { - + KdbGroup *recycleBin = [self.tree createGroup:self.tree.root]; + recycleBin.name = NSLocalizedString(@"RECYLEBIN", @"Name for the recycle bin group"); + recycleBin.image = MPIconTrash; + [self.tree.root insertObject:recycleBin inGroupsAtIndex:[self.tree.root.groups count]]; + self.treeV4.recycleBinUuid = ((Kdb4Group *)recycleBin).uuid; } else { + NSAssert(NO, @"Database with unknown version: %ld", _version); } } diff --git a/MacPass/MPInspectorViewController.m b/MacPass/MPInspectorViewController.m index 82e8e107..6bf3e4e1 100644 --- a/MacPass/MPInspectorViewController.m +++ b/MacPass/MPInspectorViewController.m @@ -95,7 +95,9 @@ enum { [_infoTabControl bind:NSSelectedIndexBinding toObject:self withKeyPath:@"activeTab" options:nil]; [_tabView bind:NSSelectedIndexBinding toObject:self withKeyPath:@"activeTab" options:nil]; - + + /* Set background to clearcolor so we can draw in the scrollview */ + [_attachmentTableView setBackgroundColor:[NSColor clearColor]]; [_attachmentTableView bind:NSContentBinding toObject:self.attachmentsController withKeyPath:@"arrangedObjects" options:nil]; [_attachmentTableView setDelegate:self]; /* Set background to clearcolor so we can draw in the scrollview */ @@ -337,6 +339,7 @@ enum { #pragma mark NSTableViewDelegate +/* TODO: Divide this into single delegates */ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { if(tableView == self.attachmentTableView) { return [self _viewForAttachmentTableColumn:tableColumn row:row]; @@ -350,14 +353,16 @@ enum { Kdb4Entry *entry = (Kdb4Entry *)self.selectedEntry; BinaryRef *binaryRef = entry.binaries[row]; [[view textField] bind:NSValueBinding toObject:binaryRef withKeyPath:@"key" options:nil]; - MPDocument *document = [[self windowController] document]; - Binary *binary = [document binaryForRef:binaryRef]; - NSLog(@"%@", binary.data); + [[view imageView] setImage:[[NSWorkspace sharedWorkspace] iconForFileType:[binaryRef.key pathExtension]]]; + //MPDocument *document = [[self windowController] document]; + //Binary *binary = [document binaryForRef:binaryRef]; + //NSLog(@"%@", binary.data); } return view; } - (NSView *)_viewForCustomFieldTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { MPCustomFieldTableCellView *view = [_customFieldsTableView makeViewWithIdentifier:[tableColumn identifier] owner:_customFieldsTableView]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_customFieldFrameChanged:) name:NSViewFrameDidChangeNotification object:view]; if([self.selectedEntry isKindOfClass:[Kdb4Entry class]]) { Kdb4Entry *entry = (Kdb4Entry *)self.selectedEntry; StringField *stringField = entry.stringFields[row]; @@ -370,5 +375,9 @@ enum { return view; } +- (void)_customFieldFrameChanged:(NSNotification *)notification { + NSView *sender = [notification object]; + NSLog(@"didChangeFrameFor: %@ to: %@", sender, NSStringFromRect([sender frame])); +} @end diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index cff1a21f..e3715c82 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -48,7 +48,7 @@ CFBundleSignature ???? CFBundleVersion - 1645 + 1686 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright diff --git a/MacPass/de.lproj/Localizable.strings b/MacPass/de.lproj/Localizable.strings index f08f5a9eedce50745d79543e0bff8ebdddf08f60..56a65ed3b940ce15a5da0121a9109a80a2d23d8f 100644 GIT binary patch delta 114 zcmX@3f5BkGIbPjFhFpeJ1_g#RhJ1!1AYHC*gZDS;@idv07ZERe*gdg diff --git a/MacPass/en.lproj/Localizable.strings b/MacPass/en.lproj/Localizable.strings index 1c552d5a28621abb8519997674c7ea583e5b2bb5..ad586bb73d03fa77564784fb762c7c56f007ea91 100644 GIT binary patch delta 122 zcmbQF*Q39|fj2XeA(tVQL4hHSA)lcLNS82VfcZs0GMS+gh;zXFB!*0eJfM6!P*pxd zDMJB}t;L|vz{Q}%5X9ih;LH%o-~*(c7(5yLfMN;^wm_`J5CT-6$WY9XG1*Zta&rf7 G7bgIyau%on delta 16 XcmeCtpQN|Jfp_u+0gug0d|jLXGyVmN