Moder Objective-C. Adoping changed KeePassKit API

Signed-off-by: michael starke <michael.starke@hicknhack-software.com>
This commit is contained in:
michael starke
2015-08-04 17:18:08 +02:00
parent fa4094ee01
commit 731384ca1e
11 changed files with 133 additions and 34 deletions

View File

@@ -253,12 +253,12 @@
- (void)_updateTrashFolders:(KPKTree *)tree {
NSMenu *menu = [self _buildTrashTreeMenu:tree];
[self.selectTrashGoupPopUpButton setMenu:menu];
self.selectTrashGoupPopUpButton.menu = menu;
}
- (void)_updateTemplateGroup:(KPKTree *)tree {
NSMenu *menu = [self _buildTemplateTreeMenu:tree];
[self.templateGroupPopUpButton setMenu:menu];
self.templateGroupPopUpButton.menu = menu;
}
- (NSMenu *)_buildTrashTreeMenu:(KPKTree *)tree {
@@ -267,7 +267,7 @@
NSMenuItem *selectItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"AUTOCREATE_TRASH_FOLDER", @"Menu item for automatic trash creation")
action:NULL
keyEquivalent:@""];
[selectItem setEnabled:YES];
selectItem.enabled = YES;
[menu insertItem:selectItem atIndex:0];
return menu;
@@ -279,7 +279,7 @@
NSMenuItem *selectItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"NO_TEMPLATE_GROUP", @"Menu item to reset the template groups")
action:NULL
keyEquivalent:@""];
[selectItem setEnabled:YES];
selectItem.enabled = YES;
[menu insertItem:selectItem atIndex:0];
return menu;
@@ -288,7 +288,7 @@
- (NSMenu *)_buildTreeMenu:(KPKTree *)tree preselect:(NSUUID *)uuid {
NSMenu *menu = [[NSMenu alloc] init];
[menu setAutoenablesItems:NO];
menu.autoenablesItems = NO;
for(KPKGroup *group in tree.root.groups) {
[self _insertMenuItemsForGroup:group atLevel:0 inMenu:menu preselect:uuid];
}
@@ -297,14 +297,14 @@
- (void)_insertMenuItemsForGroup:(KPKGroup *)group atLevel:(NSUInteger)level inMenu:(NSMenu *)menu preselect:(NSUUID *)uuid{
NSMenuItem *groupItem = [[NSMenuItem alloc] init];
[groupItem setImage:group.iconImage];
[groupItem setTitle:group.name];
[groupItem setRepresentedObject:group];
[groupItem setEnabled:YES];
groupItem.image = group.iconImage;
groupItem.title = group.title;
groupItem.representedObject = group;
groupItem.enabled = YES;
if(uuid && [group.uuid isEqual:uuid]) {
[groupItem setState:NSOnState];
groupItem.state = NSOnState;
}
[groupItem setIndentationLevel:level];
groupItem.indentationLevel = level;
[menu addItem:groupItem];
for(KPKGroup *childGroup in group.groups) {
[self _insertMenuItemsForGroup:childGroup atLevel:level + 1 inMenu:menu preselect:uuid];

View File

@@ -476,7 +476,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
return nil; // no new Groups in trash
}
KPKGroup *newGroup = [self.tree createGroup:parent];
newGroup.name = NSLocalizedString(@"DEFAULT_GROUP_NAME", @"Title for a newly created group");
newGroup.title = NSLocalizedString(@"DEFAULT_GROUP_NAME", @"Title for a newly created group");
newGroup.iconId = MPIconFolder;
[parent addGroup:newGroup];
NSDictionary *userInfo = @{ MPDocumentGroupKey : newGroup };
@@ -615,7 +615,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
if(entryUUID) {
KPKEntry *templateEntry = [self findEntry:entryUUID];
if(templateEntry && self.selectedGroup) {
KPKEntry *copy = [templateEntry copyWithTitle:templateEntry.title];
KPKEntry *copy = [templateEntry copyWithTitle:templateEntry.title options:kKPKCopyOptionNone];
[self.selectedGroup addEntry:copy];
[self.selectedGroup.undoManager setActionName:NSLocalizedString(@"ADD_TREMPLATE_ENTRY", "")];
}
@@ -623,7 +623,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
}
- (void)duplicateEntry:(id)sender {
KPKEntry *duplicate = [self.selectedEntry copyWithTitle:nil];
KPKEntry *duplicate = [self.selectedEntry copyWithTitle:nil options:kKPKCopyOptionNone];
[self.selectedEntry.parent addEntry:duplicate];
[self.undoManager setActionName:NSLocalizedString(@"DUPLICATE_ENTRY", "")];
}
@@ -751,7 +751,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
KPKGroup *trash = [self.tree createGroup:self.tree.root];
BOOL wasEnabled = [self.undoManager isUndoRegistrationEnabled];
[self.undoManager disableUndoRegistration];
trash.name = NSLocalizedString(@"TRASH", @"Name for the trash group");
trash.title = NSLocalizedString(@"TRASH", @"Name for the trash group");
trash.iconId = MPIconTrash;
[self.tree.root addGroup:trash];
if(wasEnabled) {

View File

@@ -169,12 +169,12 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
self.entryTable.autosaveTableColumns = YES;
NSString *parentNameKeyPath = [[NSString alloc] initWithFormat:@"%@.%@", NSStringFromSelector(@selector(parent)), NSStringFromSelector(@selector(name))];
NSString *parentTitleKeyPath = [[NSString alloc] initWithFormat:@"%@.%@", NSStringFromSelector(@selector(parent)), NSStringFromSelector(@selector(title))];
titleColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:NSStringFromSelector(@selector(title))ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
userNameColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:NSStringFromSelector(@selector(username)) ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
urlColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:NSStringFromSelector(@selector(url)) ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
parentColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:parentNameKeyPath ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
parentColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:parentTitleKeyPath ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
modifiedColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:[MPEntryViewController timeInfoModificationTimeKeyPath] ascending:YES selector:@selector(compare:)];
[parentColumn.headerCell setStringValue:NSLocalizedString(@"GROUP", "")];
@@ -276,15 +276,15 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
KPKEntry *entry = [self.entryArrayController arrangedObjects][row];
NSAssert(entry.parent != nil, @"Entry needs to have a parent");
NSString *parentNameKeyPath = [NSString stringWithFormat:@"%@.%@.%@",
NSString *parentTitleKeyPath = [NSString stringWithFormat:@"%@.%@.%@",
NSStringFromSelector(@selector(objectValue)),
NSStringFromSelector(@selector(parent)),
NSStringFromSelector(@selector(name))];
NSStringFromSelector(@selector(title))];
NSString *parentIconImageKeyPath = [NSString stringWithFormat:@"%@.%@.%@",
NSStringFromSelector(@selector(objectValue)),
NSStringFromSelector(@selector(parent)),
NSStringFromSelector(@selector(iconImage))];
[view.textField bind:NSValueBinding toObject:view withKeyPath:parentNameKeyPath options:nil];
[view.textField bind:NSValueBinding toObject:view withKeyPath:parentTitleKeyPath options:nil];
[view.imageView bind:NSValueBinding toObject:view withKeyPath:parentIconImageKeyPath options:nil];
}
}

View File

@@ -103,7 +103,7 @@
- (void)_updateBindings {
if(self.group) {
[self.titleTextField bind:NSValueBinding toObject:self.group withKeyPath:NSStringFromSelector(@selector(name)) options:nil];
[self.titleTextField bind:NSValueBinding toObject:self.group withKeyPath:NSStringFromSelector(@selector(title)) options:nil];
[self.expiresCheckButton bind:NSValueBinding toObject:self.group.timeInfo withKeyPath:NSStringFromSelector(@selector(expires)) options:nil];
[self.expiresCheckButton bind:NSTitleBinding toObject:self.group.timeInfo withKeyPath:NSStringFromSelector(@selector(expirationDate)) options:@{ NSValueTransformerNameBindingOption:MPExpiryDateValueTransformer }];
[self.autotypePopupButton bind:NSSelectedTagBinding toObject:self.group withKeyPath:NSStringFromSelector(@selector(isAutoTypeEnabled)) options:nil];

View File

@@ -285,12 +285,7 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
[self.itemImageView bind:NSValueBinding toObject:item withKeyPath:NSStringFromSelector(@selector(iconImage)) options:nil];
[[self.notesTextView enclosingScrollView] setHidden:NO];
[self.notesTextView bind:NSValueBinding toObject:item withKeyPath:NSStringFromSelector(@selector(notes)) options:nil];
if([item respondsToSelector:@selector(title)]) {
[self.itemNameTextField bind:NSValueBinding toObject:item withKeyPath:NSStringFromSelector(@selector(title)) options:nil];
}
else if( [item respondsToSelector:@selector(name)]) {
[self.itemNameTextField bind:NSValueBinding toObject:item withKeyPath:NSStringFromSelector(@selector(name)) options:nil];
}
[self.itemNameTextField bind:NSValueBinding toObject:item withKeyPath:NSStringFromSelector(@selector(title)) options:nil];
[self.itemImageView setHidden:NO];
[self.itemNameTextField setHidden:NO];
}

View File

@@ -143,7 +143,7 @@
KPKGroup *targetGroup = (KPKGroup *)targetItem;
if(draggedGroup) {
if(copyItem || (nil == self.localDraggedGroup) ) {
draggedGroup = [draggedGroup copyWithName:nil];
draggedGroup = [draggedGroup copyWithTitle:nil options:kKPKCopyOptionNone];
[targetGroup addGroup:draggedGroup atIndex:index];
[targetGroup.undoManager setActionName:NSLocalizedString(@"COPY_GROUP", "")];
return YES;
@@ -159,7 +159,7 @@
}
else if(draggedEntry) {
if(copyItem || (nil == self.localDraggedEntry)) {
draggedEntry = [draggedEntry copyWithTitle:nil];
draggedEntry = [draggedEntry copyWithTitle:nil options:kKPKCopyOptionNone];
[targetGroup addEntry:draggedEntry];
[targetGroup.undoManager setActionName:NSLocalizedString(@"COPY_ENTRY", "")];
return YES;

View File

@@ -216,9 +216,9 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
view = [outlineView makeViewWithIdentifier:_MPOutlineViewDataViewIdentifier owner:self];
NSString *iconImageKeyPath = [NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(iconImage))];
NSString *nameKeyPath = [NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(name))];
NSString *titleKeyPath = [NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(title))];
[[view imageView] bind:NSValueBinding toObject:item withKeyPath:iconImageKeyPath options:nil];
[[view textField] bind:NSValueBinding toObject:item withKeyPath:nameKeyPath options:nil];
[[view textField] bind:NSValueBinding toObject:item withKeyPath:titleKeyPath options:nil];
NSString *entriesCountKeyPath = [[NSString alloc] initWithFormat:@"%@.%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(entries)), @"@count"];