eric6/Plugins/VcsPlugins/vcsMercurial/HisteditExtension/HgHisteditPlanEditor.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 7836
2f0d208b8137
child 8218
7c09585bd960
permissions
-rw-r--r--

Updated copyright for 2021.

5283
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7836
diff changeset
3 # Copyright (c) 2016 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
5283
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to edit the history modification plan.
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from PyQt5.QtCore import pyqtSlot, QCoreApplication
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem, QComboBox
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from E5Gui import E5MessageBox
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from Ui_HgHisteditPlanEditor import Ui_HgHisteditPlanEditor
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 import UI.PixmapCache
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 class HgHisteditPlanActionComboBox(QComboBox):
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 Class implementing a combo box to select the action in the plan tree.
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 def __init__(self, item, column):
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 Constructor
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @param item reference to the item
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @type QTreeWidgetItem
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @param column column number inside the tree widget item
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @type int
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 super(HgHisteditPlanActionComboBox, self).__init__()
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 self.__item = item
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.__column = column
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.addItems(["pick", "drop", "mess", "fold", "roll", "edit"])
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 txt = self.__item.text(self.__column)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 index = self.findText(txt)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 if index > -1:
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.setCurrentIndex(index)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.currentIndexChanged.connect(self.__changeItem)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 @pyqtSlot(int)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 def __changeItem(self, index):
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 Private slot to handle the selection of a plan action.
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 This method sets the text of the associated item for the specified
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 cell in order to be able to retrieve it with a call of the text()
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 method of the item.
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 @param index index of the selected action
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 @type int
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.__item.setText(self.__column, self.currentText())
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 self.__item.treeWidget().setCurrentItem(self.__item)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 def showPopup(self):
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 Public method to show the list of items of the combo box.
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 This is reimplemented in order to set the associated item as the
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 current item of the tree widget.
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 self.__item.treeWidget().setCurrentItem(self.__item)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 super(HgHisteditPlanActionComboBox, self).showPopup()
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 class HgHisteditPlanEditor(QDialog, Ui_HgHisteditPlanEditor):
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 Class implementing a dialog to edit the history modification plan.
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 def __init__(self, fileName, parent=None):
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 Constructor
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 @param fileName name of the file containing the history edit plan
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 to be edited
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 @type str
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 @param parent reference to the parent widget
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 @type QWidget
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 super(HgHisteditPlanEditor, self).__init__(parent)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.setupUi(self)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
89 self.upButton.setIcon(UI.PixmapCache.getIcon("1uparrow"))
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
90 self.downButton.setIcon(UI.PixmapCache.getIcon("1downarrow"))
5283
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 self.planTreeWidget.headerItem().setText(
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 self.planTreeWidget.columnCount(), "")
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 self.__fileName = fileName
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 self.__readFile()
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 self.__updateButtons()
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 def __readFile(self):
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 Private method to read the file containing the edit plan and
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 populate the dialog.
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 try:
7785
9978016560ec Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
106 with open(self.__fileName, "r") as f:
9978016560ec Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
107 txt = f.read()
7836
2f0d208b8137 Changed code to not use the OSError aliases (IOError, EnvironmentError, socket.error and select.error) anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7785
diff changeset
108 except OSError as err:
5283
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 E5MessageBox.critical(
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 self,
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 self.tr("Edit Plan"),
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 self.tr("""<p>The file <b>{0}</b> could not be read.</p>"""
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 """<p>Reason: {1}</p>""").format(
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 self.__fileName, str(err)))
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 self.on_buttonBox_rejected()
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 return
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 infoLines = []
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 for line in txt.splitlines():
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 if line.startswith("#"):
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 infoLines.append(line[1:].lstrip())
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 else:
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 self.__createPlanItem(line)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 self.infoEdit.setPlainText("\n".join(infoLines))
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 self.__resizeSections()
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 def __addActionCombo(self, item):
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 Private method to add an edit action combo to an item.
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 @param item reference to the tree widget item
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 @type QTreeWidgetItem
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 actionCombo = HgHisteditPlanActionComboBox(item, 0)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 self.planTreeWidget.setItemWidget(item, 0, actionCombo)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 item.setSizeHint(0, actionCombo.sizeHint())
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 def __createPlanItem(self, text):
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 Private method to create an edit plan tree item.
5291
e93d14b48c34 Corrected some code style issues and regenerated the source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5283
diff changeset
142
e93d14b48c34 Corrected some code style issues and regenerated the source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5283
diff changeset
143 @param text line of text to be parsed
e93d14b48c34 Corrected some code style issues and regenerated the source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5283
diff changeset
144 @type str
5283
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 if not text.lstrip():
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 return
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 parts = text.split(" ", 3)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 action = parts[0]
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 try:
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 rev = int(parts[2])
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 if len(parts) > 3:
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 summary = parts[3]
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 else:
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 summary = ""
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 except ValueError:
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 rev = -1
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 summary = " ".join(parts[2:])
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 if rev > -1:
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 revision = "{0:>7}:{1}".format(rev, parts[1])
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 else:
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 revision = parts[1]
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 itm = QTreeWidgetItem(self.planTreeWidget, [
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 action,
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 revision,
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 summary,
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 ])
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 self.__addActionCombo(itm)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 def __resizeSections(self):
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 Private method to resize the tree widget sections.
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 for column in range(self.planTreeWidget.columnCount()):
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 self.planTreeWidget.resizeColumnToContents(column)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 self.planTreeWidget.header().setStretchLastSection(True)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 def __updateButtons(self):
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 Private method to set the enabled state of the up and down buttons.
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 if self.planTreeWidget.currentItem() is None:
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 self.upButton.setEnabled(False)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 self.downButton.setEnabled(False)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 else:
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 row = self.planTreeWidget.indexOfTopLevelItem(
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 self.planTreeWidget.currentItem())
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 self.upButton.setEnabled(row > 0)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 self.downButton.setEnabled(
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 row < self.planTreeWidget.topLevelItemCount() - 1)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 def on_planTreeWidget_currentItemChanged(self, current, previous):
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 Private slot handling the change of the current edit plan item.
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 @param current reference to the current edit plan item
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 @type QTreeWidgetItem
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 @param previous reference to the previous current edit plan item
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 @type QTreeWidgetItem
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 self.__updateButtons()
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 @pyqtSlot()
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 def on_upButton_clicked(self):
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 Private slot to move the current entry up one line.
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 row = self.planTreeWidget.indexOfTopLevelItem(
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 self.planTreeWidget.currentItem())
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 if row > 0:
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 targetRow = row - 1
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 itm = self.planTreeWidget.takeTopLevelItem(row)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 self.planTreeWidget.insertTopLevelItem(targetRow, itm)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 self.__addActionCombo(itm)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 self.planTreeWidget.setCurrentItem(itm)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 @pyqtSlot()
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 def on_downButton_clicked(self):
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 Private slot to move the current entry down one line.
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 row = self.planTreeWidget.indexOfTopLevelItem(
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 self.planTreeWidget.currentItem())
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 if row < self.planTreeWidget.topLevelItemCount() - 1:
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 targetRow = row + 1
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 itm = self.planTreeWidget.takeTopLevelItem(row)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 self.planTreeWidget.insertTopLevelItem(targetRow, itm)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 self.__addActionCombo(itm)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 self.planTreeWidget.setCurrentItem(itm)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 @pyqtSlot()
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 def on_buttonBox_accepted(self):
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 Private slot called by the buttonBox accepted signal.
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 text = self.__assembleEditPlan()
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 try:
7785
9978016560ec Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
241 with open(self.__fileName, "w") as f:
9978016560ec Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
242 f.write(text)
7836
2f0d208b8137 Changed code to not use the OSError aliases (IOError, EnvironmentError, socket.error and select.error) anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7785
diff changeset
243 except OSError as err:
5283
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 E5MessageBox.critical(
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 self,
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 self.tr("Edit Plan"),
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 self.tr("""<p>The file <b>{0}</b> could not be read.</p>"""
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 """<p>Reason: {1}</p>""").format(
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 self.__fileName, str(err)))
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 self.on_buttonBox_rejected()
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 return
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 self.close()
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 QCoreApplication.exit(0)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 @pyqtSlot()
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 def on_buttonBox_rejected(self):
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 Private slot called by the buttonBox rejected signal.
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 self.close()
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 QCoreApplication.exit(1)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 def __assembleEditPlan(self):
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 Private method to assemble the edit plan into text suitable for the
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 histedit file.
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 @return assembled edit plan text
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 @rtype str
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 """
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 lines = []
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 for row in range(self.planTreeWidget.topLevelItemCount()):
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 itm = self.planTreeWidget.topLevelItem(row)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 if ":" in itm.text(1):
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 rev, changeset = itm.text(1).split(":", 1)
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 rev = "{0} {1}".format(changeset.strip(), rev.strip())
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 else:
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 rev = itm.text(1).strip()
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 lines.append("{0} {1} {2}".format(itm.text(0).strip(), rev,
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 itm.text(2)))
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283
06423d65a2b8 Added support for the Mercurial histedit extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 return "\n".join(lines)

eric ide

mercurial