mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-10 05:34:36 +00:00
Cleaned ResultWindow's code up.
This commit is contained in:
parent
9da9c269c1
commit
ad3114c56b
@ -32,12 +32,17 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
ProblemDialog *problemDialog;
|
||||
}
|
||||
- (id)initWithParentApp:(AppDelegateBase *)app;
|
||||
|
||||
/* Virtual */
|
||||
- (void)initResultColumns;
|
||||
- (void)setScanOptions;
|
||||
- (NSString *)getScanErrorMessageForCode:(NSInteger)errorCode;
|
||||
|
||||
/* Helpers */
|
||||
- (void)fillColumnsMenu;
|
||||
- (NSTableColumn *)getColumnForIdentifier:(NSInteger)aIdentifier title:(NSString *)aTitle width:(NSInteger)aWidth refCol:(NSTableColumn *)aColumn;
|
||||
- (NSArray *)getColumnsOrder;
|
||||
- (NSDictionary *)getColumnsWidth;
|
||||
- (void)initResultColumns;
|
||||
- (void)restoreColumnsPosition:(NSArray *)aColumnsOrder widths:(NSDictionary *)aColumnsWidth;
|
||||
- (void)sendMarkedToTrash:(BOOL)hardlinkDeleted;
|
||||
- (void)updateOptionSegments;
|
||||
|
@ -44,6 +44,26 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
/* Virtual */
|
||||
- (void)initResultColumns
|
||||
{
|
||||
}
|
||||
|
||||
- (void)setScanOptions
|
||||
{
|
||||
}
|
||||
|
||||
- (NSString *)getScanErrorMessageForCode:(NSInteger)errorCode
|
||||
{
|
||||
if (errorCode == 0) {
|
||||
return nil;
|
||||
}
|
||||
if (errorCode == 3) {
|
||||
return @"The selected directories contain no scannable file.";
|
||||
}
|
||||
return @"Unknown Error.";
|
||||
}
|
||||
|
||||
/* Helpers */
|
||||
- (void)fillColumnsMenu
|
||||
{
|
||||
@ -96,11 +116,6 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void)initResultColumns
|
||||
{
|
||||
// Virtual
|
||||
}
|
||||
|
||||
- (void)restoreColumnsPosition:(NSArray *)aColumnsOrder widths:(NSDictionary *)aColumnsWidth
|
||||
{
|
||||
for (NSMenuItem *mi in [columnsMenu itemArray]) {
|
||||
@ -344,7 +359,17 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
|
||||
- (IBAction)startDuplicateScan:(id)sender
|
||||
{
|
||||
// Virtual
|
||||
if ([py resultsAreModified]) {
|
||||
if ([Dialogs askYesNo:@"You have unsaved results, do you really want to continue?"] == NSAlertSecondButtonReturn) // NO
|
||||
return;
|
||||
}
|
||||
[self setScanOptions];
|
||||
NSInteger r = n2i([py doScan]);
|
||||
NSString *errorMsg = [self getScanErrorMessageForCode:r];
|
||||
if (errorMsg != nil) {
|
||||
[[ProgressController mainProgressController] hide];
|
||||
[Dialogs showMessage:errorMsg];
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)switchSelected:(id)sender
|
||||
|
@ -8,7 +8,6 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "../base/ResultWindow.h"
|
||||
#import "DirectoryPanel.h"
|
||||
|
||||
@interface ResultWindow : ResultWindowBase {}
|
||||
- (IBAction)removeDeadTracks:(id)sender;
|
||||
|
@ -7,10 +7,9 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
*/
|
||||
|
||||
#import "ResultWindow.h"
|
||||
#import "../../cocoalib/Dialogs.h"
|
||||
#import "../../cocoalib/ProgressController.h"
|
||||
#import "../../cocoalib/Utils.h"
|
||||
#import "AppDelegate.h"
|
||||
#import "Dialogs.h"
|
||||
#import "Utils.h"
|
||||
#import "PyDupeGuru.h"
|
||||
#import "Consts.h"
|
||||
|
||||
@implementation ResultWindow
|
||||
@ -24,37 +23,8 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
return self;
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
- (IBAction)removeDeadTracks:(id)sender
|
||||
- (void)setScanOptions
|
||||
{
|
||||
[(PyDupeGuru *)py scanDeadTracks];
|
||||
}
|
||||
|
||||
- (IBAction)resetColumnsToDefault:(id)sender
|
||||
{
|
||||
NSMutableArray *columnsOrder = [NSMutableArray array];
|
||||
[columnsOrder addObject:@"0"];
|
||||
[columnsOrder addObject:@"2"];
|
||||
[columnsOrder addObject:@"3"];
|
||||
[columnsOrder addObject:@"4"];
|
||||
[columnsOrder addObject:@"6"];
|
||||
[columnsOrder addObject:@"15"];
|
||||
NSMutableDictionary *columnsWidth = [NSMutableDictionary dictionary];
|
||||
[columnsWidth setObject:i2n(235) forKey:@"0"];
|
||||
[columnsWidth setObject:i2n(63) forKey:@"2"];
|
||||
[columnsWidth setObject:i2n(50) forKey:@"3"];
|
||||
[columnsWidth setObject:i2n(50) forKey:@"4"];
|
||||
[columnsWidth setObject:i2n(40) forKey:@"6"];
|
||||
[columnsWidth setObject:i2n(57) forKey:@"15"];
|
||||
[self restoreColumnsPosition:columnsOrder widths:columnsWidth];
|
||||
}
|
||||
|
||||
- (IBAction)startDuplicateScan:(id)sender
|
||||
{
|
||||
if ([py resultsAreModified]) {
|
||||
if ([Dialogs askYesNo:@"You have unsaved results, do you really want to continue?"] == NSAlertSecondButtonReturn) // NO
|
||||
return;
|
||||
}
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
PyDupeGuru *_py = (PyDupeGuru *)py;
|
||||
[_py setScanType:[ud objectForKey:@"scanType"]];
|
||||
@ -69,13 +39,8 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
[_py setMixFileKind:n2b([ud objectForKey:@"mixFileKind"])];
|
||||
[_py setIgnoreHardlinkMatches:n2b([ud objectForKey:@"ignoreHardlinkMatches"])];
|
||||
[_py setMatchSimilarWords:[ud objectForKey:@"matchSimilarWords"]];
|
||||
NSInteger r = n2i([py doScan]);
|
||||
if (r == 3) {
|
||||
[Dialogs showMessage:@"The selected directories contain no scannable file."];
|
||||
}
|
||||
}
|
||||
|
||||
/* Public */
|
||||
- (void)initResultColumns
|
||||
{
|
||||
NSTableColumn *refCol = [matches tableColumnWithIdentifier:@"0"];
|
||||
@ -106,6 +71,31 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:17 title:@"Dupe Count" width:80 refCol:refCol]];
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
- (IBAction)removeDeadTracks:(id)sender
|
||||
{
|
||||
[(PyDupeGuru *)py scanDeadTracks];
|
||||
}
|
||||
|
||||
- (IBAction)resetColumnsToDefault:(id)sender
|
||||
{
|
||||
NSMutableArray *columnsOrder = [NSMutableArray array];
|
||||
[columnsOrder addObject:@"0"];
|
||||
[columnsOrder addObject:@"2"];
|
||||
[columnsOrder addObject:@"3"];
|
||||
[columnsOrder addObject:@"4"];
|
||||
[columnsOrder addObject:@"6"];
|
||||
[columnsOrder addObject:@"15"];
|
||||
NSMutableDictionary *columnsWidth = [NSMutableDictionary dictionary];
|
||||
[columnsWidth setObject:i2n(235) forKey:@"0"];
|
||||
[columnsWidth setObject:i2n(63) forKey:@"2"];
|
||||
[columnsWidth setObject:i2n(50) forKey:@"3"];
|
||||
[columnsWidth setObject:i2n(50) forKey:@"4"];
|
||||
[columnsWidth setObject:i2n(40) forKey:@"6"];
|
||||
[columnsWidth setObject:i2n(57) forKey:@"15"];
|
||||
[self restoreColumnsPosition:columnsOrder widths:columnsWidth];
|
||||
}
|
||||
|
||||
/* Notifications */
|
||||
- (void)jobCompleted:(NSNotification *)aNotification
|
||||
{
|
||||
|
@ -8,10 +8,8 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
|
||||
#import "ResultWindow.h"
|
||||
#import "Dialogs.h"
|
||||
#import "ProgressController.h"
|
||||
#import "Utils.h"
|
||||
#import "AppDelegate.h"
|
||||
#import "Consts.h"
|
||||
#import "PyDupeGuru.h"
|
||||
|
||||
@implementation ResultWindow
|
||||
/* Override */
|
||||
@ -24,6 +22,40 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)initResultColumns
|
||||
{
|
||||
NSTableColumn *refCol = [matches tableColumnWithIdentifier:@"0"];
|
||||
_resultColumns = [[NSMutableArray alloc] init];
|
||||
[_resultColumns addObject:[matches tableColumnWithIdentifier:@"0"]]; // File Name
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:1 title:@"Directory" width:120 refCol:refCol]];
|
||||
NSTableColumn *sizeCol = [self getColumnForIdentifier:2 title:@"Size (KB)" width:63 refCol:refCol];
|
||||
[[sizeCol dataCell] setAlignment:NSRightTextAlignment];
|
||||
[_resultColumns addObject:sizeCol];
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:3 title:@"Kind" width:40 refCol:refCol]];
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:4 title:@"Dimensions" width:80 refCol:refCol]];
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:5 title:@"Modification" width:120 refCol:refCol]];
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:6 title:@"Match %" width:58 refCol:refCol]];
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:7 title:@"Dupe Count" width:80 refCol:refCol]];
|
||||
}
|
||||
|
||||
- (void)setScanOptions
|
||||
{
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
PyDupeGuru *_py = (PyDupeGuru *)py;
|
||||
[_py setMinMatchPercentage:[ud objectForKey:@"minMatchPercentage"]];
|
||||
[_py setMixFileKind:n2b([ud objectForKey:@"mixFileKind"])];
|
||||
[_py setIgnoreHardlinkMatches:n2b([ud objectForKey:@"ignoreHardlinkMatches"])];
|
||||
[_py setMatchScaled:[ud objectForKey:@"matchScaled"]];
|
||||
}
|
||||
|
||||
- (NSString *)getScanErrorMessageForCode:(NSInteger)errorCode
|
||||
{
|
||||
if (errorCode == 4) {
|
||||
return @"The iPhoto application couldn't be found.";
|
||||
}
|
||||
return [super getScanErrorMessageForCode:errorCode];
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
- (IBAction)clearPictureCache:(id)sender
|
||||
{
|
||||
@ -48,45 +80,4 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
[columnsWidth setObject:i2n(58) forKey:@"6"];
|
||||
[self restoreColumnsPosition:columnsOrder widths:columnsWidth];
|
||||
}
|
||||
|
||||
- (IBAction)startDuplicateScan:(id)sender
|
||||
{
|
||||
if ([py resultsAreModified]) {
|
||||
if ([Dialogs askYesNo:@"You have unsaved results, do you really want to continue?"] == NSAlertSecondButtonReturn) // NO
|
||||
return;
|
||||
}
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
PyDupeGuru *_py = (PyDupeGuru *)py;
|
||||
[_py setMinMatchPercentage:[ud objectForKey:@"minMatchPercentage"]];
|
||||
[_py setMixFileKind:n2b([ud objectForKey:@"mixFileKind"])];
|
||||
[_py setIgnoreHardlinkMatches:n2b([ud objectForKey:@"ignoreHardlinkMatches"])];
|
||||
[_py setMatchScaled:[ud objectForKey:@"matchScaled"]];
|
||||
int r = n2i([py doScan]);
|
||||
if (r != 0) {
|
||||
[[ProgressController mainProgressController] hide];
|
||||
}
|
||||
if (r == 3) {
|
||||
[Dialogs showMessage:@"The selected directories contain no scannable file."];
|
||||
}
|
||||
if (r == 4) {
|
||||
[Dialogs showMessage:@"The iPhoto application couldn't be found."];
|
||||
}
|
||||
}
|
||||
|
||||
/* Public */
|
||||
- (void)initResultColumns
|
||||
{
|
||||
NSTableColumn *refCol = [matches tableColumnWithIdentifier:@"0"];
|
||||
_resultColumns = [[NSMutableArray alloc] init];
|
||||
[_resultColumns addObject:[matches tableColumnWithIdentifier:@"0"]]; // File Name
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:1 title:@"Directory" width:120 refCol:refCol]];
|
||||
NSTableColumn *sizeCol = [self getColumnForIdentifier:2 title:@"Size (KB)" width:63 refCol:refCol];
|
||||
[[sizeCol dataCell] setAlignment:NSRightTextAlignment];
|
||||
[_resultColumns addObject:sizeCol];
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:3 title:@"Kind" width:40 refCol:refCol]];
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:4 title:@"Dimensions" width:80 refCol:refCol]];
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:5 title:@"Modification" width:120 refCol:refCol]];
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:6 title:@"Match %" width:58 refCol:refCol]];
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:7 title:@"Dupe Count" width:80 refCol:refCol]];
|
||||
}
|
||||
@end
|
@ -8,11 +8,6 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "../base/ResultWindow.h"
|
||||
#import "DirectoryPanel.h"
|
||||
|
||||
@interface ResultWindow : ResultWindowBase
|
||||
{
|
||||
NSString *_lastAction;
|
||||
}
|
||||
- (IBAction)resetColumnsToDefault:(id)sender;
|
||||
@interface ResultWindow : ResultWindowBase {}
|
||||
@end
|
||||
|
@ -7,20 +7,49 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
*/
|
||||
|
||||
#import "ResultWindow.h"
|
||||
#import "../../cocoalib/Dialogs.h"
|
||||
#import "../../cocoalib/ProgressController.h"
|
||||
#import "../../cocoalib/Utils.h"
|
||||
#import "AppDelegate.h"
|
||||
#import "Consts.h"
|
||||
#import "Utils.h"
|
||||
#import "PyDupeGuru.h"
|
||||
|
||||
@implementation ResultWindow
|
||||
/* Override */
|
||||
- (void)awakeFromNib
|
||||
- (id)initWithParentApp:(AppDelegateBase *)aApp;
|
||||
{
|
||||
[super awakeFromNib];
|
||||
self = [super initWithParentApp:aApp];
|
||||
NSMutableIndexSet *deltaColumns = [NSMutableIndexSet indexSetWithIndex:2];
|
||||
[deltaColumns addIndex:4];
|
||||
[table setDeltaColumns:deltaColumns];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)initResultColumns
|
||||
{
|
||||
NSTableColumn *refCol = [matches tableColumnWithIdentifier:@"0"];
|
||||
_resultColumns = [[NSMutableArray alloc] init];
|
||||
[_resultColumns addObject:[matches tableColumnWithIdentifier:@"0"]]; // File Name
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:1 title:@"Directory" width:120 refCol:refCol]];
|
||||
NSTableColumn *sizeCol = [self getColumnForIdentifier:2 title:@"Size (KB)" width:63 refCol:refCol];
|
||||
[[sizeCol dataCell] setAlignment:NSRightTextAlignment];
|
||||
[_resultColumns addObject:sizeCol];
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:3 title:@"Kind" width:40 refCol:refCol]];
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:4 title:@"Modification" width:120 refCol:refCol]];
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:5 title:@"Match %" width:60 refCol:refCol]];
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:6 title:@"Words Used" width:120 refCol:refCol]];
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:7 title:@"Dupe Count" width:80 refCol:refCol]];
|
||||
}
|
||||
|
||||
- (void)setScanOptions
|
||||
{
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
PyDupeGuru *_py = (PyDupeGuru *)py;
|
||||
[_py setScanType:[ud objectForKey:@"scanType"]];
|
||||
[_py setMinMatchPercentage:[ud objectForKey:@"minMatchPercentage"]];
|
||||
[_py setWordWeighting:[ud objectForKey:@"wordWeighting"]];
|
||||
[_py setMixFileKind:n2b([ud objectForKey:@"mixFileKind"])];
|
||||
[_py setIgnoreHardlinkMatches:n2b([ud objectForKey:@"ignoreHardlinkMatches"])];
|
||||
[_py setMatchSimilarWords:[ud objectForKey:@"matchSimilarWords"]];
|
||||
int smallFileThreshold = [ud integerForKey:@"smallFileThreshold"]; // In KB
|
||||
int sizeThreshold = [ud boolForKey:@"ignoreSmallFiles"] ? smallFileThreshold * 1024 : 0; // The py side wants bytes
|
||||
[_py setSizeThreshold:sizeThreshold];
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
@ -38,47 +67,4 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
[columnsWidth setObject:i2n(60) forKey:@"5"];
|
||||
[self restoreColumnsPosition:columnsOrder widths:columnsWidth];
|
||||
}
|
||||
|
||||
- (IBAction)startDuplicateScan:(id)sender
|
||||
{
|
||||
if ([py resultsAreModified]) {
|
||||
if ([Dialogs askYesNo:@"You have unsaved results, do you really want to continue?"] == NSAlertSecondButtonReturn) // NO
|
||||
return;
|
||||
}
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
PyDupeGuru *_py = (PyDupeGuru *)py;
|
||||
[_py setScanType:[ud objectForKey:@"scanType"]];
|
||||
[_py setMinMatchPercentage:[ud objectForKey:@"minMatchPercentage"]];
|
||||
[_py setWordWeighting:[ud objectForKey:@"wordWeighting"]];
|
||||
[_py setMixFileKind:n2b([ud objectForKey:@"mixFileKind"])];
|
||||
[_py setIgnoreHardlinkMatches:n2b([ud objectForKey:@"ignoreHardlinkMatches"])];
|
||||
[_py setMatchSimilarWords:[ud objectForKey:@"matchSimilarWords"]];
|
||||
int smallFileThreshold = [ud integerForKey:@"smallFileThreshold"]; // In KB
|
||||
int sizeThreshold = [ud boolForKey:@"ignoreSmallFiles"] ? smallFileThreshold * 1024 : 0; // The py side wants bytes
|
||||
[_py setSizeThreshold:sizeThreshold];
|
||||
int r = n2i([py doScan]);
|
||||
if (r != 0)
|
||||
[[ProgressController mainProgressController] hide];
|
||||
if (r == 3) {
|
||||
[Dialogs showMessage:@"The selected directories contain no scannable file."];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Public */
|
||||
- (void)initResultColumns
|
||||
{
|
||||
NSTableColumn *refCol = [matches tableColumnWithIdentifier:@"0"];
|
||||
_resultColumns = [[NSMutableArray alloc] init];
|
||||
[_resultColumns addObject:[matches tableColumnWithIdentifier:@"0"]]; // File Name
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:1 title:@"Directory" width:120 refCol:refCol]];
|
||||
NSTableColumn *sizeCol = [self getColumnForIdentifier:2 title:@"Size (KB)" width:63 refCol:refCol];
|
||||
[[sizeCol dataCell] setAlignment:NSRightTextAlignment];
|
||||
[_resultColumns addObject:sizeCol];
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:3 title:@"Kind" width:40 refCol:refCol]];
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:4 title:@"Modification" width:120 refCol:refCol]];
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:5 title:@"Match %" width:60 refCol:refCol]];
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:6 title:@"Words Used" width:120 refCol:refCol]];
|
||||
[_resultColumns addObject:[self getColumnForIdentifier:7 title:@"Dupe Count" width:80 refCol:refCol]];
|
||||
}
|
||||
@end
|
||||
|
Loading…
x
Reference in New Issue
Block a user