From f7c6222910f76d230fd546cc125adf44714d21b0 Mon Sep 17 00:00:00 2001 From: michael starke Date: Wed, 5 Jun 2013 12:32:39 +0200 Subject: [PATCH] Extracted RoundedTextFieldCell --- .gitmodules | 3 ++ HNHUi | 1 + MacPass.xcodeproj/project.pbxproj | 38 ++++++++++++--- MacPass/InspectorView.xib | 33 ++++++++----- MacPass/KdbGroup+Undo.h | 7 ++- MacPass/KdbGroup+Undo.m | 33 ++++++++----- MacPass/MPAppDelegate.m | 2 + MacPass/MPDocument.h | 5 +- MacPass/MPDocument.m | 45 ++++++------------ MacPass/MPEntryViewController.m | 19 +++++--- MacPass/MPOutlineViewController.h | 2 + MacPass/MPOutlineViewController.m | 2 +- MacPass/MPOutlineViewDelegate.m | 4 +- MacPass/MPRoundedTextFieldCell.h | 14 ------ MacPass/MPRoundedTextFieldCell.m | 51 --------------------- MacPass/MPTextField.m | 26 +++-------- MacPass/MPUppercaseStringValueTransformer.h | 17 +++++++ MacPass/MPUppercaseStringValueTransformer.m | 37 +++++++++++++++ MacPass/MacPass-Info.plist | 2 +- MacPass/NSString+MPPasswordCreation.m | 1 - 20 files changed, 182 insertions(+), 160 deletions(-) create mode 160000 HNHUi delete mode 100644 MacPass/MPRoundedTextFieldCell.h delete mode 100644 MacPass/MPRoundedTextFieldCell.m create mode 100644 MacPass/MPUppercaseStringValueTransformer.h create mode 100644 MacPass/MPUppercaseStringValueTransformer.m diff --git a/.gitmodules b/.gitmodules index cc4cb943..9c1aac53 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "DMSplitView"] path = DMSplitView url = https://mstarke@github.com/mstarke/DMSplitView.git +[submodule "HNHUi"] + path = HNHUi + url = https://mstarke@github.com/mstarke/HNHUi.git diff --git a/HNHUi b/HNHUi new file mode 160000 index 00000000..7708aac7 --- /dev/null +++ b/HNHUi @@ -0,0 +1 @@ +Subproject commit 7708aac7e8a5e3b26d7a20f52a83d7815dceb5c5 diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index 86a8e804..7bfc1c0c 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -33,6 +33,7 @@ 4C586FA216D07F6A00E7DB57 /* 02_MessageBoxWarningTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C586FA116D07F6A00E7DB57 /* 02_MessageBoxWarningTemplate.pdf */; }; 4C5A11FE1708DE8700223D8A /* MPPasswordCreatorViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C5A11FC1708DE8700223D8A /* MPPasswordCreatorViewController.m */; }; 4C5A11FF1708DE8800223D8A /* PasswordCreatorView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C5A11FD1708DE8700223D8A /* PasswordCreatorView.xib */; }; + 4C5BF67B175C01F300D53DF7 /* MPUppercaseStringValueTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C5BF67A175C01F300D53DF7 /* MPUppercaseStringValueTransformer.m */; }; 4C61EA0316D2FD0800AC519E /* MPOutlineViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C61EA0216D2FD0800AC519E /* MPOutlineViewController.m */; }; 4C61EA0516D2FFE200AC519E /* OutlineView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C61EA0416D2FFE200AC519E /* OutlineView.xib */; }; 4C65C79C16DD283900E32CFF /* MPToolbarButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C65C79B16DD283900E32CFF /* MPToolbarButton.m */; }; @@ -100,12 +101,15 @@ 4CAD747F15B887FD00104512 /* DDXMLNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CAD746115B887FD00104512 /* DDXMLNode.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; 4CAD748C15B889B700104512 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CAD748B15B889B700104512 /* Security.framework */; }; 4CAD748E15B88AC100104512 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CAD748D15B88AC100104512 /* libz.dylib */; }; - 4CB25D54175A206000D1369D /* MPRoundedTextFieldCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CB25D53175A206000D1369D /* MPRoundedTextFieldCell.m */; }; 4CB25D57175A208300D1369D /* MPTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CB25D56175A208300D1369D /* MPTextField.m */; }; 4CB9339916D3A0DD00A13B5D /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 4CB9339716D3A0DD00A13B5D /* Credits.rtf */; }; 4CBA2ABA17074C07006D8139 /* MPSettingsHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CBA2AB917074C07006D8139 /* MPSettingsHelper.m */; }; 4CBFA240172B385D006090DF /* PasswordEditView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CBFA23F172B385D006090DF /* PasswordEditView.xib */; }; 4CC1AEBE16D4467C006D2AAB /* KdbTree+MPAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC1AEBD16D4467C006D2AAB /* KdbTree+MPAdditions.m */; }; + 4CC3AABC175F4983003EF01B /* .gitignore in Resources */ = {isa = PBXBuildFile; fileRef = 4CC3AAB7175F4983003EF01B /* .gitignore */; }; + 4CC3AABD175F4983003EF01B /* HNHRoundedTextFieldCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC3AAB9175F4983003EF01B /* HNHRoundedTextFieldCell.m */; }; + 4CC3AABE175F4983003EF01B /* LICENSE.MIT in Resources */ = {isa = PBXBuildFile; fileRef = 4CC3AABA175F4983003EF01B /* LICENSE.MIT */; }; + 4CC3AABF175F4983003EF01B /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 4CC3AABB175F4983003EF01B /* README.md */; }; 4CC6259115BA1C99002F5B11 /* MPOutlineViewDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC6259015BA1C99002F5B11 /* MPOutlineViewDelegate.m */; }; 4CCF9754173EFBA500460BD2 /* KdbEntry+Undo.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CCF9753173EFBA500460BD2 /* KdbEntry+Undo.m */; }; 4CD78ABC16D155FF00768A1D /* 07_NotepadTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4CD78AB716D155FF00768A1D /* 07_NotepadTemplate.pdf */; }; @@ -165,6 +169,8 @@ 4C5A11FB1708DE8700223D8A /* MPPasswordCreatorViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPPasswordCreatorViewController.h; sourceTree = ""; }; 4C5A11FC1708DE8700223D8A /* MPPasswordCreatorViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPasswordCreatorViewController.m; sourceTree = ""; }; 4C5A11FD1708DE8700223D8A /* PasswordCreatorView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PasswordCreatorView.xib; sourceTree = ""; }; + 4C5BF679175C01F300D53DF7 /* MPUppercaseStringValueTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPUppercaseStringValueTransformer.h; sourceTree = ""; }; + 4C5BF67A175C01F300D53DF7 /* MPUppercaseStringValueTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPUppercaseStringValueTransformer.m; sourceTree = ""; }; 4C61EA0116D2FD0800AC519E /* MPOutlineViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPOutlineViewController.h; sourceTree = ""; }; 4C61EA0216D2FD0800AC519E /* MPOutlineViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPOutlineViewController.m; sourceTree = ""; }; 4C61EA0416D2FFE200AC519E /* OutlineView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = OutlineView.xib; sourceTree = ""; }; @@ -298,8 +304,6 @@ 4CAD746315B887FD00104512 /* DDXMLPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDXMLPrivate.h; sourceTree = ""; }; 4CAD748B15B889B700104512 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; 4CAD748D15B88AC100104512 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; - 4CB25D52175A206000D1369D /* MPRoundedTextFieldCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPRoundedTextFieldCell.h; sourceTree = ""; }; - 4CB25D53175A206000D1369D /* MPRoundedTextFieldCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPRoundedTextFieldCell.m; sourceTree = ""; }; 4CB25D55175A208300D1369D /* MPTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPTextField.h; sourceTree = ""; }; 4CB25D56175A208300D1369D /* MPTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPTextField.m; sourceTree = ""; }; 4CB9339816D3A0DD00A13B5D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = ""; }; @@ -308,6 +312,11 @@ 4CBFA23F172B385D006090DF /* PasswordEditView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PasswordEditView.xib; sourceTree = ""; }; 4CC1AEBC16D4467C006D2AAB /* KdbTree+MPAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KdbTree+MPAdditions.h"; sourceTree = ""; }; 4CC1AEBD16D4467C006D2AAB /* KdbTree+MPAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "KdbTree+MPAdditions.m"; sourceTree = ""; }; + 4CC3AAB7175F4983003EF01B /* .gitignore */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = .gitignore; sourceTree = ""; }; + 4CC3AAB8175F4983003EF01B /* HNHRoundedTextFieldCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HNHRoundedTextFieldCell.h; sourceTree = ""; }; + 4CC3AAB9175F4983003EF01B /* HNHRoundedTextFieldCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HNHRoundedTextFieldCell.m; sourceTree = ""; }; + 4CC3AABA175F4983003EF01B /* LICENSE.MIT */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE.MIT; sourceTree = ""; }; + 4CC3AABB175F4983003EF01B /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.md; sourceTree = ""; }; 4CC6258F15BA1C99002F5B11 /* MPOutlineViewDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPOutlineViewDelegate.h; sourceTree = ""; }; 4CC6259015BA1C99002F5B11 /* MPOutlineViewDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPOutlineViewDelegate.m; sourceTree = ""; }; 4CCF9752173EFBA500460BD2 /* KdbEntry+Undo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KdbEntry+Undo.h"; sourceTree = ""; }; @@ -376,8 +385,6 @@ 4CE39AC316ECE4F7000FE29D /* MPPopupImageView.m */, 4C3D4C0617594CA40038DAAC /* MPSeparator.h */, 4C3D4C0717594CA40038DAAC /* MPSeparator.m */, - 4CB25D52175A206000D1369D /* MPRoundedTextFieldCell.h */, - 4CB25D53175A206000D1369D /* MPRoundedTextFieldCell.m */, 4CB25D55175A208300D1369D /* MPTextField.h */, 4CB25D56175A208300D1369D /* MPTextField.m */, ); @@ -408,6 +415,8 @@ 4C920E2916DCDFA00083839B /* MPLoggerProxy.m */, 4CBA2AB617074B59006D8139 /* MPSettingsHelper.h */, 4CBA2AB917074C07006D8139 /* MPSettingsHelper.m */, + 4C5BF679175C01F300D53DF7 /* MPUppercaseStringValueTransformer.h */, + 4C5BF67A175C01F300D53DF7 /* MPUppercaseStringValueTransformer.m */, ); name = Helper; sourceTree = ""; @@ -579,6 +588,7 @@ 4C77E35715B84A240093A587 = { isa = PBXGroup; children = ( + 4CC3AAB6175F4983003EF01B /* HNHUi */, 4C3CD2A5175570C9005F911C /* DMSplitView */, 4C669B2D16760ED100DD0774 /* MiniKeePassLib */, 4CAD745415B887FD00104512 /* KissXML */, @@ -741,6 +751,18 @@ path = Private; sourceTree = ""; }; + 4CC3AAB6175F4983003EF01B /* HNHUi */ = { + isa = PBXGroup; + children = ( + 4CC3AAB7175F4983003EF01B /* .gitignore */, + 4CC3AAB8175F4983003EF01B /* HNHRoundedTextFieldCell.h */, + 4CC3AAB9175F4983003EF01B /* HNHRoundedTextFieldCell.m */, + 4CC3AABA175F4983003EF01B /* LICENSE.MIT */, + 4CC3AABB175F4983003EF01B /* README.md */, + ); + path = HNHUi; + sourceTree = ""; + }; 4CDB556616E29A8A00635918 /* Controls */ = { isa = PBXGroup; children = ( @@ -868,6 +890,9 @@ 4C5A11FF1708DE8800223D8A /* PasswordCreatorView.xib in Resources */, 4C1DDCDD1711ECEB00C98DA3 /* PasswordCreatorWindow.xib in Resources */, 4CBFA240172B385D006090DF /* PasswordEditView.xib in Resources */, + 4CC3AABC175F4983003EF01B /* .gitignore in Resources */, + 4CC3AABE175F4983003EF01B /* LICENSE.MIT in Resources */, + 4CC3AABF175F4983003EF01B /* README.md in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -974,8 +999,9 @@ 4C22040D1746ED160054C916 /* KdbGroup+Undo.m in Sources */, 4C3CD2A8175570C9005F911C /* DMSplitView.m in Sources */, 4C3D4C0817594CA40038DAAC /* MPSeparator.m in Sources */, - 4CB25D54175A206000D1369D /* MPRoundedTextFieldCell.m in Sources */, 4CB25D57175A208300D1369D /* MPTextField.m in Sources */, + 4C5BF67B175C01F300D53DF7 /* MPUppercaseStringValueTransformer.m in Sources */, + 4CC3AABD175F4983003EF01B /* HNHRoundedTextFieldCell.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MacPass/InspectorView.xib b/MacPass/InspectorView.xib index dd571ac5..1460fd50 100644 --- a/MacPass/InspectorView.xib +++ b/MacPass/InspectorView.xib @@ -2,9 +2,9 @@ 1080 - 12D78 + 12E55 3084 - 1187.37 + 1187.39 626.00 com.apple.InterfaceBuilder.CocoaPlugin @@ -107,7 +107,6 @@ _NS:9 YES - 1 6 System @@ -296,6 +295,7 @@ {{199, 289}, {32, 25}} + _NS:22 YES @@ -1531,6 +1531,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + MPTextField com.apple.InterfaceBuilder.CocoaPlugin @@ -1553,7 +1554,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - MPRoundedTextFieldCell + HNHRoundedTextFieldCell com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1605,6 +1606,14 @@ + + HNHRoundedTextFieldCell + NSTextFieldCell + + IBProjectSource + ./Classes/HNHRoundedTextFieldCell.h + + MPInspectorViewController MPViewController @@ -1681,14 +1690,6 @@ ./Classes/MPPopupImageView.h - - MPRoundedTextFieldCell - NSTextFieldCell - - IBProjectSource - ./Classes/MPRoundedTextFieldCell.h - - MPSeparator NSView @@ -1697,6 +1698,14 @@ ./Classes/MPSeparator.h + + MPTextField + NSTextField + + IBProjectSource + ./Classes/MPTextField.h + + MPViewController NSViewController diff --git a/MacPass/KdbGroup+Undo.h b/MacPass/KdbGroup+Undo.h index 8fecf9a9..12dc2a73 100644 --- a/MacPass/KdbGroup+Undo.h +++ b/MacPass/KdbGroup+Undo.h @@ -12,12 +12,15 @@ APPKIT_EXTERN NSString *const MPGroupNameUndoableKey; @interface KdbGroup (Undo) -+ (NSUndoManager *)undoManager; +- (NSUndoManager *)undoManager; - (NSString *)nameUndoable; - (void)setNameUndoable:(NSString *)newName; -- (void)removeEntryUndoable:(KdbEntry *)entry; + - (void)addEntryUndoable:(KdbEntry *)entry; +- (void)addGroupUndoable:(KdbGroup *)group; +- (void)removeGroupUndoable:(KdbGroup *)group; +- (void)removeEntryUndoable:(KdbEntry *)entry; @end diff --git a/MacPass/KdbGroup+Undo.m b/MacPass/KdbGroup+Undo.m index 81591608..20229e4f 100644 --- a/MacPass/KdbGroup+Undo.m +++ b/MacPass/KdbGroup+Undo.m @@ -12,7 +12,7 @@ NSString *const MPGroupNameUndoableKey = @"nameUndoable"; @implementation KdbGroup (Undo) -+ (NSUndoManager *)undoManager { +- (NSUndoManager *)undoManager { return [[[NSDocumentController sharedDocumentController] currentDocument] undoManager]; } @@ -21,21 +21,32 @@ NSString *const MPGroupNameUndoableKey = @"nameUndoable"; } - (void)setNameUndoable:(NSString *)newName { - [[KdbGroup undoManager] registerUndoWithTarget:self selector:@selector(setNameUndoable:) object:self.name]; - [[KdbGroup undoManager] setActionName:NSLocalizedString(@"UNDO_SET_NAME", "Undo set name")]; + [[self undoManager] registerUndoWithTarget:self selector:@selector(setNameUndoable:) object:self.name]; + [[self undoManager] setActionName:NSLocalizedString(@"UNDO_SET_NAME", "Undo set name")]; self.name = newName; } -- (void)removeEntryUndoable:(KdbEntry *)entry { - [[KdbGroup undoManager] registerUndoWithTarget:self selector:@selector(addEntryUndoable:) object:entry]; - [[KdbGroup undoManager] setActionName:NSLocalizedString(@"UNDO_DELETE_ENTRY", "Undo deleting of entry")]; - [self removeEntry:entry]; -} - - (void)addEntryUndoable:(KdbEntry *)entry { - [[KdbGroup undoManager] registerUndoWithTarget:self selector:@selector(removeEntryUndoable:) object:entry]; - [[KdbGroup undoManager] setActionName:NSLocalizedString(@"UNDO_ADD_ENTRY", "Undo adding of entry")]; + [[self undoManager] registerUndoWithTarget:self selector:@selector(removeEntryUndoable:) object:entry]; + [[self undoManager] setActionName:NSLocalizedString(@"UNDO_ADD_ENTRY", "Undo adding of entry")]; [self addEntry:entry]; } +- (void)addGroupUndoable:(KdbGroup *)group { + [[self undoManager] registerUndoWithTarget:self selector:@selector(removeGroupUndoable:) object:group]; + [[self undoManager] setActionName:NSLocalizedString(@"UNDO_ADD_GROUP", @"Create Group Undo")]; + [self addGroup:group]; +} + +- (void)removeEntryUndoable:(KdbEntry *)entry { + [[self undoManager] registerUndoWithTarget:self selector:@selector(addEntryUndoable:) object:entry]; + [[self undoManager] setActionName:NSLocalizedString(@"UNDO_DELETE_ENTRY", "Undo deleting of entry")]; + [self removeEntry:entry]; +} + +- (void)removeGroupUndoable:(KdbGroup *)group { + [[self undoManager] registerUndoWithTarget:self selector:@selector(addGroupUndoable:) object:group]; + [[self undoManager] setActionName:NSLocalizedString(@"UNDO_DELETE_GROUP", @"Create Group Undo")]; + [group.parent removeGroup:group]; +} @end diff --git a/MacPass/MPAppDelegate.m b/MacPass/MPAppDelegate.m index 85a78224..9b24b956 100644 --- a/MacPass/MPAppDelegate.m +++ b/MacPass/MPAppDelegate.m @@ -14,6 +14,7 @@ #import "MPActionHelper.h" #import "MPSettingsHelper.h" #import "NSString+MPPasswordCreation.h" +#import "MPUppercaseStringValueTransformer.h" @interface MPAppDelegate () @@ -28,6 +29,7 @@ + (void)initialize { [MPSettingsHelper setupDefaults]; + [MPUppercaseStringValueTransformer registerTransformer]; } - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { diff --git a/MacPass/MPDocument.h b/MacPass/MPDocument.h index 3348ffb2..53d4eee0 100644 --- a/MacPass/MPDocument.h +++ b/MacPass/MPDocument.h @@ -11,9 +11,9 @@ APPKIT_EXTERN NSString *const MPDocumentDidAddGroupNotification; -APPKIT_EXTERN NSString *const MPDocumentDidDelteGroupNotification; +APPKIT_EXTERN NSString *const MPDocumentWillDelteGroupNotification; APPKIT_EXTERN NSString *const MPDocumentDidAddEntryNotification; -APPKIT_EXTERN NSString *const MPDocumentDidDeleteEntryNotification; +APPKIT_EXTERN NSString *const MPDocumentWillDeleteEntryNotification; APPKIT_EXTERN NSString *const MPDocumentEntryKey; APPKIT_EXTERN NSString *const MPDocumentGroupKey; @@ -36,7 +36,6 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey; - (KdbGroup *)createGroup:(KdbGroup *)parent; - (KdbEntry *)createEntry:(KdbGroup *)parent; -- (void)addGroup:(NSArray *)groupAndParent; - (void)deleteEntry:(KdbEntry *)entry; - (void)deleteGroup:(KdbGroup *)group; diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 8489d830..701a13c8 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -13,11 +13,13 @@ #import "Kdb4Node.h" #import "KdbPassword.h" #import "MPDatabaseVersion.h" +#import "KdbGroup+Undo.h" +#import "KdbEntry+Undo.h" NSString *const MPDocumentDidAddGroupNotification = @"MPDocumentDidAddGroupNotification"; -NSString *const MPDocumentDidDelteGroupNotification = @"MPDocumentDidDelteGroupNotification"; +NSString *const MPDocumentWillDelteGroupNotification = @"MPDocumentDidDelteGroupNotification"; NSString *const MPDocumentDidAddEntryNotification = @"MPDocumentDidAddEntryNotification"; -NSString *const MPDocumentDidDeleteEntryNotification = @"MPDocumentDidDeleteEntryNotification"; +NSString *const MPDocumentWillDeleteEntryNotification = @"MPDocumentDidDeleteEntryNotification"; NSString *const MPDocumentEntryKey = @"MPDocumentEntryKey"; NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey"; @@ -30,7 +32,6 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey"; @property (nonatomic, readonly) KdbPassword *passwordHash; @property (assign) MPDatabaseVersion version; @property (assign) BOOL isDecrypted; -@property (assign) BOOL isDirty; @end @@ -138,50 +139,34 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey"; - (KdbEntry *)createEntry:(KdbGroup *)parent { KdbEntry *newEntry = [self.tree createEntry:parent]; newEntry.title = NSLocalizedString(@"DEFAULT_ENTRY_TITLE", @"Title for a newly created entry"); - [[self undoManager] registerUndoWithTarget:self selector:@selector(deleteEntry:) object:newEntry]; - [[self undoManager] setActionName:NSLocalizedString(@"UNDO_ADD_ENTRY", @"Create Entry Undo")]; - [parent addEntry:newEntry]; + [parent addEntryUndoable:newEntry]; + NSDictionary *userInfo = @{ MPDocumentEntryKey : newEntry }; + [[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidAddEntryNotification object:self userInfo:userInfo]; return newEntry; } - (KdbGroup *)createGroup:(KdbGroup *)parent { KdbGroup *newGroup = [self.tree createGroup:parent]; newGroup.name = NSLocalizedString(@"DEFAULT_GROUP_NAME", @"Title for a newly created group"); - - [[self undoManager] registerUndoWithTarget:self selector:@selector(deleteGroup:) object:newGroup]; - [[self undoManager] setActionName:NSLocalizedString(@"UNDO_ADD_GROUP", @"Create Group Undo")]; - [parent addGroup:newGroup]; - NSDictionary *userInfo = @{ MPDocumentGroupKey:newGroup }; + [parent addGroupUndoable:newGroup]; + NSDictionary *userInfo = @{ MPDocumentGroupKey : newGroup }; [[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidAddGroupNotification object:self userInfo:userInfo]; - self.isDirty = YES; - return newGroup; } -- (void)addGroup:(NSArray *)groupAndParent{ - KdbGroup *parent = groupAndParent[0]; - KdbGroup *group = groupAndParent[1]; - NSDictionary *userInfo = @{ MPDocumentGroupKey:group }; - [[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidAddGroupNotification object:self userInfo:userInfo]; - [parent addGroup:group]; -} - - (void)deleteEntry:(KdbEntry *)entry { if(entry.parent) { - [entry.parent removeEntry:entry]; - self.isDirty = YES; + NSDictionary *userInfo = @{ MPDocumentEntryKey : entry }; + [[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentWillDeleteEntryNotification object:self userInfo:userInfo]; + [entry.parent removeEntryUndoable:entry]; } } - (void)deleteGroup:(KdbGroup *)group { if(group.parent) { - [[self undoManager] registerUndoWithTarget:self selector:@selector(addGroup:) object:@[group.parent, group]]; - [[self undoManager] setActionName:NSLocalizedString(@"UNDO_DELETE_GROUP", @"Create Group Undo")]; - [group.parent removeGroup:group]; - NSDictionary *userInfo = @{ MPDocumentEntryKey:group }; - [[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidDelteGroupNotification object:self userInfo:userInfo]; - - self.isDirty = YES; + NSDictionary *userInfo = @{ MPDocumentEntryKey : group }; + [[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentWillDelteGroupNotification object:self userInfo:userInfo]; + [group.parent removeGroupUndoable:group]; } } diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index 453a85b3..bff6e03f 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -16,6 +16,7 @@ #import "MPPasteBoardController.h" #import "MPOverlayWindowController.h" #import "KdbGroup+MPAdditions.h" +#import "KdbGroup+Undo.h" #import "KdbEntry+Undo.h" NSString *const MPDidChangeSelectedEntryNotification = @"com.macpass.MPDidChangeSelectedEntryNotification"; @@ -136,6 +137,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; name:MPOutlineViewDidChangeGroupSelection object:windowController.outlineViewController.outlineDelegate]; + //[[NSNotificationCenter defaultCenter] addObserver:self.entryTable selector:@selector(reloadData) name:MPDocumentDidAddEntryNotification object:nil]; [self.entryTable setDelegate:self]; [self.entryTable setDoubleAction:@selector(_columnDoubleClick:)]; @@ -244,14 +246,13 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; [self.filterSearchField setStringValue:@""]; } MPOutlineViewDelegate *delegate = [notification object]; - KdbGroup *group = delegate.selectedGroup; - //[self.entryTable deselectAll:nil]; - if(group) { - [self.entryArrayController setContent:nil]; - [self.entryArrayController addObjects:group.entries]; + self.activeGroup = delegate.selectedGroup; + + if(_activeGroup) { + [self.entryArrayController bind:NSContentArrayBinding toObject:_activeGroup withKeyPath:@"entries" options:nil]; } else { - [self.entryArrayController setContent:nil]; + [self.entryArrayController unbind:NSContentArrayBinding]; } } @@ -478,7 +479,11 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; } - (void)createEntry:(id)sender { - // TODO: + if(!_activeGroup) { + return; // Entries are not allowed in root group + } + MPDocument *document = [[NSDocumentController sharedDocumentController] currentDocument]; + [document createEntry:_activeGroup]; } - (void)deleteEntry:(id)sender { diff --git a/MacPass/MPOutlineViewController.h b/MacPass/MPOutlineViewController.h index b44b8fc4..fee5115c 100644 --- a/MacPass/MPOutlineViewController.h +++ b/MacPass/MPOutlineViewController.h @@ -9,12 +9,14 @@ #import "MPViewController.h" @class MPOutlineViewDelegate; +@class KdbGroup; @interface MPOutlineViewController : MPViewController @property (retain, readonly) MPOutlineViewDelegate *outlineDelegate; @property (assign, nonatomic) BOOL isVisible; + - (void)clearSelection; - (void)showOutline; diff --git a/MacPass/MPOutlineViewController.m b/MacPass/MPOutlineViewController.m index 9aeff311..715479c2 100644 --- a/MacPass/MPOutlineViewController.m +++ b/MacPass/MPOutlineViewController.m @@ -51,7 +51,7 @@ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didUpdateData:) - name:MPDocumentDidDelteGroupNotification + name:MPDocumentWillDelteGroupNotification object:[[self windowController] document]]; } diff --git a/MacPass/MPOutlineViewDelegate.m b/MacPass/MPOutlineViewDelegate.m index 6b9d7f26..5279d207 100644 --- a/MacPass/MPOutlineViewDelegate.m +++ b/MacPass/MPOutlineViewDelegate.m @@ -8,6 +8,7 @@ #import "MPOutlineViewDelegate.h" #import "MPIconHelper.h" +#import "MPUppercaseStringValueTransformer.h" #import "KdbLib.h" NSString *const MPOutlineViewDidChangeGroupSelection = @"com.macpass.MPOutlineViewDidChangeGroupSelection"; @@ -27,8 +28,9 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; KdbGroup *group = item; NSTableCellView *view; if(![group parent]) { + NSDictionary *options = @{ NSValueTransformerBindingOption : [NSValueTransformer valueTransformerForName:MPUppsercaseStringValueTransformerName] }; view = [outlineView makeViewWithIdentifier:_MPOutlinveViewHeaderViewIdentifier owner:self]; - [view.textField bind:NSValueBinding toObject:group withKeyPath:@"name" options:nil]; + [view.textField bind:NSValueBinding toObject:group withKeyPath:@"name" options:options]; } else { view = [outlineView makeViewWithIdentifier:_MPOutlineViewDataViewIdentifier owner:self]; diff --git a/MacPass/MPRoundedTextFieldCell.h b/MacPass/MPRoundedTextFieldCell.h deleted file mode 100644 index 1f92c070..00000000 --- a/MacPass/MPRoundedTextFieldCell.h +++ /dev/null @@ -1,14 +0,0 @@ -// -// MPRoundedTextFieldCell.h -// MacPass -// -// Created by Michael Starke on 01.06.13. -// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. -// - -#import - -@interface MPRoundedTextFieldCell : NSTextFieldCell - - -@end diff --git a/MacPass/MPRoundedTextFieldCell.m b/MacPass/MPRoundedTextFieldCell.m deleted file mode 100644 index a90fb017..00000000 --- a/MacPass/MPRoundedTextFieldCell.m +++ /dev/null @@ -1,51 +0,0 @@ -// -// MPRoundedTextFieldCell.m -// MacPass -// -// Created by Michael Starke on 01.06.13. -// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. -// - -#import "MPRoundedTextFieldCell.h" - -#define CORNER_RADIUS 3.0 - -@implementation MPRoundedTextFieldCell - -- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { - NSRect pathRect = NSInsetRect(cellFrame, 0.5, 0.5); - NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:pathRect xRadius:CORNER_RADIUS yRadius:CORNER_RADIUS]; - [([self isEnabled] ? [NSColor colorWithCalibratedWhite:0.55 alpha:1] : [NSColor colorWithCalibratedWhite:0.75 alpha:1]) setStroke]; - [[NSColor whiteColor] setFill]; - [path fill]; - - [NSGraphicsContext saveGraphicsState]; - NSShadow *shadow = [[NSShadow alloc] init]; - [shadow setShadowColor:[NSColor colorWithCalibratedWhite:0.8 alpha:1]]; - [shadow setShadowOffset:NSMakeSize(0, -1)]; - [shadow setShadowBlurRadius:2]; - [shadow set]; - [path setClip]; - [path stroke]; - [shadow release]; - - [NSGraphicsContext restoreGraphicsState]; - [path stroke]; - //[shadow release]; - [super drawInteriorWithFrame:cellFrame inView:controlView]; -} - -- (void)drawFocusRingMaskWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { - NSLog(@"drawFocusRing"); - //NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:cellFrame xRadius:CORNER_RADIUS yRadius:CORNER_RADIUS]; - //[path stroke]; - [super drawFocusRingMaskWithFrame:cellFrame inView:controlView]; -} - -- (NSRect)focusRingMaskBoundsForFrame:(NSRect)cellFrame inView:(NSView *)controlView { - return [controlView bounds]; -} - - - -@end diff --git a/MacPass/MPTextField.m b/MacPass/MPTextField.m index 68e2fc17..6225ee93 100644 --- a/MacPass/MPTextField.m +++ b/MacPass/MPTextField.m @@ -7,33 +7,19 @@ // #import "MPTextField.h" -#import "MPRoundedTextFieldCell.h" +#import "HNHRoundedTextFieldCell.h" @implementation MPTextField + (Class)cellClass { - return [MPRoundedTextFieldCell class]; + return [HNHRoundedTextFieldCell class]; } -- (id)initWithCoder:(NSCoder *)aDecoder { - self = [super initWithCoder:aDecoder]; - if(self) { - MPRoundedTextFieldCell *newCell = [[MPRoundedTextFieldCell alloc] init]; - NSTextFieldCell *cell = [self cell]; - [newCell setBackgroundStyle:[cell backgroundStyle]]; - [newCell setBezeled:[cell isBezeled]]; - [newCell setBordered:[cell isBordered]]; - [newCell setBackgroundColor:[cell backgroundColor]]; - [newCell setTextColor:[cell textColor]]; - [newCell setDrawsBackground:[cell drawsBackground]]; - [newCell setAction:[cell action]]; - [newCell setTarget:[cell target]]; - [newCell setEditable:[cell isEditable]]; - [newCell setEnabled:[cell isEnabled]]; - [self setCell:newCell]; - [newCell release]; +- (void)awakeFromNib { + [[self class] setCellClass:[HNHRoundedTextFieldCell class]]; + if([[super class] instanceMethodForSelector:@selector(awakeFromNib)]) { + [super awakeFromNib]; } - return self; } @end diff --git a/MacPass/MPUppercaseStringValueTransformer.h b/MacPass/MPUppercaseStringValueTransformer.h new file mode 100644 index 00000000..efba0053 --- /dev/null +++ b/MacPass/MPUppercaseStringValueTransformer.h @@ -0,0 +1,17 @@ +// +// MPUppercaseStringValueTransformer.h +// MacPass +// +// Created by Michael Starke on 03.06.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +APPKIT_EXTERN NSString *const MPUppsercaseStringValueTransformerName; + +#import + +@interface MPUppercaseStringValueTransformer : NSValueTransformer + ++ (void)registerTransformer; + +@end diff --git a/MacPass/MPUppercaseStringValueTransformer.m b/MacPass/MPUppercaseStringValueTransformer.m new file mode 100644 index 00000000..f0464940 --- /dev/null +++ b/MacPass/MPUppercaseStringValueTransformer.m @@ -0,0 +1,37 @@ +// +// MPUppercaseStringValueTransformer.m +// MacPass +// +// Created by Michael Starke on 03.06.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "MPUppercaseStringValueTransformer.h" + +NSString *const MPUppsercaseStringValueTransformerName = @"StringToUppercaseStringTransformer"; + +@implementation MPUppercaseStringValueTransformer + ++ (Class)transformedValueClass { + return [NSString class]; +} + ++ (BOOL)allowsReverseTransformation { + return NO; +} + ++ (void)registerTransformer { + MPUppercaseStringValueTransformer *transformer = [[MPUppercaseStringValueTransformer alloc] init]; + [NSValueTransformer setValueTransformer:transformer + forName:MPUppsercaseStringValueTransformerName]; + [transformer release]; +} + +- (id)transformedValue:(id)value { + if([value respondsToSelector:@selector(uppercaseString)]) { + return [value uppercaseString]; + } + return value; +} + +@end diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index 93c20cbc..4223bd2c 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -46,7 +46,7 @@ CFBundleSignature ???? CFBundleVersion - 7F1 + 863 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright diff --git a/MacPass/NSString+MPPasswordCreation.m b/MacPass/NSString+MPPasswordCreation.m index 133667bb..488d78d3 100644 --- a/MacPass/NSString+MPPasswordCreation.m +++ b/MacPass/NSString+MPPasswordCreation.m @@ -20,7 +20,6 @@ static NSUInteger randomInteger(NSUInteger minimum, NSUInteger maximum) { return maximum; } if( delta < 0 ) { - maximum = minimum; minimum -= delta; delta = -delta; }