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 import os |
11 import os |
11 |
12 |
12 from PyQt4.QtCore import pyqtSlot, Qt, QProcess, QTimer |
13 from PyQt4.QtCore import pyqtSlot, Qt, QProcess, QTimer |
13 from PyQt4.QtGui import QWidget, QDialogButtonBox, QMenu, QHeaderView, QTreeWidgetItem, \ |
14 from PyQt4.QtGui import QWidget, QDialogButtonBox, QMenu, QHeaderView, \ |
14 QLineEdit |
15 QTreeWidgetItem, QLineEdit |
15 |
16 |
16 from E5Gui.E5Application import e5App |
17 from E5Gui.E5Application import e5App |
17 from E5Gui import E5MessageBox |
18 from E5Gui import E5MessageBox |
18 |
19 |
19 from .Ui_HgStatusDialog import Ui_HgStatusDialog |
20 from .Ui_HgStatusDialog import Ui_HgStatusDialog |
21 import Preferences |
22 import Preferences |
22 |
23 |
23 |
24 |
24 class HgStatusDialog(QWidget, Ui_HgStatusDialog): |
25 class HgStatusDialog(QWidget, Ui_HgStatusDialog): |
25 """ |
26 """ |
26 Class implementing a dialog to show the output of the hg status command process. |
27 Class implementing a dialog to show the output of the hg status command |
|
28 process. |
27 """ |
29 """ |
28 def __init__(self, vcs, mq=False, parent=None): |
30 def __init__(self, vcs, mq=False, parent=None): |
29 """ |
31 """ |
30 Constructor |
32 Constructor |
31 |
33 |
39 self.__toBeCommittedColumn = 0 |
41 self.__toBeCommittedColumn = 0 |
40 self.__statusColumn = 1 |
42 self.__statusColumn = 1 |
41 self.__pathColumn = 2 |
43 self.__pathColumn = 2 |
42 self.__lastColumn = self.statusList.columnCount() |
44 self.__lastColumn = self.statusList.columnCount() |
43 |
45 |
44 self.refreshButton = \ |
46 self.refreshButton = self.buttonBox.addButton( |
45 self.buttonBox.addButton(self.trUtf8("Refresh"), QDialogButtonBox.ActionRole) |
47 self.trUtf8("Refresh"), QDialogButtonBox.ActionRole) |
46 self.refreshButton.setToolTip(self.trUtf8("Press to refresh the status display")) |
48 self.refreshButton.setToolTip( |
|
49 self.trUtf8("Press to refresh the status display")) |
47 self.refreshButton.setEnabled(False) |
50 self.refreshButton.setEnabled(False) |
48 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
51 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
49 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
52 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
50 |
53 |
51 self.diff = None |
54 self.diff = None |
54 self.vcs.committed.connect(self.__committed) |
57 self.vcs.committed.connect(self.__committed) |
55 self.__hgClient = self.vcs.getClient() |
58 self.__hgClient = self.vcs.getClient() |
56 self.__mq = mq |
59 self.__mq = mq |
57 |
60 |
58 self.statusList.headerItem().setText(self.__lastColumn, "") |
61 self.statusList.headerItem().setText(self.__lastColumn, "") |
59 self.statusList.header().setSortIndicator(self.__pathColumn, Qt.AscendingOrder) |
62 self.statusList.header().setSortIndicator( |
|
63 self.__pathColumn, Qt.AscendingOrder) |
60 |
64 |
61 if mq: |
65 if mq: |
62 self.buttonsLine.setVisible(False) |
66 self.buttonsLine.setVisible(False) |
63 self.addButton.setVisible(False) |
67 self.addButton.setVisible(False) |
64 self.diffButton.setVisible(False) |
68 self.diffButton.setVisible(False) |
73 self.menuactions.append(self.menu.addAction( |
77 self.menuactions.append(self.menu.addAction( |
74 self.trUtf8("Commit changes to repository..."), self.__commit)) |
78 self.trUtf8("Commit changes to repository..."), self.__commit)) |
75 self.menuactions.append(self.menu.addAction( |
79 self.menuactions.append(self.menu.addAction( |
76 self.trUtf8("Select all for commit"), self.__commitSelectAll)) |
80 self.trUtf8("Select all for commit"), self.__commitSelectAll)) |
77 self.menuactions.append(self.menu.addAction( |
81 self.menuactions.append(self.menu.addAction( |
78 self.trUtf8("Deselect all from commit"), self.__commitDeselectAll)) |
82 self.trUtf8("Deselect all from commit"), |
|
83 self.__commitDeselectAll)) |
79 self.menu.addSeparator() |
84 self.menu.addSeparator() |
80 self.menuactions.append(self.menu.addAction( |
85 self.menuactions.append(self.menu.addAction( |
81 self.trUtf8("Add to repository"), self.__add)) |
86 self.trUtf8("Add to repository"), self.__add)) |
82 self.menuactions.append(self.menu.addAction( |
87 self.menuactions.append(self.menu.addAction( |
83 self.trUtf8("Show differences"), self.__diff)) |
88 self.trUtf8("Show differences"), self.__diff)) |
94 self.trUtf8("Adjust column sizes"), self.__resizeColumns)) |
99 self.trUtf8("Adjust column sizes"), self.__resizeColumns)) |
95 for act in self.menuactions: |
100 for act in self.menuactions: |
96 act.setEnabled(False) |
101 act.setEnabled(False) |
97 |
102 |
98 self.statusList.setContextMenuPolicy(Qt.CustomContextMenu) |
103 self.statusList.setContextMenuPolicy(Qt.CustomContextMenu) |
99 self.statusList.customContextMenuRequested.connect(self.__showContextMenu) |
104 self.statusList.customContextMenuRequested.connect( |
|
105 self.__showContextMenu) |
100 |
106 |
101 self.modifiedIndicators = [ |
107 self.modifiedIndicators = [ |
102 self.trUtf8('added'), |
108 self.trUtf8('added'), |
103 self.trUtf8('modified'), |
109 self.trUtf8('modified'), |
104 self.trUtf8('removed'), |
110 self.trUtf8('removed'), |
204 |
210 |
205 self.statusFilterCombo.clear() |
211 self.statusFilterCombo.clear() |
206 self.__statusFilters = [] |
212 self.__statusFilters = [] |
207 |
213 |
208 if self.__mq: |
214 if self.__mq: |
209 self.setWindowTitle(self.trUtf8("Mercurial Queue Repository Status")) |
215 self.setWindowTitle( |
|
216 self.trUtf8("Mercurial Queue Repository Status")) |
210 else: |
217 else: |
211 self.setWindowTitle(self.trUtf8('Mercurial Status')) |
218 self.setWindowTitle(self.trUtf8('Mercurial Status')) |
212 |
219 |
213 args = [] |
220 args = [] |
214 args.append('status') |
221 args.append('status') |
278 self.inputGroup.setEnabled(True) |
285 self.inputGroup.setEnabled(True) |
279 self.inputGroup.show() |
286 self.inputGroup.show() |
280 |
287 |
281 def __finish(self): |
288 def __finish(self): |
282 """ |
289 """ |
283 Private slot called when the process finished or the user pressed the button. |
290 Private slot called when the process finished or the user pressed |
|
291 the button. |
284 """ |
292 """ |
285 if self.process is not None and \ |
293 if self.process is not None and \ |
286 self.process.state() != QProcess.NotRunning: |
294 self.process.state() != QProcess.NotRunning: |
287 self.process.terminate() |
295 self.process.terminate() |
288 QTimer.singleShot(2000, self.process.kill) |
296 QTimer.singleShot(2000, self.process.kill) |
293 self.refreshButton.setEnabled(True) |
301 self.refreshButton.setEnabled(True) |
294 |
302 |
295 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
303 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
296 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
304 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
297 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
305 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
298 self.buttonBox.button(QDialogButtonBox.Close).setFocus(Qt.OtherFocusReason) |
306 self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
|
307 Qt.OtherFocusReason) |
299 |
308 |
300 self.__statusFilters.sort() |
309 self.__statusFilters.sort() |
301 self.__statusFilters.insert(0, "<{0}>".format(self.trUtf8("all"))) |
310 self.__statusFilters.insert(0, "<{0}>".format(self.trUtf8("all"))) |
302 self.statusFilterCombo.addItems(self.__statusFilters) |
311 self.statusFilterCombo.addItems(self.__statusFilters) |
303 |
312 |
556 """ |
565 """ |
557 Private slot to handle the press of the Restore button. |
566 Private slot to handle the press of the Restore button. |
558 """ |
567 """ |
559 self.__restoreMissing() |
568 self.__restoreMissing() |
560 |
569 |
561 ############################################################################ |
570 ########################################################################### |
562 ## Context menu handling methods |
571 ## Context menu handling methods |
563 ############################################################################ |
572 ########################################################################### |
564 |
573 |
565 def __showContextMenu(self, coord): |
574 def __showContextMenu(self, coord): |
566 """ |
575 """ |
567 Protected slot to show the context menu of the status list. |
576 Protected slot to show the context menu of the status list. |
568 |
577 |
754 modifiedItems.append(itm) |
763 modifiedItems.append(itm) |
755 return modifiedItems |
764 return modifiedItems |
756 |
765 |
757 def __getUnversionedItems(self): |
766 def __getUnversionedItems(self): |
758 """ |
767 """ |
759 Private method to retrieve all entries, that have an unversioned status. |
768 Private method to retrieve all entries, that have an unversioned |
|
769 status. |
760 |
770 |
761 @return list of all items with an unversioned status |
771 @return list of all items with an unversioned status |
762 """ |
772 """ |
763 unversionedItems = [] |
773 unversionedItems = [] |
764 for itm in self.statusList.selectedItems(): |
774 for itm in self.statusList.selectedItems(): |