ProjectDjangoTagsMenu/FindTemplateTagDialog.py

changeset 2
4be31b0908c7
child 3
6d10c1249cb8
equal deleted inserted replaced
1:b2f26d630942 2:4be31b0908c7
1 # -*- coding: utf-8 -*-
2
3 """
4 Module implementing a dialog to search foe template tags.
5 """
6
7 from PyQt4.QtCore import pyqtSignal, pyqtSlot
8 from PyQt4.QtGui import QDialog, QCompleter
9
10 from .Ui_FindTemplateTagDialog import Ui_FindTemplateTagDialog
11
12
13 class FindTemplateTagDialog(QDialog, Ui_FindTemplateTagDialog):
14 """
15 Class implementing a dialog to search foe template tags.
16
17 @signal tag(str) emitted to indicate to generate template text for the
18 given tag name
19 """
20 tag = pyqtSignal(str)
21
22 def __init__(self, parent=None):
23 """
24 Constructor
25
26 @param parent reference to the parent widget (QWidget)
27 """
28 super(FindTemplateTagDialog, self).__init__(parent)
29 self.setupUi(self)
30
31 self.__completer = QCompleter((
32 'autoescape', 'block', 'comment', 'csrf_token', 'cycle', 'debug',
33 'extends', 'filter', 'firstof', 'for', 'for...empty', 'if',
34 'ifchanged', 'ifequal', 'ifnotequal', 'include', 'load', 'now',
35 'regroup', 'spaceless', 'ssi', 'templatetag', 'verbatim',
36 'in operator', 'not in operator', 'widthratio', 'with', 'add',
37 'addslashes', 'capfirst', 'center', 'cut', 'date', 'default',
38 'default_if_none', 'dictsort', 'dictsortreversed', 'divisibleby',
39 'escape', 'escapejs', 'filesizeformat', 'first', 'fix_ampersands',
40 'floatformat', 'force_escape', 'get_digit', 'iriencode', 'join',
41 'last', 'lenght', 'lenght_is', 'linebreaks', 'linebreaksbr',
42 'linenumbers', 'ljust', 'lower', 'make_list', 'phone2numeric',
43 'pluralize', 'pprint', 'random', 'removetags', 'rjust', 'safe',
44 'safeseq', 'slice', 'slugify', 'stringformat', 'striptags',
45 'time', 'timesince', 'timeuntil', 'title', 'truncatechars',
46 'truncatewords', 'truncatewords_html', 'htmlcomment',
47 'unordered_list', 'upper', 'urlencode', 'urlize', 'urlizetrunc',
48 'wordcount', 'wordwrap', 'yesno', 'apnumber', 'intcomma',
49 'intword', 'naturalday', 'naturaltime', 'ordinal', 'lorem',
50 'static', 'iecomment', 'get_static_prefix', 'get_media_prefix',
51 'singlelinecomment', 'multilinecomment', 'singlelinecommentpopup',
52 'multilinecommentpopup', 'singlelinecommentclipboard',
53 'multilinecommentclipboard', 'multilinecommentfile',
54 'singlelinecommentdatetime'), self)
55 self.__completer.setCompletionMode(QCompleter.PopupCompletion)
56 self.__completer.setCaseSensitivity(False)
57 self.tagEdit.setCompleter(self.__completer)
58
59 @pyqtSlot()
60 def on_tagEdit_returnPressed(self):
61 """
62 Private slot handling the user pressing the return key.
63 """
64 self.on_createButton_clicked()
65
66 @pyqtSlot()
67 def on_createButton_clicked(self):
68 """
69 Private slot handling the user pressing the create button
70 """
71 tagName = self.tagEdit.text().lower().strip()
72 if tagName:
73 self.tag.emit(tagName)

eric ide

mercurial