KTextEditor

katepart.cpp
1/*
2 SPDX-FileCopyrightText: 2001-2010 Christoph Cullmann <cullmann@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "katedocument.h"
8
9#include <KPluginFactory>
10
11/**
12 * wrapper factory to be sure nobody external deletes our kateglobal object
13 * each instance will just increment the reference counter of our internal
14 * super private global instance ;)
15 */
16class KateFactory : public KPluginFactory
17{
19
20 Q_PLUGIN_METADATA(IID KPluginFactory_iid FILE "katepart.json")
21
23
24public:
25 /**
26 * This function is called when the factory asked to create an Object.
27 *
28 * You may reimplement it to provide a very flexible factory. This is especially useful to
29 * provide generic factories for plugins implemented using a scripting language.
30 *
31 * \param iface The staticMetaObject::className() string identifying the plugin interface that
32 * was requested. E.g. for KCModule plugins this string will be "KCModule".
33 * \param parentWidget Only used if the requested plugin is a KPart.
34 * \param parent The parent object for the plugin object.
35 * \param args A plugin specific list of arbitrary arguments.
36 */
37 QObject *create(const char *iface, QWidget *parentWidget, QObject *parent, const QVariantList &) override
38 {
39 // iface == classname to construct
40 const QByteArray classname(iface);
41
42 // default to the kparts::* behavior of having one single widget() if the user don't requested a pure document
43 const bool bWantSingleView = (classname != "KTextEditor::Document");
44
45 // should we be readonly?
46 const bool bWantReadOnly = (classname == "KParts::ReadOnlyPart");
47
48 // construct right part variant
49 KTextEditor::DocumentPrivate *part = new KTextEditor::DocumentPrivate(metaData(), bWantSingleView, bWantReadOnly, parentWidget, parent);
50 part->setReadWrite(!bWantReadOnly);
51 return part;
52 }
53};
54
55#include "katepart.moc"
KPluginMetaData metaData() const
Q_INTERFACES(...)
Q_OBJECTQ_OBJECT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:15:44 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.