mirror of
https://github.com/arsenetar/dupeguru.git
synced 2026-01-22 14:41:39 +00:00
Implemented super() inheritance style suggested by PyQt5
This commit is contained in:
@@ -43,8 +43,8 @@ class DupeGuru(QObject):
|
||||
PREFERENCES_CLASS = None
|
||||
PREFERENCES_DIALOG_CLASS = None
|
||||
|
||||
def __init__(self):
|
||||
QObject.__init__(self)
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.prefs = self.PREFERENCES_CLASS()
|
||||
self.prefs.load()
|
||||
self.model = self.MODELCLASS(view=self)
|
||||
|
||||
@@ -15,9 +15,9 @@ from qtlib.radio_box import RadioBox
|
||||
tr = trget('ui')
|
||||
|
||||
class DeletionOptions(QDialog):
|
||||
def __init__(self, parent, model):
|
||||
def __init__(self, parent, model, **kwargs):
|
||||
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
|
||||
QDialog.__init__(self, parent, flags)
|
||||
super().__init__(parent, flags, **kwargs)
|
||||
self.model = model
|
||||
self._setupUi()
|
||||
self.model.view = self
|
||||
|
||||
@@ -12,8 +12,8 @@ from PyQt5.QtWidgets import QDialog
|
||||
from .details_table import DetailsModel
|
||||
|
||||
class DetailsDialog(QDialog):
|
||||
def __init__(self, parent, app):
|
||||
QDialog.__init__(self, parent, Qt.Tool)
|
||||
def __init__(self, parent, app, **kwargs):
|
||||
super().__init__(parent, Qt.Tool, **kwargs)
|
||||
self.app = app
|
||||
self.model = app.model.details_panel
|
||||
self._setupUi()
|
||||
@@ -33,7 +33,7 @@ class DetailsDialog(QDialog):
|
||||
|
||||
def show(self):
|
||||
self._shown_once = True
|
||||
QDialog.show(self)
|
||||
super().show()
|
||||
|
||||
#--- Events
|
||||
def appWillSavePrefs(self):
|
||||
|
||||
@@ -16,8 +16,8 @@ tr = trget('ui')
|
||||
HEADER = [tr("Attribute"), tr("Selected"), tr("Reference")]
|
||||
|
||||
class DetailsModel(QAbstractTableModel):
|
||||
def __init__(self, model):
|
||||
QAbstractTableModel.__init__(self)
|
||||
def __init__(self, model, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.model = model
|
||||
|
||||
def columnCount(self, parent):
|
||||
|
||||
@@ -22,8 +22,8 @@ from .directories_model import DirectoriesModel, DirectoriesDelegate
|
||||
tr = trget('ui')
|
||||
|
||||
class DirectoriesDialog(QMainWindow):
|
||||
def __init__(self, parent, app):
|
||||
QMainWindow.__init__(self, None)
|
||||
def __init__(self, parent, app, **kwargs):
|
||||
super().__init__(None, **kwargs)
|
||||
self.app = app
|
||||
self.lastAddedFolder = platform.INITIAL_FOLDER_IN_DIALOGS
|
||||
self.recentFolders = Recent(self.app, 'recentFolders')
|
||||
|
||||
@@ -43,7 +43,7 @@ class DirectoriesDelegate(QStyledItemDelegate):
|
||||
rect.setLeft(rect.left()+4)
|
||||
painter.drawText(rect, Qt.AlignLeft, option.text)
|
||||
else:
|
||||
QStyledItemDelegate.paint(self, painter, option, index)
|
||||
super().paint(painter, option, index)
|
||||
|
||||
def setEditorData(self, editor, index):
|
||||
value = index.model().data(index, Qt.EditRole)
|
||||
@@ -59,8 +59,8 @@ class DirectoriesDelegate(QStyledItemDelegate):
|
||||
|
||||
|
||||
class DirectoriesModel(TreeModel):
|
||||
def __init__(self, model, view):
|
||||
TreeModel.__init__(self)
|
||||
def __init__(self, model, view, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.model = model
|
||||
self.model.view = self
|
||||
self.view = view
|
||||
|
||||
@@ -16,9 +16,9 @@ from .ignore_list_table import IgnoreListTable
|
||||
tr = trget('ui')
|
||||
|
||||
class IgnoreListDialog(QDialog):
|
||||
def __init__(self, parent, model):
|
||||
def __init__(self, parent, model, **kwargs):
|
||||
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
|
||||
QDialog.__init__(self, parent, flags)
|
||||
super().__init__(parent, flags, **kwargs)
|
||||
self._setupUi()
|
||||
self.model = model
|
||||
self.model.view = self
|
||||
@@ -50,5 +50,5 @@ class IgnoreListDialog(QDialog):
|
||||
|
||||
#--- model --> view
|
||||
def show(self):
|
||||
QDialog.show(self)
|
||||
super().show()
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ tr = trget('ui')
|
||||
SUPPORTED_LANGUAGES = ['en', 'fr', 'de', 'zh_CN', 'cs', 'it', 'hy', 'ru', 'uk', 'pt_BR', 'vi']
|
||||
|
||||
class PreferencesDialogBase(QDialog):
|
||||
def __init__(self, parent, app):
|
||||
def __init__(self, parent, app, **kwargs):
|
||||
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
|
||||
QDialog.__init__(self, parent, flags)
|
||||
super().__init__(parent, flags, **kwargs)
|
||||
self.app = app
|
||||
self._setupUi()
|
||||
|
||||
|
||||
@@ -52,9 +52,9 @@ class PrioritizationList(ListviewModel):
|
||||
return Qt.MoveAction
|
||||
|
||||
class PrioritizeDialog(QDialog):
|
||||
def __init__(self, parent, app):
|
||||
def __init__(self, parent, app, **kwargs):
|
||||
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
|
||||
QDialog.__init__(self, parent, flags)
|
||||
super().__init__(parent, flags, **kwargs)
|
||||
self._setupUi()
|
||||
self.model = PrioritizeDialogModel(app=app.model)
|
||||
self.categoryList = ComboboxModel(model=self.model.category_list, view=self.categoryCombobox)
|
||||
|
||||
@@ -16,9 +16,9 @@ from .problem_table import ProblemTable
|
||||
tr = trget('ui')
|
||||
|
||||
class ProblemDialog(QDialog):
|
||||
def __init__(self, parent, model):
|
||||
def __init__(self, parent, model, **kwargs):
|
||||
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
|
||||
QDialog.__init__(self, parent, flags)
|
||||
super().__init__(parent, flags, **kwargs)
|
||||
self._setupUi()
|
||||
self.model = model
|
||||
self.model.view = self
|
||||
|
||||
@@ -15,8 +15,8 @@ class ProblemTable(Table):
|
||||
Column('msg', defaultWidth=150),
|
||||
]
|
||||
|
||||
def __init__(self, model, view):
|
||||
Table.__init__(self, model, view)
|
||||
def __init__(self, model, view, **kwargs):
|
||||
super().__init__(model, view, **kwargs)
|
||||
# we have to prevent Return from initiating editing.
|
||||
# self.view.editSelected = lambda: None
|
||||
|
||||
@@ -21,8 +21,8 @@ from .prioritize_dialog import PrioritizeDialog
|
||||
tr = trget('ui')
|
||||
|
||||
class ResultWindow(QMainWindow):
|
||||
def __init__(self, app):
|
||||
QMainWindow.__init__(self, None)
|
||||
def __init__(self, app, **kwargs):
|
||||
super().__init__(None, **kwargs)
|
||||
self.app = app
|
||||
self._setupUi()
|
||||
self.resultsModel = app.RESULT_MODEL_CLASS(self.app, self.resultsView)
|
||||
|
||||
@@ -13,9 +13,9 @@ from PyQt5.QtWidgets import QTableView
|
||||
from qtlib.table import Table
|
||||
|
||||
class ResultsModel(Table):
|
||||
def __init__(self, app, view):
|
||||
def __init__(self, app, view, **kwargs):
|
||||
model = app.model.result_table
|
||||
Table.__init__(self, model, view)
|
||||
super().__init__(model, view, **kwargs)
|
||||
view.horizontalHeader().setSortIndicator(1, Qt.AscendingOrder)
|
||||
|
||||
app.prefsChanged.connect(self.appPrefsChanged)
|
||||
@@ -109,7 +109,7 @@ class ResultsView(QTableView):
|
||||
if event.text() == ' ':
|
||||
self.spacePressed.emit()
|
||||
return
|
||||
QTableView.keyPressEvent(self, event)
|
||||
super().keyPressEvent(event)
|
||||
|
||||
def mouseDoubleClickEvent(self, event):
|
||||
self.doubleClicked.emit(None)
|
||||
|
||||
@@ -29,8 +29,8 @@ SCAN_TYPE_ORDER = [
|
||||
]
|
||||
|
||||
class PreferencesDialog(PreferencesDialogBase):
|
||||
def __init__(self, parent, app):
|
||||
PreferencesDialogBase.__init__(self, parent, app)
|
||||
def __init__(self, parent, app, **kwargs):
|
||||
super().__init__(parent, app, **kwargs)
|
||||
|
||||
self.scanTypeComboBox.currentIndexChanged[int].connect(self.scanTypeChanged)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user