File indexing completed on 2024-05-05 16:17:49
0001 /* 0002 SPDX-FileCopyrightText: 2001-2010 Christoph Cullmann <cullmann@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "katedocument.h" 0008 0009 #include <KPluginFactory> 0010 0011 /** 0012 * wrapper factory to be sure nobody external deletes our kateglobal object 0013 * each instance will just increment the reference counter of our internal 0014 * super private global instance ;) 0015 */ 0016 class KateFactory : public KPluginFactory 0017 { 0018 Q_OBJECT 0019 0020 Q_PLUGIN_METADATA(IID KPluginFactory_iid FILE "katepart.json") 0021 0022 Q_INTERFACES(KPluginFactory) 0023 0024 public: 0025 /** 0026 * This function is called when the factory asked to create an Object. 0027 * 0028 * You may reimplement it to provide a very flexible factory. This is especially useful to 0029 * provide generic factories for plugins implemented using a scripting language. 0030 * 0031 * \param iface The staticMetaObject::className() string identifying the plugin interface that 0032 * was requested. E.g. for KCModule plugins this string will be "KCModule". 0033 * \param parentWidget Only used if the requested plugin is a KPart. 0034 * \param parent The parent object for the plugin object. 0035 * \param args A plugin specific list of arbitrary arguments. 0036 * \param keyword A string that uniquely identifies the plugin. If a KService is used this 0037 * keyword is read from the X-KDE-PluginKeyword entry in the .desktop file. 0038 */ 0039 QObject *create(const char *iface, QWidget *parentWidget, QObject *parent, const QVariantList &, const QString &) override 0040 { 0041 // iface == classname to construct 0042 const QByteArray classname(iface); 0043 0044 // default to the kparts::* behavior of having one single widget() if the user don't requested a pure document 0045 const bool bWantSingleView = (classname != "KTextEditor::Document"); 0046 0047 // should we be readonly? 0048 const bool bWantReadOnly = (classname == "KParts::ReadOnlyPart"); 0049 0050 // construct right part variant 0051 KTextEditor::DocumentPrivate *part = new KTextEditor::DocumentPrivate(bWantSingleView, bWantReadOnly, parentWidget, parent); 0052 part->setReadWrite(!bWantReadOnly); 0053 part->setMetaData(metaData()); 0054 return part; 0055 } 0056 }; 0057 0058 #include "katepart.moc"