mirror of
https://github.com/arsenetar/dupeguru.git
synced 2026-01-22 14:41:39 +00:00
qt: merge ME edition into SE
(breaks PE temporarily) Adds a Standard/Music Application Mode button to SE and thus adds the ability to run ME scan types in SE. When in Music mode, the Music-specific results window, details panel and preferences panel will show up. All preferences except scan_type become shared between app modes (changing the pref in a mode changes it in the other mode). Results Window and Details Panel are now re-created at each scan operation because they could change their type between two runs. Preferences panel is instantiated on the fly and discarded after close. This is a very big merge operation and I'm trying to touch as little code as possible, sometimes at the cost of elegance. I try to minimize the breakage that this change brings.
This commit is contained in:
18
core/app.py
18
core/app.py
@@ -55,6 +55,11 @@ class JobType:
|
||||
Copy = 'job_copy'
|
||||
Delete = 'job_delete'
|
||||
|
||||
class AppMode:
|
||||
Standard = 0
|
||||
Music = 1
|
||||
Picture = 2
|
||||
|
||||
JOBID2TITLE = {
|
||||
JobType.Scan: tr("Scanning for duplicates"),
|
||||
JobType.Load: tr("Loading"),
|
||||
@@ -149,6 +154,7 @@ class DupeGuru(Broadcaster):
|
||||
# open_path(path)
|
||||
# reveal_path(path)
|
||||
# ask_yes_no(prompt) --> bool
|
||||
# create_results_window()
|
||||
# show_results_window()
|
||||
# show_problem_dialog()
|
||||
# select_dest_folder(prompt: str) --> str
|
||||
@@ -166,9 +172,8 @@ class DupeGuru(Broadcaster):
|
||||
self.appdata = desktop.special_folder_path(desktop.SpecialFolder.AppData, appname=self.NAME)
|
||||
if not op.exists(self.appdata):
|
||||
os.makedirs(self.appdata)
|
||||
self.app_mode = AppMode.Standard
|
||||
self.discarded_file_count = 0
|
||||
self.fileclasses = [fs.File]
|
||||
self.folderclass = fs.Folder
|
||||
self.directories = directories.Directories()
|
||||
self.results = results.Results(self)
|
||||
self.ignore_list = IgnoreList()
|
||||
@@ -187,10 +192,10 @@ class DupeGuru(Broadcaster):
|
||||
self.problem_dialog = ProblemDialog(self)
|
||||
self.ignore_list_dialog = IgnoreListDialog(self)
|
||||
self.stats_label = StatsLabel(self)
|
||||
self.result_table = self._create_result_table()
|
||||
self.result_table = None
|
||||
self.deletion_options = DeletionOptions()
|
||||
self.progress_window = ProgressWindow(self._job_completed)
|
||||
children = [self.result_table, self.directory_tree, self.stats_label, self.details_panel]
|
||||
children = [self.directory_tree, self.stats_label, self.details_panel]
|
||||
for child in children:
|
||||
child.connect()
|
||||
|
||||
@@ -746,6 +751,11 @@ class DupeGuru(Broadcaster):
|
||||
if hasattr(scanner, k):
|
||||
setattr(scanner, k, v)
|
||||
self.results.groups = []
|
||||
if self.result_table is not None:
|
||||
self.result_table.disconnect()
|
||||
self.result_table = self._create_result_table()
|
||||
self.result_table.connect()
|
||||
self.view.create_results_window()
|
||||
self._results_changed()
|
||||
|
||||
def do(j):
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# Created By: Virgil Dupras
|
||||
# Created On: 2010-02-05
|
||||
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
#
|
||||
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
# which should be included with this package. The terms are also available at
|
||||
#
|
||||
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
# which should be included with this package. The terms are also available at
|
||||
# http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
from hscommon.gui.base import GUIObject
|
||||
@@ -11,14 +11,14 @@ from .base import DupeGuruGUIObject
|
||||
|
||||
class DetailsPanel(GUIObject, DupeGuruGUIObject):
|
||||
def __init__(self, app):
|
||||
GUIObject.__init__(self)
|
||||
GUIObject.__init__(self, multibind=True)
|
||||
DupeGuruGUIObject.__init__(self, app)
|
||||
self._table = []
|
||||
|
||||
|
||||
def _view_updated(self):
|
||||
self._refresh()
|
||||
self.view.refresh()
|
||||
|
||||
|
||||
#--- Private
|
||||
def _refresh(self):
|
||||
if self.app.selected_dupes:
|
||||
@@ -33,16 +33,16 @@ class DetailsPanel(GUIObject, DupeGuruGUIObject):
|
||||
data2 = self.app.get_display_info(ref, group, False)
|
||||
columns = self.app.result_table.COLUMNS[1:] # first column is the 'marked' column
|
||||
self._table = [(c.display, data1[c.name], data2[c.name]) for c in columns]
|
||||
|
||||
|
||||
#--- Public
|
||||
def row_count(self):
|
||||
return len(self._table)
|
||||
|
||||
|
||||
def row(self, row_index):
|
||||
return self._table[row_index]
|
||||
|
||||
|
||||
#--- Event Handlers
|
||||
def dupes_selected(self):
|
||||
self._refresh()
|
||||
self.view.refresh()
|
||||
|
||||
|
||||
|
||||
@@ -384,7 +384,7 @@ class TestCaseDupeGuruWithResults:
|
||||
app.JOB = Job(1, lambda *args, **kw: False) # Cancels the task
|
||||
add_fake_files_to_directories(app.directories, self.objects) # We want the scan to at least start
|
||||
app.start_scanning() # will be cancelled immediately
|
||||
eq_(len(self.rtable), 0)
|
||||
eq_(len(app.result_table), 0)
|
||||
|
||||
def test_selected_dupes_after_removal(self, do_setup):
|
||||
# Purge the app's `selected_dupes` attribute when removing dupes, or else it might cause a
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# which should be included with this package. The terms are also available at
|
||||
# http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
from hscommon.testutil import TestApp as TestAppBase, eq_, with_app # noqa
|
||||
from hscommon.testutil import TestApp as TestAppBase, CallLogger, eq_, with_app # noqa
|
||||
from hscommon.path import Path
|
||||
from hscommon.util import get_file_ext, format_size
|
||||
from hscommon.gui.column import Column
|
||||
@@ -41,6 +41,8 @@ class DupeGuruView:
|
||||
def ask_yes_no(self, prompt):
|
||||
return True # always answer yes
|
||||
|
||||
def create_results_window(self):
|
||||
pass
|
||||
|
||||
class ResultTable(ResultTableBase):
|
||||
COLUMNS = [
|
||||
@@ -59,12 +61,16 @@ class DupeGuru(DupeGuruBase):
|
||||
def __init__(self):
|
||||
DupeGuruBase.__init__(self, DupeGuruView())
|
||||
self.appdata = '/tmp'
|
||||
self.result_table = self._create_result_table()
|
||||
self.result_table.connect()
|
||||
|
||||
def _prioritization_categories(self):
|
||||
return prioritize.all_categories()
|
||||
|
||||
def _create_result_table(self):
|
||||
return ResultTable(self)
|
||||
result = ResultTable(self)
|
||||
result.view = CallLogger()
|
||||
return result
|
||||
|
||||
|
||||
class NamedObject:
|
||||
@@ -141,7 +147,6 @@ class TestApp(TestAppBase):
|
||||
TestAppBase.__init__(self)
|
||||
self.app = DupeGuru()
|
||||
self.default_parent = self.app
|
||||
self.rtable = link_gui(self.app.result_table)
|
||||
self.dtree = link_gui(self.app.directory_tree)
|
||||
self.dpanel = link_gui(self.app.details_panel)
|
||||
self.slabel = link_gui(self.app.stats_label)
|
||||
@@ -155,6 +160,11 @@ class TestApp(TestAppBase):
|
||||
link_gui(self.app.progress_window.jobdesc_textfield)
|
||||
link_gui(self.app.progress_window.progressdesc_textfield)
|
||||
|
||||
@property
|
||||
def rtable(self):
|
||||
# rtable is a property because its instance can be replaced during execution
|
||||
return self.app.result_table
|
||||
|
||||
#--- Helpers
|
||||
def select_pri_criterion(self, name):
|
||||
# Select a main prioritize criterion by name instead of by index. Makes tests more
|
||||
|
||||
Reference in New Issue
Block a user