1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2025-03-10 05:34:36 +00:00

Delegate model instantiation to HSGUIController where possible.

--HG--
branch : objp
This commit is contained in:
Virgil Dupras 2012-01-15 18:07:32 -05:00
parent 1b571f6fd2
commit 302050b2d6
6 changed files with 14 additions and 25 deletions

View File

@ -15,5 +15,5 @@ http://www.hardcoded.net/licenses/bsd_license
@interface DirectoryOutline : HSOutline {} @interface DirectoryOutline : HSOutline {}
- (id)initWithPyRef:(PyObject *)aPyRef outlineView:(HSOutlineView *)aOutlineView; - (id)initWithPyRef:(PyObject *)aPyRef outlineView:(HSOutlineView *)aOutlineView;
- (PyDirectoryOutline *)py; - (PyDirectoryOutline *)model;
@end; @end;

View File

@ -7,22 +7,19 @@ http://www.hardcoded.net/licenses/bsd_license
*/ */
#import "DirectoryOutline.h" #import "DirectoryOutline.h"
#import "Utils.h"
@implementation DirectoryOutline @implementation DirectoryOutline
- (id)initWithPyRef:(PyObject *)aPyRef outlineView:(HSOutlineView *)aOutlineView - (id)initWithPyRef:(PyObject *)aPyRef outlineView:(HSOutlineView *)aOutlineView
{ {
PyDirectoryOutline *model = [[PyDirectoryOutline alloc] initWithModel:aPyRef]; self = [super initWithPyRef:aPyRef wrapperClass:[PyDirectoryOutline class]
self = [super initWithPy:model view:aOutlineView]; callbackClassName:@"DirectoryOutlineView" view:aOutlineView];
[model bindCallback:createCallback(@"DirectoryOutlineView", self)]; [[self view] registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
[model release];
[outlineView registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
return self; return self;
} }
- (PyDirectoryOutline *)py - (PyDirectoryOutline *)model
{ {
return (PyDirectoryOutline *)py; return (PyDirectoryOutline *)model;
} }
/* Delegate */ /* Delegate */
@ -50,7 +47,7 @@ http://www.hardcoded.net/licenses/bsd_license
if (!(sourceDragMask & NSDragOperationLink)) if (!(sourceDragMask & NSDragOperationLink))
return NO; return NO;
for (NSString *foldername in foldernames) { for (NSString *foldername in foldernames) {
[[self py] addDirectory:foldername]; [[self model] addDirectory:foldername];
} }
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:foldernames forKey:@"foldernames"]; NSDictionary *userInfo = [NSDictionary dictionaryWithObject:foldernames forKey:@"foldernames"];
[[NSNotificationCenter defaultCenter] postNotificationName:DGAddedFoldersNotification [[NSNotificationCenter defaultCenter] postNotificationName:DGAddedFoldersNotification
@ -64,7 +61,7 @@ http://www.hardcoded.net/licenses/bsd_license
if ([cell isKindOfClass:[NSTextFieldCell class]]) { if ([cell isKindOfClass:[NSTextFieldCell class]]) {
NSTextFieldCell *textCell = cell; NSTextFieldCell *textCell = cell;
NSIndexPath *path = item; NSIndexPath *path = item;
BOOL selected = [path isEqualTo:[outlineView selectedPath]]; BOOL selected = [path isEqualTo:[[self view] selectedPath]];
if (selected) { if (selected) {
[textCell setTextColor:[NSColor blackColor]]; [textCell setTextColor:[NSColor blackColor]];
return; return;

View File

@ -100,7 +100,7 @@ http://www.hardcoded.net/licenses/bsd_license
- (IBAction)removeSelectedDirectory:(id)sender - (IBAction)removeSelectedDirectory:(id)sender
{ {
[[self window] makeKeyAndOrderFront:nil]; [[self window] makeKeyAndOrderFront:nil];
[[outline py] removeSelectedDirectory]; [[outline model] removeSelectedDirectory];
[self refreshRemoveButtonText]; [self refreshRemoveButtonText];
} }

View File

@ -13,10 +13,8 @@ http://www.hardcoded.net/licenses/bsd_license
@implementation PrioritizeList @implementation PrioritizeList
- (id)initWithPyRef:(PyObject *)aPyRef tableView:(NSTableView *)aTableView - (id)initWithPyRef:(PyObject *)aPyRef tableView:(NSTableView *)aTableView
{ {
PyPrioritizeList *m = [[PyPrioritizeList alloc] initWithModel:aPyRef]; self = [super initWithPyRef:aPyRef wrapperClass:[PyPrioritizeList class]
self = [super initWithModel:m tableView:aTableView]; callbackClassName:@"PrioritizeListView" view:aTableView];
[m bindCallback:createCallback(@"PrioritizeListView", self)];
[m release];
return self; return self;
} }

View File

@ -20,10 +20,7 @@ http://www.hardcoded.net/licenses/bsd_license
@implementation ResultTable @implementation ResultTable
- (id)initWithPyRef:(PyObject *)aPyRef view:(NSTableView *)aTableView - (id)initWithPyRef:(PyObject *)aPyRef view:(NSTableView *)aTableView
{ {
PyResultTable *m = [[PyResultTable alloc] initWithModel:aPyRef]; self = [super initWithPyRef:aPyRef wrapperClass:[PyResultTable class] callbackClassName:@"ResultTableView" view:aTableView];
self = [super initWithModel:m tableView:aTableView];
[m bindCallback:createCallback(@"ResultTableView", self)];
[m release];
_deltaColumns = [[NSSet setWithArray:[[self model] deltaColumns]] retain]; _deltaColumns = [[NSSet setWithArray:[[self model] deltaColumns]] retain];
return self; return self;
} }

View File

@ -12,11 +12,8 @@ http://www.hardcoded.net/licenses/bsd_license
@implementation StatsLabel @implementation StatsLabel
- (id)initWithPyRef:(PyObject *)aPyRef view:(NSTextField *)aLabelView - (id)initWithPyRef:(PyObject *)aPyRef view:(NSTextField *)aLabelView
{ {
PyStatsLabel *m = [[PyStatsLabel alloc] initWithModel:aPyRef]; return [super initWithPyRef:aPyRef wrapperClass:[PyStatsLabel class]
self = [self initWithModel:m view:aLabelView]; callbackClassName:@"StatsLabelView" view:aLabelView];
[m bindCallback:createCallback(@"StatsLabelView", self)];
[m release];
return self;
} }
- (PyStatsLabel *)model - (PyStatsLabel *)model