1
0
miroir de https://github.com/arsenetar/dupeguru.git synchronisé 2025-09-11 17:58:17 +00:00

Moved column information in new edition-specific core result_table units.

Cette révision appartient à :
Virgil Dupras 2011-11-27 12:47:00 -05:00
Parent eb83b830df
révision 7e95404903
17 fichiers modifiés avec 149 ajouts et 113 suppressions

Voir le fichier

@ -7,10 +7,12 @@ http://www.hardcoded.net/licenses/bsd_license
*/ */
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "PyResultTable.h"
#import "PyApp.h" #import "PyApp.h"
@interface PyDupeGuruBase : PyApp @interface PyDupeGuruBase : PyApp
- (void)bindCocoa:(id)cocoa; - (void)bindCocoa:(id)cocoa;
- (PyResultTable *)resultTable;
//Actions //Actions
- (NSNumber *)addDirectory:(NSString *)name; - (NSNumber *)addDirectory:(NSString *)name;
- (void)removeDirectory:(NSNumber *)index; - (void)removeDirectory:(NSNumber *)index;

Voir le fichier

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

Voir le fichier

@ -17,7 +17,7 @@ http://www.hardcoded.net/licenses/bsd_license
NSIndexSet *_deltaColumns; NSIndexSet *_deltaColumns;
HSColumns *columns; HSColumns *columns;
} }
- (id)initWithPyParent:(id)aPyParent view:(NSTableView *)aTableView; - (id)initWithPy:(id)aPy view:(NSTableView *)aTableView;
- (PyResultTable *)py; - (PyResultTable *)py;
- (HSColumns *)columns; - (HSColumns *)columns;
- (BOOL)powerMarkerMode; - (BOOL)powerMarkerMode;

Voir le fichier

@ -18,9 +18,9 @@ http://www.hardcoded.net/licenses/bsd_license
@end @end
@implementation ResultTable @implementation ResultTable
- (id)initWithPyParent:(id)aPyParent view:(NSTableView *)aTableView - (id)initWithPy:(id)aPy view:(NSTableView *)aTableView
{ {
self = [super initWithPyClassName:@"PyResultTable" pyParent:aPyParent view:aTableView]; self = [super initWithPy:aPy view:aTableView];
columns = [[HSColumns alloc] initWithPy:[[self py] columns] tableView:aTableView]; columns = [[HSColumns alloc] initWithPy:[[self py] columns] tableView:aTableView];
[self connect]; [self connect];
return self; return self;
@ -145,7 +145,7 @@ http://www.hardcoded.net/licenses/bsd_license
if ([[tableView sortDescriptors] count] < 1) if ([[tableView sortDescriptors] count] < 1)
return; return;
NSSortDescriptor *sd = [[tableView sortDescriptors] objectAtIndex:0]; NSSortDescriptor *sd = [[tableView sortDescriptors] objectAtIndex:0];
[[self py] sortBy:[[sd key] integerValue] ascending:[sd ascending]]; [[self py] sortBy:[sd key] ascending:[sd ascending]];
} }
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)column row:(NSInteger)row - (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)column row:(NSInteger)row

Voir le fichier

@ -24,7 +24,7 @@ http://www.hardcoded.net/licenses/bsd_license
columnsMenu = [app columnsMenu]; columnsMenu = [app columnsMenu];
/* Put a cute iTunes-like bottom bar */ /* Put a cute iTunes-like bottom bar */
[[self window] setContentBorderThickness:28 forEdge:NSMinYEdge]; [[self window] setContentBorderThickness:28 forEdge:NSMinYEdge];
table = [[ResultTable alloc] initWithPyParent:py view:matches]; table = [[ResultTable alloc] initWithPy:[py resultTable] view:matches];
statsLabel = [[StatsLabel alloc] initWithPyParent:py labelView:stats]; statsLabel = [[StatsLabel alloc] initWithPyParent:py labelView:stats];
problemDialog = [[ProblemDialog alloc] initWithPy:py]; problemDialog = [[ProblemDialog alloc] initWithPy:py];
[self initResultColumns]; [self initResultColumns];

Voir le fichier

@ -3,12 +3,13 @@ import logging
from jobprogress import job from jobprogress import job
from hscommon import cocoa from hscommon import cocoa
from hscommon.cocoa import install_exception_hook from hscommon.cocoa import install_exception_hook
from hscommon.cocoa.inter import signature, PyFairware from hscommon.cocoa.inter import signature, subproxy, PyFairware
from hscommon.cocoa.objcmin import (NSNotificationCenter, NSSearchPathForDirectoriesInDomains, from hscommon.cocoa.objcmin import (NSNotificationCenter, NSSearchPathForDirectoriesInDomains,
NSApplicationSupportDirectory, NSUserDomainMask, NSWorkspace) NSApplicationSupportDirectory, NSUserDomainMask, NSWorkspace)
from hscommon.trans import trget from hscommon.trans import trget
from core.app import JobType from core.app import JobType
from .result_table import PyResultTable
tr = trget('ui') tr = trget('ui')
@ -31,6 +32,8 @@ class PyDupeGuruBase(PyFairware):
def bindCocoa_(self, cocoa): def bindCocoa_(self, cocoa):
self.cocoa = cocoa self.cocoa = cocoa
resultTable = subproxy('resultTable', 'result_table', PyResultTable)
#---Directories #---Directories
def addDirectory_(self, directory): def addDirectory_(self, directory):
return self.py.add_directory(directory) return self.py.add_directory(directory)

Voir le fichier

@ -1,10 +1,6 @@
from hscommon.cocoa.inter import signature, PyTable from hscommon.cocoa.inter import signature, PyTable
from core.gui.result_table import ResultTable
class PyResultTable(PyTable): class PyResultTable(PyTable):
py_class = ResultTable
@signature('c@:') @signature('c@:')
def powerMarkerMode(self): def powerMarkerMode(self):
return self.py.power_marker return self.py.power_marker
@ -29,7 +25,7 @@ class PyResultTable(PyTable):
def renameSelected_(self, newname): def renameSelected_(self, newname):
return self.py.rename_selected(newname) return self.py.rename_selected(newname)
@signature('v@:ic') @signature('v@:@c')
def sortBy_ascending_(self, key, asc): def sortBy_ascending_(self, key, asc):
self.py.sort(key, asc) self.py.sort(key, asc)

Voir le fichier

@ -65,11 +65,11 @@ def format_perc(p):
def format_dupe_count(c): def format_dupe_count(c):
return str(c) if c else '---' return str(c) if c else '---'
def cmp_value(dupe, column): def cmp_value(dupe, attrname):
if column.name == 'name': if attrname == 'name':
value = rem_file_ext(dupe.name) value = rem_file_ext(dupe.name)
else: else:
value = getattr(dupe, column.name, '') value = getattr(dupe, attrname, '')
return value.lower() if isinstance(value, str) else value return value.lower() if isinstance(value, str) else value
class DupeGuru(RegistrableApplication, Broadcaster): class DupeGuru(RegistrableApplication, Broadcaster):
@ -101,6 +101,7 @@ class DupeGuru(RegistrableApplication, Broadcaster):
'ignore_hardlink_matches': False, 'ignore_hardlink_matches': False,
} }
self.selected_dupes = [] self.selected_dupes = []
# subclasses must create self.result_table
#--- Virtual #--- Virtual
def _get_display_info(self, dupe, group, delta): def _get_display_info(self, dupe, group, delta):
@ -276,7 +277,7 @@ class DupeGuru(RegistrableApplication, Broadcaster):
column_ids = [colid for colid in column_ids if colid.isdigit()] column_ids = [colid for colid in column_ids if colid.isdigit()]
column_ids = list(map(int, column_ids)) column_ids = list(map(int, column_ids))
column_ids.sort() column_ids.sort()
colnames = [col.display for i, col in enumerate(self.COLUMNS) if i in column_ids] colnames = [col.display for i, col in enumerate(self.result_table.COLUMNS) if i in column_ids]
rows = [] rows = []
for group in self.results.groups: for group in self.results.groups:
for dupe in group: for dupe in group:
@ -287,13 +288,15 @@ class DupeGuru(RegistrableApplication, Broadcaster):
return export.export_to_xhtml(colnames, rows) return export.export_to_xhtml(colnames, rows)
def get_display_info(self, dupe, group, delta=False): def get_display_info(self, dupe, group, delta=False):
def empty_data():
return {c.name: '---' for c in self.result_table.COLUMNS[1:]}
if (dupe is None) or (group is None): if (dupe is None) or (group is None):
return ['---'] * len(self.COLUMNS) return empty_data()
try: try:
return self._get_display_info(dupe, group, delta) return self._get_display_info(dupe, group, delta)
except Exception as e: except Exception as e:
logging.warning("Exception on GetDisplayInfo for %s: %s", str(dupe.path), str(e)) logging.warning("Exception on GetDisplayInfo for %s: %s", str(dupe.path), str(e))
return ['---'] * len(self.COLUMNS) return empty_data()
def invoke_command(self, cmd): def invoke_command(self, cmd):
"""Calls command `cmd` with %d and %r placeholders replaced. """Calls command `cmd` with %d and %r placeholders replaced.

Voir le fichier

@ -12,7 +12,8 @@ from hscommon.notify import Listener
class GUIObject(Listener): class GUIObject(Listener):
def __init__(self, view, app): def __init__(self, view, app):
Listener.__init__(self, app) Listener.__init__(self, app)
self.view = view if view is not None:
self.view = view
self.app = app self.app = app
def directories_changed(self): def directories_changed(self):

Voir le fichier

@ -26,12 +26,12 @@ class DetailsPanel(GUIObject):
else: else:
dupe = None dupe = None
group = None group = None
l1 = self.app.get_display_info(dupe, group, False) data1 = self.app.get_display_info(dupe, group, False)
# we don't want the two sides of the table to display the stats for the same file # we don't want the two sides of the table to display the stats for the same file
ref = group.ref if group is not None and group.ref is not dupe else None ref = group.ref if group is not None and group.ref is not dupe else None
l2 = self.app.get_display_info(ref, group, False) data2 = self.app.get_display_info(ref, group, False)
names = [c.display for c in self.app.COLUMNS] columns = self.app.result_table.COLUMNS[1:] # first column is the 'marked' column
self._table = list(zip(names, l1, l2)) self._table = [(c.display, data1[c.name], data2[c.name]) for c in columns]
#--- Public #--- Public
def row_count(self): def row_count(self):

Voir le fichier

@ -52,14 +52,13 @@ class DupeRow(Row):
class ResultTable(GUIObject, GUITable): class ResultTable(GUIObject, GUITable):
def __init__(self, view, app): def __init__(self, app):
GUIObject.__init__(self, view, app) GUIObject.__init__(self, None, app)
GUITable.__init__(self) GUITable.__init__(self)
self.COLUMNS = app.COLUMNS
self.columns = Columns(self, prefaccess=app, savename='ResultTable') self.columns = Columns(self, prefaccess=app, savename='ResultTable')
self._power_marker = False self._power_marker = False
self._delta_values = False self._delta_values = False
self._sort_descriptors = (0, True) self._sort_descriptors = ('name', True)
#--- Override #--- Override
def connect(self): def connect(self):

Voir le fichier

@ -5,51 +5,26 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
from hscommon.trans import trget
from hscommon.util import format_size, format_time from hscommon.util import format_size, format_time
from hscommon.gui.column import Column
from core.app import (DupeGuru as DupeGuruBase, format_timestamp, from core.app import (DupeGuru as DupeGuruBase, format_timestamp,
format_perc, format_words, format_dupe_count, cmp_value) format_perc, format_words, format_dupe_count, cmp_value)
from . import prioritize from . import prioritize
from . import __appname__ from . import __appname__
from . import scanner, fs from . import scanner, fs
from .result_table import ResultTable
coltr = trget('columns')
class DupeGuru(DupeGuruBase): class DupeGuru(DupeGuruBase):
NAME = __appname__ NAME = __appname__
COLUMNS = [
Column('marked', ''),
Column('name', coltr("Filename")),
Column('folder_path', coltr("Folder"), visible=False, optional=True),
Column('size', coltr("Size (MB)"), optional=True),
Column('duration', coltr("Time"), optional=True),
Column('bitrate', coltr("Bitrate"), optional=True),
Column('samplerate', coltr("Sample Rate"), visible=False, optional=True),
Column('extension', coltr("Kind"), optional=True),
Column('mtime', coltr("Modification"), visible=False, optional=True),
Column('title', coltr("Title"), visible=False, optional=True),
Column('artist', coltr("Artist"), visible=False, optional=True),
Column('album', coltr("Album"), visible=False, optional=True),
Column('genre', coltr("Genre"), visible=False, optional=True),
Column('year', coltr("Year"), visible=False, optional=True),
Column('track', coltr("Track Number"), visible=False, optional=True),
Column('comment', coltr("Comment"), visible=False, optional=True),
Column('percentage', coltr("Match %"), optional=True),
Column('words', coltr("Words Used"), visible=False, optional=True),
Column('dupe_count', coltr("Dupe Count"), visible=False, optional=True),
]
DELTA_COLUMNS = {2, 3, 4, 5, 7} DELTA_COLUMNS = {2, 3, 4, 5, 7}
METADATA_TO_READ = ['size', 'mtime', 'duration', 'bitrate', 'samplerate', 'title', 'artist', METADATA_TO_READ = ['size', 'mtime', 'duration', 'bitrate', 'samplerate', 'title', 'artist',
'album', 'genre', 'year', 'track', 'comment'] 'album', 'genre', 'year', 'track', 'comment']
MATCHPERC_COL = 15
DUPECOUNT_COL = 17
def __init__(self, view, appdata): def __init__(self, view, appdata):
DupeGuruBase.__init__(self, view, appdata) DupeGuruBase.__init__(self, view, appdata)
self.scanner = scanner.ScannerME() self.scanner = scanner.ScannerME()
self.directories.fileclasses = [fs.MusicFile] self.directories.fileclasses = [fs.MusicFile]
self.result_table = ResultTable(self)
def _get_display_info(self, dupe, group, delta): def _get_display_info(self, dupe, group, delta):
size = dupe.size size = dupe.size
@ -93,22 +68,22 @@ class DupeGuru(DupeGuruBase):
} }
def _get_dupe_sort_key(self, dupe, get_group, key, delta): def _get_dupe_sort_key(self, dupe, get_group, key, delta):
if key == self.MATCHPERC_COL: if key == 'percentage':
m = get_group().get_match_of(dupe) m = get_group().get_match_of(dupe)
return m.percentage return m.percentage
if key == self.DUPECOUNT_COL: if key == 'dupe_count':
return 0 return 0
r = cmp_value(dupe, self.COLUMNS[key]) r = cmp_value(dupe, key)
if delta and (key in self.DELTA_COLUMNS): if delta and (key in self.DELTA_COLUMNS):
r -= cmp_value(get_group().ref, self.COLUMNS[key]) r -= cmp_value(get_group().ref, key)
return r return r
def _get_group_sort_key(self, group, key): def _get_group_sort_key(self, group, key):
if key == self.MATCHPERC_COL: if key == 'percentage':
return group.percentage return group.percentage
if key == self.DUPECOUNT_COL: if key == 'dupe_count':
return len(group) return len(group)
return cmp_value(group.ref, self.COLUMNS[key]) return cmp_value(group.ref, key)
def _prioritization_categories(self): def _prioritization_categories(self):
return prioritize.all_categories() return prioritize.all_categories()

36
core_me/result_table.py Fichier normal
Voir le fichier

@ -0,0 +1,36 @@
# Created On: 2011-11-27
# 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
from hscommon.gui.column import Column
from hscommon.trans import trget
from core.gui.result_table import ResultTable as ResultTableBase
coltr = trget('columns')
class ResultTable(ResultTableBase):
COLUMNS = [
Column('marked', ''),
Column('name', coltr("Filename")),
Column('folder_path', coltr("Folder"), visible=False, optional=True),
Column('size', coltr("Size (MB)"), optional=True),
Column('duration', coltr("Time"), optional=True),
Column('bitrate', coltr("Bitrate"), optional=True),
Column('samplerate', coltr("Sample Rate"), visible=False, optional=True),
Column('extension', coltr("Kind"), optional=True),
Column('mtime', coltr("Modification"), visible=False, optional=True),
Column('title', coltr("Title"), visible=False, optional=True),
Column('artist', coltr("Artist"), visible=False, optional=True),
Column('album', coltr("Album"), visible=False, optional=True),
Column('genre', coltr("Genre"), visible=False, optional=True),
Column('year', coltr("Year"), visible=False, optional=True),
Column('track', coltr("Track Number"), visible=False, optional=True),
Column('comment', coltr("Comment"), visible=False, optional=True),
Column('percentage', coltr("Match %"), optional=True),
Column('words', coltr("Words Used"), visible=False, optional=True),
Column('dupe_count', coltr("Dupe Count"), visible=False, optional=True),
]

Voir le fichier

@ -7,17 +7,14 @@
import os.path as op import os.path as op
from hscommon.trans import trget
from hscommon.util import format_size from hscommon.util import format_size
from hscommon.gui.column import Column
from core.app import (DupeGuru as DupeGuruBase, format_timestamp, format_perc, from core.app import (DupeGuru as DupeGuruBase, format_timestamp, format_perc,
format_dupe_count, cmp_value) format_dupe_count, cmp_value)
from .scanner import ScannerPE from .scanner import ScannerPE
from . import prioritize from . import prioritize
from . import __appname__ from . import __appname__
from .result_table import ResultTable
coltr = trget('columns')
def format_dimensions(dimensions): def format_dimensions(dimensions):
return '%d x %d' % (dimensions[0], dimensions[1]) return '%d x %d' % (dimensions[0], dimensions[1])
@ -27,27 +24,14 @@ def get_delta_dimensions(value, ref_value):
class DupeGuru(DupeGuruBase): class DupeGuru(DupeGuruBase):
NAME = __appname__ NAME = __appname__
COLUMNS = [
Column('marked', ''),
Column('name', coltr("Filename")),
Column('folder_path', coltr("Folder"), optional=True),
Column('size', coltr("Size (KB)"), optional=True),
Column('extension', coltr("Kind"), visible=False, optional=True),
Column('dimensions', coltr("Dimensions"), optional=True),
Column('mtime', coltr("Modification"), visible=False, optional=True),
Column('percentage', coltr("Match %"), optional=True),
Column('dupe_count', coltr("Dupe Count"), visible=False, optional=True),
]
DELTA_COLUMNS = {2, 4, 5} DELTA_COLUMNS = {2, 4, 5}
METADATA_TO_READ = ['size', 'mtime', 'dimensions'] METADATA_TO_READ = ['size', 'mtime', 'dimensions']
FOLDER_COL = 1
MATCHPERC_COL = 6
DUPECOUNT_COL = 7
def __init__(self, view, appdata): def __init__(self, view, appdata):
DupeGuruBase.__init__(self, view, appdata) DupeGuruBase.__init__(self, view, appdata)
self.scanner = ScannerPE() self.scanner = ScannerPE()
self.scanner.cache_path = op.join(self.appdata, 'cached_pictures.db') self.scanner.cache_path = op.join(self.appdata, 'cached_pictures.db')
self.result_table = ResultTable(self)
def _get_display_info(self, dupe, group, delta): def _get_display_info(self, dupe, group, delta):
size = dupe.size size = dupe.size
@ -78,17 +62,17 @@ class DupeGuru(DupeGuruBase):
} }
def _get_dupe_sort_key(self, dupe, get_group, key, delta): def _get_dupe_sort_key(self, dupe, get_group, key, delta):
if key == self.MATCHPERC_COL: if key == 'percentage':
m = get_group().get_match_of(dupe) m = get_group().get_match_of(dupe)
return m.percentage return m.percentage
if key == self.DUPECOUNT_COL: if key == 'dupe_count':
return 0 return 0
if key == self.FOLDER_COL: if key == 'folder_path':
dupe_folder_path = getattr(dupe, 'display_folder_path', dupe.folder_path) dupe_folder_path = getattr(dupe, 'display_folder_path', dupe.folder_path)
return str(dupe_folder_path).lower() return str(dupe_folder_path).lower()
r = cmp_value(dupe, self.COLUMNS[key]) r = cmp_value(dupe, key)
if delta and (key in self.DELTA_COLUMNS): if delta and (key in self.DELTA_COLUMNS):
ref_value = cmp_value(get_group().ref, self.COLUMNS[key]) ref_value = cmp_value(get_group().ref, key)
if key == 4: # dimensions if key == 4: # dimensions
r = get_delta_dimensions(r, ref_value) r = get_delta_dimensions(r, ref_value)
else: else:
@ -96,14 +80,14 @@ class DupeGuru(DupeGuruBase):
return r return r
def _get_group_sort_key(self, group, key): def _get_group_sort_key(self, group, key):
if key == self.MATCHPERC_COL: if key == 'percentage':
return group.percentage return group.percentage
if key == self.DUPECOUNT_COL: if key == 'dupe_count':
return len(group) return len(group)
if key == self.FOLDER_COL: if key == 'folder_path':
dupe_folder_path = getattr(group.ref, 'display_folder_path', group.ref.folder_path) dupe_folder_path = getattr(group.ref, 'display_folder_path', group.ref.folder_path)
return str(dupe_folder_path).lower() return str(dupe_folder_path).lower()
return cmp_value(group.ref, self.COLUMNS[key]) return cmp_value(group.ref, key)
def _prioritization_categories(self): def _prioritization_categories(self):
return prioritize.all_categories() return prioritize.all_categories()

26
core_pe/result_table.py Fichier normal
Voir le fichier

@ -0,0 +1,26 @@
# Created On: 2011-11-27
# 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
from hscommon.gui.column import Column
from hscommon.trans import trget
from core.gui.result_table import ResultTable as ResultTableBase
coltr = trget('columns')
class ResultTable(ResultTableBase):
COLUMNS = [
Column('marked', ''),
Column('name', coltr("Filename")),
Column('folder_path', coltr("Folder"), optional=True),
Column('size', coltr("Size (KB)"), optional=True),
Column('extension', coltr("Kind"), visible=False, optional=True),
Column('dimensions', coltr("Dimensions"), optional=True),
Column('mtime', coltr("Modification"), visible=False, optional=True),
Column('percentage', coltr("Match %"), optional=True),
Column('dupe_count', coltr("Dupe Count"), visible=False, optional=True),
]

Voir le fichier

@ -5,37 +5,22 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
from hscommon.trans import trget
from hscommon.util import format_size from hscommon.util import format_size
from hscommon.gui.column import Column
from core.app import (DupeGuru as DupeGuruBase, format_timestamp, format_perc, from core.app import (DupeGuru as DupeGuruBase, format_timestamp, format_perc,
format_words, format_dupe_count, cmp_value) format_words, format_dupe_count, cmp_value)
from core import prioritize from core import prioritize
from . import __appname__ from . import __appname__
from .result_table import ResultTable
coltr = trget('columns')
class DupeGuru(DupeGuruBase): class DupeGuru(DupeGuruBase):
NAME = __appname__ NAME = __appname__
COLUMNS = [
Column('marked', ''),
Column('name', coltr("Filename")),
Column('folder_path', coltr("Folder"), optional=True),
Column('size', coltr("Size (KB)"), optional=True),
Column('extension', coltr("Kind"), visible=False, optional=True),
Column('mtime', coltr("Modification"), visible=False, optional=True),
Column('percentage', coltr("Match %"), optional=True),
Column('words', coltr("Words Used"), visible=False, optional=True),
Column('dupe_count', coltr("Dupe Count"), visible=False, optional=True),
]
DELTA_COLUMNS = {2, 4} DELTA_COLUMNS = {2, 4}
METADATA_TO_READ = ['size', 'mtime'] METADATA_TO_READ = ['size', 'mtime']
MATCHPERC_COL = 5
DUPECOUNT_COL = 7
def __init__(self, view, appdata): def __init__(self, view, appdata):
DupeGuruBase.__init__(self, view, appdata) DupeGuruBase.__init__(self, view, appdata)
self.result_table = ResultTable(self)
def _get_display_info(self, dupe, group, delta): def _get_display_info(self, dupe, group, delta):
size = dupe.size size = dupe.size
@ -63,22 +48,22 @@ class DupeGuru(DupeGuruBase):
} }
def _get_dupe_sort_key(self, dupe, get_group, key, delta): def _get_dupe_sort_key(self, dupe, get_group, key, delta):
if key == self.MATCHPERC_COL: if key == 'percentage':
m = get_group().get_match_of(dupe) m = get_group().get_match_of(dupe)
return m.percentage return m.percentage
if key == self.DUPECOUNT_COL: if key == 'dupe_count':
return 0 return 0
r = cmp_value(dupe, self.COLUMNS[key]) r = cmp_value(dupe, key)
if delta and (key in self.DELTA_COLUMNS): if delta and (key in self.DELTA_COLUMNS):
r -= cmp_value(get_group().ref, self.COLUMNS[key]) r -= cmp_value(get_group().ref, key)
return r return r
def _get_group_sort_key(self, group, key): def _get_group_sort_key(self, group, key):
if key == self.MATCHPERC_COL: if key == 'percentage':
return group.percentage return group.percentage
if key == self.DUPECOUNT_COL: if key == 'dupe_count':
return len(group) return len(group)
return cmp_value(group.ref, self.COLUMNS[key]) return cmp_value(group.ref, key)
def _prioritization_categories(self): def _prioritization_categories(self):
return prioritize.all_categories() return prioritize.all_categories()

26
core_se/result_table.py Fichier normal
Voir le fichier

@ -0,0 +1,26 @@
# Created On: 2011-11-27
# 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
from hscommon.gui.column import Column
from hscommon.trans import trget
from core.gui.result_table import ResultTable as ResultTableBase
coltr = trget('columns')
class ResultTable(ResultTableBase):
COLUMNS = [
Column('marked', ''),
Column('name', coltr("Filename")),
Column('folder_path', coltr("Folder"), optional=True),
Column('size', coltr("Size (KB)"), optional=True),
Column('extension', coltr("Kind"), visible=False, optional=True),
Column('mtime', coltr("Modification"), visible=False, optional=True),
Column('percentage', coltr("Match %"), optional=True),
Column('words', coltr("Words Used"), visible=False, optional=True),
Column('dupe_count', coltr("Dupe Count"), visible=False, optional=True),
]