KTextEditor::MainWindow

Search for usage in LXR

KTextEditor::MainWindow Class Reference

#include <KTextEditor/MainWindow>

Inheritance diagram for KTextEditor::MainWindow:

Public Types

enum  ToolViewPosition { Left = 0 , Right = 1 , Top = 2 , Bottom = 3 }
 
- Public Types inherited from QObject
typedef  QObjectList
 

Signals

void pluginViewCreated (const QString &name, QObject *pluginView)
 
void pluginViewDeleted (const QString &name, QObject *pluginView)
 
void unhandledShortcutOverride (QEvent *e)
 
void viewChanged (KTextEditor::View *view)
 
void viewCreated (KTextEditor::View *view)
 
void widgetAdded (QWidget *widget)
 
void widgetRemoved (QWidget *widget)
 

Public Member Functions

 MainWindow (QObject *parent)
 
 ~MainWindow () override
 
KTextEditor::ViewactivateView (KTextEditor::Document *document)
 
void activateWidget (QWidget *widget)
 
KTextEditor::ViewactiveView ()
 
QWidgetactiveWidget ()
 
bool addWidget (QWidget *widget)
 
void addWidgetToViewBar (KTextEditor::View *view, QWidget *bar)
 
bool closeSplitView (KTextEditor::View *view)
 
bool closeView (KTextEditor::View *view)
 
QWidgetcreateToolView (KTextEditor::Plugin *plugin, const QString &identifier, KTextEditor::MainWindow::ToolViewPosition pos, const QIcon &icon, const QString &text)
 
QWidgetcreateViewBar (KTextEditor::View *view)
 
void deleteViewBar (KTextEditor::View *view)
 
KXMLGUIFactoryguiFactory ()
 
bool hideToolView (QWidget *widget)
 
void hideViewBar (KTextEditor::View *view)
 
bool moveToolView (QWidget *widget, KTextEditor::MainWindow::ToolViewPosition pos)
 
KTextEditor::ViewopenUrl (const QUrl &url, const QString &encoding=QString())
 
QObjectpluginView (const QString &name)
 
bool removeWidget (QWidget *widget)
 
bool showMessage (const QVariantMap &message)
 
bool showPluginConfigPage (KTextEditor::Plugin *plugin, int page)
 
bool showToolView (QWidget *widget)
 
void showViewBar (KTextEditor::View *view)
 
void splitView (Qt::Orientation orientation)
 
QList< KTextEditor::View * > views ()
 
bool viewsInSameSplitView (KTextEditor::View *view1, KTextEditor::View *view2)
 
QWidgetList widgets ()
 
QWidgetwindow ()
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
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 () const const
 
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 QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
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_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 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
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, 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 *context, Functor functor, 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)
 
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, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
- 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 to access parts of its main window.

For example the component can get a place to show view bar widgets (e.g. search&replace, goto line, ...). This is useful to e.g. have one place inside the window to show such stuff even if the application allows the user to have multiple split views available per window.

The application must pass a pointer to the MainWindow object to the createView method on view creation and ensure that this main window stays valid for the complete lifetime of the view.

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.

Hosting KTextEditor plugins

Definition at line 46 of file mainwindow.h.

Member Enumeration Documentation

◆ ToolViewPosition

Toolview position.

A toolview can only be at one side at a time.

Enumerator
Left 

Left side.

Right 

Right side.

Top 

Top side.

Bottom 

Bottom side.

Definition at line 218 of file mainwindow.h.

Constructor & Destructor Documentation

◆ MainWindow()

KTextEditor::MainWindow::MainWindow ( QObject * parent)

Construct an MainWindow 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 19 of file mainwindow.cpp.

◆ ~MainWindow()

KTextEditor::MainWindow::~MainWindow ( )
override

Virtual Destructor.

Definition at line 25 of file mainwindow.cpp.

Member Function Documentation

◆ activateView()

KTextEditor::View * KTextEditor::MainWindow::activateView ( KTextEditor::Document * document)

Activate the view with the corresponding document.

If none exist for this document, create one

Parameters
documentthe document
Returns
activated view of this document, return nullptr if not possible

Definition at line 61 of file mainwindow.cpp.

◆ activateWidget()

void KTextEditor::MainWindow::activateWidget ( QWidget * widget)

activate widget.

If the widget is not present in the window, it will be added to the window

Parameters
widgetthe widget to activate
Since
6.0

Definition at line 250 of file mainwindow.cpp.

◆ activeView()

KTextEditor::View * KTextEditor::MainWindow::activeView ( )

Access the active view.

Returns
active view, nullptr if not available

Definition at line 53 of file mainwindow.cpp.

◆ activeWidget()

QWidget * KTextEditor::MainWindow::activeWidget ( )

returns the currently active widget.

It can be a non-KTextEditorView widget or a KTextEditor::View

Since
6.0

Definition at line 242 of file mainwindow.cpp.

◆ addWidget()

bool KTextEditor::MainWindow::addWidget ( QWidget * widget)

Add a widget to the main window.

This is useful to show non-KTextEditorView widgets in the main window. The host application should try to manage this like some KTextEditor::View (e.g. as a tab) and provide the means to close it.

Parameters
widgetwidget to add
Returns
success, if false, the plugin needs to take care to show the widget itself, otherwise the main window will take ownership of the widget
Since
5.98

Definition at line 218 of file mainwindow.cpp.

◆ addWidgetToViewBar()

void KTextEditor::MainWindow::addWidgetToViewBar ( KTextEditor::View * view,
QWidget * bar )

Add a widget to the view bar.

Parameters
viewview for which the view bar is used
barbar widget, shall have the viewBarParent() as parent widget

Definition at line 130 of file mainwindow.cpp.

◆ closeSplitView()

bool KTextEditor::MainWindow::closeSplitView ( KTextEditor::View * view)

Close the split view that contains the given view.

Parameters
viewthe view.
Returns
true if the split view was closed.

Definition at line 95 of file mainwindow.cpp.

◆ closeView()

bool KTextEditor::MainWindow::closeView ( KTextEditor::View * view)

Close selected view.

Parameters
viewthe view
Returns
true if view was closed

Definition at line 81 of file mainwindow.cpp.

◆ createToolView()

QWidget * KTextEditor::MainWindow::createToolView ( KTextEditor::Plugin * plugin,
const QString & identifier,
KTextEditor::MainWindow::ToolViewPosition pos,
const QIcon & icon,
const QString & text )

Create a new toolview with unique identifier at side pos with icon and caption text.

Use the returned widget to embedd your widgets.

Parameters
pluginwhich owns this tool view
identifierunique identifier for this toolview
posposition for the toolview, if we are in session restore, this is only a preference
iconicon to use in the sidebar for the toolview
texttranslated text (i18n()) to use in addition to icon
Returns
created toolview on success, otherwise NULL

Definition at line 148 of file mainwindow.cpp.

◆ createViewBar()

QWidget * KTextEditor::MainWindow::createViewBar ( KTextEditor::View * view)

Try to create a view bar for the given view.

Parameters
viewview for which we want an view bar
Returns
suitable widget that can host view bars widgets or nullptr

Definition at line 116 of file mainwindow.cpp.

◆ deleteViewBar()

void KTextEditor::MainWindow::deleteViewBar ( KTextEditor::View * view)

Delete the view bar for the given view.

Parameters
viewview for which we want an view bar

Definition at line 124 of file mainwindow.cpp.

◆ guiFactory()

KXMLGUIFactory * KTextEditor::MainWindow::guiFactory ( )

Accessor to the XMLGUIFactory.

Returns
the mainwindow's KXMLGUIFactory, nullptr if not available

Definition at line 37 of file mainwindow.cpp.

◆ hideToolView()

bool KTextEditor::MainWindow::hideToolView ( QWidget * widget)

Hide the toolview widget.

Parameters
widgetthe toolview to hide, where the widget was constructed by createToolView().
Returns
true on success, otherwise false

Definition at line 189 of file mainwindow.cpp.

◆ hideViewBar()

void KTextEditor::MainWindow::hideViewBar ( KTextEditor::View * view)

Hide the view bar for the given view.

Parameters
viewview for which the view bar is used

Definition at line 142 of file mainwindow.cpp.

◆ moveToolView()

bool KTextEditor::MainWindow::moveToolView ( QWidget * widget,
KTextEditor::MainWindow::ToolViewPosition pos )

Move the toolview widget to position pos.

Parameters
widgetthe toolview to move, where the widget was constructed by createToolView().
posnew position to move widget to
Returns
true on success, otherwise false

Definition at line 168 of file mainwindow.cpp.

◆ openUrl()

KTextEditor::View * KTextEditor::MainWindow::openUrl ( const QUrl & url,
const QString & encoding = QString() )

Open the document url with the given encoding.

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 view for the new document, if a document with this url is already existing, its view will be activated, return nullptr if not possible

Definition at line 73 of file mainwindow.cpp.

◆ pluginView()

QObject * KTextEditor::MainWindow::pluginView ( const QString & name)

Get a plugin view for the plugin with with identifier name.

Parameters
namethe plugin's name
Returns
pointer to the plugin view if a plugin with name is loaded and has a view for this mainwindow, otherwise NULL

Definition at line 210 of file mainwindow.cpp.

◆ pluginViewCreated

void KTextEditor::MainWindow::pluginViewCreated ( const QString & name,
QObject * pluginView )
signal

This signal is emitted when the view of some Plugin is created for this main window.

Parameters
namename of plugin
pluginViewthe new plugin view

◆ pluginViewDeleted

void KTextEditor::MainWindow::pluginViewDeleted ( const QString & name,
QObject * pluginView )
signal

This signal is emitted when the view of some Plugin got 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
namename of plugin
pluginViewthe deleted plugin view

◆ removeWidget()

bool KTextEditor::MainWindow::removeWidget ( QWidget * widget)

remove this widget from this mainwindow.

The widget will be deleted afterwards

Parameters
widgetthe widget to be removed
Returns
true on success
Since
6.0

Definition at line 226 of file mainwindow.cpp.

◆ showMessage()

bool KTextEditor::MainWindow::showMessage ( const QVariantMap & message)

Display a message to the user.

The host application might show this inside a dedicated output view.

Parameters
messageincoming message we shall handle
Returns
true, if the host application was able to handle the message, else false
Since
5.98

details of message format:

message text, will be trimmed before output

message["text"] = i18n("your cool message")

the text will be split in lines, all lines beside the first can be collapsed away

message type, we support at the moment

message["type"] = "Error" message["type"] = "Warning" message["type"] = "Info" message["type"] = "Log"

this is take from https://microsoft.github.io/language-server-protocol/specification#window_showMessage MessageType of LSP

will lead to appropriate icons/... in the output view

a message should have some category, like Git, LSP, ....

message["category"] = i18n(...)

will be used to allow the user to filter for

one can additionally provide a categoryIcon

message["categoryIcon"] = QIcon(...)

the categoryIcon icon QVariant must contain a QIcon, nothing else!

A string token can be passed to allow to replace messages already send out with new ones. That is useful for e.g. progress output

message["token"] = "yourmessagetoken"

Definition at line 256 of file mainwindow.cpp.

◆ showPluginConfigPage()

bool KTextEditor::MainWindow::showPluginConfigPage ( KTextEditor::Plugin * plugin,
int page )

Shows the plugin's config page.

The page specifies which config page will be shown, see KTextEditor::Plugin::configPages().

Returns
true on success, otherwise false
Since
5.63

Definition at line 197 of file mainwindow.cpp.

◆ showToolView()

bool KTextEditor::MainWindow::showToolView ( QWidget * widget)

Show the toolview widget.

Parameters
widgetthe toolview to show, where the widget was constructed by createToolView().
Returns
true on success, otherwise false
Todo
add focus parameter: bool showToolView (QWidget *widget, bool giveFocus );

Definition at line 181 of file mainwindow.cpp.

◆ showViewBar()

void KTextEditor::MainWindow::showViewBar ( KTextEditor::View * view)

Show the view bar for the given view.

Parameters
viewview for which the view bar is used

Definition at line 136 of file mainwindow.cpp.

◆ splitView()

void KTextEditor::MainWindow::splitView ( Qt::Orientation orientation)

Split current view space according to orientation.

Parameters
orientationin which line split the view

Definition at line 89 of file mainwindow.cpp.

◆ unhandledShortcutOverride

void KTextEditor::MainWindow::unhandledShortcutOverride ( QEvent * e)
signal

This signal is emitted for every unhandled ShortcutOverride in the window.

Parameters
eresponsible event

◆ viewChanged

void KTextEditor::MainWindow::viewChanged ( KTextEditor::View * view)
signal

This signal is emitted whenever the active view changes.

Parameters
viewnew active view

◆ viewCreated

void KTextEditor::MainWindow::viewCreated ( KTextEditor::View * view)
signal

This signal is emitted whenever a new view is created.

Parameters
viewview that was created

◆ views()

QList< KTextEditor::View * > KTextEditor::MainWindow::views ( )

Get a list of all views for this main window.

It is beneficial if the list is sorted by most recently used, as the library will e.g. try to use the most recent used url() by walking over this list for save and other such things.

Returns
all views, might be empty!

Definition at line 45 of file mainwindow.cpp.

◆ viewsInSameSplitView()

bool KTextEditor::MainWindow::viewsInSameSplitView ( KTextEditor::View * view1,
KTextEditor::View * view2 )
Returns
true if the given views view1 and view2 share the same split view, false otherwise.

Definition at line 103 of file mainwindow.cpp.

◆ widgetAdded

void KTextEditor::MainWindow::widgetAdded ( QWidget * widget)
signal

The widget was added to this window.

Parameters
widgetthe widget that got added
Since
6.0

◆ widgetRemoved

void KTextEditor::MainWindow::widgetRemoved ( QWidget * widget)
signal

The widget was removed from this window.

Parameters
widgetthe widget that got removed
Since
6.0

◆ widgets()

QWidgetList KTextEditor::MainWindow::widgets ( )

returns the list of non-KTextEditorView widgets in this main window.

See also
addWidget
Since
6.0

Definition at line 234 of file mainwindow.cpp.

◆ window()

QWidget * KTextEditor::MainWindow::window ( )

Get the toplevel widget.

Returns
the real main window widget, nullptr if not available

Definition at line 29 of file mainwindow.cpp.


The documentation for this class was generated from the following files:
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.