Plugins/VcsPlugins/vcsMercurial/FetchExtension/HgFetchDialog.py

Mon, 26 Dec 2011 19:31:22 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 26 Dec 2011 19:31:22 +0100
changeset 1509
c0b5e693b0eb
parent 1131
7781e396c903
child 2302
f29e9405c851
permissions
-rw-r--r--

Updated copyright for 2012.

1066
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
1509
c0b5e693b0eb Updated copyright for 2012.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
3 # Copyright (c) 2011 - 2012 Detlev Offenbach <detlev@die-offenbachs.de>
1066
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to enter data to be used for a fetch operation.
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from PyQt4.QtCore import pyqtSlot
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 from PyQt4.QtGui import QDialog
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from .Ui_HgFetchDialog import Ui_HgFetchDialog
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 import Preferences
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 class HgFetchDialog(QDialog, Ui_HgFetchDialog):
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 Class implementing a dialog to enter data to be used for a fetch operation.
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 def __init__(self, parent=None):
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 Constructor
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 @param parent reference to the parent widget (QWidget)
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
1131
7781e396c903 Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1066
diff changeset
28 super().__init__(parent)
1066
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 self.setupUi(self)
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 self.recentCommitMessages = Preferences.toList(
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 Preferences.Prefs.settings.value('Mercurial/Commits'))
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 self.recentComboBox.clear()
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 self.recentComboBox.addItem("")
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 self.recentComboBox.addItems(self.recentCommitMessages)
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 @pyqtSlot(str)
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 def on_recentComboBox_activated(self, txt):
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 """
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 Private slot to select a commit message from recent ones.
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 @param txt text of the selected entry (string)
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 """
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 if txt:
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.messageEdit.setPlainText(txt)
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 def getData(self):
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 Public method to get the data for the fetch operation.
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 @return tuple with the commit message and a flag indicating to switch
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 the merge order (string, boolean)
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 """
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 msg = self.messageEdit.toPlainText()
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 if msg:
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 if msg in self.recentCommitMessages:
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 self.recentCommitMessages.remove(msg)
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.recentCommitMessages.insert(0, msg)
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 no = int(Preferences.Prefs.settings\
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 .value('Mercurial/CommitMessages', 20))
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 del self.recentCommitMessages[no:]
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 Preferences.Prefs.settings.setValue('Mercurial/Commits',
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 self.recentCommitMessages)
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64
a3dd41fd9ea8 Added support for the Mercurial fetch extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 return msg, self.switchCheckBox.isChecked()

eric ide

mercurial