Converted to properties where possible. Some missing due to 10.8 deployment

Signed-off-by: michael starke <michael.starke@hicknhack-software.com>
This commit is contained in:
michael starke
2015-10-21 17:29:30 +02:00
parent 50cebc0ef2
commit fa5ca62e9d
7 changed files with 44 additions and 41 deletions

View File

@@ -27,4 +27,7 @@
- (void)setImage:(NSImage *)image; - (void)setImage:(NSImage *)image;
- (void)setContextMenu:(NSMenu *)menu; - (void)setContextMenu:(NSMenu *)menu;
- (NSControlSize)controlSize;
- (void)setControlSize:(NSControlSize)controlSize;
@end @end

View File

@@ -38,12 +38,12 @@
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:[self cell]]; NSData *data = [NSKeyedArchiver archivedDataWithRootObject:[self cell]];
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data]; NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
MPSegmentedContextCell *cell = [[MPSegmentedContextCell alloc] initWithCoder:unarchiver]; MPSegmentedContextCell *cell = [[MPSegmentedContextCell alloc] initWithCoder:unarchiver];
[self setCell:cell]; self.cell = cell;
[self setFocusRingType:NSFocusRingTypeNone]; self.focusRingType = NSFocusRingTypeNone;
[self setSegmentCount:2]; self.segmentCount = 2;
[cell setTrackingMode:NSSegmentSwitchTrackingMomentary]; [cell setTrackingMode:NSSegmentSwitchTrackingMomentary];
[self setSegmentStyle:NSSegmentStyleTexturedSquare]; self.segmentStyle = NSSegmentStyleTexturedSquare;
[cell setWidth:31 forSegment:0]; [cell setWidth:31 forSegment:0];
[cell setWidth:17 forSegment:1]; [cell setWidth:17 forSegment:1];
@@ -73,7 +73,7 @@
- (void)setSegmentCount:(NSInteger)count { - (void)setSegmentCount:(NSInteger)count {
if(count == 2) { if(count == 2) {
[super setSegmentCount:count]; super.segmentCount = count;
} }
} }
@@ -82,10 +82,18 @@
} }
- (void)showContextMenu:(id)sender { - (void)showContextMenu:(id)sender {
NSPoint point = [self frame].origin; NSPoint point = self.frame.origin;
point.x = [[self cell] widthForSegment:0]; point.x = [self.cell widthForSegment:0];
point.y = NSHeight([self frame]) + 3; point.y = NSHeight(self.frame) + 3;
[_contextMenu popUpMenuPositioningItem:nil atLocation:point inView:self]; [_contextMenu popUpMenuPositioningItem:nil atLocation:point inView:self];
} }
- (void)setControlSize:(NSControlSize)controlSize {
self.cell.controlSize = controlSize;
}
- (NSControlSize)controlSize {
return self.cell.controlSize;
}
@end @end

View File

@@ -113,12 +113,11 @@ NSString *const kMPDocumentSearchResultsKey = @"kMPDocumentSearchResul
- (NSArray *)_findEntriesMatchingCurrentSearch { - (NSArray *)_findEntriesMatchingCurrentSearch {
/* Filter double passwords */ /* Filter double passwords */
if(MPIsFlagSetInOptions(MPEntrySearchDoublePasswords, self.searchContext.searchFlags)) { if(MPIsFlagSetInOptions(MPEntrySearchDoublePasswords, self.searchContext.searchFlags)) {
__block NSMutableDictionary *passwordToEntryMap = [[NSMutableDictionary alloc] initWithCapacity:100]; NSMutableDictionary *passwordToEntryMap = [[NSMutableDictionary alloc] initWithCapacity:100];
/* Build up a usage map */ /* Build up a usage map */
[[self.root searchableChildEntries] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { for(KPKEntry *entry in self.root.searchableChildEntries) {
KPKEntry *entry = obj;
/* skip entries without passwords */ /* skip entries without passwords */
if([entry.password length] > 0) { if(entry.password.length > 0) {
NSMutableSet *entrySet = passwordToEntryMap[entry.password]; NSMutableSet *entrySet = passwordToEntryMap[entry.password];
if(entrySet) { if(entrySet) {
[entrySet addObject:entry]; [entrySet addObject:entry];
@@ -127,15 +126,15 @@ NSString *const kMPDocumentSearchResultsKey = @"kMPDocumentSearchResul
passwordToEntryMap[entry.password] = [NSMutableSet setWithObject:entry]; passwordToEntryMap[entry.password] = [NSMutableSet setWithObject:entry];
} }
} }
}]; }
/* check for usage count */ /* check for usage count */
__block NSMutableArray *doublePasswords = [[NSMutableArray alloc] init]; NSMutableArray *doublePasswords = [[NSMutableArray alloc] init];
[[passwordToEntryMap allKeys] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { for(NSString *password in passwordToEntryMap.allKeys) {
NSSet *entrySet = passwordToEntryMap[obj]; NSSet *entrySet = passwordToEntryMap[password];
if([entrySet count] > 1) { if(entrySet.count > 1) {
[doublePasswords addObjectsFromArray:[entrySet allObjects]]; [doublePasswords addObjectsFromArray:entrySet.allObjects];
} }
}]; }
return doublePasswords; return doublePasswords;
} }
if(MPIsFlagSetInOptions(MPEntrySearchExpiredEntries, self.searchContext.searchFlags)) { if(MPIsFlagSetInOptions(MPEntrySearchExpiredEntries, self.searchContext.searchFlags)) {

View File

@@ -20,13 +20,6 @@
return @"ReferenceBuilderView"; return @"ReferenceBuilderView";
} }
//- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
// self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
// if(self) {
// }
// return self;
//}
- (void)didLoadView { - (void)didLoadView {
[self.searchKeyPopUpButton setMenu:[self _allocateAttributeItemMenu:YES withTitle:NSLocalizedString(@"SEARCH_VALUE", "")]]; [self.searchKeyPopUpButton setMenu:[self _allocateAttributeItemMenu:YES withTitle:NSLocalizedString(@"SEARCH_VALUE", "")]];
[self.valuePopUpButton setMenu:[self _allocateAttributeItemMenu:NO withTitle:NSLocalizedString(@"OUTPUT_VALUE", "")]]; [self.valuePopUpButton setMenu:[self _allocateAttributeItemMenu:NO withTitle:NSLocalizedString(@"OUTPUT_VALUE", "")]];

View File

@@ -43,17 +43,17 @@
} }
- (SEL)action { - (SEL)action {
if([self selectedSegment] == 1) { if(self.selectedSegment == 1) {
return self.contextMenuAction; return self.contextMenuAction;
} }
return [super action]; return super.action;
} }
- (id)target { - (id)target {
if([self selectedSegment] == 1) { if(self.selectedSegment == 1) {
return self.contextMenuTarget; return self.contextMenuTarget;
} }
return [super target]; return super.target;
} }
@end @end

View File

@@ -25,8 +25,8 @@
@interface MPToolbarButton : NSButton @interface MPToolbarButton : NSButton
/* This methods ensure, that the button get sized correctly if used as the view in a NSToolbarItem*/ /* This methods ensure, that the button get sized correctly if used as the view in a NSToolbarItem*/
- (void)setControlSize:(NSControlSize)controlSize; - (void)setControlSize:(NSControlSize)controlSize;
- (NSControlSize)controlSize; - (NSControlSize)controlSize;
@end @end

View File

@@ -27,38 +27,38 @@
- (id)initWithFrame:(NSRect)frameRect { - (id)initWithFrame:(NSRect)frameRect {
self = [super initWithFrame:frameRect]; self = [super initWithFrame:frameRect];
if(self) { if(self) {
[self setFocusRingType:NSFocusRingTypeNone]; self.focusRingType = NSFocusRingTypeNone;
[[self cell] setBezelStyle:NSTexturedRoundedBezelStyle]; self.bezelStyle = NSTexturedRoundedBezelStyle;
[[self cell] setImageScaling:NSImageScaleProportionallyDown]; [self.cell setImageScaling:NSImageScaleProportionallyDown];
[self setButtonType:NSMomentaryPushInButton]; [self setButtonType:NSMomentaryPushInButton];
[self setImagePosition:NSImageOnly]; self.imagePosition = NSImageOnly;
} }
return self; return self;
} }
- (void)setControlSize:(NSControlSize)controlSize { - (void)setControlSize:(NSControlSize)controlSize {
[[self cell] setControlSize:controlSize]; NSImageRep *rep = [self.image bestRepresentationForRect:NSMakeRect(0, 0, 100, 100) context:nil hints:nil];
NSImageRep *rep = [[self image] bestRepresentationForRect:NSMakeRect(0, 0, 100, 100) context:nil hints:nil];
CGFloat scale = rep.size.width / rep.size.height; CGFloat scale = rep.size.width / rep.size.height;
switch (controlSize) { switch (controlSize) {
case NSRegularControlSize: case NSRegularControlSize:
[[self image] setSize:NSMakeSize(16 * scale, 16)]; self.image.size = NSMakeSize(16 * scale, 16);
break; break;
case NSSmallControlSize: case NSSmallControlSize:
[[self image] setSize:NSMakeSize(14 * scale, 14)]; self.image.size = NSMakeSize(14 * scale, 14);
break; break;
case NSMiniControlSize: case NSMiniControlSize:
[[self image] setSize:NSMakeSize(8 * scale, 8)]; self.image.size = NSMakeSize(8 * scale, 8);
default: default:
break; break;
} }
super.controlSize = controlSize;
} }
- (NSControlSize)controlSize { - (NSControlSize)controlSize {
return [[self cell] controlSize]; return self.cell.controlSize;
} }
@end @end