2009-06-01 09:55:11 +00:00
|
|
|
# Created By: Virgil Dupras
|
|
|
|
# Created On: 2009-04-25
|
2011-04-12 08:04:01 +00:00
|
|
|
# Copyright 2011 Hardcoded Software (http://www.hardcoded.net)
|
2009-08-05 08:59:46 +00:00
|
|
|
#
|
2010-09-30 10:17:41 +00:00
|
|
|
# This software is licensed under the "BSD" License as described in the "LICENSE" file,
|
2009-08-05 08:59:46 +00:00
|
|
|
# which should be included with this package. The terms are also available at
|
2010-09-30 10:17:41 +00:00
|
|
|
# http://www.hardcoded.net/licenses/bsd_license
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2010-04-07 16:04:58 +00:00
|
|
|
import sys
|
|
|
|
|
2011-01-15 15:29:35 +00:00
|
|
|
from PyQt4.QtCore import Qt, SIGNAL, QUrl, QRect
|
2011-01-21 12:57:54 +00:00
|
|
|
from PyQt4.QtGui import (QMainWindow, QMenu, QLabel, QHeaderView, QMessageBox, QInputDialog,
|
|
|
|
QLineEdit, QDesktopServices, QFileDialog, QMenuBar, QWidget, QVBoxLayout, QAbstractItemView,
|
|
|
|
QStatusBar)
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2011-01-21 12:57:54 +00:00
|
|
|
from hscommon.trans import tr, trmsg
|
2011-01-11 12:36:05 +00:00
|
|
|
from hscommon.util import nonone
|
2011-02-01 10:43:16 +00:00
|
|
|
from qtlib.util import moveToScreenCenter
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2010-10-04 13:29:00 +00:00
|
|
|
from .results_model import ResultsModel, ResultsView
|
2010-08-11 14:39:06 +00:00
|
|
|
from .stats_label import StatsLabel
|
2011-01-15 15:29:35 +00:00
|
|
|
from .util import createActions
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2011-01-15 15:29:35 +00:00
|
|
|
class ResultWindow(QMainWindow):
|
2009-06-01 09:55:11 +00:00
|
|
|
def __init__(self, app):
|
|
|
|
QMainWindow.__init__(self, None)
|
|
|
|
self.app = app
|
|
|
|
self._last_filter = None
|
|
|
|
self._setupUi()
|
2010-02-12 14:39:29 +00:00
|
|
|
self.resultsModel = ResultsModel(self.app, self.resultsView)
|
|
|
|
self.stats = StatsLabel(app, self.statusLabel)
|
2009-06-01 09:55:11 +00:00
|
|
|
self._load_columns()
|
|
|
|
self._update_column_actions_status()
|
|
|
|
|
|
|
|
self.connect(self.menuColumns, SIGNAL('triggered(QAction*)'), self.columnToggled)
|
2009-06-19 11:14:27 +00:00
|
|
|
self.connect(self.resultsView, SIGNAL('doubleClicked()'), self.resultsDoubleClicked)
|
2010-02-12 14:39:29 +00:00
|
|
|
self.connect(self.resultsView, SIGNAL('spacePressed()'), self.resultsSpacePressed)
|
2010-08-15 10:27:15 +00:00
|
|
|
self.app.willSavePrefs.connect(self.appWillSavePrefs)
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2010-10-04 13:29:00 +00:00
|
|
|
def _setupActions(self):
|
|
|
|
# (name, shortcut, icon, desc, func)
|
|
|
|
ACTIONS = [
|
2011-01-21 12:57:54 +00:00
|
|
|
('actionDetails', 'Ctrl+I', '', tr("Details"), self.detailsTriggered),
|
|
|
|
('actionActions', '', '', tr("Actions"), self.actionsTriggered),
|
|
|
|
('actionPowerMarker', 'Ctrl+1', '', tr("Show Dupes Only"), self.powerMarkerTriggered),
|
|
|
|
('actionDelta', 'Ctrl+2', '', tr("Show Delta Values"), self.deltaTriggered),
|
|
|
|
('actionDeleteMarked', 'Ctrl+D', '', tr("Send Marked to Recycle Bin"), self.deleteTriggered),
|
|
|
|
('actionHardlinkMarked', 'Ctrl+Shift+D', '', tr("Delete Marked and Replace with Hardlinks"), self.hardlinkTriggered),
|
|
|
|
('actionMoveMarked', 'Ctrl+M', '', tr("Move Marked to..."), self.moveTriggered),
|
|
|
|
('actionCopyMarked', 'Ctrl+Shift+M', '', tr("Copy Marked to..."), self.copyTriggered),
|
|
|
|
('actionRemoveMarked', 'Ctrl+R', '', tr("Remove Marked from Results"), self.removeMarkedTriggered),
|
|
|
|
('actionRemoveSelected', 'Ctrl+Del', '', tr("Remove Selected from Results"), self.removeSelectedTriggered),
|
|
|
|
('actionIgnoreSelected', 'Ctrl+Shift+Del', '', tr("Add Selected to Ignore List"), self.addToIgnoreListTriggered),
|
|
|
|
('actionMakeSelectedReference', 'Ctrl+Space', '', tr("Make Selected Reference"), self.makeReferenceTriggered),
|
|
|
|
('actionOpenSelected', 'Ctrl+O', '', tr("Open Selected with Default Application"), self.openTriggered),
|
|
|
|
('actionRevealSelected', 'Ctrl+Shift+O', '', tr("Open Containing Folder of Selected"), self.revealTriggered),
|
|
|
|
('actionRenameSelected', 'F2', '', tr("Rename Selected"), self.renameTriggered),
|
|
|
|
('actionMarkAll', 'Ctrl+A', '', tr("Mark All"), self.markAllTriggered),
|
|
|
|
('actionMarkNone', 'Ctrl+Shift+A', '', tr("Mark None"), self.markNoneTriggered),
|
|
|
|
('actionInvertMarking', 'Ctrl+Alt+A', '', tr("Invert Marking"), self.markInvertTriggered),
|
|
|
|
('actionMarkSelected', '', '', tr("Mark Selected"), self.markSelectedTriggered),
|
|
|
|
('actionClearIgnoreList', '', '', tr("Clear Ignore List"), self.clearIgnoreListTriggered),
|
|
|
|
('actionApplyFilter', 'Ctrl+F', '', tr("Apply Filter"), self.applyFilterTriggered),
|
|
|
|
('actionCancelFilter', 'Ctrl+Shift+F', '', tr("Cancel Filter"), self.cancelFilterTriggered),
|
|
|
|
('actionExport', '', '', tr("Export To HTML"), self.exportTriggered),
|
|
|
|
('actionSaveResults', 'Ctrl+S', '', tr("Save Results..."), self.saveResultsTriggered),
|
|
|
|
('actionInvokeCustomCommand', 'Ctrl+Alt+I', '', tr("Invoke Custom Command"), self.app.invokeCustomCommand),
|
2010-10-04 13:29:00 +00:00
|
|
|
]
|
2011-01-15 15:29:35 +00:00
|
|
|
createActions(ACTIONS, self)
|
2010-10-04 13:29:00 +00:00
|
|
|
self.actionDelta.setCheckable(True)
|
|
|
|
self.actionPowerMarker.setCheckable(True)
|
2011-01-23 15:09:47 +00:00
|
|
|
|
|
|
|
if sys.platform not in {'darwin', 'linux2'}:
|
|
|
|
self.actionHardlinkMarked.setVisible(False)
|
2010-10-04 13:29:00 +00:00
|
|
|
|
|
|
|
def _setupMenu(self):
|
|
|
|
self.menubar = QMenuBar(self)
|
|
|
|
self.menubar.setGeometry(QRect(0, 0, 630, 22))
|
|
|
|
self.menuFile = QMenu(self.menubar)
|
2011-01-21 12:57:54 +00:00
|
|
|
self.menuFile.setTitle(tr("File"))
|
2010-10-04 13:29:00 +00:00
|
|
|
self.menuMark = QMenu(self.menubar)
|
2011-01-21 12:57:54 +00:00
|
|
|
self.menuMark.setTitle(tr("Mark"))
|
2010-10-04 13:29:00 +00:00
|
|
|
self.menuActions = QMenu(self.menubar)
|
2011-01-21 12:57:54 +00:00
|
|
|
self.menuActions.setTitle(tr("Actions"))
|
2010-10-04 13:29:00 +00:00
|
|
|
self.menuColumns = QMenu(self.menubar)
|
2011-01-21 12:57:54 +00:00
|
|
|
self.menuColumns.setTitle(tr("Columns"))
|
2011-01-15 15:29:35 +00:00
|
|
|
self.menuView = QMenu(self.menubar)
|
2011-01-21 12:57:54 +00:00
|
|
|
self.menuView.setTitle(tr("View"))
|
2010-10-04 13:29:00 +00:00
|
|
|
self.menuHelp = QMenu(self.menubar)
|
2011-01-21 12:57:54 +00:00
|
|
|
self.menuHelp.setTitle(tr("Help"))
|
2010-10-04 13:29:00 +00:00
|
|
|
self.setMenuBar(self.menubar)
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2010-10-04 13:29:00 +00:00
|
|
|
self.menuActions.addAction(self.actionDeleteMarked)
|
|
|
|
self.menuActions.addAction(self.actionHardlinkMarked)
|
|
|
|
self.menuActions.addAction(self.actionMoveMarked)
|
|
|
|
self.menuActions.addAction(self.actionCopyMarked)
|
|
|
|
self.menuActions.addAction(self.actionRemoveMarked)
|
|
|
|
self.menuActions.addSeparator()
|
|
|
|
self.menuActions.addAction(self.actionRemoveSelected)
|
|
|
|
self.menuActions.addAction(self.actionIgnoreSelected)
|
|
|
|
self.menuActions.addAction(self.actionMakeSelectedReference)
|
|
|
|
self.menuActions.addSeparator()
|
|
|
|
self.menuActions.addAction(self.actionOpenSelected)
|
|
|
|
self.menuActions.addAction(self.actionRevealSelected)
|
|
|
|
self.menuActions.addAction(self.actionInvokeCustomCommand)
|
|
|
|
self.menuActions.addAction(self.actionRenameSelected)
|
|
|
|
self.menuActions.addSeparator()
|
|
|
|
self.menuActions.addAction(self.actionApplyFilter)
|
|
|
|
self.menuActions.addAction(self.actionCancelFilter)
|
|
|
|
self.menuMark.addAction(self.actionMarkAll)
|
|
|
|
self.menuMark.addAction(self.actionMarkNone)
|
|
|
|
self.menuMark.addAction(self.actionInvertMarking)
|
|
|
|
self.menuMark.addAction(self.actionMarkSelected)
|
2011-01-15 15:29:35 +00:00
|
|
|
self.menuView.addAction(self.actionPowerMarker)
|
|
|
|
self.menuView.addAction(self.actionDelta)
|
|
|
|
self.menuView.addSeparator()
|
|
|
|
self.menuView.addAction(self.actionDetails)
|
|
|
|
self.menuView.addAction(self.app.actionPreferences)
|
|
|
|
self.menuHelp.addAction(self.app.actionShowHelp)
|
|
|
|
self.menuHelp.addAction(self.app.actionRegister)
|
|
|
|
self.menuHelp.addAction(self.app.actionCheckForUpdate)
|
|
|
|
self.menuHelp.addAction(self.app.actionOpenDebugLog)
|
|
|
|
self.menuHelp.addAction(self.app.actionAbout)
|
2010-10-04 13:29:00 +00:00
|
|
|
self.menuFile.addAction(self.actionSaveResults)
|
|
|
|
self.menuFile.addAction(self.actionExport)
|
|
|
|
self.menuFile.addAction(self.actionClearIgnoreList)
|
|
|
|
self.menuFile.addSeparator()
|
2011-01-15 15:29:35 +00:00
|
|
|
self.menuFile.addAction(self.app.actionQuit)
|
2010-10-04 13:29:00 +00:00
|
|
|
|
|
|
|
self.menubar.addAction(self.menuFile.menuAction())
|
|
|
|
self.menubar.addAction(self.menuMark.menuAction())
|
|
|
|
self.menubar.addAction(self.menuActions.menuAction())
|
|
|
|
self.menubar.addAction(self.menuColumns.menuAction())
|
2011-01-15 15:29:35 +00:00
|
|
|
self.menubar.addAction(self.menuView.menuAction())
|
2010-10-04 13:29:00 +00:00
|
|
|
self.menubar.addAction(self.menuHelp.menuAction())
|
2009-06-01 09:55:11 +00:00
|
|
|
|
|
|
|
# Columns menu
|
|
|
|
menu = self.menuColumns
|
|
|
|
self._column_actions = []
|
|
|
|
for index, column in enumerate(self.app.data.COLUMNS):
|
2011-01-29 10:07:33 +00:00
|
|
|
action = menu.addAction(column.display)
|
2009-06-01 09:55:11 +00:00
|
|
|
action.setCheckable(True)
|
|
|
|
action.column_index = index
|
|
|
|
self._column_actions.append(action)
|
|
|
|
menu.addSeparator()
|
2011-01-21 12:57:54 +00:00
|
|
|
action = menu.addAction(tr("Reset to Defaults"))
|
2009-06-01 09:55:11 +00:00
|
|
|
action.column_index = -1
|
|
|
|
|
|
|
|
# Action menu
|
2011-01-21 12:57:54 +00:00
|
|
|
actionMenu = QMenu(tr("Actions"), self.menubar)
|
2009-06-01 09:55:11 +00:00
|
|
|
actionMenu.addAction(self.actionDeleteMarked)
|
2010-09-25 13:37:18 +00:00
|
|
|
actionMenu.addAction(self.actionHardlinkMarked)
|
2009-06-01 09:55:11 +00:00
|
|
|
actionMenu.addAction(self.actionMoveMarked)
|
|
|
|
actionMenu.addAction(self.actionCopyMarked)
|
|
|
|
actionMenu.addAction(self.actionRemoveMarked)
|
|
|
|
actionMenu.addSeparator()
|
|
|
|
actionMenu.addAction(self.actionRemoveSelected)
|
|
|
|
actionMenu.addAction(self.actionIgnoreSelected)
|
|
|
|
actionMenu.addAction(self.actionMakeSelectedReference)
|
|
|
|
actionMenu.addSeparator()
|
|
|
|
actionMenu.addAction(self.actionOpenSelected)
|
|
|
|
actionMenu.addAction(self.actionRevealSelected)
|
2010-04-13 08:02:09 +00:00
|
|
|
actionMenu.addAction(self.actionInvokeCustomCommand)
|
2009-06-01 09:55:11 +00:00
|
|
|
actionMenu.addAction(self.actionRenameSelected)
|
|
|
|
self.actionActions.setMenu(actionMenu)
|
2010-10-04 13:29:00 +00:00
|
|
|
|
|
|
|
def _setupUi(self):
|
2011-04-22 09:37:53 +00:00
|
|
|
self.setWindowTitle(tr("{} Results").format(self.app.NAME))
|
2010-10-04 13:29:00 +00:00
|
|
|
self.resize(630, 514)
|
|
|
|
self.centralwidget = QWidget(self)
|
|
|
|
self.verticalLayout_2 = QVBoxLayout(self.centralwidget)
|
|
|
|
self.verticalLayout_2.setMargin(0)
|
|
|
|
self.resultsView = ResultsView(self.centralwidget)
|
|
|
|
self.resultsView.setSelectionMode(QAbstractItemView.ExtendedSelection)
|
|
|
|
self.resultsView.setSelectionBehavior(QAbstractItemView.SelectRows)
|
|
|
|
self.resultsView.setSortingEnabled(True)
|
|
|
|
self.resultsView.verticalHeader().setVisible(False)
|
|
|
|
self.resultsView.verticalHeader().setDefaultSectionSize(18)
|
|
|
|
h = self.resultsView.horizontalHeader()
|
|
|
|
h.setHighlightSections(False)
|
|
|
|
h.setMovable(True)
|
|
|
|
h.setStretchLastSection(False)
|
|
|
|
h.setDefaultAlignment(Qt.AlignLeft)
|
|
|
|
self.verticalLayout_2.addWidget(self.resultsView)
|
|
|
|
self.setCentralWidget(self.centralwidget)
|
|
|
|
self._setupActions()
|
|
|
|
self._setupMenu()
|
|
|
|
self.statusbar = QStatusBar(self)
|
|
|
|
self.statusbar.setSizeGripEnabled(True)
|
|
|
|
self.setStatusBar(self.statusbar)
|
2009-06-01 09:55:11 +00:00
|
|
|
self.statusLabel = QLabel(self)
|
|
|
|
self.statusbar.addPermanentWidget(self.statusLabel, 1)
|
2010-04-07 16:04:58 +00:00
|
|
|
|
2011-01-15 15:29:35 +00:00
|
|
|
if self.app.prefs.resultWindowIsMaximized:
|
|
|
|
self.setWindowState(self.windowState() | Qt.WindowMaximized)
|
2011-02-01 10:43:16 +00:00
|
|
|
else:
|
|
|
|
if self.app.prefs.resultWindowRect is not None:
|
|
|
|
self.setGeometry(self.app.prefs.resultWindowRect)
|
|
|
|
else:
|
|
|
|
moveToScreenCenter(self)
|
2009-06-01 09:55:11 +00:00
|
|
|
|
|
|
|
#--- Private
|
|
|
|
def _load_columns(self):
|
2010-09-24 13:48:59 +00:00
|
|
|
h = self.resultsView.horizontalHeader()
|
2009-06-01 09:55:11 +00:00
|
|
|
h.setResizeMode(QHeaderView.Interactive)
|
|
|
|
prefs = self.app.prefs
|
2010-08-11 14:39:06 +00:00
|
|
|
attrs = list(zip(prefs.columns_width, prefs.columns_visible))
|
2009-06-01 09:55:11 +00:00
|
|
|
for index, (width, visible) in enumerate(attrs):
|
|
|
|
h.resizeSection(index, width)
|
|
|
|
h.setSectionHidden(index, not visible)
|
|
|
|
h.setResizeMode(0, QHeaderView.Stretch)
|
|
|
|
|
|
|
|
def _update_column_actions_status(self):
|
2010-09-24 13:48:59 +00:00
|
|
|
h = self.resultsView.horizontalHeader()
|
2009-06-01 09:55:11 +00:00
|
|
|
for action in self._column_actions:
|
|
|
|
colid = action.column_index
|
|
|
|
action.setChecked(not h.isSectionHidden(colid))
|
|
|
|
|
|
|
|
#--- Actions
|
|
|
|
def actionsTriggered(self):
|
|
|
|
self.actionsButton.showMenu()
|
|
|
|
|
|
|
|
def addToIgnoreListTriggered(self):
|
2010-02-06 11:12:20 +00:00
|
|
|
self.app.add_selected_to_ignore_list()
|
2009-06-01 09:55:11 +00:00
|
|
|
|
|
|
|
def applyFilterTriggered(self):
|
2011-01-21 12:57:54 +00:00
|
|
|
title = tr("Apply Filter")
|
|
|
|
msg = trmsg("TypeFilterMsg")
|
2009-06-01 09:55:11 +00:00
|
|
|
text = nonone(self._last_filter, '[*]')
|
|
|
|
answer, ok = QInputDialog.getText(self, title, msg, QLineEdit.Normal, text)
|
|
|
|
if not ok:
|
|
|
|
return
|
2010-08-11 14:39:06 +00:00
|
|
|
answer = str(answer)
|
2009-06-07 07:14:47 +00:00
|
|
|
self.app.apply_filter(answer)
|
2009-06-01 09:55:11 +00:00
|
|
|
self._last_filter = answer
|
|
|
|
|
|
|
|
def cancelFilterTriggered(self):
|
2009-06-07 07:14:47 +00:00
|
|
|
self.app.apply_filter('')
|
2009-06-01 09:55:11 +00:00
|
|
|
|
|
|
|
def clearIgnoreListTriggered(self):
|
2011-01-21 12:57:54 +00:00
|
|
|
title = tr("Clear Ignore List")
|
2009-06-01 09:55:11 +00:00
|
|
|
count = len(self.app.scanner.ignore_list)
|
|
|
|
if not count:
|
2011-01-21 12:57:54 +00:00
|
|
|
QMessageBox.information(self, title, trmsg("NothingToClearMsg"))
|
2009-06-01 09:55:11 +00:00
|
|
|
return
|
2011-01-21 12:57:54 +00:00
|
|
|
msg = trmsg("ClearIgnoreListConfirmMsg").format(count)
|
2011-01-15 15:29:35 +00:00
|
|
|
if self.app.confirm(title, msg, QMessageBox.No):
|
2009-06-01 09:55:11 +00:00
|
|
|
self.app.scanner.ignore_list.Clear()
|
2011-01-21 12:57:54 +00:00
|
|
|
QMessageBox.information(self, title, trmsg("IgnoreListClearedMsg"))
|
2009-06-01 09:55:11 +00:00
|
|
|
|
|
|
|
def copyTriggered(self):
|
|
|
|
self.app.copy_or_move_marked(True)
|
|
|
|
|
|
|
|
def deleteTriggered(self):
|
|
|
|
count = self.app.results.mark_count
|
|
|
|
if not count:
|
|
|
|
return
|
2011-01-21 12:57:54 +00:00
|
|
|
title = tr("Delete duplicates")
|
|
|
|
msg = trmsg("SendToTrashConfirmMsg").format(count)
|
2011-01-15 15:29:35 +00:00
|
|
|
if self.app.confirm(title, msg):
|
2009-06-01 09:55:11 +00:00
|
|
|
self.app.delete_marked()
|
|
|
|
|
|
|
|
def deltaTriggered(self):
|
2010-02-12 14:39:29 +00:00
|
|
|
self.resultsModel.delta_values = self.actionDelta.isChecked()
|
2009-06-01 09:55:11 +00:00
|
|
|
|
|
|
|
def detailsTriggered(self):
|
|
|
|
self.app.show_details()
|
|
|
|
|
2009-09-01 16:40:29 +00:00
|
|
|
def exportTriggered(self):
|
2010-09-24 13:48:59 +00:00
|
|
|
h = self.resultsView.horizontalHeader()
|
2009-09-01 16:40:29 +00:00
|
|
|
column_ids = []
|
|
|
|
for i in range(len(self.app.data.COLUMNS)):
|
|
|
|
if not h.isSectionHidden(i):
|
|
|
|
column_ids.append(str(i))
|
|
|
|
exported_path = self.app.export_to_xhtml(column_ids)
|
|
|
|
url = QUrl.fromLocalFile(exported_path)
|
|
|
|
QDesktopServices.openUrl(url)
|
2010-08-13 11:06:18 +00:00
|
|
|
|
2010-09-25 13:37:18 +00:00
|
|
|
def hardlinkTriggered(self):
|
|
|
|
count = self.app.results.mark_count
|
|
|
|
if not count:
|
|
|
|
return
|
2011-01-21 12:57:54 +00:00
|
|
|
title = tr("Delete and hardlink duplicates")
|
|
|
|
msg = trmsg("HardlinkConfirmMsg").format(count)
|
2011-01-15 15:29:35 +00:00
|
|
|
if self.app.confirm(title, msg):
|
2010-09-25 13:37:18 +00:00
|
|
|
self.app.delete_marked(replace_with_hardlinks=True)
|
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def makeReferenceTriggered(self):
|
2010-02-06 11:27:11 +00:00
|
|
|
self.app.make_selected_reference()
|
2009-06-01 09:55:11 +00:00
|
|
|
|
|
|
|
def markAllTriggered(self):
|
|
|
|
self.app.mark_all()
|
|
|
|
|
|
|
|
def markInvertTriggered(self):
|
|
|
|
self.app.mark_invert()
|
|
|
|
|
|
|
|
def markNoneTriggered(self):
|
|
|
|
self.app.mark_none()
|
|
|
|
|
|
|
|
def markSelectedTriggered(self):
|
2010-02-12 14:39:29 +00:00
|
|
|
self.app.toggle_selected_mark_state()
|
2009-06-01 09:55:11 +00:00
|
|
|
|
|
|
|
def moveTriggered(self):
|
|
|
|
self.app.copy_or_move_marked(False)
|
|
|
|
|
|
|
|
def openTriggered(self):
|
|
|
|
self.app.open_selected()
|
|
|
|
|
|
|
|
def powerMarkerTriggered(self):
|
|
|
|
self.resultsModel.power_marker = self.actionPowerMarker.isChecked()
|
|
|
|
|
|
|
|
def preferencesTriggered(self):
|
|
|
|
self.app.show_preferences()
|
|
|
|
|
|
|
|
def removeMarkedTriggered(self):
|
|
|
|
count = self.app.results.mark_count
|
|
|
|
if not count:
|
|
|
|
return
|
2011-01-21 12:57:54 +00:00
|
|
|
title = tr("Remove duplicates")
|
|
|
|
msg = trmsg("FileRemovalConfirmMsg").format(count)
|
2011-01-15 15:29:35 +00:00
|
|
|
if self.app.confirm(title, msg):
|
2010-02-12 14:39:29 +00:00
|
|
|
self.app.remove_marked()
|
2009-06-01 09:55:11 +00:00
|
|
|
|
|
|
|
def removeSelectedTriggered(self):
|
2010-02-06 11:44:21 +00:00
|
|
|
self.app.remove_selected()
|
2009-06-01 09:55:11 +00:00
|
|
|
|
|
|
|
def renameTriggered(self):
|
|
|
|
self.resultsView.edit(self.resultsView.selectionModel().currentIndex())
|
|
|
|
|
|
|
|
def revealTriggered(self):
|
|
|
|
self.app.reveal_selected()
|
|
|
|
|
2010-08-13 11:06:18 +00:00
|
|
|
def saveResultsTriggered(self):
|
2011-01-21 12:57:54 +00:00
|
|
|
title = trmsg("SelectResultToSaveMsg")
|
|
|
|
files = tr("dupeGuru Results (*.dupeguru)")
|
2010-08-13 11:06:18 +00:00
|
|
|
destination = QFileDialog.getSaveFileName(self, title, '', files)
|
|
|
|
if destination:
|
2011-05-29 13:12:24 +00:00
|
|
|
if not destination.endswith('.dupeguru'):
|
|
|
|
destination = '{}.dupeguru'.format(destination)
|
2010-08-13 11:06:18 +00:00
|
|
|
self.app.save_as(destination)
|
2011-01-15 15:29:35 +00:00
|
|
|
self.app.recentResults.insertItem(destination)
|
2009-06-01 09:55:11 +00:00
|
|
|
|
|
|
|
#--- Events
|
2010-08-15 10:27:15 +00:00
|
|
|
def appWillSavePrefs(self):
|
|
|
|
prefs = self.app.prefs
|
2010-09-24 13:48:59 +00:00
|
|
|
h = self.resultsView.horizontalHeader()
|
2010-08-15 10:27:15 +00:00
|
|
|
widths = []
|
|
|
|
visible = []
|
|
|
|
for i in range(len(self.app.data.COLUMNS)):
|
|
|
|
widths.append(h.sectionSize(i))
|
|
|
|
visible.append(not h.isSectionHidden(i))
|
|
|
|
prefs.columns_width = widths
|
|
|
|
prefs.columns_visible = visible
|
2011-01-15 15:29:35 +00:00
|
|
|
prefs.resultWindowIsMaximized = self.isMaximized()
|
|
|
|
prefs.resultWindowRect = self.geometry()
|
2009-06-01 09:55:11 +00:00
|
|
|
|
|
|
|
def columnToggled(self, action):
|
|
|
|
colid = action.column_index
|
|
|
|
if colid == -1:
|
|
|
|
self.app.prefs.reset_columns()
|
|
|
|
self._load_columns()
|
|
|
|
else:
|
2010-09-24 13:48:59 +00:00
|
|
|
h = self.resultsView.horizontalHeader()
|
2009-06-01 09:55:11 +00:00
|
|
|
h.setSectionHidden(colid, not h.isSectionHidden(colid))
|
|
|
|
self._update_column_actions_status()
|
|
|
|
|
2009-06-19 11:32:58 +00:00
|
|
|
def contextMenuEvent(self, event):
|
|
|
|
self.actionActions.menu().exec_(event.globalPos())
|
|
|
|
|
2009-06-19 11:14:27 +00:00
|
|
|
def resultsDoubleClicked(self):
|
|
|
|
self.app.open_selected()
|
|
|
|
|
2010-02-12 14:39:29 +00:00
|
|
|
def resultsSpacePressed(self):
|
|
|
|
self.app.toggle_selected_mark_state()
|
2009-06-01 09:55:11 +00:00
|
|
|
|