\section{KText\-Editor::Template\-Interface Class Reference}
\label{classKTextEditor_1_1TemplateInterface}\index{KTextEditor::TemplateInterface@{KTextEditor::TemplateInterface}}
This is an interface for inserting template strings with user editable fields into a document.  


{\tt \#include $<$templateinterface.h$>$}

\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
uint {\bf template\-Interface\-Number} () const \label{classKTextEditor_1_1TemplateInterface_a2}

\item 
bool {\bf insert\-Template\-Text} (uint line, uint column, const {\bf QString} \&template\-String, const {\bf QMap}$<$ {\bf QString}, {\bf QString} $>$ \&initial\-Values, {\bf QWidget} $\ast$parent\-Window=0)
\end{CompactItemize}
\subsection*{Static Public Member Functions}
\begin{CompactItemize}
\item 
static bool {\bf expand\-Macros} ({\bf QMap}$<$ {\bf QString}, {\bf QString} $>$ \&initial\-Values, {\bf QWidget} $\ast$parent\-Window)
\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
void {\bf set\-Template\-Interface\-DCOPSuffix} (const {\bf QCString} \&suffix)\label{classKTextEditor_1_1TemplateInterface_b0}

\item 
virtual bool {\bf insert\-Template\-Text\-Implementation} (uint line, uint column, const {\bf QString} \&template\-String, const {\bf QMap}$<$ {\bf QString}, {\bf QString} $>$ \&initial\-Values, {\bf QWidget} $\ast$parent\-Window=0)=0
\end{CompactItemize}
\subsection*{Friends}
\begin{CompactItemize}
\item 
class {\bf Private\-Template\-Interface}\label{classKTextEditor_1_1TemplateInterface_n0}

\end{CompactItemize}


\subsection{Detailed Description}
This is an interface for inserting template strings with user editable fields into a document. 



Definition at line 37 of file templateinterface.h.

\subsection{Member Function Documentation}
\index{KTextEditor::TemplateInterface@{KText\-Editor::Template\-Interface}!expandMacros@{expandMacros}}
\index{expandMacros@{expandMacros}!KTextEditor::TemplateInterface@{KText\-Editor::Template\-Interface}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Template\-Interface::expand\-Macros ({\bf QMap}$<$ {\bf QString}, {\bf QString} $>$ \& {\em initial\-Values}, {\bf QWidget} $\ast$ {\em parent\-Window})\hspace{0.3cm}{\tt  [static]}}\label{classKTextEditor_1_1TemplateInterface_e0}


Parses {\tt template\-String} for macros in the form [\$]\{NAME\} and finds the value corresponding to NAME if any. 

The NAME string may contain any non-whitespace character execpt '\}' \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em initial\-Values}]a map with the keys for the macros to expand. keys with a value are ignored. \item[{\em parent\-Window}]is used if dialogs have to be shown \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]true if all macros was sucessfully expanded \end{Desc}
\begin{Desc}
\item[See also:]{\bf insert\-Template\-Text}{\rm (p.\,\pageref{classKTextEditor_1_1TemplateInterface_a3})} for a list of supported macros \end{Desc}


Definition at line 66 of file templateinterface.cpp.

References QMap::begin(), KLocale::calendar(), QDate\-Time::current\-Date\-Time(), QDate\-Time::date(), QMap::end(), KLocale::format\-Date(), KLocale::format\-Time(), QString::from\-Local8Bit(), KGlobal::locale(), QString::number(), QDate\-Time::time(), and KCalendar\-System::year\-String().

Referenced by insert\-Template\-Text().\index{KTextEditor::TemplateInterface@{KText\-Editor::Template\-Interface}!insertTemplateText@{insertTemplateText}}
\index{insertTemplateText@{insertTemplateText}!KTextEditor::TemplateInterface@{KText\-Editor::Template\-Interface}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Template\-Interface::insert\-Template\-Text (uint {\em line}, uint {\em column}, const {\bf QString} \& {\em template\-String}, const {\bf QMap}$<$ {\bf QString}, {\bf QString} $>$ \& {\em initial\-Values}, {\bf QWidget} $\ast$ {\em parent\-Window} = {\tt 0})}\label{classKTextEditor_1_1TemplateInterface_a3}


Inserts an interactive ediable template text at line \char`\"{}line\char`\"{}, column \char`\"{}col\char`\"{}. 

{\tt parent\-Window} is used if dialogs have to be shown \begin{Desc}
\item[Returns:]true if inserting the string succeeded\end{Desc}
Use insert\-Template\-Text(num\-Lines(), ...) to append text at end of document Template strings look like \char`\"{}for( int \$\{index\}=0;\$\{index\}$<$10;\$\{index\}++) \{ \$\{cursor\} \};\char`\"{} or \char`\"{}\%\{date\}\char`\"{}

This syntax is somewhat similiar to the one found in the Eclipse editor.

There are certain common placeholders (macros), which get assigned a default initial\-Value, If the second parameter does not a given value. For all others the initial value is the name of the placeholder.

Placeholder names may only consist of a-z\-A-Z0-9\_\- Common placeholders and values are

\begin{itemize}
\item index: \char`\"{}i\char`\"{}\item loginname: The current users's loginname\item firstname: The current user's first name retrieved from kabc\item lastname: The current user's last name retrieved from kabc\item fullname: The current user's first and last name retrieved from kabc\item email: The current user's primary email adress retrieved from kabc\item date: current date\item time: current time\item year: current year\item month: current month\item day: current day\item hostname: hostname of the computer\item 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 \char`\"{}$|$\char`\"{} assigned.\end{itemize}


If a macro is started with a  (persent sign) like \char`\"{}\%\{date\}\char`\"{} it isn't added to the list editable strings ( for example TAB key navigation) if a value differing from the macro name is found.

If the editor supports some kind of smart indentation, the inserted code should be layouted by the indenter. 

Definition at line 141 of file templateinterface.cpp.

References QReg\-Exp::cap(), QMap::contains(), expand\-Macros(), insert\-Template\-Text\-Implementation(), QReg\-Exp::matched\-Length(), QReg\-Exp::search(), and QReg\-Exp::set\-Minimal().\index{KTextEditor::TemplateInterface@{KText\-Editor::Template\-Interface}!insertTemplateTextImplementation@{insertTemplateTextImplementation}}
\index{insertTemplateTextImplementation@{insertTemplateTextImplementation}!KTextEditor::TemplateInterface@{KText\-Editor::Template\-Interface}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual bool KText\-Editor::Template\-Interface::insert\-Template\-Text\-Implementation (uint {\em line}, uint {\em column}, const {\bf QString} \& {\em template\-String}, const {\bf QMap}$<$ {\bf QString}, {\bf QString} $>$ \& {\em initial\-Values}, {\bf QWidget} $\ast$ {\em parent\-Window} = {\tt 0})\hspace{0.3cm}{\tt  [protected, pure virtual]}}\label{classKTextEditor_1_1TemplateInterface_b1}


You must implement this, it is called by insert\-Template\-Text, after all default values are inserted. 

If you are implementing this interface, this method should work as described in the documentation for insert\-Template\-Text above. \begin{Desc}
\item[Returns:]true if any text was inserted. \end{Desc}


Referenced by insert\-Template\-Text().

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
templateinterface.h\item 
templateinterface.cpp\end{CompactItemize}
