Database settings now store and load color of db and compression algorithm

Fixed wrong sort descriptor for modificationDate on entry view table
This commit is contained in:
michael starke
2013-10-15 00:26:57 +02:00
parent 63a756039c
commit 8a7b2f8085
7 changed files with 533 additions and 4238 deletions

2
HNHUi

Submodule HNHUi updated: 7bf39a4be9...435f37c254

File diff suppressed because it is too large Load Diff

View File

@@ -11,11 +11,7 @@
@implementation MPAttachmentTableDataSource
- (NSDragOperation)tableView:(NSTableView *)tableView
validateDrop:(id<NSDraggingInfo>)info
proposedRow:(NSInteger)row
proposedDropOperation:(NSTableViewDropOperation)dropOperation {
- (NSDragOperation)tableView:(NSTableView *)tableView validateDrop:(id<NSDraggingInfo>)info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)dropOperation {
NSPasteboard *draggingPasteBoard = [info draggingPasteboard];
NSArray *classArray = [NSArray arrayWithObject:[NSURL class]];
NSArray *arrayOfURLs = [draggingPasteBoard readObjectsForClasses:classArray options:nil];
@@ -37,11 +33,7 @@
return NSDragOperationCopy;
}
- (BOOL)tableView:(NSTableView *)tableView
acceptDrop:(id<NSDraggingInfo>)info
row:(NSInteger)row
dropOperation:(NSTableViewDropOperation)dropOperation {
- (BOOL)tableView:(NSTableView *)tableView acceptDrop:(id<NSDraggingInfo>)info row:(NSInteger)row dropOperation:(NSTableViewDropOperation)dropOperation {
MPDocument *document = [[[tableView window] windowController] document];
id entry = document.selectedEntry;
@@ -54,8 +46,10 @@
}
return YES;
}
/*
- (BOOL)tableView:(NSTableView *)tableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard {
return NO;
/*
NSString *extension;
if([rowIndexes count] != 1) {
@@ -77,42 +71,7 @@
[pboard setPropertyList:@[uti] forType:(NSString *)kPasteboardTypeFilePromiseContent];
[pboard setPropertyList:@[uti] forType:(NSString *)kPasteboardTypeFileURLPromise ];
return YES;
return YES;*/
}
- (NSArray *)tableView:(NSTableView *)tableView namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination forDraggedRowsWithIndexes:(NSIndexSet *)indexSet {
if([indexSet count] != 1) {
return nil; // We only work with one file at a time
}
if(![dropDestination isFileURL]) {
return nil;
}
NSUInteger row = [indexSet lastIndex];
NSData *fileData;
NSString *filename;
MPDocument *document = [[[tableView window] windowController] document];
id entry = document.selectedEntry;
if([entry isKindOfClass:[Kdb3Entry class]]) {
Kdb3Entry *entryV3 = (Kdb3Entry *)entry;
filename = entryV3.binaryDesc;
fileData = entryV3.binary;
}
else if([entry isKindOfClass:[Kdb4Entry class]]) {
Kdb4Entry *entryV4 = (Kdb4Entry *)entry;
BinaryRef *binaryRef = entryV4.binaries[row];
filename = binaryRef.key;
fileData = [document attachmentDataForItem:binaryRef];
}
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
NSURL *writeURL = [dropDestination URLByAppendingPathComponent:filename];
// Create unique filename if already present
[fileData writeToURL:writeURL atomically:YES];
});
return @[filename];
}
*/
@end

View File

@@ -24,7 +24,9 @@ typedef NS_ENUM(NSUInteger, MPDatabaseSettingsTab) {
/* General Tab */
@property (weak) IBOutlet NSTextField *databaseNameTextField;
@property (weak) IBOutlet NSPopUpButton *databaseCompressionPopupButton;
@property (unsafe_unretained) IBOutlet NSTextView *databaseDescriptionTextView;
@property (weak) IBOutlet NSColorWell *databaseColorColorWell;
/* Security Tab */
@property (weak) IBOutlet NSButton *protectTitleCheckButton;

View File

@@ -14,6 +14,7 @@
#import "MPSettingsHelper.h"
#import "MPNumericalInputFormatter.h"
#import "KPKXmlFormat.h"
#import "KPKGroup.h"
#import "KPKTree.h"
#import "KPKMetaData.h"
@@ -66,9 +67,19 @@
KPKMetaData *metaData = _document.tree.metaData;
metaData.databaseDescription = [self.databaseDescriptionTextView string];
metaData.databaseName = [self.databaseNameTextField stringValue];
/* Display */
NSInteger compressionIndex = [self.databaseCompressionPopupButton indexOfSelectedItem];
if(compressionIndex >= KPKCompressionNone && compressionIndex < KPKCompressionCount) {
metaData.compressionAlgorithm = compressionIndex;
}
NSColor *databaseColor = [self.databaseColorColorWell color];
if([databaseColor isEqual:[NSColor clearColor]]) {
metaData.color = nil;
}
else {
metaData.color = databaseColor;
}
/* Advanced */
metaData.recycleBinEnabled = self.trashEnabled;
NSMenuItem *trashMenuItem = [self.selectRecycleBinGroupPopUpButton selectedItem];
@@ -122,7 +133,7 @@
}
/* Update all stuff that might have changed */
KPKMetaData *metaData = _document.tree.metaData;
[self _setupDatabase:metaData];
[self _setupDatabaseTab:metaData];
[self _setupProtectionTab:metaData];
[self _setupAdvancedTab:_document.tree];
self.isDirty = NO;
@@ -154,9 +165,12 @@
}
#pragma mark Private Helper
- (void)_setupDatabase:(KPKMetaData *)metaData {
- (void)_setupDatabaseTab:(KPKMetaData *)metaData {
[self.databaseNameTextField setStringValue:metaData.databaseName];
[self.databaseDescriptionTextView setString:metaData.databaseDescription];
[self.databaseCompressionPopupButton selectItemAtIndex:metaData.compressionAlgorithm];
NSColor *databaseColor = metaData.color ? metaData.color : [NSColor clearColor];
[self.databaseColorColorWell setColor:databaseColor];
}
- (void)_setupProtectionTab:(KPKMetaData *)metaData {

View File

@@ -166,7 +166,7 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
NSSortDescriptor *userNameSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"username" ascending:YES selector:@selector(compare:)];
NSSortDescriptor *urlSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"url" ascending:YES selector:@selector(compare:)];
NSSortDescriptor *groupnameSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"parent.name" ascending:YES selector:@selector(compare:)];
NSSortDescriptor *dateSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"lastModificationTime" ascending:YES selector:@selector(compare:)];
NSSortDescriptor *dateSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"timeInfo.lastModificationTime" ascending:YES selector:@selector(compare:)];
[titleColumn setSortDescriptorPrototype:titleColumSortDescriptor];
[userNameColumn setSortDescriptorPrototype:userNameSortDescriptor];