mirror of
https://github.com/arsenetar/dupeguru.git
synced 2026-01-22 14:41:39 +00:00
[#138] Added drag & drop criteria re-ordering capabilities to the re-prioritization panel.
This commit is contained in:
@@ -18,6 +18,19 @@ class CriterionCategoryList(GUISelectableList):
|
||||
def _update_selection(self):
|
||||
self.dialog.select_category(self.dialog.categories[self.selected_index])
|
||||
|
||||
class PrioritizationList(GUISelectableList):
|
||||
def __init__(self, dialog):
|
||||
self.dialog = dialog
|
||||
GUISelectableList.__init__(self)
|
||||
|
||||
def move_indexes(self, indexes, dest_index):
|
||||
indexes.sort()
|
||||
prilist = self.dialog.prioritizations
|
||||
selected = [prilist[i] for i in indexes]
|
||||
for i in reversed(indexes):
|
||||
del prilist[i]
|
||||
prilist[dest_index:dest_index] = selected
|
||||
self[:] = [crit.display for crit in prilist]
|
||||
|
||||
class PrioritizeDialog:
|
||||
def __init__(self, view, app):
|
||||
@@ -27,7 +40,7 @@ class PrioritizeDialog:
|
||||
self.criteria = []
|
||||
self.criteria_list = GUISelectableList()
|
||||
self.prioritizations = []
|
||||
self.prioritization_list = GUISelectableList()
|
||||
self.prioritization_list = PrioritizationList(self)
|
||||
|
||||
#--- Private
|
||||
def _sort_key(self, dupe):
|
||||
|
||||
@@ -101,3 +101,8 @@ class TestApp(TestAppBase):
|
||||
# maintainable.
|
||||
index = self.pdialog.category_list.index(name)
|
||||
self.pdialog.category_list.select(index)
|
||||
|
||||
def add_pri_criterion(self, name, index):
|
||||
self.select_pri_criterion("Kind")
|
||||
self.pdialog.criteria_list.select([index])
|
||||
self.pdialog.add_selected()
|
||||
|
||||
@@ -98,3 +98,14 @@ def test_size_reprioritization(app):
|
||||
app.pdialog.add_selected()
|
||||
app.pdialog.perform_reprioritization()
|
||||
eq_(app.rtable[0].data[0], 'foo2.ext2')
|
||||
|
||||
@with_app(app_normal_results)
|
||||
def test_reorder_prioritizations(app):
|
||||
app.add_pri_criterion("Kind", 0) # ext1
|
||||
app.add_pri_criterion("Kind", 1) # ext2
|
||||
app.pdialog.prioritization_list.move_indexes([1], 0)
|
||||
expected = [
|
||||
"Kind (ext2)",
|
||||
"Kind (ext1)",
|
||||
]
|
||||
eq_(app.pdialog.prioritization_list[:], expected)
|
||||
|
||||
Reference in New Issue
Block a user