Plugins/VcsPlugins/vcsMercurial/HgStatusDialog.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2847
1843ef6e2656
parent 3008
7848489bcb92
child 3058
0a02c433f52d
equal deleted inserted replaced
3056:9986ec0e559a 3057:10516539f238
2 2
3 # Copyright (c) 2010 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> 3 # Copyright (c) 2010 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
4 # 4 #
5 5
6 """ 6 """
7 Module implementing a dialog to show the output of the hg status command process. 7 Module implementing a dialog to show the output of the hg status command
8 process.
8 """ 9 """
9 10
10 from __future__ import unicode_literals # __IGNORE_WARNING__ 11 from __future__ import unicode_literals # __IGNORE_WARNING__
11 try: 12 try:
12 str = unicode 13 str = unicode
14 pass 15 pass
15 16
16 import os 17 import os
17 18
18 from PyQt4.QtCore import pyqtSlot, Qt, QProcess, QTimer 19 from PyQt4.QtCore import pyqtSlot, Qt, QProcess, QTimer
19 from PyQt4.QtGui import QWidget, QDialogButtonBox, QMenu, QHeaderView, QTreeWidgetItem, \ 20 from PyQt4.QtGui import QWidget, QDialogButtonBox, QMenu, QHeaderView, \
20 QLineEdit 21 QTreeWidgetItem, QLineEdit
21 22
22 from E5Gui.E5Application import e5App 23 from E5Gui.E5Application import e5App
23 from E5Gui import E5MessageBox 24 from E5Gui import E5MessageBox
24 25
25 from .Ui_HgStatusDialog import Ui_HgStatusDialog 26 from .Ui_HgStatusDialog import Ui_HgStatusDialog
27 import Preferences 28 import Preferences
28 29
29 30
30 class HgStatusDialog(QWidget, Ui_HgStatusDialog): 31 class HgStatusDialog(QWidget, Ui_HgStatusDialog):
31 """ 32 """
32 Class implementing a dialog to show the output of the hg status command process. 33 Class implementing a dialog to show the output of the hg status command
34 process.
33 """ 35 """
34 def __init__(self, vcs, mq=False, parent=None): 36 def __init__(self, vcs, mq=False, parent=None):
35 """ 37 """
36 Constructor 38 Constructor
37 39
45 self.__toBeCommittedColumn = 0 47 self.__toBeCommittedColumn = 0
46 self.__statusColumn = 1 48 self.__statusColumn = 1
47 self.__pathColumn = 2 49 self.__pathColumn = 2
48 self.__lastColumn = self.statusList.columnCount() 50 self.__lastColumn = self.statusList.columnCount()
49 51
50 self.refreshButton = \ 52 self.refreshButton = self.buttonBox.addButton(
51 self.buttonBox.addButton(self.trUtf8("Refresh"), QDialogButtonBox.ActionRole) 53 self.trUtf8("Refresh"), QDialogButtonBox.ActionRole)
52 self.refreshButton.setToolTip(self.trUtf8("Press to refresh the status display")) 54 self.refreshButton.setToolTip(
55 self.trUtf8("Press to refresh the status display"))
53 self.refreshButton.setEnabled(False) 56 self.refreshButton.setEnabled(False)
54 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 57 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
55 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 58 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
56 59
57 self.diff = None 60 self.diff = None
60 self.vcs.committed.connect(self.__committed) 63 self.vcs.committed.connect(self.__committed)
61 self.__hgClient = self.vcs.getClient() 64 self.__hgClient = self.vcs.getClient()
62 self.__mq = mq 65 self.__mq = mq
63 66
64 self.statusList.headerItem().setText(self.__lastColumn, "") 67 self.statusList.headerItem().setText(self.__lastColumn, "")
65 self.statusList.header().setSortIndicator(self.__pathColumn, Qt.AscendingOrder) 68 self.statusList.header().setSortIndicator(
69 self.__pathColumn, Qt.AscendingOrder)
66 70
67 if mq: 71 if mq:
68 self.buttonsLine.setVisible(False) 72 self.buttonsLine.setVisible(False)
69 self.addButton.setVisible(False) 73 self.addButton.setVisible(False)
70 self.diffButton.setVisible(False) 74 self.diffButton.setVisible(False)
79 self.menuactions.append(self.menu.addAction( 83 self.menuactions.append(self.menu.addAction(
80 self.trUtf8("Commit changes to repository..."), self.__commit)) 84 self.trUtf8("Commit changes to repository..."), self.__commit))
81 self.menuactions.append(self.menu.addAction( 85 self.menuactions.append(self.menu.addAction(
82 self.trUtf8("Select all for commit"), self.__commitSelectAll)) 86 self.trUtf8("Select all for commit"), self.__commitSelectAll))
83 self.menuactions.append(self.menu.addAction( 87 self.menuactions.append(self.menu.addAction(
84 self.trUtf8("Deselect all from commit"), self.__commitDeselectAll)) 88 self.trUtf8("Deselect all from commit"),
89 self.__commitDeselectAll))
85 self.menu.addSeparator() 90 self.menu.addSeparator()
86 self.menuactions.append(self.menu.addAction( 91 self.menuactions.append(self.menu.addAction(
87 self.trUtf8("Add to repository"), self.__add)) 92 self.trUtf8("Add to repository"), self.__add))
88 self.menuactions.append(self.menu.addAction( 93 self.menuactions.append(self.menu.addAction(
89 self.trUtf8("Show differences"), self.__diff)) 94 self.trUtf8("Show differences"), self.__diff))
100 self.trUtf8("Adjust column sizes"), self.__resizeColumns)) 105 self.trUtf8("Adjust column sizes"), self.__resizeColumns))
101 for act in self.menuactions: 106 for act in self.menuactions:
102 act.setEnabled(False) 107 act.setEnabled(False)
103 108
104 self.statusList.setContextMenuPolicy(Qt.CustomContextMenu) 109 self.statusList.setContextMenuPolicy(Qt.CustomContextMenu)
105 self.statusList.customContextMenuRequested.connect(self.__showContextMenu) 110 self.statusList.customContextMenuRequested.connect(
111 self.__showContextMenu)
106 112
107 self.modifiedIndicators = [ 113 self.modifiedIndicators = [
108 self.trUtf8('added'), 114 self.trUtf8('added'),
109 self.trUtf8('modified'), 115 self.trUtf8('modified'),
110 self.trUtf8('removed'), 116 self.trUtf8('removed'),
210 216
211 self.statusFilterCombo.clear() 217 self.statusFilterCombo.clear()
212 self.__statusFilters = [] 218 self.__statusFilters = []
213 219
214 if self.__mq: 220 if self.__mq:
215 self.setWindowTitle(self.trUtf8("Mercurial Queue Repository Status")) 221 self.setWindowTitle(
222 self.trUtf8("Mercurial Queue Repository Status"))
216 else: 223 else:
217 self.setWindowTitle(self.trUtf8('Mercurial Status')) 224 self.setWindowTitle(self.trUtf8('Mercurial Status'))
218 225
219 args = [] 226 args = []
220 args.append('status') 227 args.append('status')
284 self.inputGroup.setEnabled(True) 291 self.inputGroup.setEnabled(True)
285 self.inputGroup.show() 292 self.inputGroup.show()
286 293
287 def __finish(self): 294 def __finish(self):
288 """ 295 """
289 Private slot called when the process finished or the user pressed the button. 296 Private slot called when the process finished or the user pressed
297 the button.
290 """ 298 """
291 if self.process is not None and \ 299 if self.process is not None and \
292 self.process.state() != QProcess.NotRunning: 300 self.process.state() != QProcess.NotRunning:
293 self.process.terminate() 301 self.process.terminate()
294 QTimer.singleShot(2000, self.process.kill) 302 QTimer.singleShot(2000, self.process.kill)
299 self.refreshButton.setEnabled(True) 307 self.refreshButton.setEnabled(True)
300 308
301 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) 309 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
302 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) 310 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
303 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 311 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
304 self.buttonBox.button(QDialogButtonBox.Close).setFocus(Qt.OtherFocusReason) 312 self.buttonBox.button(QDialogButtonBox.Close).setFocus(
313 Qt.OtherFocusReason)
305 314
306 self.__statusFilters.sort() 315 self.__statusFilters.sort()
307 self.__statusFilters.insert(0, "<{0}>".format(self.trUtf8("all"))) 316 self.__statusFilters.insert(0, "<{0}>".format(self.trUtf8("all")))
308 self.statusFilterCombo.addItems(self.__statusFilters) 317 self.statusFilterCombo.addItems(self.__statusFilters)
309 318
562 """ 571 """
563 Private slot to handle the press of the Restore button. 572 Private slot to handle the press of the Restore button.
564 """ 573 """
565 self.__restoreMissing() 574 self.__restoreMissing()
566 575
567 ############################################################################ 576 ###########################################################################
568 ## Context menu handling methods 577 ## Context menu handling methods
569 ############################################################################ 578 ###########################################################################
570 579
571 def __showContextMenu(self, coord): 580 def __showContextMenu(self, coord):
572 """ 581 """
573 Protected slot to show the context menu of the status list. 582 Protected slot to show the context menu of the status list.
574 583
760 modifiedItems.append(itm) 769 modifiedItems.append(itm)
761 return modifiedItems 770 return modifiedItems
762 771
763 def __getUnversionedItems(self): 772 def __getUnversionedItems(self):
764 """ 773 """
765 Private method to retrieve all entries, that have an unversioned status. 774 Private method to retrieve all entries, that have an unversioned
775 status.
766 776
767 @return list of all items with an unversioned status 777 @return list of all items with an unversioned status
768 """ 778 """
769 unversionedItems = [] 779 unversionedItems = []
770 for itm in self.statusList.selectedItems(): 780 for itm in self.statusList.selectedItems():

eric ide

mercurial