12 str = unicode # __IGNORE_WARNING__ |
12 str = unicode # __IGNORE_WARNING__ |
13 except NameError: |
13 except NameError: |
14 pass |
14 pass |
15 |
15 |
16 from PyQt5.QtCore import pyqtSlot, Qt, QProcess, QTimer, QPoint |
16 from PyQt5.QtCore import pyqtSlot, Qt, QProcess, QTimer, QPoint |
17 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QAbstractButton, \ |
17 from PyQt5.QtWidgets import ( |
18 QHeaderView, QTreeWidgetItem, QMenu, QAbstractItemView, QInputDialog, \ |
18 QDialog, QDialogButtonBox, QAbstractButton, |
|
19 QHeaderView, QTreeWidgetItem, QMenu, QAbstractItemView, QInputDialog, |
19 QLineEdit |
20 QLineEdit |
|
21 ) |
20 |
22 |
21 from E5Gui import E5MessageBox |
23 from E5Gui import E5MessageBox |
22 |
24 |
23 from .Ui_DjangoMigrationsListDialog import Ui_DjangoMigrationsListDialog |
25 from .Ui_DjangoMigrationsListDialog import Ui_DjangoMigrationsListDialog |
24 |
26 |
102 def __finish(self): |
104 def __finish(self): |
103 """ |
105 """ |
104 Private slot called when the process finished or the user pressed the |
106 Private slot called when the process finished or the user pressed the |
105 button. |
107 button. |
106 """ |
108 """ |
107 if self.proc is not None and \ |
109 if ( |
108 self.proc.state() != QProcess.NotRunning: |
110 self.proc is not None and |
|
111 self.proc.state() != QProcess.NotRunning |
|
112 ): |
109 self.proc.terminate() |
113 self.proc.terminate() |
110 QTimer.singleShot(2000, self.proc.kill) |
114 QTimer.singleShot(2000, self.proc.kill) |
111 self.proc.waitForFinished(3000) |
115 self.proc.waitForFinished(3000) |
112 |
116 |
113 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
117 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
307 self.__unapplyMigration).setEnabled(len(selApps) == 1) |
311 self.__unapplyMigration).setEnabled(len(selApps) == 1) |
308 menu.addSeparator() |
312 menu.addSeparator() |
309 menu.addAction( |
313 menu.addAction( |
310 self.tr("Make Migrations"), |
314 self.tr("Make Migrations"), |
311 self.__makeMigrations).setEnabled(len(selApps) > 0) |
315 self.__makeMigrations).setEnabled(len(selApps) > 0) |
312 menu.addAction( |
316 act = menu.addAction( |
313 self.tr("Make Empty Migrations"), |
317 self.tr("Make Empty Migrations"), |
314 lambda: self.__makeMigrations(empty=True))\ |
318 lambda: self.__makeMigrations(empty=True)) |
315 .setEnabled(len(selApps) > 0) |
319 act.setEnabled(len(selApps) > 0) |
316 menu.addAction( |
320 act = menu.addAction( |
317 self.tr("Make Migrations (dry-run)"), |
321 self.tr("Make Migrations (dry-run)"), |
318 lambda: self.__makeMigrations(dryRun=True))\ |
322 lambda: self.__makeMigrations(dryRun=True)) |
319 .setEnabled(len(selApps) > 0) |
323 act.setEnabled(len(selApps) > 0) |
320 else: |
324 else: |
321 menu.addAction(self.tr("Apply Selected Migrations"), |
325 menu.addAction(self.tr("Apply Selected Migrations"), |
322 self.__applyMigration) |
326 self.__applyMigration) |
323 |
327 |
324 menu.popup(self.migrationsList.mapToGlobal(pos)) |
328 menu.popup(self.migrationsList.mapToGlobal(pos)) |