KTextEditor

application.cpp
1 /* SPDX-License-Identifier: LGPL-2.0-or-later
2 
3  Copyright (C) 2013 Christoph Cullmann <[email protected]>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include <ktexteditor/application.h>
22 #include <ktexteditor/mainwindow.h>
23 #include <ktexteditor/plugin.h>
24 
25 #include "kateglobal.h"
26 
27 namespace KTextEditor
28 {
30  : QObject(parent)
31  , d(nullptr)
32 {
33 }
34 
36 {
37 }
38 
40 {
44  bool success = false;
45  QMetaObject::invokeMethod(parent(), "quit", Qt::DirectConnection, Q_RETURN_ARG(bool, success));
46 
47  return success;
48 }
49 
51 {
56  QMetaObject::invokeMethod(parent(), "mainWindows", Qt::DirectConnection, Q_RETURN_ARG(QList<KTextEditor::MainWindow *>, mainWindow));
57  return mainWindow;
58 }
59 
61 {
65  KTextEditor::MainWindow *window = nullptr;
66  QMetaObject::invokeMethod(parent(), "activeMainWindow", Qt::DirectConnection, Q_RETURN_ARG(KTextEditor::MainWindow *, window));
67 
71  return window ? window : KTextEditor::EditorPrivate::self()->dummyMainWindow();
72 }
73 
75 {
81  return documents;
82 }
83 
85 {
89  KTextEditor::Document *document = nullptr;
90  QMetaObject::invokeMethod(parent(), "findUrl", Qt::DirectConnection, Q_RETURN_ARG(KTextEditor::Document *, document), Q_ARG(QUrl, url));
91  return document;
92 }
93 
95 {
99  KTextEditor::Document *document = nullptr;
100  QMetaObject::invokeMethod(parent(), "openUrl", Qt::DirectConnection, Q_RETURN_ARG(KTextEditor::Document *, document), Q_ARG(QUrl, url), Q_ARG(QString, encoding));
101  return document;
102 }
103 
105 {
109  bool success = false;
110  QMetaObject::invokeMethod(parent(), "closeDocument", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(KTextEditor::Document *, document));
111  return success;
112 }
113 
115 {
119  bool success = false;
120  QMetaObject::invokeMethod(parent(), "closeDocuments", Qt::DirectConnection, Q_RETURN_ARG(bool, success), Q_ARG(QList<KTextEditor::Document *>, documents));
121  return success;
122 }
123 
125 {
129  Plugin *plugin = nullptr;
130  QMetaObject::invokeMethod(parent(), "plugin", Qt::DirectConnection, Q_RETURN_ARG(KTextEditor::Plugin *, plugin), Q_ARG(QString, name));
131  return plugin;
132 }
133 
134 } // namespace KTextEditor
KTextEditor::Document * openUrl(const QUrl &url, const QString &encoding=QString())
Open the document url with the given encoding.
Definition: application.cpp:94
QList< KTextEditor::Document * > documents()
Get a list of all documents that are managed by the application.
Definition: application.cpp:74
virtual ~Application()
Virtual Destructor.
Definition: application.cpp:35
KTextEditor::MainWindow * activeMainWindow()
Accessor to the active main window.
Definition: application.cpp:60
QList< KTextEditor::MainWindow * > mainWindows()
Get a list of all main windows.
Definition: application.cpp:50
Application(QObject *parent)
Construct an Application wrapper object.
Definition: application.cpp:29
bool closeDocuments(const QList< KTextEditor::Document * > &documents)
Close a list of documents.
A KParts derived class representing a text document.
Definition: document.h:199
KTextEditor::Plugin * plugin(const QString &name)
Get a plugin for the plugin with with identifier name.
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
KTextEditor::MainWindow * dummyMainWindow()
Dummy main window to be null safe.
Definition: kateglobal.h:398
bool quit()
Ask app to quit.
Definition: application.cpp:39
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)
KTextEditor Plugin interface.
Definition: plugin.h:92
bool closeDocument(KTextEditor::Document *document)
Close the given document.
DirectConnection
static KTextEditor::EditorPrivate * self()
Kate Part Internal stuff ;)
Definition: kateglobal.cpp:373
QObject * parent() const const
This class allows the application that embeds the KTextEditor component to allow it to access parts o...
Definition: mainwindow.h:57
KTextEditor::Document * findUrl(const QUrl &url)
Get the document with the URL url.
Definition: application.cpp:84
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat Jul 11 2020 22:57:07 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.