KTextEditor::Application

KTextEditor::Application Class Reference

#include <KTextEditor/Application>

Inheritance diagram for KTextEditor::Application:

Signals

void aboutToCreateDocuments ()
 
void aboutToDeleteDocuments (const QList< KTextEditor::Document * > &)
 
void documentCreated (KTextEditor::Document *document)
 
void documentDeleted (KTextEditor::Document *document)
 
void documentsCreated (const QList< KTextEditor::Document * > &documents)
 
void documentsDeleted (const QList< KTextEditor::Document * > &documents)
 
void documentWillBeDeleted (KTextEditor::Document *document)
 
void pluginCreated (const QString &name, KTextEditor::Plugin *plugin)
 
void pluginDeleted (const QString &name, KTextEditor::Plugin *plugin)
 

Public Member Functions

 Application (QObject *parent)
 
virtual ~Application ()
 
KTextEditor::MainWindowactiveMainWindow ()
 
bool closeDocument (KTextEditor::Document *document)
 
bool closeDocuments (const QList< KTextEditor::Document * > &documents)
 
QList< KTextEditor::Document * > documents ()
 
KTextEditor::DocumentfindUrl (const QUrl &url)
 
QList< KTextEditor::MainWindow * > mainWindows ()
 
KTextEditor::DocumentopenUrl (const QUrl &url, const QString &encoding=QString())
 
KTextEditor::Pluginplugin (const QString &name)
 
bool quit ()
 
- 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
 

Additional Inherited Members

- Properties inherited from QObject
 objectName
 
- 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)
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- 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)
 

Detailed Description

This class allows the application that embeds the KTextEditor component to allow it access to application wide information and interactions.

For example the component can get the current active main window of the application.

The application must pass a pointer to the Application object to the setApplication method of the global editor instance and ensure that this object stays valid for the complete lifetime of the editor.

It must not reimplement this class but construct an instance and pass a pointer to a QObject that has the required slots to receive the requests.

KTextEditor::Editor::instance()->application() will always return a non-nullptr object to avoid the need for nullptr checks before calling the API.

The same holds for activeMainWindow(), even if no main window is around, you will get a non-nullptr interface object that allows to call the functions of the MainWindow without needs for a nullptr check around it in the client code.

Definition at line 55 of file application.h.

Constructor & Destructor Documentation

KTextEditor::Application::Application ( QObject parent)

Construct an Application wrapper object.

The passed parent is both the parent of this QObject and the receiver of all interface calls via invokeMethod.

Parameters
parentobject the calls are relayed to

Definition at line 29 of file application.cpp.

KTextEditor::Application::~Application ( )
virtual

Virtual Destructor.

Definition at line 35 of file application.cpp.

Member Function Documentation

void KTextEditor::Application::aboutToCreateDocuments ( )
signal

This signal is emitted before the batch of documents is being created.

You can use it to pause some updates.

void KTextEditor::Application::aboutToDeleteDocuments ( const QList< KTextEditor::Document * > &  )
signal

This signal is emitted before the documents batch is going to be deleted.

note that the batch can be interrupted in the middle and only some of the documents may be actually deleted. See documentsDeleted() signal.

KTextEditor::MainWindow * KTextEditor::Application::activeMainWindow ( )

Accessor to the active main window.

Returns
a pointer to the active mainwindow, even if no main window is active you will get a non-nullptr dummy interface that allows you to call interface functions without the need for null checks

dispatch to parent

always return some kind of window to not need to check for valid pointer

Definition at line 60 of file application.cpp.

bool KTextEditor::Application::closeDocument ( KTextEditor::Document document)

Close the given document.

If the document is modified, user will be asked if he wants that.

Parameters
documentthe document to be closed
Returns
true on success, otherwise false

dispatch to parent

Definition at line 104 of file application.cpp.

bool KTextEditor::Application::closeDocuments ( const QList< KTextEditor::Document * > &  documents)

Close a list of documents.

If any of them are modified, user will be asked if he wants that. Use this, if you want to close multiple documents at once, as the application might be able to group the "do you really want that" dialogs into one.

Parameters
documentslist of documents to be closed
Returns
true on success, otherwise false

dispatch to parent

Definition at line 114 of file application.cpp.

void KTextEditor::Application::documentCreated ( KTextEditor::Document document)
signal

This signal is emitted when the document was created.

Parameters
documentdocument that was created
void KTextEditor::Application::documentDeleted ( KTextEditor::Document document)
signal

This signal is emitted when the document has been deleted.

Warning !!! DO NOT ACCESS THE DATA REFERENCED BY THE POINTER, IT IS ALREADY INVALID Use the pointer only to remove mappings in hash or maps

Parameters
documentdocument that is deleted
QList< KTextEditor::Document * > KTextEditor::Application::documents ( )

Get a list of all documents that are managed by the application.

This might contain less documents than the editor has in his documents () list.

Returns
all documents the application manages, might be empty!

dispatch to parent

Definition at line 74 of file application.cpp.

void KTextEditor::Application::documentsCreated ( const QList< KTextEditor::Document * > &  documents)
signal

This signal is emitted after the batch of documents is created.

Parameters
documentslist of documents that have been created
void KTextEditor::Application::documentsDeleted ( const QList< KTextEditor::Document * > &  documents)
signal

This signal is emitted after the documents batch was deleted.

This is the batch closing signal for aboutToDeleteDocuments

Parameters
documentsthe documents that weren't deleted after all
void KTextEditor::Application::documentWillBeDeleted ( KTextEditor::Document document)
signal

This signal is emitted before a document which should be closed is deleted The document is still accessible and usable, but it will be deleted after this signal was send.

Parameters
documentdocument that will be deleted
KTextEditor::Document * KTextEditor::Application::findUrl ( const QUrl url)

Get the document with the URL url.

if multiple documents match the searched url, return the first found one...

Parameters
urlthe document's URL
Returns
the document with the given url or nullptr, if none found

dispatch to parent

Definition at line 84 of file application.cpp.

QList< KTextEditor::MainWindow * > KTextEditor::Application::mainWindows ( )

Get a list of all main windows.

Returns
all main windows, might be empty!

dispatch to parent

Definition at line 50 of file application.cpp.

KTextEditor::Document * KTextEditor::Application::openUrl ( const QUrl url,
const QString encoding = QString() 
)

Open the document url with the given encoding.

if the url is empty, a new empty document will be created

Parameters
urlthe document's url
encodingthe preferred encoding. If encoding is QString() the encoding will be guessed or the default encoding will be used.
Returns
a pointer to the created document

dispatch to parent

Definition at line 94 of file application.cpp.

KTextEditor::Plugin * KTextEditor::Application::plugin ( const QString name)

Get a plugin for the plugin with with identifier name.

Parameters
namethe plugin's name
Returns
pointer to the plugin if a plugin with name is loaded, otherwise nullptr

dispatch to parent

Definition at line 124 of file application.cpp.

void KTextEditor::Application::pluginCreated ( const QString name,
KTextEditor::Plugin plugin 
)
signal

This signal is emitted when an Plugin was loaded.

Parameters
namename of plugin
pluginthe new plugin
void KTextEditor::Application::pluginDeleted ( const QString name,
KTextEditor::Plugin plugin 
)
signal

This signal is emitted when an Plugin got deleted.

Parameters
namename of plugin
pluginthe deleted plugin

Warning !!! DO NOT ACCESS THE DATA REFERENCED BY THE POINTER, IT IS ALREADY INVALID Use the pointer only to remove mappings in hash or maps

bool KTextEditor::Application::quit ( )

Ask app to quit.

The app might interact with the user and decide that quitting is not possible and return false.

Returns
true if the app could quit

dispatch to parent

Definition at line 39 of file application.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Jul 14 2020 22:57:47 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.