|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2003 - 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to enter the data for a tagging operation. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 from PyQt5.QtCore import pyqtSlot |
|
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
|
14 |
|
15 from .Ui_SvnTagDialog import Ui_SvnTagDialog |
|
16 |
|
17 |
|
18 class SvnTagDialog(QDialog, Ui_SvnTagDialog): |
|
19 """ |
|
20 Class implementing a dialog to enter the data for a tagging operation. |
|
21 """ |
|
22 def __init__(self, taglist, reposURL, standardLayout, parent=None): |
|
23 """ |
|
24 Constructor |
|
25 |
|
26 @param taglist list of previously entered tags (list of strings) |
|
27 @param reposURL repository path (string) or None |
|
28 @param standardLayout flag indicating the layout of the |
|
29 repository (boolean) |
|
30 @param parent parent widget (QWidget) |
|
31 """ |
|
32 super(SvnTagDialog, self).__init__(parent) |
|
33 self.setupUi(self) |
|
34 |
|
35 self.okButton = self.buttonBox.button(QDialogButtonBox.Ok) |
|
36 self.okButton.setEnabled(False) |
|
37 |
|
38 self.tagCombo.clear() |
|
39 self.tagCombo.addItems(sorted(taglist, reverse=True)) |
|
40 |
|
41 if reposURL is not None and reposURL != "": |
|
42 self.tagCombo.setEditText(reposURL) |
|
43 |
|
44 if not standardLayout: |
|
45 self.TagActionGroup.setEnabled(False) |
|
46 |
|
47 msh = self.minimumSizeHint() |
|
48 self.resize(max(self.width(), msh.width()), msh.height()) |
|
49 |
|
50 @pyqtSlot(str) |
|
51 def on_tagCombo_editTextChanged(self, text): |
|
52 """ |
|
53 Private method used to enable/disable the OK-button. |
|
54 |
|
55 @param text tag name entered in the combo (string) |
|
56 """ |
|
57 self.okButton.setDisabled(text == "") |
|
58 |
|
59 def getParameters(self): |
|
60 """ |
|
61 Public method to retrieve the tag data. |
|
62 |
|
63 @return tuple of string and int (tag, tag operation) |
|
64 """ |
|
65 tag = self.tagCombo.currentText() |
|
66 tagOp = 0 |
|
67 if self.createRegularButton.isChecked(): |
|
68 tagOp = 1 |
|
69 elif self.createBranchButton.isChecked(): |
|
70 tagOp = 2 |
|
71 elif self.deleteRegularButton.isChecked(): |
|
72 tagOp = 4 |
|
73 elif self.deleteBranchButton.isChecked(): |
|
74 tagOp = 8 |
|
75 return (tag, tagOp) |