eric6/Plugins/VcsPlugins/vcsMercurial/HgBookmarksListDialog.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 7533
88261c96484b
child 7970
c4ee8a81584c
permissions
-rw-r--r--

Updated copyright for 2021.

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
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
3 # Copyright (c) 2011 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
1011
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
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 pyqtSlot, Qt, QCoreApplication, QPoint
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
13 from PyQt5.QtWidgets import (
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
14 QDialog, QDialogButtonBox, QHeaderView, QTreeWidgetItem, QLineEdit, QMenu,
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
15 QInputDialog
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
16 )
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
5325
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
18 from E5Gui.E5Application import e5App
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 from E5Gui import E5MessageBox
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 from .Ui_HgBookmarksListDialog import Ui_HgBookmarksListDialog
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
5325
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
23 import UI.PixmapCache
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
5325
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
25
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 class HgBookmarksListDialog(QDialog, Ui_HgBookmarksListDialog):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 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
29 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 def __init__(self, vcs, parent=None):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 Constructor
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @param vcs reference to the vcs object
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 @param parent parent widget (QWidget)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 """
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
37 super(HgBookmarksListDialog, self).__init__(parent)
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.setupUi(self)
4278
ccd1e13cb9bd Fixed issues where dialogs could not be minimized on some desktop environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4212
diff changeset
39 self.setWindowFlags(Qt.Window)
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
4126
c28d0cf3b639 Some changes to the various VCS interfaces to use one dialog instead of creating a new one each time.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
41 self.refreshButton = self.buttonBox.addButton(
c28d0cf3b639 Some changes to the various VCS interfaces to use one dialog instead of creating a new one each time.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
42 self.tr("Refresh"), QDialogButtonBox.ActionRole)
c28d0cf3b639 Some changes to the various VCS interfaces to use one dialog instead of creating a new one each time.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
43 self.refreshButton.setToolTip(
c28d0cf3b639 Some changes to the various VCS interfaces to use one dialog instead of creating a new one each time.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
44 self.tr("Press to refresh the bookmarks display"))
c28d0cf3b639 Some changes to the various VCS interfaces to use one dialog instead of creating a new one each time.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
45 self.refreshButton.setEnabled(False)
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.vcs = vcs
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.__bookmarksList = None
5325
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
51 self.__repoDir = None
1251
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
52 self.__hgClient = vcs.getClient()
5322
c2cabdca0734 Added bookmark actions to the Mercurial Log Browser tools menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
53 self.__bookmarksDefined = False
5325
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
54 self.__currentRevision = ""
1011
0b118aefae5b Started implementing the Mercurial bookmarks 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: 2771
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: 2771
diff changeset
57 self.bookmarksList.columnCount(), "")
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.bookmarksList.header().setSortIndicator(3, Qt.AscendingOrder)
0b118aefae5b Started implementing the Mercurial bookmarks 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()
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 def closeEvent(self, e):
0b118aefae5b Started implementing the Mercurial bookmarks 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.
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 @param e close event (QCloseEvent)
0b118aefae5b Started implementing the Mercurial bookmarks 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()
1011
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 e.accept()
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 def start(self, path, bookmarksList):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 Public slot to start the bookmarks command.
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 @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
79 @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
80 (list of strings)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 """
4126
c28d0cf3b639 Some changes to the various VCS interfaces to use one dialog instead of creating a new one each time.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
82 self.bookmarksList.clear()
5322
c2cabdca0734 Added bookmark actions to the Mercurial Log Browser tools menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
83 self.__bookmarksDefined = False
4126
c28d0cf3b639 Some changes to the various VCS interfaces to use one dialog instead of creating a new one each time.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
84
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 self.errorGroup.hide()
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.intercept = False
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.activateWindow()
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 self.__bookmarksList = bookmarksList
4126
c28d0cf3b639 Some changes to the various VCS interfaces to use one dialog instead of creating a new one each time.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
91 del self.__bookmarksList[:] # clear the list
c28d0cf3b639 Some changes to the various VCS interfaces to use one dialog instead of creating a new one each time.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
92
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 dname, fname = self.vcs.splitPath(path)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 # find the root of the repo
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 repodir = dname
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 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
98 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
99 if os.path.splitdrive(repodir)[1] == os.sep:
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 return
5325
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
101 self.__repoDir = repodir
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102
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
103 args = self.vcs.initCommand("bookmarks")
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104
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
105 self.refreshButton.setEnabled(False)
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
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 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
108 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
109 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
110 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
111 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
112 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
113 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
114 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
115 self.__finish()
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 def __finish(self):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 """
3008
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
119 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: 2771
diff changeset
120 the button.
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 """
4126
c28d0cf3b639 Some changes to the various VCS interfaces to use one dialog instead of creating a new one each time.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
122 self.refreshButton.setEnabled(True)
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 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: 2771
diff changeset
127 self.buttonBox.button(QDialogButtonBox.Close).setFocus(
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
128 Qt.OtherFocusReason)
1011
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 if self.bookmarksList.topLevelItemCount() == 0:
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 # no bookmarks defined
3008
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
132 self.__generateItem(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
133 self.tr("no bookmarks defined"), "", "", "")
5322
c2cabdca0734 Added bookmark actions to the Mercurial Log Browser tools menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
134 self.__bookmarksDefined = False
c2cabdca0734 Added bookmark actions to the Mercurial Log Browser tools menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
135 else:
c2cabdca0734 Added bookmark actions to the Mercurial Log Browser tools menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
136 self.__bookmarksDefined = True
c2cabdca0734 Added bookmark actions to the Mercurial Log Browser tools menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
137
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 self.__resizeColumns()
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 self.__resort()
5325
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
140
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
141 # restore current item
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
142 if self.__currentRevision:
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
143 items = self.bookmarksList.findItems(
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
144 self.__currentRevision, Qt.MatchExactly, 0)
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
145 if items:
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
146 self.bookmarksList.setCurrentItem(items[0])
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
147 self.__currentRevision = ""
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
148 self.bookmarksList.setFocus(Qt.OtherFocusReason)
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 def on_buttonBox_clicked(self, button):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 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
153
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 @param button button that was clicked (QAbstractButton)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 if button == self.buttonBox.button(QDialogButtonBox.Close):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 self.close()
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 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
159 if self.__hgClient:
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
160 self.__hgClient.cancel()
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
161 else:
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
162 self.__finish()
4126
c28d0cf3b639 Some changes to the various VCS interfaces to use one dialog instead of creating a new one each time.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
163 elif button == self.refreshButton:
c28d0cf3b639 Some changes to the various VCS interfaces to use one dialog instead of creating a new one each time.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
164 self.on_refreshButton_clicked()
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 def __resort(self):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 Private method to resort the tree.
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 """
3023
34ce20603bf7 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
170 self.bookmarksList.sortItems(
34ce20603bf7 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
171 self.bookmarksList.sortColumn(),
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 self.bookmarksList.header().sortIndicatorOrder())
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 def __resizeColumns(self):
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 Private method to resize the list columns.
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 """
3008
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
178 self.bookmarksList.header().resizeSections(
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
179 QHeaderView.ResizeToContents)
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 self.bookmarksList.header().setStretchLastSection(True)
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 def __generateItem(self, revision, changeset, status, name):
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 """
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 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
185
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 @param revision revision of the bookmark (string)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 @param changeset changeset of the bookmark (string)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 @param status of the bookmark (string)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 @param name name of the bookmark (string)
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 """
1640
1699d46026cd Fixed a compatibility issue with Qt 4.8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1532
diff changeset
191 itm = QTreeWidgetItem(self.bookmarksList)
3562
ef3f13a2c599 Moved the Mercurial bookmarks to the Mercurial core because they are no extension since Mercurial 1.8 anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
192 if revision[0].isdecimal():
ef3f13a2c599 Moved the Mercurial bookmarks to the Mercurial core because they are no extension since Mercurial 1.8 anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
193 # valid bookmark entry
ef3f13a2c599 Moved the Mercurial bookmarks to the Mercurial core because they are no extension since Mercurial 1.8 anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
194 itm.setData(0, Qt.DisplayRole, int(revision))
ef3f13a2c599 Moved the Mercurial bookmarks to the Mercurial core because they are no extension since Mercurial 1.8 anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
195 itm.setData(1, Qt.DisplayRole, changeset)
ef3f13a2c599 Moved the Mercurial bookmarks to the Mercurial core because they are no extension since Mercurial 1.8 anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
196 itm.setData(2, Qt.DisplayRole, status)
ef3f13a2c599 Moved the Mercurial bookmarks to the Mercurial core because they are no extension since Mercurial 1.8 anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
197 itm.setData(3, Qt.DisplayRole, name)
ef3f13a2c599 Moved the Mercurial bookmarks to the Mercurial core because they are no extension since Mercurial 1.8 anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
198 itm.setTextAlignment(0, Qt.AlignRight)
ef3f13a2c599 Moved the Mercurial bookmarks to the Mercurial core because they are no extension since Mercurial 1.8 anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
199 itm.setTextAlignment(1, Qt.AlignRight)
ef3f13a2c599 Moved the Mercurial bookmarks to the Mercurial core because they are no extension since Mercurial 1.8 anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
200 itm.setTextAlignment(2, Qt.AlignHCenter)
ef3f13a2c599 Moved the Mercurial bookmarks to the Mercurial core because they are no extension since Mercurial 1.8 anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
201 else:
ef3f13a2c599 Moved the Mercurial bookmarks to the Mercurial core because they are no extension since Mercurial 1.8 anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
202 # error message
ef3f13a2c599 Moved the Mercurial bookmarks to the Mercurial core because they are no extension since Mercurial 1.8 anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
203 itm.setData(0, Qt.DisplayRole, revision)
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204
1251
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
205 def __processOutputLine(self, line):
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
206 """
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
207 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
208
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
209 @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
210 """
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3023
diff changeset
211 li = line.split()
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3023
diff changeset
212 if li[-1][0] in "1234567890":
1251
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
213 # last element is a rev:changeset
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3023
diff changeset
214 rev, changeset = li[-1].split(":", 1)
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3023
diff changeset
215 del li[-1]
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3023
diff changeset
216 if li[0] == "*":
1251
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
217 status = "current"
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3023
diff changeset
218 del li[0]
1251
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
219 else:
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
220 status = ""
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3023
diff changeset
221 name = " ".join(li)
1251
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
222 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
223 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
224 self.__bookmarksList.append(name)
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225
1251
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
226 def __showError(self, out):
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
227 """
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
228 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
229
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
230 @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
231 """
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
232 self.errorGroup.show()
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
233 self.errors.insertPlainText(out)
d40491ba96ce Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
234 self.errors.ensureCursorVisible()
1011
0b118aefae5b Started implementing the Mercurial bookmarks support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235
4126
c28d0cf3b639 Some changes to the various VCS interfaces to use one dialog instead of creating a new one each time.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
236 @pyqtSlot()
c28d0cf3b639 Some changes to the various VCS interfaces to use one dialog instead of creating a new one each time.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
237 def on_refreshButton_clicked(self):
c28d0cf3b639 Some changes to the various VCS interfaces to use one dialog instead of creating a new one each time.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
238 """
c28d0cf3b639 Some changes to the various VCS interfaces to use one dialog instead of creating a new one each time.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
239 Private slot to refresh the status display.
c28d0cf3b639 Some changes to the various VCS interfaces to use one dialog instead of creating a new one each time.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
240 """
5325
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
241 # save the current items commit ID
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
242 itm = self.bookmarksList.currentItem()
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
243 if itm is not None:
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
244 self.__currentRevision = itm.text(0)
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
245 else:
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
246 self.__currentRevision = ""
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
247
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
248 self.start(self.__repoDir, self.__bookmarksList)
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
249
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
250 @pyqtSlot(QPoint)
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
251 def on_bookmarksList_customContextMenuRequested(self, pos):
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
252 """
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
253 Private slot to handle the context menu request.
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
254
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
255 @param pos position the context menu was requetsed at
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
256 @type QPoint
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
257 """
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
258 itm = self.bookmarksList.itemAt(pos)
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
259 if itm is not None:
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
260 menu = QMenu(self.bookmarksList)
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
261 menu.addAction(
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: 7370
diff changeset
262 UI.PixmapCache.getIcon("vcsSwitch"),
5325
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
263 self.tr("Switch to"), self.__switchTo)
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
264 menu.addSeparator()
5328
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
265 menu.addAction(
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: 7370
diff changeset
266 UI.PixmapCache.getIcon("deleteBookmark"),
5353
60fcaa1c3c3c Corrected some code style issues and regenerated the source docu files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5328
diff changeset
267 self.tr("Delete"), self.__deleteBookmark)
5328
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
268 menu.addAction(
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: 7370
diff changeset
269 UI.PixmapCache.getIcon("renameBookmark"),
5328
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
270 self.tr("Rename"), self.__renameBookmark)
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
271 menu.addSeparator()
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
272 act = menu.addAction(
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: 7370
diff changeset
273 UI.PixmapCache.getIcon("pullBookmark"),
5328
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
274 self.tr("Pull"), self.__pullBookmark)
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
275 act.setEnabled(self.vcs.canPull())
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
276 act = menu.addAction(
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: 7370
diff changeset
277 UI.PixmapCache.getIcon("pushBookmark"),
5328
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
278 self.tr("Push"), self.__pushBookmark)
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
279 act.setEnabled(self.vcs.canPush())
5325
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
280 menu.popup(self.bookmarksList.mapToGlobal(pos))
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
281
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
282 def __switchTo(self):
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
283 """
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
284 Private slot to switch the working directory to the selected revision.
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
285 """
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
286 itm = self.bookmarksList.currentItem()
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
287 bookmark = itm.text(3).strip()
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
288 if bookmark:
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
289 shouldReopen = self.vcs.vcsUpdate(
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
290 self.__repoDir, revision=bookmark)
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
291 if shouldReopen:
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
292 res = E5MessageBox.yesNo(
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
293 None,
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
294 self.tr("Switch"),
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
295 self.tr(
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
296 """The project should be reread. Do this now?"""),
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
297 yesDefault=True)
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
298 if res:
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
299 e5App().getObject("Project").reopenProject()
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
300 return
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
301
d0b6adb1721f Started to implement a context menu for the Mercurial bookmarks list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5322
diff changeset
302 self.on_refreshButton_clicked()
5328
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
303
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
304 def __deleteBookmark(self):
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
305 """
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
306 Private slot to delete the selected bookmark.
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
307 """
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
308 itm = self.bookmarksList.currentItem()
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
309 bookmark = itm.text(3).strip()
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
310 if bookmark:
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
311 yes = E5MessageBox.yesNo(
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
312 self,
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
313 self.tr("Delete Bookmark"),
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
314 self.tr("""<p>Shall the bookmark <b>{0}</b> really be"""
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
315 """ deleted?</p>""").format(bookmark))
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
316 if yes:
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
317 self.vcs.hgBookmarkDelete(self.__repoDir, bookmark=bookmark)
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
318 self.on_refreshButton_clicked()
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
319
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
320 def __renameBookmark(self):
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
321 """
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
322 Private slot to rename the selected bookmark.
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
323 """
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
324 itm = self.bookmarksList.currentItem()
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
325 bookmark = itm.text(3).strip()
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
326 if bookmark:
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
327 newName, ok = QInputDialog.getText(
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
328 self,
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
329 self.tr("Rename Bookmark"),
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
330 self.tr("<p>Enter the new name for bookmark <b>{0}</b>:</p>")
5353
60fcaa1c3c3c Corrected some code style issues and regenerated the source docu files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5328
diff changeset
331 .format(bookmark),
5328
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
332 QLineEdit.Normal)
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
333 if ok and bool(newName):
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
334 self.vcs.hgBookmarkRename(self.__repoDir, (bookmark, newName))
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
335 self.on_refreshButton_clicked()
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
336
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
337 def __pullBookmark(self):
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
338 """
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
339 Private slot to pull the selected bookmark.
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
340 """
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
341 itm = self.bookmarksList.currentItem()
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
342 bookmark = itm.text(3).strip()
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
343 if bookmark:
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
344 self.vcs.hgBookmarkPull(self.__repoDir, bookmark=bookmark)
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
345 self.on_refreshButton_clicked()
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
346
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
347 def __pushBookmark(self):
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
348 """
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
349 Private slot to push the selected bookmark.
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
350 """
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
351 itm = self.bookmarksList.currentItem()
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
352 bookmark = itm.text(3).strip()
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
353 if bookmark:
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
354 self.vcs.hgBookmarkPush(self.__repoDir, bookmark=bookmark)
9c11e9285a46 Added context menu actions to the Mercurial bookmark list dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5325
diff changeset
355 self.on_refreshButton_clicked()

eric ide

mercurial