mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 11:42:30 +00:00
Fixed memory leaks
Introduced Sorting
This commit is contained in:
@@ -57,7 +57,7 @@
|
|||||||
[[NSBundle mainBundle] loadNibNamed:@"PasswordCreatorWindow"owner:self topLevelObjects:nil];
|
[[NSBundle mainBundle] loadNibNamed:@"PasswordCreatorWindow"owner:self topLevelObjects:nil];
|
||||||
}
|
}
|
||||||
if(!self.passwordCreatorController) {
|
if(!self.passwordCreatorController) {
|
||||||
self.passwordCreatorController = [[MPPasswordCreatorViewController alloc] init];
|
self.passwordCreatorController = [[[MPPasswordCreatorViewController alloc] init] autorelease];
|
||||||
}
|
}
|
||||||
[self.passwordCreatorWindow setContentView:[self.passwordCreatorController view]];
|
[self.passwordCreatorWindow setContentView:[self.passwordCreatorController view]];
|
||||||
[self.passwordCreatorWindow makeKeyAndOrderFront:self.passwordCreatorWindow];
|
[self.passwordCreatorWindow makeKeyAndOrderFront:self.passwordCreatorWindow];
|
||||||
|
|||||||
@@ -9,6 +9,15 @@
|
|||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#import "MPDatabaseVersion.h"
|
#import "MPDatabaseVersion.h"
|
||||||
|
|
||||||
|
|
||||||
|
APPKIT_EXTERN NSString *const MPDocumentDidAddGroupNotification;
|
||||||
|
APPKIT_EXTERN NSString *const MPDocumentDidDelteGroupNotification;
|
||||||
|
APPKIT_EXTERN NSString *const MPDocumentDidAddEntryNotification;
|
||||||
|
APPKIT_EXTERN NSString *const MPDocumentDidDeleteEntryNotification;
|
||||||
|
|
||||||
|
APPKIT_EXTERN NSString *const MPDocumentEntryKey;
|
||||||
|
APPKIT_EXTERN NSString *const MPDocumentGroupKey;
|
||||||
|
|
||||||
@class KdbGroup;
|
@class KdbGroup;
|
||||||
@class KdbEntry;
|
@class KdbEntry;
|
||||||
|
|
||||||
@@ -24,8 +33,12 @@
|
|||||||
- (id)initWithVersion:(MPDatabaseVersion)version;
|
- (id)initWithVersion:(MPDatabaseVersion)version;
|
||||||
- (BOOL)decryptWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL;
|
- (BOOL)decryptWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- (KdbGroup *)createGroup:(KdbGroup *)parent;
|
- (KdbGroup *)createGroup:(KdbGroup *)parent;
|
||||||
- (KdbEntry *)createEntry:(KdbGroup *)parent;
|
- (KdbEntry *)createEntry:(KdbGroup *)parent;
|
||||||
|
|
||||||
|
- (void)addGroup:(NSArray *)groupAndParent;
|
||||||
- (void)deleteEntry:(KdbEntry *)entry;
|
- (void)deleteEntry:(KdbEntry *)entry;
|
||||||
- (void)deleteGroup:(KdbGroup *)group;
|
- (void)deleteGroup:(KdbGroup *)group;
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,15 @@
|
|||||||
#import "KdbPassword.h"
|
#import "KdbPassword.h"
|
||||||
#import "MPDatabaseVersion.h"
|
#import "MPDatabaseVersion.h"
|
||||||
|
|
||||||
|
NSString *const MPDocumentDidAddGroupNotification = @"MPDocumentDidAddGroupNotification";
|
||||||
|
NSString *const MPDocumentDidDelteGroupNotification = @"MPDocumentDidDelteGroupNotification";
|
||||||
|
NSString *const MPDocumentDidAddEntryNotification = @"MPDocumentDidAddEntryNotification";
|
||||||
|
NSString *const MPDocumentDidDeleteEntryNotification = @"MPDocumentDidDeleteEntryNotification";
|
||||||
|
|
||||||
|
NSString *const MPDocumentEntryKey = @"MPDocumentEntryKey";
|
||||||
|
NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
|
||||||
|
|
||||||
|
|
||||||
@interface MPDocument ()
|
@interface MPDocument ()
|
||||||
|
|
||||||
@property (retain) KdbTree *tree;
|
@property (retain) KdbTree *tree;
|
||||||
@@ -58,6 +67,7 @@
|
|||||||
- (void) makeWindowControllers {
|
- (void) makeWindowControllers {
|
||||||
MPDocumentWindowController *windowController = [[MPDocumentWindowController alloc] init];
|
MPDocumentWindowController *windowController = [[MPDocumentWindowController alloc] init];
|
||||||
[self addWindowController:windowController];
|
[self addWindowController:windowController];
|
||||||
|
[windowController release];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowControllerDidLoadNib:(NSWindowController *)aController
|
- (void)windowControllerDidLoadNib:(NSWindowController *)aController
|
||||||
@@ -128,7 +138,7 @@
|
|||||||
- (KdbEntry *)createEntry:(KdbGroup *)parent {
|
- (KdbEntry *)createEntry:(KdbGroup *)parent {
|
||||||
KdbEntry *newEntry = [self.tree createEntry:parent];
|
KdbEntry *newEntry = [self.tree createEntry:parent];
|
||||||
newEntry.title = NSLocalizedString(@"DEFAULT_ENTRY_TITLE", @"Title for a newly created entry");
|
newEntry.title = NSLocalizedString(@"DEFAULT_ENTRY_TITLE", @"Title for a newly created entry");
|
||||||
[[[self undoManager] prepareWithInvocationTarget:self] deleteEntry:newEntry];
|
[[self undoManager] registerUndoWithTarget:self selector:@selector(deleteEntry:) object:newEntry];
|
||||||
[[self undoManager] setActionName:NSLocalizedString(@"ADD_ENTRY_UNDO", @"Create Entry Undo")];
|
[[self undoManager] setActionName:NSLocalizedString(@"ADD_ENTRY_UNDO", @"Create Entry Undo")];
|
||||||
[parent addEntry:newEntry];
|
[parent addEntry:newEntry];
|
||||||
return newEntry;
|
return newEntry;
|
||||||
@@ -138,13 +148,24 @@
|
|||||||
KdbGroup *newGroup = [self.tree createGroup:parent];
|
KdbGroup *newGroup = [self.tree createGroup:parent];
|
||||||
newGroup.name = NSLocalizedString(@"DEFAULT_GROUP_NAME", @"Title for a newly created group");
|
newGroup.name = NSLocalizedString(@"DEFAULT_GROUP_NAME", @"Title for a newly created group");
|
||||||
|
|
||||||
[[[self undoManager] prepareWithInvocationTarget:self] deleteGroup:newGroup];
|
[[self undoManager] registerUndoWithTarget:self selector:@selector(deleteGroup:) object:newGroup];
|
||||||
[[self undoManager] setActionName:NSLocalizedString(@"ADD_GROUP_UNDO", @"Create Group Undo")];
|
[[self undoManager] setActionName:NSLocalizedString(@"ADD_GROUP_UNDO", @"Create Group Undo")];
|
||||||
[parent addGroup:newGroup];
|
[parent addGroup:newGroup];
|
||||||
|
NSDictionary *userInfo = @{ MPDocumentGroupKey:newGroup };
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidAddGroupNotification object:self userInfo:userInfo];
|
||||||
|
self.isDirty = YES;
|
||||||
|
|
||||||
return newGroup;
|
return newGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)addGroup:(NSArray *)groupAndParent{
|
||||||
|
KdbGroup *parent = groupAndParent[0];
|
||||||
|
KdbGroup *group = groupAndParent[1];
|
||||||
|
NSDictionary *userInfo = @{ MPDocumentGroupKey:group };
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidAddGroupNotification object:self userInfo:userInfo];
|
||||||
|
[parent addGroup:group];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)deleteEntry:(KdbEntry *)entry {
|
- (void)deleteEntry:(KdbEntry *)entry {
|
||||||
if(entry.parent) {
|
if(entry.parent) {
|
||||||
[entry.parent removeEntry:entry];
|
[entry.parent removeEntry:entry];
|
||||||
@@ -154,7 +175,12 @@
|
|||||||
|
|
||||||
- (void)deleteGroup:(KdbGroup *)group {
|
- (void)deleteGroup:(KdbGroup *)group {
|
||||||
if(group.parent) {
|
if(group.parent) {
|
||||||
|
[[self undoManager] registerUndoWithTarget:self selector:@selector(addGroup:) object:@[group.parent, group]];
|
||||||
|
[[self undoManager] setActionName:NSLocalizedString(@"DELETE_GROUP_UNDO", @"Create Group Undo")];
|
||||||
[group.parent removeGroup:group];
|
[group.parent removeGroup:group];
|
||||||
|
NSDictionary *userInfo = @{ MPDocumentEntryKey:group };
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidDelteGroupNotification object:self userInfo:userInfo];
|
||||||
|
|
||||||
self.isDirty = YES;
|
self.isDirty = YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,6 +151,14 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
|
|||||||
[passwordColumn setIdentifier:MPEntryTablePasswordColumnIdentifier];
|
[passwordColumn setIdentifier:MPEntryTablePasswordColumnIdentifier];
|
||||||
[urlColumn setIdentifier:MPEntryTableURLColumnIdentifier];
|
[urlColumn setIdentifier:MPEntryTableURLColumnIdentifier];
|
||||||
|
|
||||||
|
NSSortDescriptor *titleColumSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"title" ascending:YES selector:@selector(compare:)];
|
||||||
|
NSSortDescriptor *userNameSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"username" ascending:YES selector:@selector(compare:)];
|
||||||
|
NSSortDescriptor *urlSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"url" ascending:YES selector:@selector(compare:)];
|
||||||
|
|
||||||
|
[titleColumn setSortDescriptorPrototype:titleColumSortDescriptor];
|
||||||
|
[userNameColumn setSortDescriptorPrototype:userNameSortDescriptor];
|
||||||
|
[urlColumn setSortDescriptorPrototype:urlSortDescriptor];
|
||||||
|
|
||||||
[[parentColumn headerCell] setStringValue:@"Group"];
|
[[parentColumn headerCell] setStringValue:@"Group"];
|
||||||
[[titleColumn headerCell] setStringValue:@"Title"];
|
[[titleColumn headerCell] setStringValue:@"Title"];
|
||||||
[[userNameColumn headerCell] setStringValue:@"Username"];
|
[[userNameColumn headerCell] setStringValue:@"Username"];
|
||||||
@@ -158,6 +166,8 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
|
|||||||
[[urlColumn headerCell] setStringValue:@"URL"];
|
[[urlColumn headerCell] setStringValue:@"URL"];
|
||||||
|
|
||||||
[self.entryTable bind:NSContentBinding toObject:self.entryArrayController withKeyPath:@"arrangedObjects" options:nil];
|
[self.entryTable bind:NSContentBinding toObject:self.entryArrayController withKeyPath:@"arrangedObjects" options:nil];
|
||||||
|
[self.entryTable bind:NSSortDescriptorsBinding toObject:self.entryArrayController withKeyPath:@"sortDescriptors" options:nil];
|
||||||
|
|
||||||
[parentColumn setHidden:YES];
|
[parentColumn setHidden:YES];
|
||||||
}
|
}
|
||||||
#pragma mark NSTableViewDelgate
|
#pragma mark NSTableViewDelgate
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
@property (retain) NSMenu *menu;
|
@property (retain) NSMenu *menu;
|
||||||
|
|
||||||
|
|
||||||
|
- (void)_didUpdateData:(NSNotification *)notification;
|
||||||
- (NSMenu *)_contextMenu;
|
- (NSMenu *)_contextMenu;
|
||||||
- (KdbGroup *)_clickedOrSelectedGroup;
|
- (KdbGroup *)_clickedOrSelectedGroup;
|
||||||
|
|
||||||
@@ -38,6 +39,18 @@
|
|||||||
if (self) {
|
if (self) {
|
||||||
self.outlineDelegate = [[[MPOutlineViewDelegate alloc] init] autorelease];
|
self.outlineDelegate = [[[MPOutlineViewDelegate alloc] init] autorelease];
|
||||||
self.datasource = [[[MPOutlineDataSource alloc] init] autorelease];
|
self.datasource = [[[MPOutlineDataSource alloc] init] autorelease];
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(_didUpdateData:)
|
||||||
|
name:MPDocumentDidAddGroupNotification
|
||||||
|
object:[[self windowController] document]];
|
||||||
|
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(_didUpdateData:)
|
||||||
|
name:MPDocumentDidDelteGroupNotification
|
||||||
|
object:[[self windowController] document]];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
@@ -116,5 +129,9 @@
|
|||||||
return [self.outlineView itemAtRow:row];
|
return [self.outlineView itemAtRow:row];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)_didUpdateData:(NSNotification *)notification {
|
||||||
|
[self.outlineView reloadData];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc {
|
- (void)dealloc {
|
||||||
[self.pathControlDelegate release];
|
[_pathControlDelegate release];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>67C</string>
|
<string>69B</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
||||||
<key>NSHumanReadableCopyright</key>
|
<key>NSHumanReadableCopyright</key>
|
||||||
|
|||||||
Reference in New Issue
Block a user