Missing files from last commit

This commit is contained in:
michael starke
2013-02-21 03:39:36 +01:00
parent 687aef74ad
commit 82afcfbf0f
11 changed files with 4581 additions and 322 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -42,12 +42,23 @@
<reference key="NSNextResponder"/>
<int key="NSvFlags">268</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="NSCustomView" id="1025687547">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{20, 20}, {250, 137}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<string key="NSClassName">MPGradientView</string>
</object>
<object class="NSPopUpButton" id="421904700">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{146, 292}, {127, 26}}</string>
<string key="NSFrame">{{146, 174}, {127, 26}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1025687547"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<string key="NSAntiCompressionPriority">{750, 751}</string>
<bool key="NSEnabled">YES</bool>
@@ -125,7 +136,7 @@
<object class="NSTextField" id="637214120">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{17, 298}, {127, 17}}</string>
<string key="NSFrame">{{17, 180}, {127, 17}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="421904700"/>
@@ -160,7 +171,7 @@
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
</object>
</array>
<string key="NSFrameSize">{290, 336}</string>
<string key="NSFrameSize">{290, 218}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="637214120"/>
@@ -298,6 +309,70 @@
<float key="scoringTypeFloat">40</float>
<int key="contentType">3</int>
</object>
<object class="IBNSLayoutConstraint" id="750377732">
<reference key="firstItem" ref="1005"/>
<int key="firstAttribute">4</int>
<int key="relation">0</int>
<reference key="secondItem" ref="1025687547"/>
<int key="secondAttribute">4</int>
<float key="multiplier">1</float>
<object class="IBNSLayoutSymbolicConstant" key="constant">
<double key="value">20</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="1005"/>
<int key="scoringType">8</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
</object>
<object class="IBNSLayoutConstraint" id="763066747">
<reference key="firstItem" ref="1005"/>
<int key="firstAttribute">6</int>
<int key="relation">0</int>
<reference key="secondItem" ref="1025687547"/>
<int key="secondAttribute">6</int>
<float key="multiplier">1</float>
<object class="IBNSLayoutSymbolicConstant" key="constant">
<double key="value">20</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="1005"/>
<int key="scoringType">8</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
</object>
<object class="IBNSLayoutConstraint" id="465685960">
<reference key="firstItem" ref="1025687547"/>
<int key="firstAttribute">5</int>
<int key="relation">0</int>
<reference key="secondItem" ref="1005"/>
<int key="secondAttribute">5</int>
<float key="multiplier">1</float>
<object class="IBNSLayoutSymbolicConstant" key="constant">
<double key="value">20</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="1005"/>
<int key="scoringType">8</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
</object>
<object class="IBNSLayoutConstraint" id="428150913">
<reference key="firstItem" ref="1025687547"/>
<int key="firstAttribute">3</int>
<int key="relation">0</int>
<reference key="secondItem" ref="421904700"/>
<int key="secondAttribute">4</int>
<float key="multiplier">1</float>
<object class="IBLayoutConstant" key="constant">
<double key="value">20</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="1005"/>
<int key="scoringType">6</int>
<float key="scoringTypeFloat">24</float>
<int key="contentType">3</int>
</object>
<object class="IBNSLayoutConstraint" id="689515169">
<reference key="firstItem" ref="637214120"/>
<int key="firstAttribute">7</int>
@@ -346,6 +421,7 @@
<float key="scoringTypeFloat">40</float>
<int key="contentType">3</int>
</object>
<reference ref="1025687547"/>
</array>
<reference key="parent" ref="0"/>
</object>
@@ -443,6 +519,31 @@
<reference key="object" ref="835508122"/>
<reference key="parent" ref="1005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">143</int>
<reference key="object" ref="1025687547"/>
<reference key="parent" ref="1005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">148</int>
<reference key="object" ref="428150913"/>
<reference key="parent" ref="1005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">151</int>
<reference key="object" ref="465685960"/>
<reference key="parent" ref="1005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">152</int>
<reference key="object" ref="763066747"/>
<reference key="parent" ref="1005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">154</int>
<reference key="object" ref="750377732"/>
<reference key="parent" ref="1005"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
@@ -453,6 +554,10 @@
<reference ref="180695068"/>
<reference ref="989429017"/>
<reference ref="689515169"/>
<reference ref="428150913"/>
<reference ref="465685960"/>
<reference ref="763066747"/>
<reference ref="750377732"/>
<reference ref="704304955"/>
<reference ref="106372279"/>
<reference ref="850330857"/>
@@ -466,7 +571,13 @@
<string key="131.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="NO" key="14.IBNSViewMetadataTranslatesAutoresizingMaskIntoConstraints"/>
<string key="14.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="NO" key="143.IBNSViewMetadataTranslatesAutoresizingMaskIntoConstraints"/>
<string key="143.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="148.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="15.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="151.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="152.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="154.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="16.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="17.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="18.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -483,7 +594,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">142</int>
<int key="maxID">154</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -506,6 +617,14 @@
<string key="minorKey">./Classes/MPGeneralSettingsController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">MPGradientView</string>
<string key="superclassName">NSView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/MPGradientView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSLayoutConstraint</string>
<string key="superclassName">NSObject</string>

View File

@@ -8,12 +8,17 @@
#import "MPViewController.h"
APPKIT_EXTERN NSString *const MPEntryTableUserNameColumnIdentifier;
APPKIT_EXTERN NSString *const MPEntryTableTitleColumnIdentifier;
APPKIT_EXTERN NSString *const MPEntryTablePasswordColumnIdentifier;
APPKIT_EXTERN NSString *const MPEntryTableParentColumnIdentifier;
@class KdbGroup;
@class MPOutlineViewDelegate;
@interface MPEntryViewController : MPViewController
@interface MPEntryViewController : MPViewController <NSTableViewDelegate>
@property (nonatomic, assign) id<NSOutlineViewDelegate> outlineViewDelegate;
@property (assign) KdbGroup *activeGroup;
@property (readonly, retain) NSArrayController *entryArrayController;
@property (nonatomic, retain) NSString *filter;

View File

@@ -10,17 +10,24 @@
#import "MPOutlineViewDelegate.h"
#import "MPDatabaseController.h"
#import "MPDatabaseDocument.h"
#import "MPIconHelper.h"
#import "KdbGroup+MPAdditions.h"
NSString *const _MPUserNameColumnIdentifier = @"MPUserNameColumnIdentifier";
NSString *const _MPTitleColumnIdentifier = @"MPTitleColumnIdentifier";
NSString *const _MPPasswordColumnIdentifier = @"MPPasswordColumnIdentifier";
NSString *const MPEntryTableUserNameColumnIdentifier = @"MPUserNameColumnIdentifier";
NSString *const MPEntryTableTitleColumnIdentifier = @"MPTitleColumnIdentifier";
NSString *const MPEntryTablePasswordColumnIdentifier = @"MPPasswordColumnIdentifier";
NSString *const MPEntryTableParentColumnIdentifier = @"MPParentColumnIdentifier";
NSString *const _MPTableImageCellView = @"ImageCell";
NSString *const _MPTableStringCellView = @"StringCell";
NSString *const _MPTAbleSecurCellView = @"PasswordCell";
@interface MPEntryViewController ()
@property (retain) NSArrayController *entryArrayController;
@property (retain) NSArray *filteredEntries;
@property (assign) IBOutlet NSTableView *entryTable;
@property (assign) IBOutlet NSView *statusBar;
- (BOOL)hasActiveFilter;
@@ -31,6 +38,7 @@ NSString *const _MPPasswordColumnIdentifier = @"MPPasswordColumnIdentifier";
@implementation MPEntryViewController
- (id)init {
return [[MPEntryViewController alloc] initWithNibName:@"EntryView" bundle:nil];
}
@@ -48,23 +56,68 @@ NSString *const _MPPasswordColumnIdentifier = @"MPPasswordColumnIdentifier";
}
- (void)didLoadView {
NSTableColumn *nameColumn = [self.entryTable tableColumns][0];
NSTableColumn *userNameColumn = [self.entryTable tableColumns][1];
NSTableColumn *passwordColumn = [self.entryTable tableColumns][2];
[nameColumn setIdentifier:_MPTitleColumnIdentifier];
[userNameColumn setIdentifier:_MPUserNameColumnIdentifier];
[passwordColumn setIdentifier:_MPPasswordColumnIdentifier];
[self.entryTable setDelegate:self];
NSTableColumn *parentColumn = [self.entryTable tableColumns][0];
NSTableColumn *titleColumn = [self.entryTable tableColumns][1];
NSTableColumn *userNameColumn = [self.entryTable tableColumns][2];
NSTableColumn *passwordColumn = [self.entryTable tableColumns][3];
[[nameColumn headerCell] setStringValue:@"Title"];
[parentColumn setIdentifier:MPEntryTableParentColumnIdentifier];
[titleColumn setIdentifier:MPEntryTableTitleColumnIdentifier];
[userNameColumn setIdentifier:MPEntryTableUserNameColumnIdentifier];
[passwordColumn setIdentifier:MPEntryTablePasswordColumnIdentifier];
[[parentColumn headerCell] setStringValue:@"Group"];
[[titleColumn headerCell] setStringValue:@"Title"];
[[userNameColumn headerCell] setStringValue:@"Username"];
[[passwordColumn headerCell] setStringValue:@"Password"];
[nameColumn bind:NSValueBinding toObject:self.entryArrayController withKeyPath:@"arrangedObjects.title" options:nil];
[userNameColumn bind:NSValueBinding toObject:self.entryArrayController withKeyPath:@"arrangedObjects.username" options:nil];
[passwordColumn bind:NSValueBinding toObject:self.entryArrayController withKeyPath:@"arrangedObjects.password" options:nil];
[self.entryTable bind:NSContentBinding toObject:self.entryArrayController withKeyPath:@"arrangedObjects" options:nil];
[parentColumn setHidden:YES];
}
#pragma mark NSTableViewDelgate
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
KdbEntry *entry = [self.entryArrayController arrangedObjects][row];
const BOOL isTitleColumn = [[tableColumn identifier] isEqualToString:MPEntryTableTitleColumnIdentifier];
const BOOL isGroupColumn = [[tableColumn identifier] isEqualToString:MPEntryTableParentColumnIdentifier];
const BOOL isPasswordColum = [[tableColumn identifier] isEqualToString:MPEntryTablePasswordColumnIdentifier];
const BOOL isUsernameColumn = [[tableColumn identifier] isEqualToString:MPEntryTableUserNameColumnIdentifier];
NSTableCellView *view = nil;
if(isTitleColumn || isGroupColumn) {
view = [tableView makeViewWithIdentifier:_MPTableImageCellView owner:self];
[[view imageView] setImage:[MPIconHelper randomIcon]];
if( isTitleColumn ) {
[[view textField] setStringValue:entry.title];
}
else {
[[view textField] setStringValue:entry.parent.name];
}
return view;
}
if( isPasswordColum ) {
view = [tableView makeViewWithIdentifier:_MPTAbleSecurCellView owner:self];
[[view textField] setStringValue:entry.password];
return view;
}
if( isUsernameColumn ) {
view = [tableView makeViewWithIdentifier:_MPTableStringCellView owner:self];
[[view textField] setStringValue:entry.username];
return view;
}
return view;
}
#pragma mark Notifications
- (void)didChangeGroupSelectionInOutlineView:(NSNotification *)notification {
/*
If we have an active search, do not mess with the content
@@ -72,6 +125,9 @@ NSString *const _MPPasswordColumnIdentifier = @"MPPasswordColumnIdentifier";
if([self hasActiveFilter]) {
return;
}
else {
[[self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier] setHidden:YES];
}
MPOutlineViewDelegate *delegate = [notification object];
KdbGroup *group = delegate.selectedGroup;
if(group) {
@@ -82,6 +138,8 @@ NSString *const _MPPasswordColumnIdentifier = @"MPPasswordColumnIdentifier";
}
}
#pragma mark Filtering
- (BOOL)hasActiveFilter {
return ([self.filter length] > 0);
}
@@ -97,14 +155,24 @@ NSString *const _MPPasswordColumnIdentifier = @"MPPasswordColumnIdentifier";
- (void)updateFilter {
MPDatabaseDocument *openDatabase = [MPDatabaseController defaultController].database;
if(openDatabase) {
if([self.filter isEqualToString:@"*"]) {
self.filteredEntries = [openDatabase.root childEntries];
}
else {
NSPredicate *filterPredicate = [NSPredicate predicateWithFormat:@"SELF.title CONTAINS[cd] %@", self.filter];
self.filteredEntries = [[openDatabase.root childEntries] filteredArrayUsingPredicate:filterPredicate];
}
[self.entryArrayController setContent:self.filteredEntries];
/*
Search in the background
*/
dispatch_queue_t backgroundQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(backgroundQueue, ^{
if([self.filter length] == 0) {
self.filteredEntries = [openDatabase.root childEntries];
}
else {
NSPredicate *filterPredicate = [NSPredicate predicateWithFormat:@"SELF.title CONTAINS[cd] %@", self.filter];
self.filteredEntries = [[openDatabase.root childEntries] filteredArrayUsingPredicate:filterPredicate];
}
dispatch_async(dispatch_get_main_queue(), ^{
[self.entryArrayController setContent:self.filteredEntries];
[[self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier] setHidden:NO];
});
});
}
else {
[self.entryArrayController setContent:nil];

View File

@@ -10,4 +10,6 @@
@interface MPGradientView : NSView
- (id)initWithFrame:(NSRect)frame activeGradient:(NSGradient *)activeGradient inactiveGradient:(NSGradient *)inactiveGradient;
@end

View File

@@ -8,21 +8,70 @@
#import "MPGradientView.h"
@interface MPGradientView ()
@property (assign, nonatomic) BOOL isRenderedActive;
@property (retain) NSGradient *activeGradient;
@property (retain) NSGradient *inactiveGradient;
- (void)refreshActiveState;
@end
@implementation MPGradientView
- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code here.
}
return self;
- (id)initWithFrame:(NSRect)frameRect {
NSColor *activeTop = [NSColor colorWithCalibratedWhite:0.85 alpha:1];
NSColor *activeBottom = [NSColor colorWithCalibratedWhite:0.7 alpha:1];
NSColor *inactiveTop = [NSColor colorWithCalibratedWhite:0.9 alpha:1];
NSColor *inactiveBottom = [NSColor colorWithCalibratedWhite:0.85 alpha:1];
NSGradient *activeGradient = [[[NSGradient alloc] initWithColors:@[ activeBottom, activeTop ]] autorelease];
NSGradient *inactiveGradient = [[[NSGradient alloc] initWithColors:@[ inactiveBottom, inactiveTop ]] autorelease];
return [self initWithFrame:frameRect activeGradient:activeGradient inactiveGradient:inactiveGradient];
}
- (void)drawRect:(NSRect)dirtyRect
{
// Drawing code here.
- (id)initWithFrame:(NSRect)frame activeGradient:(NSGradient *)activeGradient inactiveGradient:(NSGradient *)inactiveGradient {
self = [super initWithFrame:frame];
if(self) {
_activeGradient = [activeGradient retain];
_inactiveGradient = [inactiveGradient retain];
}
return self;
}
- (void)drawRect:(NSRect)dirtyRect {
NSGradient *gradient = self.isRenderedActive ? self.activeGradient : self.inactiveGradient;
[gradient drawInRect:dirtyRect angle:90];
}
- (void)_registerWindow:(NSWindow *)newWindow {
if([self window]) {
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidBecomeKeyNotification object:[self window]];
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidResignKeyNotification object:[self window]];
}
if(newWindow) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshActiveState) name:NSWindowDidBecomeKeyNotification object:newWindow];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshActiveState) name:NSWindowDidResignKeyNotification object:newWindow];
}
}
- (void)viewWillMoveToWindow:(NSWindow *)newWindow {
[self _registerWindow:newWindow];
[super viewWillMoveToWindow:newWindow];
}
- (void)refreshActiveState {
self.isRenderedActive = [[self window] isKeyWindow];
}
- (void)setIsRenderedActive:(BOOL)isRenderedActive {
if(_isRenderedActive != isRenderedActive) {
_isRenderedActive = isRenderedActive;
[self setNeedsDisplay:YES];
}
}
@end

View File

@@ -24,10 +24,20 @@ typedef enum {
@interface MPIconHelper : NSObject
/*
@param type Icon identifier typ MPIconTyp
@returns Icon for given identifier
*/
+ (NSImage *)icon:(MPIconType)type;
/*
Available Icons, Use the MPDatabaseIconType to access a individual icon;
@returns all availble Icons
*/
+ (NSDictionary *)availableIcons;
/*
@returns a random Icon image
*/
+ (NSImage *)randomIcon;
@end

View File

@@ -10,7 +10,6 @@
@implementation MPIconHelper
# pragma mark Icon accessors
+ (NSImage *)icon:(MPIconType)type {
NSDictionary *icons = [MPIconHelper availableIcons];
NSString *imageName = icons[@(type)];
@@ -33,4 +32,15 @@
return imageNames;
}
+ (NSImage *)randomIcon {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
srandom([[NSDate date] timeIntervalSince1970]);
});
NSArray *types = [[MPIconHelper availableIcons] allKeys];
NSUInteger randomIndex = random() % [types count];
return [MPIconHelper icon:(MPIconType)randomIndex];
}
@end

View File

@@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>F7</string>
<string>15D</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key>