• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KTextEditor

KTextEditor::TemplateInterface

KTextEditor::TemplateInterface Class Reference
[View Extension Interfaces]

#include <templateinterface.h>

List of all members.


Detailed Description

This is an interface for inserting template strings with user editable fields into a document.

Definition at line 39 of file templateinterface.h.


Public Member Functions

bool insertTemplateText (const Cursor &insertPosition, const QString &templateString, const QMap< QString, QString > &initialValues)
 TemplateInterface ()
virtual ~TemplateInterface ()

Static Public Member Functions

static bool expandMacros (QMap< QString, QString > &initialValues, QWidget *parentWindow)

Protected Member Functions

virtual bool insertTemplateTextImplementation (const Cursor &insertPosition, const QString &templateString, const QMap< QString, QString > &initialValues)=0

Constructor & Destructor Documentation

TemplateInterface::TemplateInterface (  ) 

Definition at line 313 of file ktexteditor.cpp.

TemplateInterface::~TemplateInterface (  )  [virtual]

Definition at line 317 of file ktexteditor.cpp.


Member Function Documentation

bool TemplateInterface::expandMacros ( QMap< QString, QString > &  initialValues,
QWidget *  parentWindow 
) [static]

Parses templateString 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 '}'

Parameters:
initialValues a map with the keys for the macros to expand. keys with a value are ignored.
parentWindow is used if dialogs have to be shown
Returns:
true if all macros was successfully expanded
See also:
insertTemplateText for a list of supported macros

Definition at line 36 of file templateinterface.cpp.

bool TemplateInterface::insertTemplateText ( const Cursor &  insertPosition,
const QString &  templateString,
const QMap< QString, QString > &  initialValues 
)

Inserts an interactive ediable template text at line "line", column "col".

Returns:
true if inserting the string succeeded
Use insertTemplateText(lines(), ...) to append text at end of document Template strings look like "for( int ${index}=0;${index}<10;${index}++) { ${cursor} };" or "%{date}"

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

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.

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

  • index: "i"
  • loginname: The current users's loginname
  • firstname: The current user's first name retrieved from kabc
  • lastname: The current user's last name retrieved from kabc
  • fullname: The current user's first and last name retrieved from kabc
  • email: The current user's primary email address retrieved from kabc
  • date: current date
  • time: current time
  • year: current year
  • month: current month
  • day: current day
  • hostname: hostname of the computer
  • 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.

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.

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

Definition at line 114 of file templateinterface.cpp.

virtual bool KTextEditor::TemplateInterface::insertTemplateTextImplementation ( const Cursor &  insertPosition,
const QString &  templateString,
const QMap< QString, QString > &  initialValues 
) [protected, pure virtual]

You must implement this, it is called by insertTemplateText, after all default values are inserted.

If you are implementing this interface, this method should work as described in the documentation for insertTemplateText above.

Returns:
true if any text was inserted.


The documentation for this class was generated from the following files:
  • templateinterface.h
  • ktexteditor.cpp
  • templateinterface.cpp

KTextEditor

Skip menu "KTextEditor"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal