eric6/Plugins/VcsPlugins/vcsMercurial/HgBookmarksInOutDialog.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 7370
5fb53279f2df
child 7970
c4ee8a81584c
permissions
-rw-r--r--

Updated copyright for 2021.

1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
3 # Copyright (c) 2011 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to show a list of incoming or outgoing bookmarks.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
12 from PyQt5.QtCore import Qt, QCoreApplication
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
13 from PyQt5.QtWidgets import (
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
14 QDialog, QDialogButtonBox, QHeaderView, QTreeWidgetItem
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
15 )
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from .Ui_HgBookmarksInOutDialog import Ui_HgBookmarksInOutDialog
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 class HgBookmarksInOutDialog(QDialog, Ui_HgBookmarksInOutDialog):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
3008
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2962
diff changeset
22 Class implementing a dialog to show a list of incoming or outgoing
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2962
diff changeset
23 bookmarks.
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 INCOMING = 0
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 OUTGOING = 1
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 def __init__(self, vcs, mode, parent=None):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 Constructor
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @param vcs reference to the vcs object
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @param mode mode of the dialog (HgBookmarksInOutDialog.INCOMING,
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 HgBookmarksInOutDialog.OUTGOING)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 @param parent reference to the parent widget (QWidget)
2962
d6c9d1ca2da4 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
36 @exception ValueError raised to indicate an invalid dialog mode
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
38 super(HgBookmarksInOutDialog, self).__init__(parent)
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.setupUi(self)
4278
ccd1e13cb9bd Fixed issues where dialogs could not be minimized on some desktop environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4126
diff changeset
40 self.setWindowFlags(Qt.Window)
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 if mode not in [self.INCOMING, self.OUTGOING]:
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 raise ValueError("Bad value for mode")
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 if mode == self.INCOMING:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
48 self.setWindowTitle(self.tr("Mercurial Incoming Bookmarks"))
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 elif mode == self.OUTGOING:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
50 self.setWindowTitle(self.tr("Mercurial Outgoing Bookmarks"))
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.vcs = vcs
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.mode = mode
1251
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
54 self.__hgClient = vcs.getClient()
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
3008
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2962
diff changeset
56 self.bookmarksList.headerItem().setText(
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2962
diff changeset
57 self.bookmarksList.columnCount(), "")
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.bookmarksList.header().setSortIndicator(3, Qt.AscendingOrder)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59
1260
9488a3aceb0e Added code to some Mercurial dialogs to improve user experience.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1256
diff changeset
60 self.show()
9488a3aceb0e Added code to some Mercurial dialogs to improve user experience.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1256
diff changeset
61 QCoreApplication.processEvents()
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 def closeEvent(self, e):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3562
diff changeset
65 Protected slot implementing a close event handler.
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 @param e close event (QCloseEvent)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 """
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
69 if self.__hgClient.isExecuting():
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
70 self.__hgClient.cancel()
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 e.accept()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 def start(self, path):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 Public slot to start the bookmarks command.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 @param path name of directory to be listed (string)
2962
d6c9d1ca2da4 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
79 @exception ValueError raised to indicate an invalid dialog mode
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.errorGroup.hide()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 self.intercept = False
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 self.activateWindow()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 dname, fname = self.vcs.splitPath(path)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 # find the root of the repo
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 repodir = dname
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 repodir = os.path.dirname(repodir)
1318
6fa303bd65d6 Fixed issues in various Mercurial files that could cause infinite loops on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1260
diff changeset
92 if os.path.splitdrive(repodir)[1] == os.sep:
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 return
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 if self.mode == self.INCOMING:
3302
e92f0dd51979 Removed the Mercurial support for a command options dialog and added useable global options to the Mercurial config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
96 args = self.vcs.initCommand("incoming")
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 elif self.mode == self.OUTGOING:
3302
e92f0dd51979 Removed the Mercurial support for a command options dialog and added useable global options to the Mercurial config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
98 args = self.vcs.initCommand("outgoing")
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 else:
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 raise ValueError("Bad value for mode")
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 args.append('--bookmarks')
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
103 out, err = self.__hgClient.runcommand(args)
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
104 if err:
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
105 self.__showError(err)
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
106 if out:
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
107 for line in out.splitlines():
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
108 self.__processOutputLine(line)
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
109 if self.__hgClient.wasCanceled():
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
110 break
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
111 self.__finish()
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 def __finish(self):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 """
3008
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2962
diff changeset
115 Private slot called when the process finished or the user pressed
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2962
diff changeset
116 the button.
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
3008
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2962
diff changeset
121 self.buttonBox.button(QDialogButtonBox.Close).setFocus(
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2962
diff changeset
122 Qt.OtherFocusReason)
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 if self.bookmarksList.topLevelItemCount() == 0:
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 # no bookmarks defined
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
126 self.__generateItem(self.tr("no bookmarks found"), "")
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 self.__resizeColumns()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 self.__resort()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 def on_buttonBox_clicked(self, button):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 Private slot called by a button of the button box clicked.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 @param button button that was clicked (QAbstractButton)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 if button == self.buttonBox.button(QDialogButtonBox.Close):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 self.close()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 elif button == self.buttonBox.button(QDialogButtonBox.Cancel):
1251
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
139 if self.__hgClient:
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
140 self.__hgClient.cancel()
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
141 else:
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
142 self.__finish()
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 def __resort(self):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 Private method to resort the tree.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 """
3023
34ce20603bf7 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
148 self.bookmarksList.sortItems(
34ce20603bf7 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
149 self.bookmarksList.sortColumn(),
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 self.bookmarksList.header().sortIndicatorOrder())
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 def __resizeColumns(self):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 Private method to resize the list columns.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 """
3008
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2962
diff changeset
156 self.bookmarksList.header().resizeSections(
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2962
diff changeset
157 QHeaderView.ResizeToContents)
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 self.bookmarksList.header().setStretchLastSection(True)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 def __generateItem(self, changeset, name):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 Private method to generate a bookmark item in the bookmarks list.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 @param changeset changeset of the bookmark (string)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 @param name name of the bookmark (string)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 """
1251
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
167 QTreeWidgetItem(self.bookmarksList, [
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 name,
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 changeset])
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170
1251
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
171 def __processOutputLine(self, line):
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
172 """
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
173 Private method to process the lines of output.
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
174
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
175 @param line output line to be processed (string)
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
176 """
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
177 if line.startswith(" "):
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3023
diff changeset
178 li = line.strip().split()
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3023
diff changeset
179 changeset = li[-1]
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3023
diff changeset
180 del li[-1]
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3023
diff changeset
181 name = " ".join(li)
1251
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
182 self.__generateItem(changeset, name)
1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183
1251
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
184 def __showError(self, out):
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
185 """
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
186 Private slot to show some error.
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
187
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
188 @param out error to be shown (string)
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
189 """
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
190 self.errorGroup.show()
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
191 self.errors.insertPlainText(out)
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
192 self.errors.ensureCursorVisible()

eric ide

mercurial