eric6/Plugins/VcsPlugins/vcsMercurial/ShelveExtension/HgShelvesSelectionDialog.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7780
41420f82c0ac
child 8143
2c730d5fd177
permissions
-rw-r--r--

Updated copyright for 2021.

3297
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2014 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4543
2e6a880670e9 Fixed a few code style issues (forgotten future imports, copyrights,...).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
4 #
2e6a880670e9 Fixed a few code style issues (forgotten future imports, copyrights,...).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
5
3297
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to select multiple shelve names.
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
10 from PyQt5.QtCore import pyqtSlot
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
11 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
3297
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from .Ui_HgShelvesSelectionDialog import Ui_HgShelvesSelectionDialog
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 class HgShelvesSelectionDialog(QDialog, Ui_HgShelvesSelectionDialog):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 Class implementing a dialog to select multiple shelve names.
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 def __init__(self, message, shelveNames, parent=None):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 Constructor
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
3359
6b6c224d67d6 Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3297
diff changeset
24 @param message message to be shown (string)
6b6c224d67d6 Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3297
diff changeset
25 @param shelveNames list of shelve names (list of string)
3297
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 @param parent reference to the parent widget (QWidget)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
3484
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3359
diff changeset
28 super(HgShelvesSelectionDialog, self).__init__(parent)
3297
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 self.setupUi(self)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 self.message.setText(message)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 self.shelvesList.addItems(shelveNames)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 @pyqtSlot()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 def on_shelvesList_itemSelectionChanged(self):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 Private slot to enabled the OK button if items have been selected.
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 len(self.shelvesList.selectedItems()) > 0)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 def getSelectedShelves(self):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 Public method to retrieve the selected shelve names.
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 @return selected shelve names (list of string)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 names = []
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 for itm in self.shelvesList.selectedItems():
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 names.append(itm.text())
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 return names

eric ide

mercurial