File indexing completed on 2024-04-21 03:57:31
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 */ 0037 QObject *create(const char *iface, QWidget *parentWidget, QObject *parent, const QVariantList &) override 0038 { 0039 // iface == classname to construct 0040 const QByteArray classname(iface); 0041 0042 // default to the kparts::* behavior of having one single widget() if the user don't requested a pure document 0043 const bool bWantSingleView = (classname != "KTextEditor::Document"); 0044 0045 // should we be readonly? 0046 const bool bWantReadOnly = (classname == "KParts::ReadOnlyPart"); 0047 0048 // construct right part variant 0049 KTextEditor::DocumentPrivate *part = new KTextEditor::DocumentPrivate(metaData(), bWantSingleView, bWantReadOnly, parentWidget, parent); 0050 part->setReadWrite(!bWantReadOnly); 0051 return part; 0052 } 0053 }; 0054 0055 #include "katepart.moc"