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

Began a long overdue overhaul of the columns system. Cocoa-only so far, but it will affect the Qt part.

This commit is contained in:
Virgil Dupras
2011-11-26 10:55:14 -05:00
parent 0b1bf79796
commit eb83b830df
17 changed files with 233 additions and 428 deletions

View File

@@ -158,14 +158,6 @@ http://www.hardcoded.net/licenses/bsd_license
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[[ProgressController mainProgressController] setWorker:py];
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
//Restore Columns
NSArray *columnsOrder = [ud arrayForKey:@"columnsOrder"];
NSDictionary *columnsWidth = [ud dictionaryForKey:@"columnsWidth"];
if ([columnsOrder count])
[[self resultWindow] restoreColumnsPosition:columnsOrder widths:columnsWidth];
else
[[self resultWindow] resetColumnsToDefault:nil];
[py initialRegistrationSetup];
[py loadSession];
}
@@ -191,8 +183,6 @@ http://www.hardcoded.net/licenses/bsd_license
- (void)applicationWillTerminate:(NSNotification *)aNotification
{
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
[ud setObject: [[self resultWindow] getColumnsOrder] forKey:@"columnsOrder"];
[ud setObject: [[self resultWindow] getColumnsWidth] forKey:@"columnsWidth"];
NSInteger sc = [ud integerForKey:@"sessionCountSinceLastIgnorePurge"];
if (sc >= 10) {
sc = -1;

View File

@@ -15,7 +15,7 @@ http://www.hardcoded.net/licenses/bsd_license
- (BOOL)deltaValuesMode;
- (void)setDeltaValuesMode:(BOOL)aDeltaValuesMode;
- (NSString *)valueForRow:(NSInteger)rowIndex column:(NSInteger)aColumn;
- (NSString *)valueForRow:(NSInteger)rowIndex column:(NSString *)aColumn;
- (BOOL)renameSelected:(NSString *)aNewName;
- (void)sortBy:(NSInteger)aIdentifier ascending:(BOOL)aAscending;
- (void)markSelected;

View File

@@ -9,14 +9,17 @@ http://www.hardcoded.net/licenses/bsd_license
#import <Cocoa/Cocoa.h>
#import <Quartz/Quartz.h>
#import "HSTable.h"
#import "HSColumns.h"
#import "PyResultTable.h"
@interface ResultTable : HSTable <QLPreviewPanelDataSource, QLPreviewPanelDelegate>
{
NSIndexSet *_deltaColumns;
HSColumns *columns;
}
- (id)initWithPyParent:(id)aPyParent view:(NSTableView *)aTableView;
- (PyResultTable *)py;
- (HSColumns *)columns;
- (BOOL)powerMarkerMode;
- (void)setPowerMarkerMode:(BOOL)aPowerMarkerMode;
- (BOOL)deltaValuesMode;

View File

@@ -21,6 +21,7 @@ http://www.hardcoded.net/licenses/bsd_license
- (id)initWithPyParent:(id)aPyParent view:(NSTableView *)aTableView
{
self = [super initWithPyClassName:@"PyResultTable" pyParent:aPyParent view:aTableView];
columns = [[HSColumns alloc] initWithPy:[[self py] columns] tableView:aTableView];
[self connect];
return self;
}
@@ -28,6 +29,7 @@ http://www.hardcoded.net/licenses/bsd_license
- (void)dealloc
{
[self disconnect];
[columns release];
[_deltaColumns release];
[super dealloc];
}
@@ -58,6 +60,11 @@ http://www.hardcoded.net/licenses/bsd_license
}
/* Public */
- (HSColumns *)columns
{
return columns;
}
- (BOOL)powerMarkerMode
{
return [[self py] powerMarkerMode];
@@ -108,8 +115,7 @@ http://www.hardcoded.net/licenses/bsd_license
if ([identifier isEqual:@"marked"]) {
return [[self py] valueForColumn:@"marked" row:row];
}
NSInteger columnId = [identifier integerValue];
return [[self py] valueForRow:row column:columnId];
return [[self py] valueForRow:row column:identifier];
}
- (void)tableView:(NSTableView *)aTableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)column row:(NSInteger)row
@@ -118,8 +124,8 @@ http://www.hardcoded.net/licenses/bsd_license
if ([identifier isEqual:@"marked"]) {
[[self py] setValue:object forColumn:identifier row:row];
}
else if ([identifier isEqual:@"0"]) {
NSString *oldName = [[self py] valueForRow:row column:0];
else if ([identifier isEqual:@"name"]) {
NSString *oldName = [[self py] valueForRow:row column:identifier];
NSString *newName = object;
if (![newName isEqual:oldName]) {
BOOL renamed = [[self py] renameSelected:newName];

View File

@@ -27,7 +27,6 @@ http://www.hardcoded.net/licenses/bsd_license
AppDelegateBase *app;
PyDupeGuruBase *py;
NSMenu *columnsMenu;
NSMutableArray *_resultColumns;
ResultTable *table;
StatsLabel *statsLabel;
ProblemDialog *problemDialog;
@@ -41,10 +40,7 @@ http://www.hardcoded.net/licenses/bsd_license
/* Helpers */
- (void)fillColumnsMenu;
- (NSTableColumn *)getColumnForIdentifier:(NSInteger)aIdentifier title:(NSString *)aTitle width:(NSInteger)aWidth refCol:(NSTableColumn *)aColumn;
- (NSArray *)getColumnsOrder;
- (NSDictionary *)getColumnsWidth;
- (void)restoreColumnsPosition:(NSArray *)aColumnsOrder widths:(NSDictionary *)aColumnsWidth;
- (void)sendMarkedToTrash:(BOOL)hardlinkDeleted;
- (void)updateOptionSegments;

View File

@@ -50,9 +50,6 @@ http://www.hardcoded.net/licenses/bsd_license
/* Virtual */
- (void)initResultColumns
{
NSUserDefaults *udc = [NSUserDefaultsController sharedUserDefaultsController];
NSTableColumn *refCol = [matches tableColumnWithIdentifier:@"0"];
[refCol bind:@"fontSize" toObject:udc withKeyPath:@"values.TableFontSize" options:nil];
}
- (void)setScanOptions
@@ -62,14 +59,15 @@ http://www.hardcoded.net/licenses/bsd_license
/* Helpers */
- (void)fillColumnsMenu
{
// The columns menu is supposed to be empty and initResultColumns must have been called
for (NSTableColumn *col in _resultColumns)
{
NSMenuItem *mi = [columnsMenu addItemWithTitle:[[col headerCell] stringValue] action:@selector(toggleColumn:) keyEquivalent:@""];
[mi setTag:[[col identifier] integerValue]];
NSArray *menuItems = [[[table columns] py] menuItems];
for (NSInteger i=0; i < [menuItems count]; i++) {
NSArray *pair = [menuItems objectAtIndex:i];
NSString *display = [pair objectAtIndex:0];
BOOL marked = n2b([pair objectAtIndex:1]);
NSMenuItem *mi = [columnsMenu addItemWithTitle:display action:@selector(toggleColumn:) keyEquivalent:@""];
[mi setTarget:self];
if ([[matches tableColumns] containsObject:col])
[mi setState:NSOnState];
[mi setState:marked ? NSOnState : NSOffState];
[mi setTag:i];
}
[columnsMenu addItem:[NSMenuItem separatorItem]];
NSMenuItem *mi = [columnsMenu addItemWithTitle:TR(@"Reset to Default")
@@ -77,21 +75,6 @@ http://www.hardcoded.net/licenses/bsd_license
[mi setTarget:self];
}
- (NSTableColumn *)getColumnForIdentifier:(NSInteger)aIdentifier title:(NSString *)aTitle width:(NSInteger)aWidth refCol:(NSTableColumn *)aColumn
{
NSNumber *n = [NSNumber numberWithInteger:aIdentifier];
NSTableColumn *col = [[NSTableColumn alloc] initWithIdentifier:[n stringValue]];
[col setWidth:aWidth];
[col setEditable:NO];
[[col dataCell] setFont:[[aColumn dataCell] font]];
[[col headerCell] setStringValue:aTitle];
[col setResizingMask:NSTableColumnUserResizingMask];
[col setSortDescriptorPrototype:[[NSSortDescriptor alloc] initWithKey:[n stringValue] ascending:YES]];
NSUserDefaults *udc = [NSUserDefaultsController sharedUserDefaultsController];
[col bind:@"fontSize" toObject:udc withKeyPath:@"values.TableFontSize" options:nil];
return col;
}
//Returns an array of identifiers, in order.
- (NSArray *)getColumnsOrder
{
@@ -103,40 +86,6 @@ http://www.hardcoded.net/licenses/bsd_license
return result;
}
- (NSDictionary *)getColumnsWidth
{
NSMutableDictionary *result = [NSMutableDictionary dictionary];
for (NSTableColumn *col in [matches tableColumns]) {
NSString *colId = [col identifier];
NSNumber *width = [NSNumber numberWithDouble:[col width]];
[result setObject:width forKey:colId];
}
return result;
}
- (void)restoreColumnsPosition:(NSArray *)aColumnsOrder widths:(NSDictionary *)aColumnsWidth
{
for (NSMenuItem *mi in [columnsMenu itemArray]) {
if ([mi state] == NSOnState) {
[self toggleColumn:mi];
}
}
//Add columns and set widths
for (NSString *colId in aColumnsOrder) {
NSInteger colIndex = [colId integerValue];
if ((colIndex == 0) && (![colId isEqual:@"0"])) {
continue;
}
NSTableColumn *col = [_resultColumns objectAtIndex:colIndex];
NSNumber *width = [aColumnsWidth objectForKey:[col identifier]];
NSMenuItem *mi = [columnsMenu itemWithTag:colIndex];
if (width) {
[col setWidth:[width floatValue]];
}
[self toggleColumn:mi];
}
}
- (void)sendMarkedToTrash:(BOOL)hardlinkDeleted
{
NSInteger mark_count = [[py getMarkCount] intValue];
@@ -223,6 +172,7 @@ http://www.hardcoded.net/licenses/bsd_license
- (IBAction)exportToXHTML:(id)sender
{
// XXX No need to get column order from GUI anymore.
NSString *exported = [py exportToXHTMLwithColumns:[self getColumnsOrder]];
[[NSWorkspace sharedWorkspace] openFile:exported];
}
@@ -346,7 +296,7 @@ http://www.hardcoded.net/licenses/bsd_license
- (IBAction)resetColumnsToDefault:(id)sender
{
// Virtual
[[[table columns] py] resetToDefaults];
}
- (IBAction)revealSelected:(id)sender
@@ -384,19 +334,8 @@ http://www.hardcoded.net/licenses/bsd_license
- (IBAction)toggleColumn:(id)sender
{
NSMenuItem *mi = sender;
NSString *colId = [NSString stringWithFormat:@"%d",[mi tag]];
NSTableColumn *col = [matches tableColumnWithIdentifier:colId];
if (col == nil) {
//Add Column
col = [_resultColumns objectAtIndex:[mi tag]];
[matches addTableColumn:col];
[mi setState:NSOnState];
}
else {
//Remove column
[matches removeTableColumn:col];
[mi setState:NSOffState];
}
BOOL checked = [[[table columns] py] toggleMenuItem:[mi tag]];
[mi setState:checked ? NSOnState : NSOffState];
}
- (IBAction)toggleDetailsPanel:(id)sender

View File

@@ -2,13 +2,13 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1060</int>
<string key="IBDocument.SystemVersion">11B26</string>
<string key="IBDocument.InterfaceBuilderVersion">1617</string>
<string key="IBDocument.AppKitVersion">1138</string>
<string key="IBDocument.HIToolboxVersion">566.00</string>
<string key="IBDocument.SystemVersion">11C74</string>
<string key="IBDocument.InterfaceBuilderVersion">1938</string>
<string key="IBDocument.AppKitVersion">1138.23</string>
<string key="IBDocument.HIToolboxVersion">567.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">1617</string>
<string key="NS.object.0">1938</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>NSPopUpButton</string>
@@ -18,13 +18,12 @@
<string>NSToolbarFlexibleSpaceItem</string>
<string>NSCustomObject</string>
<string>NSTableView</string>
<string>NSTextField</string>
<string>NSSearchField</string>
<string>NSTextField</string>
<string>NSSearchFieldCell</string>
<string>NSWindowTemplate</string>
<string>NSTextFieldCell</string>
<string>NSButtonCell</string>
<string>NSTableColumn</string>
<string>NSSegmentedControl</string>
<string>NSToolbarSpaceItem</string>
<string>NSPopUpButtonCell</string>
@@ -40,7 +39,10 @@
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</array>
<dictionary class="NSMutableDictionary" key="IBDocument.Metadata"/>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
<integer value="1" key="NS.object.0"/>
</object>
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<object class="NSCustomObject" id="1001">
<string key="NSClassName">ResultWindow</string>
@@ -162,7 +164,7 @@
<object class="NSSegmentedCell" key="NSCell" id="993391476">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">0</int>
<object class="NSFont" key="NSSupport" id="241613967">
<object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">11</double>
<int key="NSfFlags">16</int>
@@ -240,7 +242,7 @@
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlTextColor</string>
<object class="NSColor" key="NSColor" id="300787132">
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
</object>
@@ -703,94 +705,7 @@
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="607866053"/>
</object>
<array class="NSMutableArray" key="NSTableColumns">
<object class="NSTableColumn" id="442382151">
<string key="NSIdentifier">marked</string>
<double key="NSWidth">26</double>
<double key="NSMinWidth">26</double>
<double key="NSMaxWidth">26</double>
<object class="NSTableHeaderCell" key="NSHeaderCell">
<int key="NSCellFlags">75628096</int>
<int key="NSCellFlags2">134219776</int>
<string key="NSContents"/>
<object class="NSFont" key="NSSupport" id="26">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">11</double>
<int key="NSfFlags">3100</int>
</object>
<object class="NSColor" key="NSBackgroundColor" id="980928921">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">headerColor</string>
<reference key="NSColor" ref="552368973"/>
</object>
<object class="NSColor" key="NSTextColor" id="532863179">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">headerTextColor</string>
<reference key="NSColor" ref="300787132"/>
</object>
</object>
<object class="NSButtonCell" key="NSDataCell" id="777504751">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">131072</int>
<string key="NSContents"/>
<reference key="NSSupport" ref="26"/>
<reference key="NSControlView" ref="387493015"/>
<int key="NSButtonFlags">1211912703</int>
<int key="NSButtonFlags2">2</int>
<object class="NSCustomResource" key="NSNormalImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSSwitch</string>
</object>
<object class="NSButtonImageSource" key="NSAlternateImage">
<string key="NSImageName">NSSwitch</string>
</object>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
<int key="NSPeriodicDelay">200</int>
<int key="NSPeriodicInterval">25</int>
</object>
<bool key="NSIsEditable">YES</bool>
<reference key="NSTableView" ref="387493015"/>
</object>
<object class="NSTableColumn" id="418301244">
<string key="NSIdentifier">0</string>
<double key="NSWidth">195</double>
<double key="NSMinWidth">16</double>
<double key="NSMaxWidth">3.4028234663852886e+38</double>
<object class="NSTableHeaderCell" key="NSHeaderCell">
<int key="NSCellFlags">75628096</int>
<int key="NSCellFlags2">2048</int>
<string key="NSContents">Name</string>
<reference key="NSSupport" ref="26"/>
<reference key="NSBackgroundColor" ref="980928921"/>
<reference key="NSTextColor" ref="532863179"/>
</object>
<object class="NSTextFieldCell" key="NSDataCell" id="270170598">
<int key="NSCellFlags">337772096</int>
<int key="NSCellFlags2">2048</int>
<string key="NSContents">Text Cell</string>
<reference key="NSSupport" ref="241613967"/>
<reference key="NSControlView" ref="387493015"/>
<object class="NSColor" key="NSBackgroundColor" id="1072464721">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlBackgroundColor</string>
<reference key="NSColor" ref="359204506"/>
</object>
<reference key="NSTextColor" ref="453389366"/>
</object>
<int key="NSResizingMask">2</int>
<bool key="NSIsResizeable">YES</bool>
<reference key="NSTableView" ref="387493015"/>
<object class="NSSortDescriptor" key="NSSortDescriptorPrototype">
<string key="NSKey">0</string>
<bool key="NSAscending">YES</bool>
<string key="NSSelector">compare:</string>
</object>
</object>
</array>
<array class="NSMutableArray" key="NSTableColumns"/>
<double key="NSIntercellSpacingWidth">3</double>
<double key="NSIntercellSpacingHeight">2</double>
<reference key="NSBackgroundColor" ref="552368973"/>
@@ -821,7 +736,12 @@
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="387493015"/>
<reference key="NSDocView" ref="387493015"/>
<reference key="NSBGColor" ref="1072464721"/>
<object class="NSColor" key="NSBGColor" id="1072464721">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlBackgroundColor</string>
<reference key="NSColor" ref="359204506"/>
</object>
<int key="NScvFlags">4</int>
</object>
<object class="NSScroller" id="777138208">
@@ -894,14 +814,6 @@
</array>
<object class="IBObjectContainer" key="IBDocument.Objects">
<array class="NSMutableArray" key="connectionRecords">
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="866620243"/>
<reference key="destination" ref="1001"/>
</object>
<int key="connectionID">45</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">window</string>
@@ -1094,6 +1006,14 @@
</object>
<int key="connectionID">81</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">toggleQuicklookPanel:</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="831294603"/>
</object>
<int key="connectionID">87</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">showDirectoryWindow:</string>
@@ -1102,6 +1022,14 @@
</object>
<int key="connectionID">82</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="866620243"/>
<reference key="destination" ref="1001"/>
</object>
<int key="connectionID">45</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">menu</string>
@@ -1110,14 +1038,6 @@
</object>
<int key="connectionID">83</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">toggleQuicklookPanel:</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="831294603"/>
</object>
<int key="connectionID">87</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">rowHeight: values.TableFontSize</string>
@@ -1216,10 +1136,7 @@
<object class="IBObjectRecord">
<int key="objectID">8</int>
<reference key="object" ref="387493015"/>
<array class="NSMutableArray" key="children">
<reference ref="418301244"/>
<reference ref="442382151"/>
</array>
<array class="NSMutableArray" key="children"/>
<reference key="parent" ref="489091452"/>
</object>
<object class="IBObjectRecord">
@@ -1232,32 +1149,6 @@
<reference key="object" ref="777138208"/>
<reference key="parent" ref="489091452"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">11</int>
<reference key="object" ref="418301244"/>
<array class="NSMutableArray" key="children">
<reference ref="270170598"/>
</array>
<reference key="parent" ref="387493015"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">12</int>
<reference key="object" ref="442382151"/>
<array class="NSMutableArray" key="children">
<reference ref="777504751"/>
</array>
<reference key="parent" ref="387493015"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">13</int>
<reference key="object" ref="777504751"/>
<reference key="parent" ref="442382151"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">14</int>
<reference key="object" ref="270170598"/>
<reference key="parent" ref="418301244"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">67</int>
<reference key="object" ref="593436906"/>
@@ -1530,10 +1421,6 @@
<string key="1.IBWindowTemplateEditedContentRect">{{324, 305}, {557, 400}}</string>
<boolean value="NO" key="1.NSWindowTemplate.visibleAtLaunch"/>
<string key="10.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="11.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="12.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="13.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="14.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="15.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="16.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="17.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -1905,7 +1792,7 @@
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
<integer value="1050" key="NS.object.0"/>
<real value="1060" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
@@ -1918,7 +1805,6 @@
<string key="NSMenuCheckmark">{9, 8}</string>
<string key="NSMenuMixedState">{7, 2}</string>
<string key="NSQuickLookTemplate">{21, 16}</string>
<string key="NSSwitch">{15, 15}</string>
<string key="folder32">{32, 32}</string>
</dictionary>
</data>