1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2026-01-22 14:41:39 +00:00

[#138] Added drag & drop re-ordering capabilities to the pri-pist (Cocoa).

This commit is contained in:
Virgil Dupras
2011-09-16 11:08:24 -04:00
parent 880f0787ce
commit 5a26f1c2ae
8 changed files with 103 additions and 3 deletions

View File

@@ -18,4 +18,6 @@ http://www.hardcoded.net/licenses/bsd_license
#define jobMove @"job_move"
#define jobDelete @"job_delete"
#define DGPrioritizeIndexPasteboardType @"DGPrioritizeIndexPasteboardType"
#define TR(s) NSLocalizedString(s, @"")

View File

@@ -12,6 +12,7 @@ http://www.hardcoded.net/licenses/bsd_license
#import "PyPrioritizeDialog.h"
#import "HSPopUpList.h"
#import "HSSelectableList.h"
#import "PrioritizeList.h"
@interface PrioritizeDialog : HSWindowController
{
@@ -21,7 +22,7 @@ http://www.hardcoded.net/licenses/bsd_license
HSPopUpList *categoryPopUp;
HSSelectableList *criteriaList;
HSSelectableList *prioritizationList;
PrioritizeList *prioritizationList;
}
- (id)initWithPy:(PyApp *)aPy;
- (PyPrioritizeDialog *)py;

View File

@@ -15,7 +15,7 @@ http://www.hardcoded.net/licenses/bsd_license
[self window];
categoryPopUp = [[HSPopUpList alloc] initWithPy:[[self py] categoryList] view:categoryPopUpView];
criteriaList = [[HSSelectableList alloc] initWithPy:[[self py] criteriaList] view:criteriaTableView];
prioritizationList = [[HSSelectableList alloc] initWithPy:[[self py] prioritizationList] view:prioritizationTableView];
prioritizationList = [[PrioritizeList alloc] initWithPy:[[self py] prioritizationList] view:prioritizationTableView];
[self connect];
return self;
}
@@ -25,6 +25,7 @@ http://www.hardcoded.net/licenses/bsd_license
[self disconnect];
[categoryPopUp release];
[criteriaList release];
[prioritizationList release];
[super dealloc];
}

View File

@@ -0,0 +1,15 @@
/*
Copyright 2011 Hardcoded Software (http://www.hardcoded.net)
This software is licensed under the "BSD" License as described in the "LICENSE" file,
which should be included with this package. The terms are also available at
http://www.hardcoded.net/licenses/bsd_license
*/
#import <Cocoa/Cocoa.h>
#import "HSSelectableList.h"
#import "PyPrioritizeList.h"
@interface PrioritizeList : HSSelectableList {}
- (PyPrioritizeList *)py;
@end

View File

@@ -0,0 +1,51 @@
/*
Copyright 2011 Hardcoded Software (http://www.hardcoded.net)
This software is licensed under the "BSD" License as described in the "LICENSE" file,
which should be included with this package. The terms are also available at
http://www.hardcoded.net/licenses/bsd_license
*/
#import "PrioritizeList.h"
#import "Utils.h"
#import "Consts.h"
@implementation PrioritizeList
- (PyPrioritizeList *)py
{
return (PyPrioritizeList *)py;
}
- (void)setView:(NSTableView *)aTableView
{
[super setView:aTableView];
[[self view] registerForDraggedTypes:[NSArray arrayWithObject:DGPrioritizeIndexPasteboardType]];
}
- (BOOL)tableView:(NSTableView *)tv writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard*)pboard
{
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
[pboard declareTypes:[NSArray arrayWithObject:DGPrioritizeIndexPasteboardType] owner:self];
[pboard setData:data forType:DGPrioritizeIndexPasteboardType];
return YES;
}
- (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id <NSDraggingInfo>)info proposedRow:(NSInteger)row
proposedDropOperation:(NSTableViewDropOperation)op
{
if (op == NSTableViewDropAbove) {
return NSDragOperationMove;
}
return NSDragOperationNone;
}
- (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id <NSDraggingInfo>)info
row:(NSInteger)row dropOperation:(NSTableViewDropOperation)operation
{
NSPasteboard* pboard = [info draggingPasteboard];
NSData* rowData = [pboard dataForType:DGPrioritizeIndexPasteboardType];
NSIndexSet* rowIndexes = [NSKeyedUnarchiver unarchiveObjectWithData:rowData];
[[self py] moveIndexes:[Utils indexSet2Array:rowIndexes] toIndex:row];
return YES;
}
@end

View File

@@ -0,0 +1,14 @@
/*
Copyright 2011 Hardcoded Software (http://www.hardcoded.net)
This software is licensed under the "BSD" License as described in the "LICENSE" file,
which should be included with this package. The terms are also available at
http://www.hardcoded.net/licenses/bsd_license
*/
#import <Cocoa/Cocoa.h>
#import "PySelectableList.h"
@interface PyPrioritizeList : PySelectableList
- (void)moveIndexes:(NSArray *)indexes toIndex:(NSInteger)destIndex;
@end