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

Format all files with black correcting line length

This commit is contained in:
2021-08-15 04:10:18 -05:00
parent 9446f37fad
commit ffe6b7047c
80 changed files with 517 additions and 970 deletions

View File

@@ -25,12 +25,7 @@ tr = trget("qtlib")
class AboutBox(QDialog):
def __init__(self, parent, app, **kwargs):
flags = (
Qt.CustomizeWindowHint
| Qt.WindowTitleHint
| Qt.WindowSystemMenuHint
| Qt.MSWindowsFixedSizeDialogHint
)
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.MSWindowsFixedSizeDialogHint
super().__init__(parent, flags, **kwargs)
self.app = app
self._setupUi()
@@ -39,9 +34,7 @@ class AboutBox(QDialog):
self.buttonBox.rejected.connect(self.reject)
def _setupUi(self):
self.setWindowTitle(
tr("About {}").format(QCoreApplication.instance().applicationName())
)
self.setWindowTitle(tr("About {}").format(QCoreApplication.instance().applicationName()))
self.resize(400, 290)
sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
@@ -61,9 +54,7 @@ class AboutBox(QDialog):
self.nameLabel.setText(QCoreApplication.instance().applicationName())
self.verticalLayout.addWidget(self.nameLabel)
self.versionLabel = QLabel(self)
self.versionLabel.setText(
tr("Version {}").format(QCoreApplication.instance().applicationVersion())
)
self.versionLabel.setText(tr("Version {}").format(QCoreApplication.instance().applicationVersion()))
self.verticalLayout.addWidget(self.versionLabel)
self.label_3 = QLabel(self)
self.verticalLayout.addWidget(self.label_3)

View File

@@ -62,9 +62,7 @@ class Columns:
# See moneyguru #14 and #15. This was added in order to allow automatic resizing of columns.
for column in self.model.column_list:
if column.resizeToFit:
self._headerView.setSectionResizeMode(
column.logical_index, QHeaderView.ResizeToContents
)
self._headerView.setSectionResizeMode(column.logical_index, QHeaderView.ResizeToContents)
# --- Public
def setColumnsWidth(self, widths):

View File

@@ -34,9 +34,7 @@ class ErrorReportDialog(QDialog):
self._setupUi()
name = QCoreApplication.applicationName()
version = QCoreApplication.applicationVersion()
errorText = "Application Name: {}\nVersion: {}\n\n{}".format(
name, version, error
)
errorText = "Application Name: {}\nVersion: {}\n\n{}".format(name, version, error)
# Under windows, we end up with an error report without linesep if we don't mangle it
errorText = errorText.replace("\n", os.linesep)
self.errorTextEdit.setPlainText(errorText)

View File

@@ -102,20 +102,14 @@ class SearchEdit(ClearableEdit):
if not bool(self.text()) and self.inactiveText and not self.hasFocus():
panel = QStyleOptionFrame()
self.initStyleOption(panel)
textRect = self.style().subElementRect(
QStyle.SE_LineEditContents, panel, self
)
textRect = self.style().subElementRect(QStyle.SE_LineEditContents, panel, self)
leftMargin = 2
rightMargin = self._clearButton.iconSize().width()
textRect.adjust(leftMargin, 0, -rightMargin, 0)
painter = QPainter(self)
disabledColor = (
self.palette().brush(QPalette.Disabled, QPalette.Text).color()
)
disabledColor = self.palette().brush(QPalette.Disabled, QPalette.Text).color()
painter.setPen(disabledColor)
painter.drawText(
textRect, Qt.AlignLeft | Qt.AlignVCenter, self.inactiveText
)
painter.drawText(textRect, Qt.AlignLeft | Qt.AlignVCenter, self.inactiveText)
# --- Event Handlers
def _returnPressed(self):
@@ -123,6 +117,4 @@ class SearchEdit(ClearableEdit):
self.searchChanged.emit()
# --- Signals
searchChanged = (
pyqtSignal()
) # Emitted when return is pressed or when the test is cleared
searchChanged = pyqtSignal() # Emitted when return is pressed or when the test is cleared

View File

@@ -76,15 +76,11 @@ class ComboboxModel(SelectableList):
class ListviewModel(SelectableList):
def __init__(self, model, view, **kwargs):
super().__init__(model, view, **kwargs)
self.view.selectionModel().selectionChanged[
(QItemSelection, QItemSelection)
].connect(self.selectionChanged)
self.view.selectionModel().selectionChanged[(QItemSelection, QItemSelection)].connect(self.selectionChanged)
# --- Override
def _updateSelection(self):
newIndexes = [
modelIndex.row() for modelIndex in self.view.selectionModel().selectedRows()
]
newIndexes = [modelIndex.row() for modelIndex in self.view.selectionModel().selectedRows()]
if newIndexes != self.model.selected_indexes:
self.model.select(newIndexes)
@@ -92,14 +88,10 @@ class ListviewModel(SelectableList):
newSelection = QItemSelection()
for index in self.model.selected_indexes:
newSelection.select(self.createIndex(index, 0), self.createIndex(index, 0))
self.view.selectionModel().select(
newSelection, QItemSelectionModel.ClearAndSelect
)
self.view.selectionModel().select(newSelection, QItemSelectionModel.ClearAndSelect)
if len(newSelection.indexes()):
currentIndex = newSelection.indexes()[0]
self.view.selectionModel().setCurrentIndex(
currentIndex, QItemSelectionModel.Current
)
self.view.selectionModel().setCurrentIndex(currentIndex, QItemSelectionModel.Current)
self.view.scrollTo(currentIndex)
# --- Events

View File

@@ -29,22 +29,16 @@ class Table(QAbstractTableModel):
self.view.setModel(self)
self.model.view = self
if hasattr(self.model, "columns"):
self.columns = Columns(
self.model.columns, self.COLUMNS, view.horizontalHeader()
)
self.columns = Columns(self.model.columns, self.COLUMNS, view.horizontalHeader())
self.view.selectionModel().selectionChanged[
(QItemSelection, QItemSelection)
].connect(self.selectionChanged)
self.view.selectionModel().selectionChanged[(QItemSelection, QItemSelection)].connect(self.selectionChanged)
def _updateModelSelection(self):
# Takes the selection on the view's side and update the model with it.
# an _updateViewSelection() call will normally result in an _updateModelSelection() call.
# to avoid infinite loops, we check that the selection will actually change before calling
# model.select()
newIndexes = [
modelIndex.row() for modelIndex in self.view.selectionModel().selectedRows()
]
newIndexes = [modelIndex.row() for modelIndex in self.view.selectionModel().selectedRows()]
if newIndexes != self.model.selected_indexes:
self.model.select(newIndexes)
@@ -53,17 +47,11 @@ class Table(QAbstractTableModel):
newSelection = QItemSelection()
columnCount = self.columnCount(QModelIndex())
for index in self.model.selected_indexes:
newSelection.select(
self.createIndex(index, 0), self.createIndex(index, columnCount - 1)
)
self.view.selectionModel().select(
newSelection, QItemSelectionModel.ClearAndSelect
)
newSelection.select(self.createIndex(index, 0), self.createIndex(index, columnCount - 1))
self.view.selectionModel().select(newSelection, QItemSelectionModel.ClearAndSelect)
if len(newSelection.indexes()):
currentIndex = newSelection.indexes()[0]
self.view.selectionModel().setCurrentIndex(
currentIndex, QItemSelectionModel.Current
)
self.view.selectionModel().setCurrentIndex(currentIndex, QItemSelectionModel.Current)
self.view.scrollTo(currentIndex)
# --- Data Model methods

View File

@@ -84,9 +84,7 @@ class DummyNode(TreeNode):
class TreeModel(QAbstractItemModel, NodeContainer):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self._dummyNodes = (
set()
) # dummy nodes' reference have to be kept to avoid segfault
self._dummyNodes = set() # dummy nodes' reference have to be kept to avoid segfault
# --- Private
def _createDummyNode(self, parent, row):
@@ -98,8 +96,7 @@ class TreeModel(QAbstractItemModel, NodeContainer):
return DummyNode(self, parent, row)
def _lastIndex(self):
"""Index of the very last item in the tree.
"""
"""Index of the very last item in the tree."""
currentIndex = QModelIndex()
rowCount = self.rowCount(currentIndex)
while rowCount > 0: