--- a/ProjectDjango/DjangoMigrationsListDialog.py Sat May 29 15:03:26 2021 +0200 +++ b/ProjectDjango/DjangoMigrationsListDialog.py Sat May 29 18:33:03 2021 +0200 @@ -7,14 +7,14 @@ Module implementing a dialog show a list of all available migrations. """ -from PyQt5.QtCore import pyqtSlot, Qt, QProcess, QTimer, QPoint -from PyQt5.QtWidgets import ( +from PyQt6.QtCore import pyqtSlot, Qt, QProcess, QTimer, QPoint +from PyQt6.QtWidgets import ( QDialog, QDialogButtonBox, QAbstractButton, QHeaderView, QTreeWidgetItem, QMenu, QAbstractItemView, QInputDialog, QLineEdit ) -from E5Gui import E5MessageBox +from EricWidgets import EricMessageBox from .Ui_DjangoMigrationsListDialog import Ui_DjangoMigrationsListDialog @@ -42,8 +42,10 @@ super().__init__(parent) self.setupUi(self) - self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) - self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Close).setEnabled(False) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel).setDefault(True) self.ioEncoding = Preferences.getSystem("IOEncoding") @@ -64,7 +66,7 @@ self.tr("Name"), ]) self.migrationsList.setSelectionMode( - QAbstractItemView.ExtendedSelection) + QAbstractItemView.SelectionMode.ExtendedSelection) else: self.setWindowTitle(self.tr("Migrations Plan")) self.migrationsList.setHeaderLabels([ @@ -72,10 +74,10 @@ self.tr("Dependencies"), ]) self.migrationsList.setSelectionMode( - QAbstractItemView.SingleSelection) + QAbstractItemView.SelectionMode.SingleSelection) self.refreshButton = self.buttonBox.addButton( - self.tr("&Refresh"), QDialogButtonBox.ActionRole) + self.tr("&Refresh"), QDialogButtonBox.ButtonRole.ActionRole) self.refreshButton.setToolTip( self.tr("Press to refresh the list")) self.refreshButton.setEnabled(False) @@ -88,9 +90,13 @@ @param button button that was clicked @type QAbstractButton """ - if button == self.buttonBox.button(QDialogButtonBox.Close): + if button == self.buttonBox.button( + QDialogButtonBox.StandardButton.Close + ): self.close() - elif button == self.buttonBox.button(QDialogButtonBox.Cancel): + elif button == self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel + ): self.__finish() elif button == self.refreshButton: self.on_refreshButton_clicked() @@ -102,15 +108,18 @@ """ if ( self.proc is not None and - self.proc.state() != QProcess.NotRunning + self.proc.state() != QProcess.ProcessState.NotRunning ): self.proc.terminate() QTimer.singleShot(2000, self.proc.kill) self.proc.waitForFinished(3000) - self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) - self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) - self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Close).setEnabled(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel).setEnabled(False) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Close).setDefault(True) self.refreshButton.setEnabled(True) @@ -120,8 +129,10 @@ """ Private slot connected to the finished signal. - @param exitCode exit code of the process (integer) - @param exitStatus exit status of the process (QProcess.ExitStatus) + @param exitCode exit code of the process + @type int + @param exitStatus exit status of the process + @type QProcess.ExitStatus """ self.__finish() @@ -130,7 +141,7 @@ Private method to resize the list columns. """ self.migrationsList.header().resizeSections( - QHeaderView.ResizeToContents) + QHeaderView.ResizeMode.ResizeToContents) if self.__mode == DjangoMigrationsListDialog.MigrationsListMode: self.migrationsList.header().setStretchLastSection(True) @@ -174,7 +185,7 @@ procStarted = self.proc.waitForStarted() if not procStarted: self.buttonBox.setFocus() - E5MessageBox.critical( + EricMessageBox.critical( self, self.tr('Process Generation Error'), self.tr( @@ -220,9 +231,9 @@ else: itm = QTreeWidgetItem(self.migrationsList, [name]) if applied[1] == " ": - itm.setCheckState(0, Qt.Unchecked) + itm.setCheckState(0, Qt.CheckState.Unchecked) else: - itm.setCheckState(0, Qt.Checked) + itm.setCheckState(0, Qt.CheckState.Checked) def __createPlanItem(self, line): """ @@ -248,7 +259,7 @@ "", ]) if applied[1] != " ": - itm.setCheckState(0, Qt.Checked) + itm.setCheckState(0, Qt.CheckState.Checked) def __readStderr(self): """ @@ -269,9 +280,12 @@ """ Private slot to refresh the log. """ - self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) - self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) - self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Close).setEnabled(False) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel).setEnabled(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel).setDefault(True) self.refreshButton.setEnabled(False) @@ -381,7 +395,7 @@ self.tr("Make Migrations"), self.tr("Enter a name for the migrations (leave empty to" " use system supplied name):"), - QLineEdit.Normal) + QLineEdit.EchoMode.Normal) if ok: self.__django.makeMigrations(apps, migration, dryRun, empty,