Wed, 01 Jan 2020 11:58:57 +0100
Updated copyright for 2020.
8
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
44
3ea572ed13b6
Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
40
diff
changeset
|
3 | # Copyright (c) 2014 - 2020 Detlev Offenbach <detlev@die-offenbachs.de> |
8
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a dialog to enter the parameters for the if tag. |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
23
070a6c65c8a9
Released as stable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
16
diff
changeset
|
10 | from __future__ import unicode_literals |
10
ef5694c0bf3a
Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8
diff
changeset
|
11 | |
26
b21b4fc418bc
Ported to PyQt5 and eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
23
diff
changeset
|
12 | from PyQt5.QtCore import pyqtSlot |
b21b4fc418bc
Ported to PyQt5 and eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
23
diff
changeset
|
13 | from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
8
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | from .Ui_IfTagInputDialog import Ui_IfTagInputDialog |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | class IfTagInputDialog(QDialog, Ui_IfTagInputDialog): |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | """ |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | Class implementing a dialog to enter the parameters for the if tag. |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | """ |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | def __init__(self, parent=None): |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | """ |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | Constructor |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | @param parent reference to the parent widget (QWidget) |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | """ |
16
f2d493540f04
Added Python2 compatibility code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
28 | super(IfTagInputDialog, self).__init__(parent) |
8
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | self.setupUi(self) |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | @pyqtSlot(str) |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | def on_ifEdit_textChanged(self, txt): |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | """ |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | Private slot to handle changes of the 'if' expression. |
10
ef5694c0bf3a
Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8
diff
changeset
|
37 | |
ef5694c0bf3a
Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8
diff
changeset
|
38 | @param txt text of the line edit (string) |
8
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | """ |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(bool(txt)) |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | def getTag(self): |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | """ |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | Public method to retrieve the tag. |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | @return tag (string) |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | """ |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | tag = '{{% if {0} %}}\n'.format(self.ifEdit.text()) |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | elifText = self.elifEdit.toPlainText() |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | if elifText: |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | for expression in elifText.splitlines(): |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | if expression.strip(): |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | tag += '{{% elif {0} %}}\n'.format(expression.strip()) |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | if self.elseCheckBox.isChecked(): |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | tag += '{% else %}\n' |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | tag += '{% endif %}' |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | |
7e8f788fe340
Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | return tag |