1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2026-01-22 06:37:17 +00:00

Implement exclude list dialog on the Qt side

This commit is contained in:
glubsy
2020-08-17 04:13:20 +02:00
parent a26de27c47
commit 2eaf7e7893
9 changed files with 400 additions and 92 deletions

View File

@@ -8,8 +8,6 @@
# from hscommon.trans import tr
from .exclude_list_table import ExcludeListTable
default_regexes = [".*thumbs", "\.DS.Store", "\.Trash", "Trash-Bin"]
class ExcludeListDialogCore:
# --- View interface
@@ -22,13 +20,7 @@ class ExcludeListDialogCore:
self.exclude_list_table = ExcludeListTable(self, app) # GUITable, this is the "model"
def restore_defaults(self):
for _, regex in self.exclude_list:
if regex not in default_regexes:
self.exclude_list.unmark(regex)
for default_regex in default_regexes:
if not self.exclude_list.isExcluded(default_regex):
self.exclude_list.add(default_regex)
self.exclude_list.mark(default_regex)
self.exclude_list.restore_defaults()
self.refresh()
def refresh(self):
@@ -55,9 +47,11 @@ class ExcludeListDialogCore:
return False
def add(self, regex):
self.exclude_list.add(regex)
try:
self.exclude_list.add(regex)
except Exception as e:
raise(e)
self.exclude_list.mark(regex)
# TODO make checks here before adding to GUI
self.exclude_list_table.add(regex)
def show(self):

View File

@@ -12,21 +12,18 @@ tr = trget("ui")
class ExcludeListTable(GUITable, DupeGuruGUIObject):
COLUMNS = [
Column("marked", ""),
Column("regex", tr("Regex"))
Column("regex", tr("Regular Expressions"))
]
def __init__(self, exclude_list_dialog, app):
GUITable.__init__(self)
DupeGuruGUIObject.__init__(self, app)
# self.columns = Columns(self, prefaccess=app, savename="ExcludeTable")
self.columns = Columns(self)
self.dialog = exclude_list_dialog
def rename_selected(self, newname):
row = self.selected_row
if row is None:
# There's all kinds of way the current row can be swept off during rename. When it
# happens, selected_row will be None.
return False
row._data = None
return self.dialog.rename_selected(newname)
@@ -95,7 +92,7 @@ class ExcludeListRow(Row):
@property
def markable(self):
return True
return self._app.exclude_list.is_markable(self.regex)
@property
def marked(self):
@@ -108,10 +105,18 @@ class ExcludeListRow(Row):
else:
self._app.exclude_list.unmark(self.regex)
@property
def error(self):
# This assumes error() returns an Exception()
message = self._app.exclude_list.error(self.regex)
if hasattr(message, "msg"):
return self._app.exclude_list.error(self.regex).msg
else:
return message # Exception object
# @property
# def regex(self):
# return self.regex
# @regex.setter
# def regex(self, value):
# self._app.exclude_list.add(self._regex, value)
# self._app.exclude_list.add(self._regex, value)