KTextEditor

application.cpp
1 /*
2  SPDX-FileCopyrightText: 2013 Christoph Cullmann <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include <ktexteditor/application.h>
8 #include <ktexteditor/mainwindow.h>
9 #include <ktexteditor/plugin.h>
10 
11 #include "kateglobal.h"
12 
13 namespace KTextEditor
14 {
16  : QObject(parent)
17  , d(nullptr)
18 {
19 }
20 
21 Application::~Application() = default;
22 
24 {
25  // dispatch to parent
26  bool success = false;
27  QMetaObject::invokeMethod(parent(), "quit", Qt::DirectConnection, Q_RETURN_ARG(bool, success));
28 
29  return success;
30 }
31 
33 {
34  // dispatch to parent
36  QMetaObject::invokeMethod(parent(), "mainWindows", Qt::DirectConnection, Q_RETURN_ARG(QList<KTextEditor::MainWindow *>, mainWindow));
37  return mainWindow;
38 }
39 
41 {
42  // dispatch to parent
43  KTextEditor::MainWindow *window = nullptr;
44  QMetaObject::invokeMethod(parent(), "activeMainWindow", Qt::DirectConnection, Q_RETURN_ARG(KTextEditor::MainWindow *, window));
45 
46  // always return some kind of window to not need to check for valid pointer
47  return window ? window : KTextEditor::EditorPrivate::self()->dummyMainWindow();
48 }
49 
51 {
52  // dispatch to parent
55  return documents;
56 }
57 
59 {
60  // dispatch to parent
61  KTextEditor::Document *document = nullptr;
62  QMetaObject::invokeMethod(parent(), "findUrl", Qt::DirectConnection, Q_RETURN_ARG(KTextEditor::Document *, document), Q_ARG(QUrl, url));
63  return document;
64 }
65 
67 {
68  // dispatch to parent
69  KTextEditor::Document *document = nullptr;
71  "openUrl",
73  Q_RETURN_ARG(KTextEditor::Document *, document),
74  Q_ARG(QUrl, url),
75  Q_ARG(QString, encoding));
76  return document;
77 }
78 
80 {
81  // dispatch to parent
82  bool success = false;
83  QMetaObject::invokeMethod(parent(), "closeDocument", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(KTextEditor::Document *, document));
84  return success;
85 }
86 
88 {
89  // dispatch to parent
90  bool success = false;
91  QMetaObject::invokeMethod(parent(), "closeDocuments", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(QList<KTextEditor::Document *>, documents));
92  return success;
93 }
94 
96 {
97  // dispatch to parent
98  Plugin *plugin = nullptr;
99  QMetaObject::invokeMethod(parent(), "plugin", Qt::DirectConnection, Q_RETURN_ARG(KTextEditor::Plugin *, plugin), Q_ARG(QString, name));
100  return plugin;
101 }
102 
103 } // namespace KTextEditor
KTextEditor::Document * openUrl(const QUrl &url, const QString &encoding=QString())
Open the document url with the given encoding.
Definition: application.cpp:66
QList< KTextEditor::Document * > documents()
Get a list of all documents that are managed by the application.
Definition: application.cpp:50
KTextEditor::MainWindow * activeMainWindow()
Accessor to the active main window.
Definition: application.cpp:40
QList< KTextEditor::MainWindow * > mainWindows()
Get a list of all main windows.
Definition: application.cpp:32
Application(QObject *parent)
Construct an Application wrapper object.
Definition: application.cpp:15
bool closeDocuments(const QList< KTextEditor::Document * > &documents)
Close a list of documents.
Definition: application.cpp:87
A KParts derived class representing a text document.
Definition: document.h:185
KTextEditor::Plugin * plugin(const QString &name)
Get a plugin for the plugin with with identifier name.
Definition: application.cpp:95
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
Definition: katetextblock.h:22
KTextEditor::MainWindow * dummyMainWindow()
Dummy main window to be null safe.
Definition: kateglobal.h:372
bool quit()
Ask app to quit.
Definition: application.cpp:23
bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType type, QGenericReturnArgument ret, QGenericArgument val0, QGenericArgument val1, QGenericArgument val2, QGenericArgument val3, QGenericArgument val4, QGenericArgument val5, QGenericArgument val6, QGenericArgument val7, QGenericArgument val8, QGenericArgument val9)
~Application() override
Virtual Destructor.
KTextEditor Plugin interface.
Definition: plugin.h:78
bool closeDocument(KTextEditor::Document *document)
Close the given document.
Definition: application.cpp:79
DirectConnection
static KTextEditor::EditorPrivate * self()
Kate Part Internal stuff ;)
Definition: kateglobal.cpp:335
QObject * parent() const const
This class allows the application that embeds the KTextEditor component to allow it to access parts o...
Definition: mainwindow.h:43
KTextEditor::Document * findUrl(const QUrl &url)
Get the document with the URL url.
Definition: application.cpp:58
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Dec 6 2021 22:50:09 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.