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)setContextMenu:(NSMenu *)menu;
- (NSControlSize)controlSize;
- (void)setControlSize:(NSControlSize)controlSize;
@end

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -27,38 +27,38 @@
- (id)initWithFrame:(NSRect)frameRect {
self = [super initWithFrame:frameRect];
if(self) {
[self setFocusRingType:NSFocusRingTypeNone];
[[self cell] setBezelStyle:NSTexturedRoundedBezelStyle];
[[self cell] setImageScaling:NSImageScaleProportionallyDown];
self.focusRingType = NSFocusRingTypeNone;
self.bezelStyle = NSTexturedRoundedBezelStyle;
[self.cell setImageScaling:NSImageScaleProportionallyDown];
[self setButtonType:NSMomentaryPushInButton];
[self setImagePosition:NSImageOnly];
self.imagePosition = NSImageOnly;
}
return self;
}
- (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;
switch (controlSize) {
case NSRegularControlSize:
[[self image] setSize:NSMakeSize(16 * scale, 16)];
self.image.size = NSMakeSize(16 * scale, 16);
break;
case NSSmallControlSize:
[[self image] setSize:NSMakeSize(14 * scale, 14)];
self.image.size = NSMakeSize(14 * scale, 14);
break;
case NSMiniControlSize:
[[self image] setSize:NSMakeSize(8 * scale, 8)];
self.image.size = NSMakeSize(8 * scale, 8);
default:
break;
}
super.controlSize = controlSize;
}
- (NSControlSize)controlSize {
return [[self cell] controlSize];
return self.cell.controlSize;
}
@end