KTextEditor

Overview of the Core Interface Design

Overview | Design | Coding Guidelines | Porting to KDE Frameworks 5

The core of the KTextEditor interfaces consists of three main interfaces:

  • KTextEditor::Editor (singleton)
    The Editor is a singleton accessed through KTextEditor::Editor::instance(). This singleton allows to create documents, get a document list, and a be informed when a new document is created.
  • KTextEditor::Document
    The Document interface represents a single document and enables the creation of views, access to and manipulation of document contents, and access to document extension interfaces.
  • KTextEditor::View
    The View provides a widget that displays the contents of a Document, and its interface allows for manipulation of text selection, position of the cursor and mouse, text selections, and behavior of the view. Additionally it provides access to the view extension interfaces.

The hierarchy can be illustrated as follows:

Basic KTextEditor Hierarchy

Notes for KTextEditor Users

To use the KTextEditor framework you first have to get the KTextEditor::Editor singleton through KTextEditor::Editor::instance(). Using this object, documents can be created and deleted.

Using KTextEditor as KPart

If linking to KF5::TextEditor is not an option, you can also access the KTextEditor framework as follows

if (service) {
m_part = service->createInstance<KParts::ReadWritePart>(0);
}
static Ptr serviceByDesktopPath(const QString &_path)

Notes for KTextEditor Developers

The KTextEditor::Editor has a list of all opened documents and can create new documents. A Document's content is visualized by a KTextEditor::View. A Document can have any number of views (or none). When the content of the document is changed, the change is reflected in all views.

See also
KTextEditor::Editor, KTextEditor::Document, KTextEditor::View
Author
Dominik Haumann <dhaum.nosp@m.ann@.nosp@m.kde.o.nosp@m.rg>
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:56 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.