From cc58ec3770b91d626fee7ce3574e0fe1fe30cd31 Mon Sep 17 00:00:00 2001 From: michael starke Date: Thu, 13 Jun 2013 23:31:19 +0200 Subject: [PATCH] Refactored to NS_ENUM and NS_OPTION --- MacPass.xcodeproj/project.pbxproj | 6 ++ MacPass/Base.lproj/InspectorView.xib | 15 ++++- MacPass/EntryView.xib | 20 +++++-- MacPass/MPActionHelper.h | 5 +- MacPass/MPDatabaseVersion.h | 4 +- MacPass/MPEntryViewController.m | 29 ++++++---- MacPass/MPIconHelper.h | 4 +- MacPass/MPInspectorViewController.h | 2 + MacPass/MPInspectorViewController.m | 2 + MacPass/MPOutlineViewController.h | 2 + MacPass/MPOutlineViewController.m | 2 + MacPass/MPSettingsHelper.h | 4 +- MacPass/MPShadowBox.h | 10 ++-- MacPass/MacPass-Info.plist | 2 +- MacPass/NSString+MPPasswordAnalysis.h | 4 +- MacPass/NSString+MPPasswordCreation.h | 4 +- MacPass/OutlineView.xib | 83 ++++----------------------- 17 files changed, 91 insertions(+), 107 deletions(-) diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index e7976601..f9b3bec3 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -19,6 +19,7 @@ 4C2E381F16D11FF900037A9D /* 05_LanguagesTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C2E381C16D11FF900037A9D /* 05_LanguagesTemplate.pdf */; }; 4C2E382316D1421B00037A9D /* MPIconHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C2E382216D1421B00037A9D /* MPIconHelper.m */; }; 4C2E382616D1470200037A9D /* MPViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C2E382516D1470200037A9D /* MPViewController.m */; }; + 4C37A6731769393300AD0A40 /* HNHTableHeaderCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C37A6721769393300AD0A40 /* HNHTableHeaderCell.m */; }; 4C37A84015B8B474005EF8EE /* MPOutlineDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C37A83F15B8B474005EF8EE /* MPOutlineDataSource.m */; }; 4C3BD51516D276F800389F1F /* MPToolbarDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C3BD51416D276F800389F1F /* MPToolbarDelegate.m */; }; 4C3CD2A8175570C9005F911C /* DMSplitView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C3CD2A7175570C9005F911C /* DMSplitView.m */; }; @@ -155,6 +156,8 @@ 4C2E382216D1421B00037A9D /* MPIconHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPIconHelper.m; sourceTree = ""; }; 4C2E382416D1470200037A9D /* MPViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPViewController.h; sourceTree = ""; }; 4C2E382516D1470200037A9D /* MPViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPViewController.m; sourceTree = ""; }; + 4C37A6711769393300AD0A40 /* HNHTableHeaderCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HNHTableHeaderCell.h; sourceTree = ""; }; + 4C37A6721769393300AD0A40 /* HNHTableHeaderCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HNHTableHeaderCell.m; sourceTree = ""; }; 4C37A83E15B8B474005EF8EE /* MPOutlineDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPOutlineDataSource.h; sourceTree = ""; }; 4C37A83F15B8B474005EF8EE /* MPOutlineDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPOutlineDataSource.m; sourceTree = ""; }; 4C3BD51316D276F800389F1F /* MPToolbarDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPToolbarDelegate.h; sourceTree = ""; }; @@ -816,6 +819,8 @@ 4C69A73916D589DF00EC1B1A /* HNHGradientView.m */, 4C01C243176500C40016D5D0 /* HNHLevelIndicatorCell.h */, 4C01C244176500C40016D5D0 /* HNHLevelIndicatorCell.m */, + 4C37A6711769393300AD0A40 /* HNHTableHeaderCell.h */, + 4C37A6721769393300AD0A40 /* HNHTableHeaderCell.m */, ); path = HNHUi; sourceTree = ""; @@ -1068,6 +1073,7 @@ 4C569DA417653F3500595B62 /* KdbEntry+MPTreeTools.m in Sources */, 4C79DF2A176685870083708F /* HNHRoundedTextField.m in Sources */, 4C46E09E17673A0A00DA62E8 /* HNHShadowBox.m in Sources */, + 4C37A6731769393300AD0A40 /* HNHTableHeaderCell.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MacPass/Base.lproj/InspectorView.xib b/MacPass/Base.lproj/InspectorView.xib index 8a4780f3..72aa4e84 100644 --- a/MacPass/Base.lproj/InspectorView.xib +++ b/MacPass/Base.lproj/InspectorView.xib @@ -446,6 +446,14 @@ 710 + + + bottomBar + + + + 711 + @@ -1614,7 +1622,7 @@ - 710 + 711 @@ -1674,6 +1682,7 @@ NSTextField + HNHGradientView MPPopupImageView NSTextField NSTextField @@ -1686,6 +1695,10 @@ URLTextField NSTextField + + bottomBar + HNHGradientView + itemImageView MPPopupImageView diff --git a/MacPass/EntryView.xib b/MacPass/EntryView.xib index e0393961..56437fbc 100644 --- a/MacPass/EntryView.xib +++ b/MacPass/EntryView.xib @@ -58,7 +58,6 @@ {{7, 5}, {32, 19}} - _NS:9 YES @@ -108,7 +107,7 @@ {684, 548} - + _NS:13 YES NO @@ -393,7 +392,7 @@ {{0, 30}, {684, 565}} - + _NS:9 133680 @@ -455,6 +454,14 @@ 686 + + + bottomBar + + + + 744 + textField @@ -1735,7 +1742,7 @@ - 743 + 744 @@ -1751,6 +1758,7 @@ MPEntryViewController MPViewController + HNHGradientView NSTableView NSView NSButton @@ -1762,6 +1770,10 @@ NSLayoutConstraint + + bottomBar + HNHGradientView + entryTable NSTableView diff --git a/MacPass/MPActionHelper.h b/MacPass/MPActionHelper.h index 8b65c59a..113c07c0 100644 --- a/MacPass/MPActionHelper.h +++ b/MacPass/MPActionHelper.h @@ -8,7 +8,7 @@ #import -typedef enum { +typedef NS_ENUM(NSUInteger, MPActionType) { MPActionAddEntry, // Add an new entry MPActionAddGroup, // Add a new group MPActionEdit, // Edit entry or group @@ -19,8 +19,7 @@ typedef enum { MPActionOpenURL, // open url in default browser MPActionToggleInspector, MPActionLock, // show the lock screen -} -MPActionType; +}; @interface MPActionHelper : NSObject diff --git a/MacPass/MPDatabaseVersion.h b/MacPass/MPDatabaseVersion.h index d4d087b5..5301d12a 100644 --- a/MacPass/MPDatabaseVersion.h +++ b/MacPass/MPDatabaseVersion.h @@ -9,9 +9,9 @@ #ifndef MacPass_MPDatabaseVersion_h #define MacPass_MPDatabaseVersion_h -typedef enum { +typedef NS_ENUM(NSUInteger, MPDatabaseVersion) { MPDatabaseVersion3, MPDatabaseVersion4 -} MPDatabaseVersion; +}; #endif diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index 5b2e6638..21b5c7f7 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -21,23 +21,25 @@ #import "MPContextMenuHelper.h" #import "MPConstants.h" #import "MPEntryTableDataSource.h" +#import "HNHTableHeaderCell.h" +#import "HNHGradientView.h" NSString *const MPDidChangeSelectedEntryNotification = @"com.macpass.MPDidChangeSelectedEntryNotification"; #define STATUS_BAR_ANIMATION_TIME 0.2 -typedef enum { - MPFilterNone = 0, - MPFilterUrls = 2, - MPFilterUsernames = 4, - MPFilterTitles = 8, -} MPFilterModeType; +typedef NS_OPTIONS(NSUInteger, MPFilterModeType) { + MPFilterNone = 0, + MPFilterUrls = (1<<0), + MPFilterUsernames = (1<<1), + MPFilterTitles = (1<<2), +}; -typedef enum { +typedef NS_ENUM(NSUInteger,MPOVerlayInfoType) { MPOverlayInfoPassword, MPOverlayInfoUsername, MPOverlayInfoURL, -} MPOVerlayInfoType; +}; NSString *const MPEntryTableUserNameColumnIdentifier = @"MPUserNameColumnIdentifier"; NSString *const MPEntryTableTitleColumnIdentifier = @"MPTitleColumnIdentifier"; @@ -67,6 +69,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; @property (assign) IBOutlet NSButton *filterURLButton; @property (assign) IBOutlet NSTextField *filterLabelTextField; @property (assign) IBOutlet NSSearchField *filterSearchField; +@property (assign) IBOutlet HNHGradientView *bottomBar; @property (assign) KdbEntry *selectedEntry; @@ -115,6 +118,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; - (void)didLoadView { [self.view setWantsLayer:YES]; [self _hideFilterBarAnimated:NO]; + [_bottomBar setBorderType:HNHBorderTop]; MPDocumentWindowController *windowController = [self windowController]; [[NSNotificationCenter defaultCenter] addObserver:self @@ -128,13 +132,18 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; [self.entryTable setFloatsGroupRows:NO]; [self.entryTable registerForDraggedTypes:@[MPPasteBoardType]]; [self _setupEntryMenu]; - + NSTableColumn *parentColumn = [self.entryTable tableColumns][0]; NSTableColumn *titleColumn = [self.entryTable tableColumns][1]; NSTableColumn *userNameColumn = [self.entryTable tableColumns][2]; NSTableColumn *passwordColumn = [self.entryTable tableColumns][3]; NSTableColumn *urlColumn = [self.entryTable tableColumns][4]; + for(NSTableColumn *column in [self.entryTable tableColumns]) { + [column setHeaderCell:[[HNHTableHeaderCell alloc] init]]; + } + + [parentColumn setIdentifier:MPEntryTableParentColumnIdentifier]; [titleColumn setIdentifier:MPEntryTableTitleColumnIdentifier]; [userNameColumn setIdentifier:MPEntryTableUserNameColumnIdentifier]; @@ -237,7 +246,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; #pragma mark Filtering - (void)showFilter:(id)sender { - //[self _showFilterBarAnimated:NO]; + [self _showFilterBarAnimated:NO]; } - (BOOL)hasFilter { diff --git a/MacPass/MPIconHelper.h b/MacPass/MPIconHelper.h index 05088f95..b3173667 100644 --- a/MacPass/MPIconHelper.h +++ b/MacPass/MPIconHelper.h @@ -8,7 +8,7 @@ #import -typedef enum { +typedef NS_ENUM(NSUInteger, MPIconType) { MPIconPassword, MPIconPackageNetwork, MPIconWarning, @@ -20,7 +20,7 @@ typedef enum { MPIconIdentity, MPIconContact, MPIconCamera -} MPIconType; +}; @interface MPIconHelper : NSObject diff --git a/MacPass/MPInspectorViewController.h b/MacPass/MPInspectorViewController.h index ab4895bb..60abbe62 100644 --- a/MacPass/MPInspectorViewController.h +++ b/MacPass/MPInspectorViewController.h @@ -11,6 +11,7 @@ @class MPPopupImageView; @class KdbEntry; @class KdbGroup; +@class HNHGradientView; @interface MPInspectorViewController : MPViewController @@ -22,6 +23,7 @@ @property (assign) IBOutlet NSTextField *URLTextField; @property (assign) IBOutlet NSTextField *passwordTextField; @property (assign) IBOutlet NSTextField *titleOrNameLabel; +@property (assign) IBOutlet HNHGradientView *bottomBar; - (void)closeActivePopup:(id)sender; diff --git a/MacPass/MPInspectorViewController.m b/MacPass/MPInspectorViewController.m index 278e5a04..6f7055d6 100644 --- a/MacPass/MPInspectorViewController.m +++ b/MacPass/MPInspectorViewController.m @@ -17,6 +17,7 @@ #import "KdbLib.h" #import "KdbGroup+Undo.h" #import "KdbEntry+Undo.h" +#import "HNHGradientView.h" @interface MPInspectorViewController () { BOOL _visible; @@ -58,6 +59,7 @@ [[self.itemImageView cell] setBackgroundStyle:NSBackgroundStyleRaised]; [self.itemImageView setTarget:self]; + [_bottomBar setBorderType:HNHBorderTop]; /* Register for Entry selection */ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didChangeSelectedEntry:) diff --git a/MacPass/MPOutlineViewController.h b/MacPass/MPOutlineViewController.h index 8efa5776..beec2f00 100644 --- a/MacPass/MPOutlineViewController.h +++ b/MacPass/MPOutlineViewController.h @@ -10,10 +10,12 @@ @class MPOutlineViewDelegate; @class KdbGroup; +@class HNHGradientView; @interface MPOutlineViewController : MPViewController @property (retain, readonly) MPOutlineViewDelegate *outlineDelegate; +@property (assign) IBOutlet HNHGradientView *bottomBar; - (void)clearSelection; - (void)showOutline; diff --git a/MacPass/MPOutlineViewController.m b/MacPass/MPOutlineViewController.m index 487aa262..a6508eb5 100644 --- a/MacPass/MPOutlineViewController.m +++ b/MacPass/MPOutlineViewController.m @@ -15,6 +15,7 @@ #import "KdbGroup+Undo.h" #import "MPContextMenuHelper.h" #import "MPConstants.h" +#import "HNHGradientView.h" @interface MPOutlineViewController () { @@ -64,6 +65,7 @@ [self.outlineView setFloatsGroupRows:NO]; [_outlineView registerForDraggedTypes:@[ MPPasteBoardType ]]; [self.outlineView setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES]; + [_bottomBar setBorderType:HNHBorderTop]; } - (void)showOutline { diff --git a/MacPass/MPSettingsHelper.h b/MacPass/MPSettingsHelper.h index 2cf8dadd..ac94dccf 100644 --- a/MacPass/MPSettingsHelper.h +++ b/MacPass/MPSettingsHelper.h @@ -13,10 +13,10 @@ APPKIT_EXTERN NSString *const kMPSettingsKeyClearPasteboardOnQuit; APPKIT_EXTERN NSString *const kMPSettingsKeyPasswordEncoding; APPKIT_EXTERN NSString *const kMPSettingsKeyOpenEmptyDatabaseOnLaunch; -typedef enum { +typedef NS_ENUM(NSUInteger, MPPasswordEncoding) { MPPasswordEncodingUTF8, MPPasswordEncodingASCII, -} MPPasswordEncoding; +}; @interface MPSettingsHelper : NSObject diff --git a/MacPass/MPShadowBox.h b/MacPass/MPShadowBox.h index 8636cdad..d8873fd3 100644 --- a/MacPass/MPShadowBox.h +++ b/MacPass/MPShadowBox.h @@ -8,11 +8,11 @@ #import -typedef enum { - MPShadowTop = 1 << 0, - MPShadowBottom = 1 << 1, - MPShadowTopAndBottom = MPShadowTop | MPShadowBottom -} MPShadowDisplay; +typedef NS_OPTIONS(NSUInteger, MPShadowDisplay) { + MPShadowTop = (1<<0), + MPShadowBottom = (1<<1), + MPShadowTopAndBottom = MPShadowTop | MPShadowBottom +}; @interface MPShadowBox : NSView diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index 78011c31..34388f8c 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -48,7 +48,7 @@ CFBundleSignature ???? CFBundleVersion - CC5 + CDC LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright diff --git a/MacPass/NSString+MPPasswordAnalysis.h b/MacPass/NSString+MPPasswordAnalysis.h index 5bfdf1bc..1cddda16 100644 --- a/MacPass/NSString+MPPasswordAnalysis.h +++ b/MacPass/NSString+MPPasswordAnalysis.h @@ -8,13 +8,13 @@ #import -typedef enum { +typedef NS_ENUM(NSUInteger, MPPasswordStrength) { MPPasswordWeak, MPPasswordOK, MPPasswordGood, MPPasswordStrong, MPPasswordExcelent, -} MPPasswordStrength; +}; @interface NSString (MPPasswordAnalysis) diff --git a/MacPass/NSString+MPPasswordCreation.h b/MacPass/NSString+MPPasswordCreation.h index ec4c6ffa..a703e6ba 100644 --- a/MacPass/NSString+MPPasswordCreation.h +++ b/MacPass/NSString+MPPasswordCreation.h @@ -8,13 +8,13 @@ #import -typedef enum { +typedef NS_OPTIONS(NSUInteger, MPPasswordCharacterFlags) { MPPasswordCharactersUpperCase = (1<<0), // NSCharacterset lowerCaseCharacterSet MPPasswordCharactersLowerCase = (1<<1), // NSCharacterSet upperCaseCharacterSet MPPasswordCharactersNumbers = (1<<2), // NSCharacterSet numberCharacterSet MPPasswordCharactersSymbols = (1<<3), // NSCharacterSet symbolCharacterSet MPPasswordCharactersAll = MPPasswordCharactersUpperCase | MPPasswordCharactersLowerCase | MPPasswordCharactersNumbers | MPPasswordCharactersSymbols -} MPPasswordCharacterFlags; +}; /* Generates a random integer in between (inkluding) minimum and maxium diff --git a/MacPass/OutlineView.xib b/MacPass/OutlineView.xib index e7aa7254..61d047aa 100644 --- a/MacPass/OutlineView.xib +++ b/MacPass/OutlineView.xib @@ -56,8 +56,6 @@ 268 {{7, 5}, {32, 19}} - - _NS:9 YES @@ -87,7 +85,6 @@ {272, 30} - _NS:9 HNHGradientView @@ -106,7 +103,6 @@ {272, 419} - _NS:13 YES @@ -221,7 +217,6 @@ {272, 419} - _NS:11 @@ -233,7 +228,6 @@ -2147483392 {{224, 17}, {15, 102}} - _NS:15 NO @@ -246,7 +240,6 @@ -2147483392 {{1, 119}, {238, 15}} - _NS:60 NO @@ -258,7 +251,6 @@ {{0, 30}, {272, 419}} - _NS:9 133680 @@ -273,7 +265,6 @@ {272, 449} - _NS:9 NSView @@ -297,6 +288,14 @@ 273 + + + bottomBar + + + + 433 + textField @@ -1119,71 +1118,9 @@ - 432 - - - - - HNHBadgedTextField - NSTextField - - IBProjectSource - ./Classes/HNHBadgedTextField.h - - - - HNHBadgedTextFieldCell - NSTextFieldCell - - IBProjectSource - ./Classes/HNHBadgedTextFieldCell.h - - - - HNHGradientView - NSView - - IBProjectSource - ./Classes/HNHGradientView.h - - - - MPOutlineViewController - MPViewController - - outlineView - NSOutlineView - - - outlineView - - outlineView - NSOutlineView - - - - IBProjectSource - ./Classes/MPOutlineViewController.h - - - - MPViewController - NSViewController - - IBProjectSource - ./Classes/MPViewController.h - - - - NSLayoutConstraint - NSObject - - IBProjectSource - ./Classes/NSLayoutConstraint.h - - - + 433 + 0 IBCocoaFramework YES