eric4.Templates.TemplateViewer

Module implementing a template viewer and associated classes.

Classes

TemplateEntry Class immplementing a template entry.
TemplateGroup Class implementing a template group.
TemplateViewer Class implementing the template viewer.

Functions

None


TemplateEntry

Class immplementing a template entry.

Derived from

QTreeWidgetItem

Methods

TemplateEntry Constructor
__expandFormattedVariable Private method to expand a template variable with special formatting.
__extractVariables Private method to retrieve the list of variables.
getExpandedText Public method to get the template text with all variables expanded.
getGroupName Public method to get the name of the group this entry belongs to.
getName Public method to get the name of the group.
getTemplateText Public method to get the template text.
getVariables Public method to get the list of variables.
setName Public method to update the name of the group.
setTemplateText Public method to update the template text.

TemplateEntry (Constructor)

TemplateEntry(parent, name, templateText)

Constructor

parent
parent widget of the template group (QWidget)
name
name of the group (string or QString)
templateText
text of the template entry (string or QString)

TemplateEntry.__expandFormattedVariable

__expandFormattedVariable(var, val, txt)

Private method to expand a template variable with special formatting.

var
template variable name (string)
val
value of the template variable (string)
txt
template text (string)

TemplateEntry.__extractVariables

__extractVariables()

Private method to retrieve the list of variables.

TemplateEntry.getExpandedText

getExpandedText(varDict, indent)

Public method to get the template text with all variables expanded.

varDict
dictionary containing the texts of each variable with the variable name as key.
indent
indentation of the line receiving he expanded template text (string)
Returns:
a tuple of the expanded template text (string), the number of lines (integer) and the length of the last line (integer)

TemplateEntry.getGroupName

getGroupName()

Public method to get the name of the group this entry belongs to.

Returns:
name of the group containing this entry (string)

TemplateEntry.getName

getName()

Public method to get the name of the group.

Returns:
name of the group (string)

TemplateEntry.getTemplateText

getTemplateText()

Public method to get the template text.

Returns:
the template text (string)

TemplateEntry.getVariables

getVariables()

Public method to get the list of variables.

Returns:
list of variables (list of strings)

TemplateEntry.setName

setName(name)

Public method to update the name of the group.

name
name of the group (string or QString)

TemplateEntry.setTemplateText

setTemplateText(templateText)

Public method to update the template text.

templateText
text of the template entry (string or QString)

Up


TemplateGroup

Class implementing a template group.

Derived from

QTreeWidgetItem

Methods

TemplateGroup Constructor
addEntry Public method to add a template entry to this group.
getAllEntries Public method to retrieve all entries.
getEntry Public method to get an entry.
getLanguage Public method to get the name of the group.
getName Public method to get the name of the group.
removeAllEntries Public method to remove all template entries of this group.
removeEntry Public method to remove a template entry from this group.
setLanguage Public method to update the name of the group.
setName Public method to update the name of the group.

TemplateGroup (Constructor)

TemplateGroup(parent, name, language = "All")

Constructor

parent
parent widget of the template group (QWidget)
name
name of the group (string or QString)
language
programming language for the group (string or QString)

TemplateGroup.addEntry

addEntry(name, template, quiet = False)

Public method to add a template entry to this group.

name
name of the entry (string or QString)
template
template text of the entry (string or QString)
quiet
flag indicating quiet operation (boolean)

TemplateGroup.getAllEntries

getAllEntries()

Public method to retrieve all entries.

Returns:
list of all entries (list of TemplateEntry)

TemplateGroup.getEntry

getEntry(name)

Public method to get an entry.

name
name of the entry to retrieve (string or QString)
Returns:
reference to the entry (TemplateEntry)

TemplateGroup.getLanguage

getLanguage()

Public method to get the name of the group.

Returns:
language of the group (string)

TemplateGroup.getName

getName()

Public method to get the name of the group.

Returns:
name of the group (string)

TemplateGroup.removeAllEntries

removeAllEntries()

Public method to remove all template entries of this group.

TemplateGroup.removeEntry

removeEntry(name)

Public method to remove a template entry from this group.

name
name of the entry to be removed (string or QString)

TemplateGroup.setLanguage

setLanguage(language)

Public method to update the name of the group.

language
programming language for the group (string or QString)

TemplateGroup.setName

setName(name)

Public method to update the name of the group.

name
name of the group (string or QString)

Up


TemplateViewer

Class implementing the template viewer.

Derived from

QTreeWidget

Methods

TemplateViewer Constructor
__addEntry Private slot to handle the Add Entry context menu action.
__addGroup Private slot to handle the Add Group context menu action.
__edit Private slot to handle the Edit context menu action.
__export Private slot to handle the Export context menu action.
__import Private slot to handle the Import context menu action.
__remove Private slot to handle the Remove context menu action.
__resort Private method to resort the tree.
__save Private slot to handle the Save context menu action.
__showContextMenu Private slot to show the context menu of the list.
__showHelp Private method to show some help.
__templateItemActivated Private slot to handle the activation of an item.
addEntry Public method to add a template entry.
addGroup Public method to add a group.
applyTemplate Public method to apply the template.
changeEntry Public method to change a template entry.
changeGroup Public method to rename a group.
getAllGroups Public method to get all groups.
getGroupNames Public method to get all group names.
readTemplates Public method to read in the templates file (.e4c)
removeEntry Public method to remove a template entry.
removeGroup Public method to remove a group.
writeTemplates Public method to write the templates data to an XML file (.e4c).

TemplateViewer (Constructor)

TemplateViewer(parent, viewmanager)

Constructor

parent
the parent (QWidget)
viewmanager
reference to the viewmanager object

TemplateViewer.__addEntry

__addEntry()

Private slot to handle the Add Entry context menu action.

TemplateViewer.__addGroup

__addGroup()

Private slot to handle the Add Group context menu action.

TemplateViewer.__edit

__edit()

Private slot to handle the Edit context menu action.

TemplateViewer.__export

__export()

Private slot to handle the Export context menu action.

TemplateViewer.__import

__import()

Private slot to handle the Import context menu action.

TemplateViewer.__remove

__remove()

Private slot to handle the Remove context menu action.

TemplateViewer.__resort

__resort()

Private method to resort the tree.

TemplateViewer.__save

__save()

Private slot to handle the Save context menu action.

TemplateViewer.__showContextMenu

__showContextMenu(coord)

Private slot to show the context menu of the list.

coord
the position of the mouse pointer (QPoint)

TemplateViewer.__showHelp

__showHelp()

Private method to show some help.

TemplateViewer.__templateItemActivated

__templateItemActivated(itm = None, col = 0)

Private slot to handle the activation of an item.

itm
reference to the activated item (QTreeWidgetItem)
col
column the item was activated in (integer)

TemplateViewer.addEntry

addEntry(groupName, name, template, quiet = False)

Public method to add a template entry.

groupName
name of the group to add to (string or QString)
name
name of the entry to add (string or QString)
template
template text of the entry (string or QString)
quiet
flag indicating quiet operation (boolean)

TemplateViewer.addGroup

addGroup(name, language = "All")

Public method to add a group.

name
name of the group to be added (string or QString)
language
programming language for the group (string or QString)

TemplateViewer.applyTemplate

applyTemplate(itm)

Public method to apply the template.

itm
reference to the template item to apply (TemplateEntry)

TemplateViewer.changeEntry

changeEntry(itm, name, groupName, template)

Public method to change a template entry.

itm
template entry to be changed (TemplateEntry)
name
new name for the entry (string or QString)
groupName
name of the group the entry should belong to (string or QString)
template
template text of the entry (string or QString)

TemplateViewer.changeGroup

changeGroup(oldname, newname, language = "All")

Public method to rename a group.

oldname
old name of the group (string or QString)
newname
new name of the group (string or QString)
language
programming language for the group (string or QString)

TemplateViewer.getAllGroups

getAllGroups()

Public method to get all groups.

Returns:
list of all groups (list of TemplateGroup)

TemplateViewer.getGroupNames

getGroupNames()

Public method to get all group names.

Returns:
list of all group names (list of strings)

TemplateViewer.readTemplates

readTemplates(filename = None)

Public method to read in the templates file (.e4c)

filename
name of a templates file to read (string or QString)

TemplateViewer.removeEntry

removeEntry(itm)

Public method to remove a template entry.

itm
template entry to be removed (TemplateEntry)

TemplateViewer.removeGroup

removeGroup(itm)

Public method to remove a group.

itm
template group to be removed (TemplateGroup)

TemplateViewer.writeTemplates

writeTemplates(filename = None)

Public method to write the templates data to an XML file (.e4c).

filename
name of a templates file to read (string or QString)

Up