Sun, 09 Feb 2014 18:21:45 +0100
Implemented the comments menu.
2
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
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:
4
diff
changeset
|
3 | # Copyright (c) 2014 Detlev Offenbach <detlev@die-offenbachs.de> |
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:
4
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:
4
diff
changeset
|
5 | |
2
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a dialog to search foe template tags. |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | from PyQt4.QtCore import pyqtSignal, pyqtSlot |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | from PyQt4.QtGui import QDialog, QCompleter |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | from .Ui_FindTemplateTagDialog import Ui_FindTemplateTagDialog |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | class FindTemplateTagDialog(QDialog, Ui_FindTemplateTagDialog): |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | """ |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | Class implementing a dialog to search foe template tags. |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | @signal tag(str) emitted to indicate to generate template text for the |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | given tag name |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | """ |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | tag = pyqtSignal(str) |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | def __init__(self, parent=None): |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | """ |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | Constructor |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | @param parent reference to the parent widget (QWidget) |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | """ |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | super(FindTemplateTagDialog, self).__init__(parent) |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | self.setupUi(self) |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | self.__completer = QCompleter(( |
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:
4
diff
changeset
|
35 | # template tags |
2
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | 'autoescape', 'block', 'comment', 'csrf_token', 'cycle', 'debug', |
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:
4
diff
changeset
|
37 | 'extendsvariable', 'extendsfile', 'filter', 'firstof', 'for', |
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:
4
diff
changeset
|
38 | 'for...empty', 'if', 'ifchanged', 'ifequal', 'ifnotequal', |
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:
4
diff
changeset
|
39 | 'includevariable', 'includefile', 'load', 'now', 'regroup', |
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:
4
diff
changeset
|
40 | 'spaceless', 'ssi', 'ssifile', 'templatetag', 'url', 'urlas', |
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:
4
diff
changeset
|
41 | 'verbatim', 'widthratio', 'with', |
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:
4
diff
changeset
|
42 | |
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:
4
diff
changeset
|
43 | # template filters |
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:
4
diff
changeset
|
44 | 'add', 'addslashes', 'capfirst', 'center', 'cut', 'date', |
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:
4
diff
changeset
|
45 | 'default', 'default_if_none', 'dictsort', 'dictsortreversed', |
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:
4
diff
changeset
|
46 | 'divisibleby', 'escape', 'escapejs', 'filesizeformat', 'first', |
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:
4
diff
changeset
|
47 | 'fix_ampersands', 'floatformat', 'force_escape', 'get_digit', |
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:
4
diff
changeset
|
48 | 'iriencode', 'join', 'last', 'lenght', 'lenght_is', 'linebreaks', |
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:
4
diff
changeset
|
49 | 'linebreaksbr', 'linenumbers', 'ljust', 'lower', 'make_list', |
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:
4
diff
changeset
|
50 | 'phone2numeric', 'pluralize', 'pprint', 'random', 'removetags', |
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:
4
diff
changeset
|
51 | 'rjust', 'safe', 'safeseq', 'slice', 'slugify', 'stringformat', |
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:
4
diff
changeset
|
52 | 'striptags', 'time', 'timesince', 'timeuntil', 'title', |
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:
4
diff
changeset
|
53 | 'truncatechars', 'truncatewords', 'truncatewords_html', |
2
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | 'unordered_list', 'upper', 'urlencode', 'urlize', 'urlizetrunc', |
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:
4
diff
changeset
|
55 | 'wordcount', 'wordwrap', 'yesno', |
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:
4
diff
changeset
|
56 | |
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:
4
diff
changeset
|
57 | # humanize tags |
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:
4
diff
changeset
|
58 | 'loadhumanize', 'apnumber', 'intcomma', 'intword', 'naturalday', |
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:
4
diff
changeset
|
59 | 'naturaltime', 'ordinal', |
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:
4
diff
changeset
|
60 | |
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:
4
diff
changeset
|
61 | # web design tags |
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:
4
diff
changeset
|
62 | 'loadweb', 'lorem', |
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:
4
diff
changeset
|
63 | |
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:
4
diff
changeset
|
64 | # static tags |
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:
4
diff
changeset
|
65 | 'loadstatic', 'staticfile', 'staticvariable', 'get_static_prefix', |
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:
4
diff
changeset
|
66 | 'get_media_prefix', |
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:
4
diff
changeset
|
67 | |
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:
4
diff
changeset
|
68 | # comments |
9
1b11bf54b3b2
Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8
diff
changeset
|
69 | 'singlelinecommentselect', 'multilinecommentselect', |
1b11bf54b3b2
Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8
diff
changeset
|
70 | 'singlelinecommentdialog', 'multilinecommentdialog', |
1b11bf54b3b2
Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8
diff
changeset
|
71 | 'singlelinecommentclipboard', 'multilinecommentclipboard', |
1b11bf54b3b2
Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8
diff
changeset
|
72 | 'multilinecommentfile', 'singlelinecommentdatetime', |
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:
4
diff
changeset
|
73 | 'htmlcomment', 'iecomment', |
9
1b11bf54b3b2
Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8
diff
changeset
|
74 | |
1b11bf54b3b2
Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8
diff
changeset
|
75 | # internationalisation |
1b11bf54b3b2
Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8
diff
changeset
|
76 | # TODO: check tags against handler |
1b11bf54b3b2
Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8
diff
changeset
|
77 | ), self) |
2
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | self.__completer.setCompletionMode(QCompleter.PopupCompletion) |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | self.__completer.setCaseSensitivity(False) |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | self.tagEdit.setCompleter(self.__completer) |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | @pyqtSlot() |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | def on_tagEdit_returnPressed(self): |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
84 | """ |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | Private slot handling the user pressing the return key. |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | """ |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | self.on_createButton_clicked() |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | @pyqtSlot() |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | def on_createButton_clicked(self): |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | """ |
3
6d10c1249cb8
Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
92 | Private slot handling the user pressing the create button. |
2
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | """ |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
94 | tagName = self.tagEdit.text().lower().strip() |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | if tagName: |
4be31b0908c7
Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | self.tag.emit(tagName) |