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

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];
@@ -322,7 +348,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
[group removeObjectFromGroupsAtIndex:index];
}
#pragma mark Private
#pragma mark Private
- (void)_cleanupLock {
if(_didLockFile) {
[[NSFileManager defaultManager] removeItemAtURL:_lockFileURL error:nil];

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.