1
# -*- coding: utf-8 -*-
3
# Copyright (c) 2005 - 2007 Detlev Offenbach <detlev@die-offenbachs.de>
7
Module implementing the templates properties dialog.
12
from KdeQt import KQMessageBox
14
from TemplatePropertiesForm import TemplatePropertiesForm
17
class TemplatePropertiesDialog(TemplatePropertiesForm):
19
Class implementing the templates properties dialog.
21
def __init__(self, parent, groupMode = 0, itm = None):
25
@param parent the parent widget (QWidget)
26
@param groupMode flag indicating group mode (boolean)
27
@param itm item (TemplateEntry or TemplateGroup) to
30
TemplatePropertiesForm.__init__(self, parent, None, 1)
33
("All", self.trUtf8("All")),
34
("Bash", self.trUtf8("Bash")),
35
("Batch", self.trUtf8("Batch")),
36
("C/C++", self.trUtf8("C++")),
37
("C#", self.trUtf8("C#")),
38
("HTML/XML", self.trUtf8("HTML/XML")),
39
("IDL", self.trUtf8("IDL")),
40
("Java", self.trUtf8("Java")),
41
("JavaScript", self.trUtf8("JavaScript")),
42
("Lua", self.trUtf8("Lua")),
43
("Makefile", self.trUtf8("Makefile")),
44
("Perl", self.trUtf8("Perl")),
45
("Properties", self.trUtf8("Properties")),
46
("Python", self.trUtf8("Python")),
47
("Ruby", self.trUtf8("Ruby")),
48
("SQL", self.trUtf8("SQL")),
49
("TeX", self.trUtf8("TeX")),
52
self.groupMode = groupMode
54
langList = QStringList()
55
for lang, langDisp in self.languages:
56
langList.append(langDisp)
58
self.groupLabel.setText(self.trUtf8("Language:"))
59
self.groupCombo.insertStringList(langList)
60
self.templateLabel.setEnabled(0)
61
self.templateEdit.setEnabled(0)
62
self.templateEdit.setText(self.trUtf8("GROUP"))
63
self.helpButton.setEnabled(0)
65
groups = QStringList()
66
for group in parent.getGroupNames():
68
self.groupCombo.insertStringList(groups)
71
self.nameEdit.setText(itm.getName())
73
lang = itm.getLanguage()
74
for l, d in self.languages:
76
self.groupCombo.setCurrentText(d)
79
self.groupCombo.setCurrentText(itm.getGroupName())
80
self.templateEdit.setText(itm.getTemplateText())
84
Public slot to show some help.
86
KQMessageBox.information(self,
87
self.trUtf8("Template Help"),
88
self.trUtf8("""<p>To use variables in a template, you just have to enclose"""
89
""" the variablename with $-characters. When you use the template,"""
90
""" you will then be asked for a value for this variable.</p>"""
91
"""<p>Example template: This is a $VAR$</p>"""
92
"""<p>When you use this template you will be prompted for a value"""
93
""" for the variable $VAR$. Any occurences of $VAR$ will then be"""
94
""" replaced with whatever you've entered.</p>"""
95
"""<p>If you need a single $-character in a template, which is not"""
96
""" used to enclose a variable, type $$(two dollar characters)"""
97
""" instead. They will automatically be replaced with a single"""
98
""" $-character when you use the template.</p>"""
99
"""<p>If you want a variables contents to be treated specially,"""
100
""" the variablename must be followed by a ':' and one formatting"""
101
""" specifier (e.g. $VAR:ml$). The supported specifiers are:"""
103
"""<tr><td>ml</td><td>Specifies a multiline formatting."""
104
""" Each line of the variable contents is prefixed with the string"""
105
""" occuring before the variable on the same line of the template."""
108
"""<p>If you want to change the default delimiter to anything"""
109
""" different, please use the configuration dialog to do so.</p>"""),
115
def setSelectedGroup(self, name):
117
Public method to select a group.
119
@param name name of the group to be selected (string or QString)
121
self.groupCombo.setCurrentText(name)
125
Public method to get the data entered into the dialog.
127
@return a tuple of two strings (name, language), if the dialog is in group mode,
128
and a tuple of three strings (name, group name, template) otherwise.
131
return (unicode(self.nameEdit.text()),
132
self.languages[self.groupCombo.currentItem()][0]
135
return (unicode(self.nameEdit.text()),
136
unicode(self.groupCombo.currentText()),
137
unicode(self.templateEdit.text())