Plugins/VcsPlugins/vcsMercurial/BookmarksExtension/HgBookmarksListDialog.py

Wed, 31 Aug 2011 19:28:49 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 31 Aug 2011 19:28:49 +0200
changeset 1256
885706dbb69f
parent 1251
d40491ba96ce
child 1260
9488a3aceb0e
permissions
-rw-r--r--

Refined the Mercurial command server interface.

1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3 # Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de>
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to show a list of bookmarks.
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt4.QtCore import pyqtSlot, QProcess, Qt, QTimer
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from PyQt4.QtGui import QDialog, QDialogButtonBox, QHeaderView, QTreeWidgetItem, \
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 QLineEdit
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 from E5Gui import E5MessageBox
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 from .Ui_HgBookmarksListDialog import Ui_HgBookmarksListDialog
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 import Preferences
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 class HgBookmarksListDialog(QDialog, Ui_HgBookmarksListDialog):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 Class implementing a dialog to show a list of bookmarks.
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 def __init__(self, vcs, parent=None):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 Constructor
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @param vcs reference to the vcs object
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @param parent parent widget (QWidget)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
1131
7781e396c903 Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1011
diff changeset
34 super().__init__(parent)
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 self.setupUi(self)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 self.process = QProcess()
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.vcs = vcs
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.__bookmarksList = None
1251
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
43 self.__hgClient = vcs.getClient()
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.bookmarksList.headerItem().setText(self.bookmarksList.columnCount(), "")
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self.bookmarksList.header().setSortIndicator(3, Qt.AscendingOrder)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.process.finished.connect(self.__procFinished)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.process.readyReadStandardOutput.connect(self.__readStdout)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.process.readyReadStandardError.connect(self.__readStderr)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 def closeEvent(self, e):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 Private slot implementing a close event handler.
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 @param e close event (QCloseEvent)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 """
1256
885706dbb69f Refined the Mercurial command server interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1251
diff changeset
58 if self.__hgClient:
885706dbb69f Refined the Mercurial command server interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1251
diff changeset
59 if self.__hgClient.isExecuting():
885706dbb69f Refined the Mercurial command server interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1251
diff changeset
60 self.__hgClient.cancel()
885706dbb69f Refined the Mercurial command server interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1251
diff changeset
61 else:
885706dbb69f Refined the Mercurial command server interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1251
diff changeset
62 if self.process is not None and \
885706dbb69f Refined the Mercurial command server interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1251
diff changeset
63 self.process.state() != QProcess.NotRunning:
885706dbb69f Refined the Mercurial command server interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1251
diff changeset
64 self.process.terminate()
885706dbb69f Refined the Mercurial command server interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1251
diff changeset
65 QTimer.singleShot(2000, self.process.kill)
885706dbb69f Refined the Mercurial command server interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1251
diff changeset
66 self.process.waitForFinished(3000)
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 e.accept()
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 def start(self, path, bookmarksList):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 Public slot to start the bookmarks command.
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 @param path name of directory to be listed (string)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 @param bookmarksList reference to string list receiving the bookmarks
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 (list of strings)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 self.errorGroup.hide()
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 self.intercept = False
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.activateWindow()
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 self.__bookmarksList = bookmarksList
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 dname, fname = self.vcs.splitPath(path)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 # find the root of the repo
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 repodir = dname
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 repodir = os.path.dirname(repodir)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 if repodir == os.sep:
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 return
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 args = []
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 args.append('bookmarks')
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95
1251
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
96 if self.__hgClient:
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 self.inputGroup.setEnabled(False)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 self.inputGroup.hide()
1251
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
99
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
100 out, err = self.__hgClient.runcommand(args)
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
101 if err:
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
102 self.__showError(err)
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
103 if out:
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
104 for line in out.splitlines():
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
105 self.__processOutputLine(line)
1256
885706dbb69f Refined the Mercurial command server interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1251
diff changeset
106 if self.__hgClient.wasCanceled():
885706dbb69f Refined the Mercurial command server interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1251
diff changeset
107 break
1251
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
108 self.__finish()
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 else:
1251
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
110 self.process.kill()
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
111 self.process.setWorkingDirectory(repodir)
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
112
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
113 self.process.start('hg', args)
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
114 procStarted = self.process.waitForStarted()
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
115 if not procStarted:
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
116 self.inputGroup.setEnabled(False)
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
117 self.inputGroup.hide()
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
118 E5MessageBox.critical(self,
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
119 self.trUtf8('Process Generation Error'),
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
120 self.trUtf8(
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
121 'The process {0} could not be started. '
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
122 'Ensure, that it is in the search path.'
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
123 ).format('hg'))
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
124 else:
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
125 self.inputGroup.setEnabled(True)
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
126 self.inputGroup.show()
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 def __finish(self):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 Private slot called when the process finished or the user pressed the button.
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 if self.process is not None and \
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 self.process.state() != QProcess.NotRunning:
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 self.process.terminate()
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 QTimer.singleShot(2000, self.process.kill)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 self.process.waitForFinished(3000)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 self.inputGroup.setEnabled(False)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 self.inputGroup.hide()
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 self.buttonBox.button(QDialogButtonBox.Close).setFocus(Qt.OtherFocusReason)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 self.process = None
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 if self.bookmarksList.topLevelItemCount() == 0:
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 # no bookmarks defined
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 self.__generateItem(self.trUtf8("no bookmarks defined"), "", "", "")
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 self.bookmarksList.doItemsLayout()
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 self.__resizeColumns()
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 self.__resort()
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 def on_buttonBox_clicked(self, button):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 Private slot called by a button of the button box clicked.
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 @param button button that was clicked (QAbstractButton)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 if button == self.buttonBox.button(QDialogButtonBox.Close):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 self.close()
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 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
164 if self.__hgClient:
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
165 self.__hgClient.cancel()
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
166 else:
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
167 self.__finish()
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 def __procFinished(self, exitCode, exitStatus):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 Private slot connected to the finished signal.
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 @param exitCode exit code of the process (integer)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 @param exitStatus exit status of the process (QProcess.ExitStatus)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 self.__finish()
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 def __resort(self):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 Private method to resort the tree.
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 self.bookmarksList.sortItems(self.bookmarksList.sortColumn(),
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 self.bookmarksList.header().sortIndicatorOrder())
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 def __resizeColumns(self):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 Private method to resize the list columns.
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 self.bookmarksList.header().resizeSections(QHeaderView.ResizeToContents)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 self.bookmarksList.header().setStretchLastSection(True)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 def __generateItem(self, revision, changeset, status, name):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 Private method to generate a bookmark item in the bookmarks list.
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 @param revision revision of the bookmark (string)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 @param changeset changeset of the bookmark (string)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 @param status of the bookmark (string)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 @param name name of the bookmark (string)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 itm = QTreeWidgetItem(self.bookmarksList, [
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 "{0:>7}".format(revision),
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 changeset,
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 status,
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 name])
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 itm.setTextAlignment(0, Qt.AlignRight)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 itm.setTextAlignment(1, Qt.AlignRight)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 itm.setTextAlignment(2, Qt.AlignHCenter)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 def __readStdout(self):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 Private slot to handle the readyReadStdout signal.
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 It reads the output of the process, formats it and inserts it into
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 the contents pane.
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 self.process.setReadChannel(QProcess.StandardOutput)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 while self.process.canReadLine():
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 s = str(self.process.readLine(),
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 Preferences.getSystem("IOEncoding"),
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 'replace').strip()
1251
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
223 self.__processOutputLine(s)
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
224
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
225 def __processOutputLine(self, line):
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
226 """
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
227 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
228
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
229 @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
230 """
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
231 l = line.split()
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
232 if l[-1][0] in "1234567890":
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
233 # last element is a rev:changeset
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
234 rev, changeset = l[-1].split(":", 1)
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
235 del l[-1]
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
236 if l[0] == "*":
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
237 status = "current"
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
238 del l[0]
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
239 else:
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
240 status = ""
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
241 name = " ".join(l)
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
242 self.__generateItem(rev, changeset, status, name)
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
243 if self.__bookmarksList is not None:
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
244 self.__bookmarksList.append(name)
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 def __readStderr(self):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 Private slot to handle the readyReadStderr signal.
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 It reads the error output of the process and inserts it into the
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 error pane.
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 if self.process is not None:
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 s = str(self.process.readAllStandardError(),
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 Preferences.getSystem("IOEncoding"),
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 'replace')
1251
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
257 self.__showError(s)
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
258
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
259 def __showError(self, out):
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
260 """
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
261 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
262
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
263 @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
264 """
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
265 self.errorGroup.show()
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
266 self.errors.insertPlainText(out)
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
267 self.errors.ensureCursorVisible()
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 def on_passwordCheckBox_toggled(self, isOn):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 Private slot to handle the password checkbox toggled.
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 @param isOn flag indicating the status of the check box (boolean)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 if isOn:
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 self.input.setEchoMode(QLineEdit.Password)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 else:
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 self.input.setEchoMode(QLineEdit.Normal)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 @pyqtSlot()
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 def on_sendButton_clicked(self):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 Private slot to send the input to the subversion process.
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 input = self.input.text()
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 input += os.linesep
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 if self.passwordCheckBox.isChecked():
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 self.errors.insertPlainText(os.linesep)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 self.errors.ensureCursorVisible()
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 else:
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 self.errors.insertPlainText(input)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 self.errors.ensureCursorVisible()
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 self.process.write(input)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 self.passwordCheckBox.setChecked(False)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 self.input.clear()
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 def on_input_returnPressed(self):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 Private slot to handle the press of the return key in the input field.
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 self.intercept = True
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 self.on_sendButton_clicked()
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 def keyPressEvent(self, evt):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 Protected slot to handle a key press event.
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 @param evt the key press event (QKeyEvent)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 if self.intercept:
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 self.intercept = False
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 evt.accept()
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 return
1131
7781e396c903 Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1011
diff changeset
317 super().keyPressEvent(evt)

eric ide

mercurial