Changed custom fields to use a tableview

Custom fields are stored and loaded, missing Undo
This commit is contained in:
michael starke
2013-06-28 02:17:49 +02:00
parent 1be2827da2
commit f56c325242
18 changed files with 1441 additions and 323 deletions

View File

@@ -51,6 +51,8 @@
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 */; };
4C36E5B1177CD38C00152132 /* Kdb4Tree+Undo.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C36E5B0177CD38C00152132 /* Kdb4Tree+Undo.m */; };
4C36E5B4177CD4FB00152132 /* Kdb4Tree+KVOAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C36E5B3177CD4FB00152132 /* Kdb4Tree+KVOAdditions.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 */; };
@@ -63,6 +65,8 @@
4C46E09E17673A0A00DA62E8 /* HNHShadowBox.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C46E09D17673A0A00DA62E8 /* HNHShadowBox.m */; };
4C4A100F176286FD00BBF2CA /* MPTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C4A100E176286FD00BBF2CA /* MPTableView.m */; };
4C4A101217629DA900BBF2CA /* KdbGroup+KVOAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C4A101117629DA900BBF2CA /* KdbGroup+KVOAdditions.m */; };
4C4FCE15177CFE6B00BBF7AE /* MPCustomFieldTableCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C4FCE14177CFE6B00BBF7AE /* MPCustomFieldTableCellView.m */; };
4C4FCE18177D03D700BBF7AE /* Kdb4Entry+KVOAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C4FCE17177D03D700BBF7AE /* Kdb4Entry+KVOAdditions.m */; };
4C569D9E17652B0600595B62 /* MPConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C569D9D17652B0600595B62 /* MPConstants.m */; };
4C569DA117652BFE00595B62 /* MPEntryTableDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C569DA017652BFE00595B62 /* MPEntryTableDataSource.m */; };
4C569DA417653F3500595B62 /* KdbEntry+MPTreeTools.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C569DA317653F3500595B62 /* KdbEntry+MPTreeTools.m */; };
@@ -268,6 +272,10 @@
4C2E382216D1421B00037A9D /* MPIconHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPIconHelper.m; sourceTree = "<group>"; };
4C2E382416D1470200037A9D /* MPViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPViewController.h; sourceTree = "<group>"; };
4C2E382516D1470200037A9D /* MPViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPViewController.m; sourceTree = "<group>"; };
4C36E5AF177CD38C00152132 /* Kdb4Tree+Undo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Kdb4Tree+Undo.h"; sourceTree = "<group>"; };
4C36E5B0177CD38C00152132 /* Kdb4Tree+Undo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "Kdb4Tree+Undo.m"; sourceTree = "<group>"; };
4C36E5B2177CD4FB00152132 /* Kdb4Tree+KVOAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Kdb4Tree+KVOAdditions.h"; sourceTree = "<group>"; };
4C36E5B3177CD4FB00152132 /* Kdb4Tree+KVOAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "Kdb4Tree+KVOAdditions.m"; sourceTree = "<group>"; };
4C37A6711769393300AD0A40 /* HNHTableHeaderCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HNHTableHeaderCell.h; sourceTree = "<group>"; };
4C37A6721769393300AD0A40 /* HNHTableHeaderCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HNHTableHeaderCell.m; sourceTree = "<group>"; };
4C37A83E15B8B474005EF8EE /* MPOutlineDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPOutlineDataSource.h; sourceTree = "<group>"; };
@@ -290,6 +298,10 @@
4C4A100E176286FD00BBF2CA /* MPTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPTableView.m; sourceTree = "<group>"; };
4C4A101017629DA900BBF2CA /* KdbGroup+KVOAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KdbGroup+KVOAdditions.h"; sourceTree = "<group>"; };
4C4A101117629DA900BBF2CA /* KdbGroup+KVOAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "KdbGroup+KVOAdditions.m"; sourceTree = "<group>"; };
4C4FCE13177CFE6B00BBF7AE /* MPCustomFieldTableCellView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPCustomFieldTableCellView.h; sourceTree = "<group>"; };
4C4FCE14177CFE6B00BBF7AE /* MPCustomFieldTableCellView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPCustomFieldTableCellView.m; sourceTree = "<group>"; };
4C4FCE16177D03D700BBF7AE /* Kdb4Entry+KVOAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Kdb4Entry+KVOAdditions.h"; sourceTree = "<group>"; };
4C4FCE17177D03D700BBF7AE /* Kdb4Entry+KVOAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "Kdb4Entry+KVOAdditions.m"; sourceTree = "<group>"; };
4C569D9C17652AC800595B62 /* MPConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPConstants.h; sourceTree = "<group>"; };
4C569D9D17652B0600595B62 /* MPConstants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPConstants.m; sourceTree = "<group>"; };
4C569D9F17652BFE00595B62 /* MPEntryTableDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPEntryTableDataSource.h; sourceTree = "<group>"; };
@@ -561,6 +573,8 @@
4CE39AC316ECE4F7000FE29D /* MPPopupImageView.m */,
4C4A100D176286FD00BBF2CA /* MPTableView.h */,
4C4A100E176286FD00BBF2CA /* MPTableView.m */,
4C4FCE13177CFE6B00BBF7AE /* MPCustomFieldTableCellView.h */,
4C4FCE14177CFE6B00BBF7AE /* MPCustomFieldTableCellView.m */,
);
name = Views;
sourceTree = "<group>";
@@ -739,8 +753,14 @@
4C01C23E1764D2980016D5D0 /* KdbEntry+Undo.m */,
4C22040B1746ED160054C916 /* KdbGroup+Undo.h */,
4C22040C1746ED160054C916 /* KdbGroup+Undo.m */,
4C36E5AF177CD38C00152132 /* Kdb4Tree+Undo.h */,
4C36E5B0177CD38C00152132 /* Kdb4Tree+Undo.m */,
4C4A101017629DA900BBF2CA /* KdbGroup+KVOAdditions.h */,
4C4A101117629DA900BBF2CA /* KdbGroup+KVOAdditions.m */,
4C36E5B2177CD4FB00152132 /* Kdb4Tree+KVOAdditions.h */,
4C36E5B3177CD4FB00152132 /* Kdb4Tree+KVOAdditions.m */,
4C4FCE16177D03D700BBF7AE /* Kdb4Entry+KVOAdditions.h */,
4C4FCE17177D03D700BBF7AE /* Kdb4Entry+KVOAdditions.m */,
4C83F4A81774B155006C5FC0 /* Kdb3Tree+NewTree.h */,
4C83F4A91774B155006C5FC0 /* Kdb3Tree+NewTree.m */,
4C83F4AB1774B25F006C5FC0 /* Kdb4Tree+NewTree.h */,
@@ -1442,6 +1462,10 @@
4CD5D705177A5F3300100649 /* MPDocumentSettingsWindowController.m in Sources */,
4C5EC302177B700D00DA955B /* MPRootAdapter.m in Sources */,
4C74DD07177BD1640034A9DB /* MPCustomFieldView.m in Sources */,
4C36E5B1177CD38C00152132 /* Kdb4Tree+Undo.m in Sources */,
4C36E5B4177CD4FB00152132 /* Kdb4Tree+KVOAdditions.m in Sources */,
4C4FCE15177CFE6B00BBF7AE /* MPCustomFieldTableCellView.m in Sources */,
4C4FCE18177D03D700BBF7AE /* Kdb4Entry+KVOAdditions.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
//
// Kdb4Entry+KVOAdditions.h
// MacPass
//
// Created by Michael Starke on 28.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "Kdb4Node.h"
@interface Kdb4Entry (KVOAdditions)
- (NSUInteger)countOfStringFields;
- (StringField *)objectInStringFieldsAtIndex:(NSUInteger)index;
- (void)removeObjectFromStringFieldsAtIndex:(NSUInteger)anIndex;
- (void)insertObject:(StringField *)stringfield inStringFieldsAtIndex:(NSUInteger)anIndex;
@end

View File

@@ -0,0 +1,29 @@
//
// Kdb4Entry+KVOAdditions.m
// MacPass
//
// Created by Michael Starke on 28.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "Kdb4Entry+KVOAdditions.h"
@implementation Kdb4Entry (KVOAdditions)
- (NSUInteger)countOfStringFields {
return [self.stringFields count];
}
- (StringField *)objectInStringFieldsAtIndex:(NSUInteger)index {
return [self.stringFields objectAtIndex:index];
}
- (void)insertObject:(StringField *)stringfield inStringFieldsAtIndex:(NSUInteger)anIndex {
[self.stringFields insertObject:stringfield atIndex:anIndex];
}
- (void)removeObjectFromStringFieldsAtIndex:(NSUInteger)anIndex {
[self.stringFields removeObjectAtIndex:anIndex];
}
@end

View File

@@ -0,0 +1,19 @@
//
// Kdb4Tree+KVOAdditions.h
// MacPass
//
// Created by Michael Starke on 27.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "Kdb4Node.h"
@interface Kdb4Tree (KVOAdditions)
- (void)insertObject:(Binary *)binary inBinariesAtIndex:(NSUInteger)index;
- (void)insertObject:(CustomIcon *)icon inCustomIconsAtIndex:(NSUInteger)index;
- (CustomIcon *)objectInCustomIconsAtIndex:(NSUInteger)index;
- (Binary *)objectInBinariesAtIndex:(NSUInteger)index;
@end

View File

@@ -0,0 +1,29 @@
//
// Kdb4Tree+KVOAdditions.m
// MacPass
//
// Created by Michael Starke on 27.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "Kdb4Tree+KVOAdditions.h"
@implementation Kdb4Tree (KVOAdditions)
- (void)insertObject:(Binary *)binary inBinariesAtIndex:(NSUInteger)index {
[self.binaries insertObject:binary atIndex:index];
}
- (void)insertObject:(CustomIcon *)icon inCustomIconsAtIndex:(NSUInteger)index {
[self.customIcons insertObject:icon atIndex:index];
}
- (Binary *)objectInBinariesAtIndex:(NSUInteger)index {
return [self.binaries objectAtIndex:index];
}
- (CustomIcon *)objectInCustomIconsAtIndex:(NSUInteger)index {
return [self.customIcons objectAtIndex:index];
}
@end

58
MacPass/Kdb4Tree+Undo.h Normal file
View File

@@ -0,0 +1,58 @@
//
// Kdb4Tree+Undo.h
// MacPass
//
// Created by Michael Starke on 27.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "Kdb4Node.h"
APPKIT_EXTERN NSString *const MPTree4DatabaseNameUndoableKey;
APPKIT_EXTERN NSString *const MPTree4DatabaseDescriptionUndoableKey;
APPKIT_EXTERN NSString *const MPTree4DatabaseDefaultUsernameUndoableKey;
APPKIT_EXTERN NSString *const MPTree4ProtectNotesUndoableKey;
APPKIT_EXTERN NSString *const MPTree4ProtectPasswordUndoableKey;
APPKIT_EXTERN NSString *const MPTree4ProtectTitleUndoableKey;
APPKIT_EXTERN NSString *const MPTree4ProtectUrlUndoableKey;
APPKIT_EXTERN NSString *const MPTree4ProtectUsernameUndoableKey;
@interface Kdb4Tree (Undo)
- (NSString *)databaseNameUndoable;
- (NSString *)databaseDescriptionUndoable;
- (NSString *)defaultUserNameUndoable;
- (void)setDatabaseDescriptionUndoable:(NSString *)databaseDescription;
- (void)setDatabaseNameUndoable:(NSString *)databaseName;
- (void)setDefaultUserNameUndoable:(NSString *)defaultUserName;
- (BOOL)protectNotesUndoable;
- (BOOL)protectPasswordUndoable;
- (BOOL)protectTitleUndoable;
- (BOOL)protectUrlUndoable;
- (BOOL)protectUserNameUndoable;
- (void)setProtectNotesUndoable:(BOOL)protectNotes;
- (void)setProtectPasswordUndoable:(BOOL)protectPassword;
- (void)setProtectTitleUndoable:(BOOL)protectTitle;
- (void)setProtectUrlUndoable:(BOOL)protectUrl;
- (void)setProtectUserNameUndoable:(BOOL)protectUserName;
//@property(nonatomic, assign) NSInteger maintenanceHistoryDays;
//
//@property(nonatomic, retain) NSDate *masterKeyChanged;
//@property(nonatomic, assign) NSInteger masterKeyChangeRec;
//@property(nonatomic, assign) NSInteger masterKeyChangeForce;
//
//@property(nonatomic, assign) BOOL recycleBinEnabled;
//@property(nonatomic, retain) NSDate *recycleBinChanged;
//
//@property(nonatomic, assign) NSInteger historyMaxItems;
//@property(nonatomic, assign) NSInteger historyMaxSize;
//
//@property(nonatomic, readonly) NSMutableArray *binaries;
@end

127
MacPass/Kdb4Tree+Undo.m Normal file
View File

@@ -0,0 +1,127 @@
//
// Kdb4Tree+Undo.m
// MacPass
//
// Created by Michael Starke on 27.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "Kdb4Tree+Undo.h"
NSString *const MPTree4DatabaseNameUndoableKey = @"databaseNameUndoable";
NSString *const MPTree4DatabaseDescriptionUndoableKey = @"databaseDescriptionUndoable";
NSString *const MPTree4DatabaseDefaultUsernameUndoableKey = @"defaultUserNameUndoable";
NSString *const MPTree4ProtectNotesUndoableKey = @"protectNotesUndoable";
NSString *const MPTree4ProtectPasswordUndoableKey = @"protectPasswordUndoable";
NSString *const MPTree4ProtectTitleUndoableKey = @"protectTitleUndoable";
NSString *const MPTree4ProtectUrlUndoableKey = @"protectUrlUndoable";
NSString *const MPTree4ProtectUsernameUndoableKey = @"protectUserNameUndoable";
@implementation Kdb4Tree (Undo)
- (NSUndoManager *)undoManager {
return [[[NSDocumentController sharedDocumentController] currentDocument] undoManager];
}
- (NSString *)databaseDescriptionUndoable {
return self.databaseDescription;
}
- (NSString *)databaseNameUndoable {
return self.databaseName;
}
- (NSString *)defaultUserNameUndoable {
return self.defaultUserName;
}
- (void)setDatabaseDescriptionUndoable:(NSString *)databaseDescription {
if(![self.databaseDescription isEqualToString:databaseDescription]) {
[[self undoManager] registerUndoWithTarget:self selector:@selector(setDatabaseDescriptionUndoable:) object:self.databaseDescription];
[[self undoManager] setActionName:NSLocalizedString(@"UNDO_SET_DATABASE_DESCRIPTION", @"Undo edit databse description")];
self.databaseDescriptionChanged = [NSDate date];
self.databaseDescription = databaseDescription;
}
}
- (void)setDatabaseNameUndoable:(NSString *)databaseName {
if(![self.databaseName isEqualToString:databaseName]) {
[[self undoManager] registerUndoWithTarget:self selector:@selector(setDatabaseNameUndoable:) object:self.databaseName];
[[self undoManager] setActionName:NSLocalizedString(@"UNDO_SET_DATABASE_NAME", @"Undo edit database name")];
self.databaseName = databaseName;
self.databaseNameChanged = [NSDate date];
}
}
- (void)setDefaultUserNameUndoable:(NSString *)defaultUserName {
if(![self.defaultUserName isEqualToString:defaultUserName]) {
[[self undoManager] registerUndoWithTarget:self selector:@selector(setDefaultUserNameUndoable:) object:self.defaultUserName];
[[self undoManager] setActionName:NSLocalizedString(@"UNDO_SET_DEFAULT_USERNAME", @"Undo edit default username")];
self.defaultUserName = defaultUserName;
self.defaultUserNameChanged = [NSDate date];
}
}
- (BOOL)protectNotesUndoable {
return self.protectNotes;
}
- (BOOL)protectPasswordUndoable {
return self.protectPassword;
}
- (BOOL)protectTitleUndoable {
return self.protectTitle;
}
- (BOOL)protectUrlUndoable {
return self.protectUrl;
}
- (BOOL)protectUserNameUndoable {
return self.protectUserName;
}
- (void)setProtectNotesUndoable:(BOOL)protectNotes {
if(self.protectNotes != protectNotes) {
[[[self undoManager] prepareWithInvocationTarget:self] setProtectNotesUndoable:self.protectNotes];
[[self undoManager] setActionName:NSLocalizedString(@"UNOD_SET_PROTECT_NOTES", @"")];
self.protectNotes = protectNotes;
}
}
- (void)setProtectPasswordUndoable:(BOOL)protectPassword {
if(self.protectPassword != protectPassword) {
[[[self undoManager] prepareWithInvocationTarget:self] setProtectPasswordUndoable:self.protectPassword];
[[self undoManager] setActionName:NSLocalizedString(@"UNDO_SET_PROTECT_PASSWORD", @"")];
self.protectPassword = protectPassword;
}
}
- (void)setProtectTitleUndoable:(BOOL)protectTitle {
if(self.protectTitle != protectTitle) {
[[[self undoManager] prepareWithInvocationTarget:self] setProtectTitleUndoable:self.protectPassword];
[[self undoManager] setActionName:NSLocalizedString(@"UNDO_SET_PROTECT_TITLE", @"")];
self.protectTitle = protectTitle;
}
}
- (void)setProtectUrlUndoable:(BOOL)protectUrl {
if(self.protectUrl != protectUrl) {
[[[self undoManager] prepareWithInvocationTarget:self] setProtectUrlUndoable:self.protectUrl];
[[self undoManager] setActionName:NSLocalizedString(@"UNDO_SET_PROTECT_URL", @"")];
self.protectUrl = protectUrl;
}
}
- (void)setProtectUserNameUndoable:(BOOL)protectUserName {
if(self.protectUserName != protectUserName) {
[[[self undoManager] prepareWithInvocationTarget:self] setProtectUserNameUndoable:self.protectUserName];
[[self undoManager] setActionName:NSLocalizedString(@"UNDO_SET_PROTECT_USERNAME", @"")];
self.protectUserName = protectUserName;
}
}
@end

View File

@@ -0,0 +1,17 @@
//
// MPCustomFieldTableCellView.h
// MacPass
//
// Created by Michael Starke on 28.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface MPCustomFieldTableCellView : NSTableCellView
@property (assign) IBOutlet NSTextField *labelTextField;
@property (assign) IBOutlet NSTextField *valueTextField;
@property (assign) IBOutlet NSButton *removeButton;
@end

View File

@@ -0,0 +1,17 @@
//
// MPCustomFieldTableCellView.m
// MacPass
//
// Created by Michael Starke on 28.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "MPCustomFieldTableCellView.h"
@implementation MPCustomFieldTableCellView
- (void)setBackgroundStyle:(NSBackgroundStyle)backgroundStyle {
[super setBackgroundStyle:NSBackgroundStyleLight];
}
@end

View File

@@ -22,6 +22,8 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
@class KdbGroup;
@class KdbEntry;
@class KdbTree;
@class Kdb4Tree;
@class Kdb3Tree;
@class UUID;
@class Binary;
@class BinaryRef;
@@ -56,6 +58,8 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
*/
- (Binary *)binaryForRef:(BinaryRef *)binaryRef;
- (Kdb4Tree *)treeV4;
- (Kdb3Tree *)treeV3;
#pragma mark Data Manipulation
/* Undoable Intiialization of elements */

View File

@@ -225,11 +225,37 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
return [filteredBinary lastObject];
}
- (Kdb3Tree *)treeV3 {
switch (_version) {
case MPDatabaseVersion3:
NSAssert([self.tree isKindOfClass:[Kdb3Tree class]], @"Tree has to be Version3");
return (Kdb3Tree *)self.tree;
case MPDatabaseVersion4:
return nil;
default:
return nil;
}
}
- (Kdb4Tree *)treeV4 {
switch (_version) {
case MPDatabaseVersion3:
return nil;
case MPDatabaseVersion4:
NSAssert([self.tree isKindOfClass:[Kdb4Tree class]], @"Tree has to be Version4");
return (Kdb4Tree *)self.tree;
default:
return nil;
}
}
#pragma mark Data manipulation
- (KdbEntry *)createEntry:(KdbGroup *)parent {
KdbEntry *newEntry = [self.tree createEntry:parent];
newEntry.title = NSLocalizedString(@"DEFAULT_ENTRY_TITLE", @"Title for a newly created entry");
if(self.treeV4 && ([self.treeV4.defaultUserName length] > 0)) {
newEntry.title = self.treeV4.defaultUserName;
}
[self group:parent addEntry:newEntry];
NSDictionary *userInfo = @{ MPDocumentEntryKey : newEntry };
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidAddEntryNotification object:self userInfo:userInfo];

View File

@@ -10,6 +10,7 @@
#import "MPDocument.h"
#import "MPDatabaseVersion.h"
#import "Kdb4Node.h"
#import "Kdb4Tree+Undo.h"
@interface MPDocumentSettingsWindowController () {
MPDocument *_document;
@@ -36,14 +37,14 @@
NSAssert(_document != nil, @"Document needs to be present");
if( _document.version == MPDatabaseVersion4 ) {
Kdb4Tree *tree = (Kdb4Tree *)_document.tree;
[self.databaseNameTextField bind:NSValueBinding toObject:tree withKeyPath:@"databaseName" options:nil];
[self.databaseDescriptionTextView bind:NSValueBinding toObject:tree withKeyPath:@"databaseDescription" options:nil];
[self.databaseNameTextField bind:NSValueBinding toObject:tree withKeyPath:MPTree4DatabaseNameUndoableKey options:nil];
[self.databaseDescriptionTextView bind:NSValueBinding toObject:tree withKeyPath:MPTree4DatabaseDescriptionUndoableKey options:nil];
[self.protectNotesCheckButton bind:NSValueBinding toObject:tree withKeyPath:@"protectNotes" options:nil];
[self.protectPasswortCheckButton bind:NSValueBinding toObject:tree withKeyPath:@"protectPassword" options:nil];
[self.protectTitleCheckButton bind:NSValueBinding toObject:tree withKeyPath:@"protectTitle" options:nil];
[self.protectURLCheckButton bind:NSValueBinding toObject:tree withKeyPath:@"protectUrl" options:nil];
[self.protectUserNameCheckButton bind:NSValueBinding toObject:tree withKeyPath:@"protectUserName" options:nil];
[self.protectNotesCheckButton bind:NSValueBinding toObject:tree withKeyPath:MPTree4ProtectNotesUndoableKey options:nil];
[self.protectPasswortCheckButton bind:NSValueBinding toObject:tree withKeyPath:MPTree4ProtectPasswordUndoableKey options:nil];
[self.protectTitleCheckButton bind:NSValueBinding toObject:tree withKeyPath:MPTree4ProtectTitleUndoableKey options:nil];
[self.protectURLCheckButton bind:NSValueBinding toObject:tree withKeyPath:MPTree4ProtectUrlUndoableKey options:nil];
[self.protectUserNameCheckButton bind:NSValueBinding toObject:tree withKeyPath:MPTree4ProtectUsernameUndoableKey options:nil];
}
else {
// Switch to KdbV3 View

View File

@@ -29,6 +29,7 @@
@property (assign) IBOutlet NSTextField *modifiedTextField;
@property (assign) IBOutlet NSSegmentedControl *infoTabControl;
@property (assign) IBOutlet NSTableView *attachmentTableView;
@property (assign) IBOutlet NSTableView *customFieldsTableView;
@property (assign) IBOutlet NSTextView *notesTextView;
@property (assign) IBOutlet NSTextField *customFieldsTextField;

View File

@@ -17,12 +17,15 @@
#import "MPOutlineViewController.h"
#import "MPDocument.h"
#import "MPCustomFieldView.h"
#import "MPDatabaseVersion.h"
#import "MPCustomFieldTableCellView.h"
#import "KdbLib.h"
#import "Kdb4Node.h"
#import "Kdb3Node.h"
#import "KdbGroup+Undo.h"
#import "KdbEntry+Undo.h"
#import "Kdb4Entry+KVOAdditions.h"
#import "NSMutableData+Base64.h"
#import "HNHGradientView.h"
@@ -50,7 +53,7 @@ enum {
@property (nonatomic, assign) NSUInteger activeTab;
@property (assign) IBOutlet NSTabView *tabView;
@property (retain) NSArrayController *attachmentsController;
@property (retain) NSMutableArray *customFieldViews;
@property (retain) NSArrayController *customFieldsController;
- (IBAction)addCustomField:(id)sender;
- (IBAction)removeCustomField:(id)sender;
@@ -69,8 +72,8 @@ enum {
_selectedEntry = nil;
_selectedGroup = nil;
_attachmentsController = [[NSArrayController alloc] init];
_customFieldsController = [[NSArrayController alloc] init];
_activeTab = MPGeneralTab;
_customFieldViews = [[NSMutableArray alloc] initWithCapacity:5];
}
return self;
}
@@ -79,7 +82,7 @@ enum {
[[NSNotificationCenter defaultCenter] removeObserver:self];
[_activePopover release];
[_attachmentsController release];
[_customFieldViews release];
[_customFieldsController release];
[super dealloc];
}
@@ -94,6 +97,8 @@ enum {
[_attachmentTableView bind:NSContentBinding toObject:self.attachmentsController withKeyPath:@"arrangedObjects" options:nil];
[_attachmentTableView setDelegate:self];
[_customFieldsTableView bind:NSContentBinding toObject:self.customFieldsController withKeyPath:@"arrangedObjects" options:nil];
[_customFieldsTableView setDelegate:self];
[self _clearContent];
}
@@ -135,6 +140,7 @@ enum {
[self _clearContent];
}
[self _updateAttachments];
[self _updateCustomFields];
}
- (void)_updateAttachments {
@@ -143,16 +149,24 @@ enum {
[self.attachmentsController bind:NSContentArrayBinding toObject:self.selectedEntry withKeyPath:@"binaries" options:nil];
}
else {
/* Use binarydes and binary form Kdb3Entry */
/* Use binary from Kdb3Entry */
}
}
else if([self.attachmentsController content] != nil){
[self.attachmentsController unbind:NSContentArrayBinding];
[self.attachmentsController setContent:nil];
}
}
- (void)_updateCustomFields {
if(self.selectedEntry && [self.selectedEntry isKindOfClass:[Kdb4Entry class]]) {
[self.customFieldsController bind:NSContentArrayBinding toObject:self.selectedEntry withKeyPath:@"stringFields" options:nil];
}
else if([self.customFieldsController content] != nil){
[self.customFieldsController unbind:NSContentArrayBinding];
[self.customFieldsController setContent:nil];
}
}
- (void)_showEntry {
@@ -239,8 +253,10 @@ enum {
[self.URLTextField setEnabled:enabled];
[self.generatePasswordButton setEnabled:enabled];
[self.infoTabControl setEnabled:enabled forSegment:MPAttachmentsTab];
[self.infoTabControl setEnabled:enabled forSegment:MPNotesTab];
[self.infoTabControl setEnabled:enabled forSegment:MPAttachmentsTab];
enabled &= [self.selectedEntry isKindOfClass:[Kdb4Entry class]];
[self.infoTabControl setEnabled:enabled forSegment:MPCustomFieldsTab];
}
@@ -287,68 +303,14 @@ enum {
#pragma mark Actions
- (IBAction)addCustomField:(id)sender {
NSArray *topLevelObjects;
BOOL success = [[NSBundle mainBundle] loadNibNamed:@"CustomFieldView" owner:self topLevelObjects:&topLevelObjects];
if(success) {
id object = [topLevelObjects lastObject];
MPCustomFieldView *fieldView;
if(![object isKindOfClass:[MPCustomFieldView class]]) {
fieldView = topLevelObjects[0];
}
else {
fieldView = object;
}
[fieldView.deleteButton setTarget:self];
NSTabViewItem *tabViewItem = [self.tabView tabViewItemAtIndex:MPCustomFieldsTab];
NSView *predecessorView = [self.customFieldViews lastObject];
if(!predecessorView) {
predecessorView = _customFieldsTextField;
}
[[tabViewItem view] addSubview:fieldView];
[self.customFieldViews addObject:fieldView];
NSDictionary *views = NSDictionaryOfVariableBindings(fieldView, predecessorView);
[[tabViewItem view] addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-20-[fieldView]-20-|"
options:0
metrics:nil
views:views]];
[[tabViewItem view] addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[predecessorView]-10-[fieldView]"
options:0
metrics:nil
views:views]];
[[tabViewItem view] layoutSubtreeIfNeeded];
}
Kdb4Entry *entry = (Kdb4Entry *)self.selectedEntry;
StringField *stringField = [StringField stringFieldWithKey:@"Key" andValue:@"Value"];
[entry insertObject:stringField inStringFieldsAtIndex:[entry.stringFields count]];
}
- (IBAction)removeCustomField:(id)sender {
NSControl *button = sender;
NSView *fieldView = [button superview];
if([self.customFieldViews containsObject:fieldView]) {
[fieldView removeFromSuperview];
NSUInteger index = [self.customFieldViews indexOfObject:fieldView];
NSView *newPredecessorView = nil;
NSView *newSuccesorView = nil;
if(index == 0) {
newPredecessorView = _customFieldsTextField;
}
else {
NSAssert(index > 0, @"");
newPredecessorView = [self.customFieldViews objectAtIndex:index - 1];
}
NSTabViewItem *tabViewItem = [self.tabView tabViewItemAtIndex:MPCustomFieldsTab];
if(index < [self.customFieldViews count] - 1) {
newSuccesorView = [self.customFieldViews objectAtIndex:index + 1];
NSDictionary *views = NSDictionaryOfVariableBindings(newPredecessorView, newSuccesorView);
[[tabViewItem view] addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[newPredecessorView]-10-[newSuccesorView]"
options:0
metrics:nil
views:views]];
}
[self.customFieldViews removeObject:fieldView];
[[tabViewItem view] layoutSubtreeIfNeeded];
}
NSButton *button = sender;
Kdb4Entry *entry = (Kdb4Entry *)self.selectedEntry;
[entry removeObjectFromStringFieldsAtIndex:[button tag]];
}
#pragma mark Notificiations
@@ -373,7 +335,14 @@ enum {
#pragma mark NSTableViewDelegate
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
NSTableCellView *view = [tableView makeViewWithIdentifier:[tableColumn identifier] owner:tableView];
if(tableView == self.attachmentTableView) {
return [self _viewForAttachmentTableColumn:tableColumn row:row];
}
return [self _viewForCustomFieldTableColumn:tableColumn row:row];
}
- (NSView *)_viewForAttachmentTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
NSTableCellView *view = [_attachmentTableView makeViewWithIdentifier:[tableColumn identifier] owner:_attachmentTableView];
if([self.selectedEntry isKindOfClass:[Kdb4Entry class]]) {
Kdb4Entry *entry = (Kdb4Entry *)self.selectedEntry;
BinaryRef *binaryRef = entry.binaries[row];
@@ -384,4 +353,19 @@ enum {
}
return view;
}
- (NSView *)_viewForCustomFieldTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
MPCustomFieldTableCellView *view = [_customFieldsTableView makeViewWithIdentifier:[tableColumn identifier] owner:_customFieldsTableView];
if([self.selectedEntry isKindOfClass:[Kdb4Entry class]]) {
Kdb4Entry *entry = (Kdb4Entry *)self.selectedEntry;
StringField *stringField = entry.stringFields[row];
[view.labelTextField bind:NSValueBinding toObject:stringField withKeyPath:@"key" options:nil];
[view.valueTextField bind:NSValueBinding toObject:stringField withKeyPath:@"value" options:nil];
[view.removeButton setTarget:self];
[view.removeButton setAction:@selector(removeCustomField:)];
[view.removeButton setTag:row];
}
return view;
}
@end

View File

@@ -48,7 +48,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1354</string>
<string>1407</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key>

Binary file not shown.

Binary file not shown.