mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-10 05:34:36 +00:00
[#29] qt base: Made the resultsChanged event remember the selected dupe and re-select it.
--HG-- extra : convert_revision : svn%3Ac306627e-7827-47d3-bdf0-9a457c9553a1/trunk%4048
This commit is contained in:
parent
8ce12d785f
commit
f23c6e37bc
@ -48,6 +48,8 @@ class DetailsModel(QAbstractTableModel):
|
||||
#--- Events
|
||||
def duplicateSelected(self):
|
||||
dupe = self._app.selected_dupe
|
||||
if dupe is None:
|
||||
return
|
||||
group = self._app.results.get_group_of_duplicate(dupe)
|
||||
ref = group.ref
|
||||
self._dupe_data = self._data.GetDisplayInfo(dupe, group)
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
from PyQt4.QtCore import Qt, QCoreApplication, QProcess, SIGNAL
|
||||
from PyQt4.QtGui import (QMainWindow, QMenu, QPixmap, QIcon, QToolButton, QLabel, QHeaderView,
|
||||
QMessageBox, QInputDialog, QLineEdit)
|
||||
QMessageBox, QInputDialog, QLineEdit, QItemSelectionModel)
|
||||
|
||||
from hsutil.misc import nonone
|
||||
|
||||
@ -292,6 +292,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
|
||||
def resultsChanged(self):
|
||||
self.resultsView.model().reset()
|
||||
dupe = self.app.selected_dupe
|
||||
if dupe is not None:
|
||||
[modelIndex] = self.resultsModel.indexesForDupes([dupe])
|
||||
if modelIndex.isValid():
|
||||
flags = QItemSelectionModel.ClearAndSelect | QItemSelectionModel.Rows
|
||||
self.resultsView.selectionModel().select(modelIndex, flags)
|
||||
|
||||
def resultsReset(self):
|
||||
self.resultsView.expandAll()
|
||||
|
@ -102,6 +102,30 @@ class ResultsModel(TreeModel):
|
||||
nodes = [index.internalPointer() for index in indexes]
|
||||
return [node.dupe for node in nodes]
|
||||
|
||||
def indexesForDupes(self, dupes):
|
||||
def index(dupe):
|
||||
try:
|
||||
if self.power_marker:
|
||||
row = self._results.dupes.index(dupe)
|
||||
node = self.nodes[row]
|
||||
assert node.dupe is dupe
|
||||
return self.createIndex(row, 0, node)
|
||||
else:
|
||||
group = self._results.get_group_of_duplicate(dupe)
|
||||
row = self._results.groups.index(group)
|
||||
node = self.nodes[row]
|
||||
if dupe is group.ref:
|
||||
assert node.dupe is dupe
|
||||
return self.createIndex(row, 0, node)
|
||||
subrow = group.dupes.index(dupe)
|
||||
subnode = node.children[subrow]
|
||||
assert subnode.dupe is dupe
|
||||
return self.createIndex(subrow, 0, subnode)
|
||||
except ValueError: # the dupe is not there anymore
|
||||
return QModelIndex()
|
||||
|
||||
return map(index, dupes)
|
||||
|
||||
def flags(self, index):
|
||||
if not index.isValid():
|
||||
return Qt.ItemIsEnabled
|
||||
|
Loading…
x
Reference in New Issue
Block a user