• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.10.2 API Reference
  • KDE Home
  • Contact Us
 

KTextEditor

  • KTextEditor
  • Editor
Signals | Public Member Functions | Protected Member Functions
KTextEditor::Editor Class Reference

#include <editor.h>

Inheritance diagram for KTextEditor::Editor:
QObject

List of all members.

Signals

void documentCreated (KTextEditor::Editor *editor, KTextEditor::Document *document)

Public Member Functions

 Editor (QObject *parent)
virtual ~Editor ()
virtual const KAboutData * aboutData () const =0
virtual void configDialog (QWidget *parent)=0
virtual bool configDialogSupported () const =0
virtual ConfigPage * configPage (int number, QWidget *parent)=0
virtual QString configPageFullName (int number) const =0
virtual KIcon configPageIcon (int number) const =0
virtual QString configPageName (int number) const =0
virtual int configPages () const =0
virtual Document * createDocument (QObject *parent)=0
const QString & defaultEncoding () const
virtual const QList< Document * > & documents ()=0
virtual void readConfig (KConfig *config=0)=0
void setSimpleMode (bool on)
bool simpleMode () const
virtual void writeConfig (KConfig *config=0)=0

Protected Member Functions

void setDefaultEncoding (const QString &defaultEncoding)

Detailed Description

Accessor interface for Editor part.

Topics:

  • Introduction
  • Editor Configuration
  • Implementation Notes
  • Editor Extension Interfaces

Introduction

The Editor part can be accessed via the KTextEditor::Factory or the KTextEditor::EditorChooser and provides general information and configuration methods for the Editor implementation, for example KAboutData by using aboutData().

The Editor implementation has a list of all opened documents. Get this list with documents(). To create a new Document call createDocument(). The signal documentCreated() is emitted whenever the Editor created a new document.

Editor Configuration

If the Editor implementation supports a config dialog configDialogSupported() returns true, then the config dialog can be shown with configDialog(). Instead of using the config dialog, the config pages can be embedded into the application's config dialog. To do this, configPages() returns the number of config pages the Editor implementation provides and configPage() returns the requested page. Further, a config page has a short descriptive name, get it with configPageName(). You can get more detailed name by using configPageFullName(). Also every config page has a pixmap, get it with configPagePixmap(). The configuration can be saved and loaded with readConfig() and writeConfig().

Note:
We recommend to embedd the config pages into the main application's config dialog instead of using a separate config dialog, if the config dialog does not look cluttered then. This way, all settings are grouped together in one place.

Implementation Notes

Usually only one instance of the Editor exists. The Kate Part implementation internally uses a static accessor to make sure that only one Kate Part Editor object exists. So several factories still use the same Editor.

readConfig() and writeConfig() should be forwarded to all loaded plugins as well, see KTextEditor::Plugin::readConfig() and KTextEditor::Plugin::writeConfig().

Editor Extension Interfaces

There is only a single extension interface for the Editor: the CommandInterface. With the CommandInterface it is possible to add and remove new command line commands which are valid for all documents. Common use cases are for example commands like find or setting document variables. For further details read the detailed descriptions in the class KTextEditor::CommandInterface.

See also:
KTextEditor::Factory, KTextEditor::Document, KTextEditor::ConfigPage KTextEditor::Plugin, KTextEditor::CommandInterface
Author:
Christoph Cullmann <cullm.nosp@m.ann@.nosp@m.kde.o.nosp@m.rg>

Definition at line 102 of file editor.h.


Constructor & Destructor Documentation

Editor::Editor ( QObject *  parent)

Constructor.

Create the Editor object with parent.

Parameters:
parentparent object

Definition at line 85 of file ktexteditor.cpp.

Editor::~Editor ( )
virtual

Virtual destructor.

Definition at line 91 of file ktexteditor.cpp.


Member Function Documentation

virtual const KAboutData* KTextEditor::Editor::aboutData ( ) const
pure virtual

Get the about data of this Editor part.

Returns:
about data
virtual void KTextEditor::Editor::configDialog ( QWidget *  parent)
pure virtual

Show the editor's config dialog, changes will be applied to the editor, but not saved anywhere automagically, call writeConfig() to save them.

Note:
Instead of using the config dialog, the config pages can be embedded into your own config dialog by using configPages() and configPage().
Parameters:
parentparent widget
See also:
configDialogSupported()
virtual bool KTextEditor::Editor::configDialogSupported ( ) const
pure virtual

Check, whether this editor has a configuration dialog.

Returns:
true, if the editor has a configuration dialog, otherwise false
See also:
configDialog()
virtual ConfigPage* KTextEditor::Editor::configPage ( int  number,
QWidget *  parent 
)
pure virtual

Get the config page with the number, config pages from 0 to configPages()-1 are available if configPages() > 0.

Parameters:
numberindex of config page
parentparent widget for config page
Returns:
created config page or NULL, if the number is out of bounds
See also:
configPages()
virtual QString KTextEditor::Editor::configPageFullName ( int  number) const
pure virtual

Get a readable full name for the config page number.

The name should be translated.

Example: If the name is "Filetypes", the full name could be "Filetype Specific Settings". For "Shortcuts" the full name would be something like "Shortcut Configuration".

Parameters:
numberindex of config page
Returns:
full name of given page index
See also:
configPageName(), configPagePixmap()
virtual KIcon KTextEditor::Editor::configPageIcon ( int  number) const
pure virtual

Get a pixmap with size for the config page number.

Parameters:
numberindex of config page
Returns:
pixmap for the given page index
See also:
configPageName(), configPageFullName()
virtual QString KTextEditor::Editor::configPageName ( int  number) const
pure virtual

Get a readable name for the config page number.

The name should be translated.

Parameters:
numberindex of config page
Returns:
name of given page index
See also:
configPageFullName(), configPagePixmap()
virtual int KTextEditor::Editor::configPages ( ) const
pure virtual

Get the number of available config pages.

If the editor returns a number < 1, it does not support config pages and the embedding application should use configDialog() instead.

Returns:
number of config pages
See also:
configPage(), configDialog()
virtual Document* KTextEditor::Editor::createDocument ( QObject *  parent)
pure virtual

Create a new document object with parent.

Parameters:
parentparent object
Returns:
new KTextEditor::Document object
See also:
documents()
const QString & Editor::defaultEncoding ( ) const

Get the current default encoding for this Editor part.

Returns:
default encoding
Since:
4.5

Definition at line 106 of file ktexteditor.cpp.

void KTextEditor::Editor::documentCreated ( KTextEditor::Editor *  editor,
KTextEditor::Document *  document 
)
signal

The editor emits this signal whenever a document was successfully created.

Parameters:
editoreditor which created the new document
documentthe newly created document instance
See also:
createDocument()
virtual const QList<Document*>& KTextEditor::Editor::documents ( )
pure virtual

Get a list of all documents of this editor.

Returns:
list of all existing documents
See also:
createDocument()
virtual void KTextEditor::Editor::readConfig ( KConfig *  config = 0)
pure virtual

Read editor configuration from KConfig config.

Note:
Implementation Notes: If config is NULL you should use kapp->config() as a fallback solution. Additionally the readConfig() call should be forwarded to every loaded plugin.
Parameters:
configconfig object
See also:
writeConfig()
void Editor::setDefaultEncoding ( const QString &  defaultEncoding)
protected

Set the current default encoding for this Editor part.

Editor part implementation should call this internally on creation and config changes.

Parameters:
defaultEncodingnew default encoding
Since:
4.5

Definition at line 111 of file ktexteditor.cpp.

void Editor::setSimpleMode ( bool  on)

Switch editor to simple mode for average users.

Switch the editor to a simple mode which will hide advanced stuff from average user or switch it back to normal mode. This mode will only affect documents/views created after the change.

Parameters:
onturn simple mode on or not

Definition at line 96 of file ktexteditor.cpp.

bool Editor::simpleMode ( ) const

Query the editor whether simple mode is on or not.

Returns:
true if simple mode is on, otherwise false
See also:
setSimpleMode()

Definition at line 101 of file ktexteditor.cpp.

virtual void KTextEditor::Editor::writeConfig ( KConfig *  config = 0)
pure virtual

Write editor configuration to KConfig config.

Note:
Implementation Notes: If config is NULL you should use kapp->config() as a fallback solution. Additionally the writeConfig() call should be forwarded to every loaded plugin.
Parameters:
configconfig object
See also:
readConfig()

The documentation for this class was generated from the following files:
  • editor.h
  • ktexteditor.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sun Apr 28 2013 14:32:01 by doxygen 1.8.1.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KTextEditor

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

kdelibs-4.10.2 API Reference

Skip menu "kdelibs-4.10.2 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal