Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesQueueManagementDialog.py

changeset 3008
7848489bcb92
parent 2962
d6c9d1ca2da4
child 3057
10516539f238
child 3160
209a07d7e401
equal deleted inserted replaced
3007:bad2e89047e7 3008:7848489bcb92
6 """ 6 """
7 Module implementing a dialog used by the queue management functions. 7 Module implementing a dialog used by the queue management functions.
8 """ 8 """
9 9
10 from PyQt4.QtCore import pyqtSlot, QProcess, QCoreApplication 10 from PyQt4.QtCore import pyqtSlot, QProcess, QCoreApplication
11 from PyQt4.QtGui import QDialog, QDialogButtonBox, QAbstractItemView, QListWidgetItem, \ 11 from PyQt4.QtGui import QDialog, QDialogButtonBox, QAbstractItemView, \
12 QAbstractButton 12 QListWidgetItem, QAbstractButton
13 13
14 from .Ui_HgQueuesQueueManagementDialog import Ui_HgQueuesQueueManagementDialog 14 from .Ui_HgQueuesQueueManagementDialog import Ui_HgQueuesQueueManagementDialog
15 15
16 import Preferences 16 import Preferences
17 17
30 30
31 @param mode mode of the dialog (HgQueuesQueueManagementDialog.NO_INPUT 31 @param mode mode of the dialog (HgQueuesQueueManagementDialog.NO_INPUT
32 HgQueuesQueueManagementDialog.NAME_INPUT, 32 HgQueuesQueueManagementDialog.NAME_INPUT,
33 HgQueuesQueueManagementDialog.QUEUE_INPUT) 33 HgQueuesQueueManagementDialog.QUEUE_INPUT)
34 @param title title for the dialog (string) 34 @param title title for the dialog (string)
35 @param suppressActive flag indicating to not show the name of the active 35 @param suppressActive flag indicating to not show the name of the
36 queue (boolean) 36 active queue (boolean)
37 @param repodir name of the repository directory (string) 37 @param repodir name of the repository directory (string)
38 @param vcs reference to the vcs object 38 @param vcs reference to the vcs object
39 @param parent reference to the parent widget (QWidget) 39 @param parent reference to the parent widget (QWidget)
40 @exception ValueError raised to indicate an invalid dialog mode 40 @exception ValueError raised to indicate an invalid dialog mode
41 """ 41 """
50 self.__mode = mode 50 self.__mode = mode
51 self.__repodir = repodir 51 self.__repodir = repodir
52 self.__suppressActive = suppressActive 52 self.__suppressActive = suppressActive
53 self.__hgClient = vcs.getClient() 53 self.__hgClient = vcs.getClient()
54 54
55 self.inputFrame.setHidden(mode != HgQueuesQueueManagementDialog.NAME_INPUT) 55 self.inputFrame.setHidden(
56 self.selectLabel.setHidden(mode != HgQueuesQueueManagementDialog.QUEUE_INPUT) 56 mode != HgQueuesQueueManagementDialog.NAME_INPUT)
57 self.selectLabel.setHidden(
58 mode != HgQueuesQueueManagementDialog.QUEUE_INPUT)
57 if mode != HgQueuesQueueManagementDialog.QUEUE_INPUT: 59 if mode != HgQueuesQueueManagementDialog.QUEUE_INPUT:
58 self.queuesList.setSelectionMode(QAbstractItemView.NoSelection) 60 self.queuesList.setSelectionMode(QAbstractItemView.NoSelection)
59 61
60 if mode == HgQueuesQueueManagementDialog.NO_INPUT: 62 if mode == HgQueuesQueueManagementDialog.NO_INPUT:
61 self.buttonBox.removeButton(self.buttonBox.button(QDialogButtonBox.Ok)) 63 self.buttonBox.removeButton(
62 self.buttonBox.removeButton(self.buttonBox.button(QDialogButtonBox.Cancel)) 64 self.buttonBox.button(QDialogButtonBox.Ok))
65 self.buttonBox.removeButton(
66 self.buttonBox.button(QDialogButtonBox.Cancel))
63 self.refreshButton = self.buttonBox.addButton( 67 self.refreshButton = self.buttonBox.addButton(
64 self.trUtf8("Refresh"), QDialogButtonBox.ActionRole) 68 self.trUtf8("Refresh"), QDialogButtonBox.ActionRole)
65 self.refreshButton.setToolTip( 69 self.refreshButton.setToolTip(
66 self.trUtf8("Press to refresh the queues list")) 70 self.trUtf8("Press to refresh the queues list"))
67 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 71 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
68 else: 72 else:
69 self.buttonBox.removeButton(self.buttonBox.button(QDialogButtonBox.Close)) 73 self.buttonBox.removeButton(
74 self.buttonBox.button(QDialogButtonBox.Close))
70 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) 75 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
71 self.refreshButton = None 76 self.refreshButton = None
72 77
73 self.setWindowTitle(title) 78 self.setWindowTitle(title)
74 79
77 82
78 self.refresh() 83 self.refresh()
79 84
80 def __getQueuesList(self): 85 def __getQueuesList(self):
81 """ 86 """
82 Public method to get a list of all queues and the name of the active queue. 87 Public method to get a list of all queues and the name of the active
88 queue.
83 89
84 @return tuple with a list of all queues and the name of the active queue 90 @return tuple with a list of all queues and the name of the active
85 (list of strings, string) 91 queue (list of strings, string)
86 """ 92 """
87 queuesList = [] 93 queuesList = []
88 activeQueue = "" 94 activeQueue = ""
89 95
90 args = [] 96 args = []
101 process.start('hg', args) 107 process.start('hg', args)
102 procStarted = process.waitForStarted(5000) 108 procStarted = process.waitForStarted(5000)
103 if procStarted: 109 if procStarted:
104 finished = process.waitForFinished(30000) 110 finished = process.waitForFinished(30000)
105 if finished and process.exitCode() == 0: 111 if finished and process.exitCode() == 0:
106 output = \ 112 output = str(
107 str(process.readAllStandardOutput(), ioEncoding, 'replace') 113 process.readAllStandardOutput(), ioEncoding, 'replace')
108 114
109 for queue in output.splitlines(): 115 for queue in output.splitlines():
110 queue = queue.strip() 116 queue = queue.strip()
111 if queue.endswith(")"): 117 if queue.endswith(")"):
112 queue = queue.rsplit(None, 1)[0] 118 queue = queue.rsplit(None, 1)[0]

eric ide

mercurial