KTextEditor::Editor

Search for usage in LXR

#include <KTextEditor/Editor>

Inheritance diagram for KTextEditor::Editor:

Public Types

using ExpandFunction = QString(*)(const QStringView &text, KTextEditor::View *view)
 

Signals

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

Public Member Functions

virtual const KAboutDataaboutData () const =0
 
void addVariableExpansion (const QVector< QWidget * > &widgets, const QStringList &variables=QStringList()) const
 
virtual KTextEditor::Applicationapplication () const =0
 
virtual QStringList commandList () const =0
 
virtual QList< Command * > commands () const =0
 
virtual void configDialog (QWidget *parent)=0
 
virtual ConfigPageconfigPage (int number, QWidget *parent)=0
 
virtual int configPages () const =0
 
virtual DocumentcreateDocument (QObject *parent)=0
 
QString defaultEncoding () const
 
virtual QList< Document * > documents ()=0
 
void expandText (const QString &text, KTextEditor::View *view, QString &output) const
 
bool expandVariable (const QString &variable, KTextEditor::View *view, QString &output) const
 
QFont font () const
 
virtual CommandqueryCommand (const QString &cmd) const =0
 
bool registerVariableMatch (const QString &name, const QString &description, ExpandFunction expansionFunc)
 
bool registerVariablePrefix (const QString &prefix, const QString &description, ExpandFunction expansionFunc)
 
const KSyntaxHighlighting::Repositoryrepository () const
 
virtual void setApplication (KTextEditor::Application *application)=0
 
KSyntaxHighlighting::Theme theme () const
 
bool unregisterVariableMatch (const QString &variable)
 
bool unregisterVariablePrefix (const QString &variable)
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Static Public Member Functions

static Editorinstance ()
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 

Protected Member Functions

 Editor (EditorPrivate *impl)
 
virtual ~Editor ()
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Properties inherited from QObject
 objectName
 
- Public Attributes inherited from QObject
typedef QObjectList
 

Detailed Description

Accessor interface for the KTextEditor framework.

Topics:

Introduction

The Editor part can either be accessed through the static accessor Editor::instance() or through the KParts component model (see Using KTextEditor as KPart). The Editor singleton provides general information and configuration methods for the Editor, for example KAboutData by using aboutData().

The Editor 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

The config dialog can be shown with configDialog(). Instead of using the config dialog, the config pages can also be embedded into the application's config dialog. To do this, configPages() returns the number of config pages that exist and configPage() returns the requested page. The configuration are saved automatically by the Editor.

Note
It is recommended to embed 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.

Command Line Commands

With Commands it is possible to add new commands to the command line. These Commands then are added to all document Views. Common use cases include commands like find or setting document variables. The list of all registered commands can be obtained either through commandList() or through commands(). Further, a specific command can be obtained through queryCommand(). For further information, read the Command API documentation.

See also
KTextEditor::Document, KTextEditor::ConfigPage, KTextEditor::Command
Author
Christoph Cullmann <cullm[email protected][email protected][email protected]kde.o[email protected]rg>

Definition at line 90 of file editor.h.

Member Typedef Documentation

Function that is called to expand a variable in text.

Definition at line 309 of file editor.h.

Constructor & Destructor Documentation

Editor::Editor ( EditorPrivate impl)
protected

Constructor.

Create the Editor object and pass it the internal implementation to store a d-pointer.

Parameters
impld-pointer to use

Definition at line 73 of file ktexteditor.cpp.

Editor::~Editor ( )
protectedvirtualdefault

Virtual destructor.

Member Function Documentation

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

Get the about data of this Editor part.

Returns
about data

Implemented in KTextEditor::EditorPrivate.

void Editor::addVariableExpansion ( const QVector< QWidget * > &  widgets,
const QStringList variables = QStringList() 
) const

Adds a QAction to the widget in widgets that whenever focus is gained.

When the action is invoked, a non-modal dialog is shown that lists all variables. If variables is non-empty, then only the variables in variables are listed.

The supported QWidgets in the widgets argument currently are:

Since
5.63

Definition at line 125 of file ktexteditor.cpp.

virtual KTextEditor::Application* KTextEditor::Editor::application ( ) const
pure virtual

Current hosting application, if any set.

Returns
current application object or a dummy interface that allows you to call the functions will never return a nullptr

Implemented in KTextEditor::EditorPrivate.

virtual QStringList KTextEditor::Editor::commandList ( ) const
pure virtual

Get a list of available command line strings.

Returns
command line strings
See also
commands()

Implemented in KTextEditor::EditorPrivate.

virtual QList<Command *> KTextEditor::Editor::commands ( ) const
pure virtual

Get a list of all registered commands.

Returns
list of all commands
See also
queryCommand(), commandList()

Implemented in KTextEditor::EditorPrivate.

void KTextEditor::Editor::configChanged ( KTextEditor::Editor editor)
signal

This signal is emitted whenever the editor configuration is changed.

Parameters
editorthe editor which's config has changed
Since
5.79
virtual void KTextEditor::Editor::configDialog ( QWidget parent)
pure virtual

Show the editor's config dialog, changes will be applied to the editor and the configuration changes are saved.

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

Implemented in KTextEditor::EditorPrivate.

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.

Configuration changes done over this widget are automatically saved.

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()

Implemented in KTextEditor::EditorPrivate.

virtual int KTextEditor::Editor::configPages ( ) const
pure virtual

Get the number of available config pages.

If a number < 1 is returned, it does not support config pages.

Returns
number of config pages
See also
configPage()

Implemented in KTextEditor::EditorPrivate.

virtual Document* KTextEditor::Editor::createDocument ( QObject parent)
pure virtual

Create a new document object with parent.

For each created document, the signal documentCreated() is emitted.

Parameters
parentparent object
Returns
new KTextEditor::Document object
See also
documents(), documentCreated()

Implemented in KTextEditor::EditorPrivate.

QString Editor::defaultEncoding ( ) const

Get the current default encoding for this Editor part.

Returns
default encoding

Definition at line 87 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
editorpointer to the Editor singleton which created the new document
documentthe newly created document instance
See also
createDocument()
virtual 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()

Implemented in KTextEditor::EditorPrivate.

void Editor::expandText ( const QString text,
KTextEditor::View view,
QString output 
) const

Expands arbitrary text that may contain arbitrary many variables.

On success, the expanded text is written to output.

Since
5.57

Definition at line 120 of file ktexteditor.cpp.

bool Editor::expandVariable ( const QString variable,
KTextEditor::View view,
QString output 
) const

Expands a single variable, writing the expanded value to output.

Returns
true on success, otherwise false.
Since
5.57

Definition at line 115 of file ktexteditor.cpp.

QFont Editor::font ( ) const

Get the current global editor font.

Might change during runtime, configChanged() will be emitted in that cases. Individual views might have set different fonts, can be queried with the "font" key via

See also
KTextEditor::ConfigInterface::configValue().
Returns
current global font for all views
Since
5.80

Definition at line 130 of file ktexteditor.cpp.

Editor * KTextEditor::Editor::instance ( )
static

Accessor to get the Editor instance.

Note
This object will stay alive until QCoreApplication terminates. You shall not delete it yourself. There is only ONE Editor instance of this per process.
Returns
Editor controller, after initial construction, will live until QCoreApplication is terminating.

Definition at line 81 of file ktexteditor.cpp.

virtual Command* KTextEditor::Editor::queryCommand ( const QString cmd) const
pure virtual

Query for the command cmd.

If the command cmd does not exist the return value is NULL.

Parameters
cmdname of command to query for
Returns
the found command or NULL if no such command exists

Implemented in KTextEditor::EditorPrivate.

bool Editor::registerVariableMatch ( const QString name,
const QString description,
ExpandFunction  expansionFunc 
)

Registers a variable called name for exact matches.

For instance, a variable called "CurrentDocument:Path" could be registered which then expands to the path the current document.

Returns
true on success, false if the variable could not be registered, e.g. because it already was registered previously.
Since
5.57

Definition at line 93 of file ktexteditor.cpp.

bool Editor::registerVariablePrefix ( const QString prefix,
const QString description,
ExpandFunction  expansionFunc 
)

Registers a variable for arbitrary text that matches the specified prefix.

For instance, a variable called "ENV:" could be registered which then expands arbitrary environment variables, e.g. ENV:HOME would expand to the user's home directory.

Note
A colon ':' is used as separator for the prefix and the text after the colon that should be evaluated.
Returns
true on success, false if a prefix could not be registered, e.g. because it already was registered previously.
Since
5.57

Definition at line 99 of file ktexteditor.cpp.

const KSyntaxHighlighting::Repository & Editor::repository ( ) const

Get read-only access to the syntax highlighting repository the editor uses.

Might be reloaded during runtime, repositoryReloaded() will be emitted in that cases.

Returns
syntax repository used by the editor
Since
5.79

Definition at line 140 of file ktexteditor.cpp.

void KTextEditor::Editor::repositoryReloaded ( KTextEditor::Editor editor)
signal

This signal is emitted whenever the editor syntax repository is reloaded.

Can be used to e.g. re-instantiate syntax definitions that got invalidated by the repository reload.

Parameters
editorthe editor which's repository was reloaded
Since
5.79
virtual void KTextEditor::Editor::setApplication ( KTextEditor::Application application)
pure virtual

Set the global application object.

This will allow the editor component to access the hosting application.

Parameters
applicationapplication object if the argument is a nullptr, this will reset the application back to a dummy interface

Implemented in KTextEditor::EditorPrivate.

KSyntaxHighlighting::Theme Editor::theme ( ) const

Get the current global theme.

Might change during runtime, configChanged() will be emitted in that cases. Individual views might have set different themes,

See also
KTextEditor::View::theme().
Returns
current global theme for all views
Since
5.79

Definition at line 135 of file ktexteditor.cpp.

bool Editor::unregisterVariableMatch ( const QString variable)

Unregisters a variable that was previously registered with registerVariableMatch().

Returns
true if the variable was successfully unregistered, and false if the variable did not exist.
Since
5.57

Definition at line 105 of file ktexteditor.cpp.

bool Editor::unregisterVariablePrefix ( const QString variable)

Unregisters a prefix of variable that was previously registered with registerVariableMatch().

Returns
true if the variable was successfully unregistered, and false if the variable did not exist.
Since
5.57

Definition at line 110 of file ktexteditor.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Jul 31 2021 22:59:42 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.