.TH "KTextEditor::TemplateInterface" kde3 "11 Jun 2005" "Version Version 3.4.1" "interfaces Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KTextEditor::TemplateInterface \- This is an interface for inserting template strings with user editable fields into a document.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <templateinterface.h>\fP
.PP
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "uint \fBtemplateInterfaceNumber\fP () const "
.br
.ti -1c
.RI "bool \fBinsertTemplateText\fP (uint line, uint column, const \fBQString\fP &templateString, const \fBQMap\fP< \fBQString\fP, \fBQString\fP > &initialValues, \fBQWidget\fP *parentWindow=0)"
.br
.in -1c
.SS "Static Public Member Functions"

.in +1c
.ti -1c
.RI "static bool \fBexpandMacros\fP (\fBQMap\fP< \fBQString\fP, \fBQString\fP > &initialValues, \fBQWidget\fP *parentWindow)"
.br
.in -1c
.SS "Protected Member Functions"

.in +1c
.ti -1c
.RI "void \fBsetTemplateInterfaceDCOPSuffix\fP (const \fBQCString\fP &suffix)"
.br
.ti -1c
.RI "virtual bool \fBinsertTemplateTextImplementation\fP (uint line, uint column, const \fBQString\fP &templateString, const \fBQMap\fP< \fBQString\fP, \fBQString\fP > &initialValues, \fBQWidget\fP *parentWindow=0)=0"
.br
.in -1c
.SS "Friends"

.in +1c
.ti -1c
.RI "class \fBPrivateTemplateInterface\fP"
.br
.in -1c
.SH "Detailed Description"
.PP 
This is an interface for inserting template strings with user editable fields into a document. 
.PP
Definition at line 37 of file templateinterface.h.
.SH "Member Function Documentation"
.PP 
.SS "bool TemplateInterface::expandMacros (\fBQMap\fP< \fBQString\fP, \fBQString\fP > & initialValues, \fBQWidget\fP * parentWindow)\fC [static]\fP"
.PP
Parses \fCtemplateString\fP for macros in the form [$]{NAME} and finds the value corresponding to NAME if any. 
.PP
The NAME string may contain any non-whitespace character execpt '}' 
.PP
\fBParameters:\fP
.RS 4
\fIinitialValues\fP a map with the keys for the macros to expand. keys with a value are ignored. 
.br
\fIparentWindow\fP is used if dialogs have to be shown 
.RE
.PP
\fBReturns:\fP
.RS 4
true if all macros was sucessfully expanded 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBinsertTemplateText\fP for a list of supported macros 
.RE
.PP

.PP
Definition at line 66 of file templateinterface.cpp.
.PP
References QMap::begin(), KLocale::calendar(), QDateTime::currentDateTime(), QDateTime::date(), QMap::end(), KLocale::formatDate(), KLocale::formatTime(), QString::fromLocal8Bit(), KGlobal::locale(), QString::number(), QDateTime::time(), and KCalendarSystem::yearString().
.PP
Referenced by insertTemplateText().
.SS "bool TemplateInterface::insertTemplateText (uint line, uint column, const \fBQString\fP & templateString, const \fBQMap\fP< \fBQString\fP, \fBQString\fP > & initialValues, \fBQWidget\fP * parentWindow = \fC0\fP)"
.PP
Inserts an interactive ediable template text at line 'line', column 'col'. 
.PP
\fCparentWindow\fP is used if dialogs have to be shown 
.PP
\fBReturns:\fP
.RS 4
true if inserting the string succeeded
.RE
.PP
Use insertTemplateText(numLines(), ...) to append text at end of document Template strings look like 'for( int ${index}=0;${index}<10;${index}++) { ${cursor} };' or '%{date}'
.PP
This syntax is somewhat similiar to the one found in the Eclipse editor.
.PP
There are certain common placeholders (macros), which get assigned a default initialValue, If the second parameter does not a given value. For all others the initial value is the name of the placeholder.
.PP
Placeholder names may only consist of a-zA-Z0-9_ Common placeholders and values are
.PP
.IP "\(bu" 2
index: 'i'
.IP "\(bu" 2
loginname: The current users's loginname
.IP "\(bu" 2
firstname: The current user's first name retrieved from kabc
.IP "\(bu" 2
lastname: The current user's last name retrieved from kabc
.IP "\(bu" 2
fullname: The current user's first and last name retrieved from kabc
.IP "\(bu" 2
email: The current user's primary email adress retrieved from kabc
.IP "\(bu" 2
date: current date
.IP "\(bu" 2
time: current time
.IP "\(bu" 2
year: current year
.IP "\(bu" 2
month: current month
.IP "\(bu" 2
day: current day
.IP "\(bu" 2
hostname: hostname of the computer
.IP "\(bu" 2
cursor: at this position the cursor will be after editing of the template has finished, this has to be taken care of by the actual implementation. The placeholder gets a value of '|' assigned.
.PP
.PP
If a macro is started with a  (persent sign) like '%{date}' it isn't added to the list editable strings ( for example TAB key navigation) if a value differing from the macro name is found.
.PP
If the editor supports some kind of smart indentation, the inserted code should be layouted by the indenter. 
.PP
Definition at line 141 of file templateinterface.cpp.
.PP
References QRegExp::cap(), QMap::contains(), expandMacros(), insertTemplateTextImplementation(), QRegExp::matchedLength(), QRegExp::search(), and QRegExp::setMinimal().
.SS "virtual bool KTextEditor::TemplateInterface::insertTemplateTextImplementation (uint line, uint column, const \fBQString\fP & templateString, const \fBQMap\fP< \fBQString\fP, \fBQString\fP > & initialValues, \fBQWidget\fP * parentWindow = \fC0\fP)\fC [protected, pure virtual]\fP"
.PP
You must implement this, it is called by insertTemplateText, after all default values are inserted. 
.PP
If you are implementing this interface, this method should work as described in the documentation for insertTemplateText above. 
.PP
\fBReturns:\fP
.RS 4
true if any text was inserted. 
.RE
.PP

.PP
Referenced by insertTemplateText().

.SH "Author"
.PP 
Generated automatically by Doxygen for interfaces Library from the source code.
