File indexing completed on 2024-05-12 16:39:37
0001 /* This file is part of the KDE project 0002 Copyright (C) 2004 Lucijan Busch <lucijan@kde.org> 0003 Copyright (C) 2004-2006 Jarosław Staniek <staniek@kde.org> 0004 0005 This library is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU Library General Public 0007 License as published by the Free Software Foundation; either 0008 version 2 of the License, or (at your option) any later version. 0009 0010 This library is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 Library General Public License for more details. 0014 0015 You should have received a copy of the GNU Library General Public License 0016 along with this library; see the file COPYING.LIB. If not, write to 0017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #ifndef KEXIINTERNALPART_H 0022 #define KEXIINTERNALPART_H 0023 0024 #include <QVariant> 0025 0026 #include "kexipartbase.h" 0027 0028 class QDialog; 0029 class KexiWindow; 0030 class KexiView; 0031 class KDbMessageHandler; 0032 0033 /** 0034 * @short A prototype for Kexi Internal Parts (plugins) implementation. 0035 * 0036 * Internal Kexi parts are parts that are not available for users, but loaded 0037 * internally by application when needed. Example of such part is Relations Window. 0038 * The internal part instance is unique and has no explicitly stored data. 0039 * Parts may be able to create widgets or/and dialogs, depending on implementation 0040 * (createWidgetInstance(), createKexiWindowInstance(), createModalDialogInstance()). 0041 * Parts can have unique flag set for windows (true by default) 0042 * - then a dialog created by createModalDialogInstance() is unique. 0043 */ 0044 class KEXICORE_EXPORT KexiInternalPart : public KexiPart::PartBase 0045 { 0046 Q_OBJECT 0047 0048 public: 0049 KexiInternalPart(QObject *parent, const QVariantList &list); 0050 virtual ~KexiInternalPart(); 0051 0052 /*! Creates a new widget instance using part pointed by \a className. 0053 \a widgetClass is a pseudo class used in case when the part offers more 0054 than one widget type. 0055 \a msgHdr is a message handler for displaying error messages. 0056 \a args is two-way optional argument: it can contain custom options used 0057 on widget's creation. Depending on implementation, the created widget can write its 0058 state (e.g. result or status information) back to this argument. 0059 Created widget will have assigned \a parent widget and \a objName name. */ 0060 Q_REQUIRED_RESULT static QWidget *createWidgetInstance(const QString &className, 0061 const char* widgetClass, 0062 KDbMessageHandler *msgHdr, 0063 QWidget *parent, const char *objName = nullptr, 0064 QMap<QString, QString>* args = nullptr); 0065 0066 /*! For convenience. */ 0067 Q_REQUIRED_RESULT static QWidget *createWidgetInstance(const QString &className, 0068 KDbMessageHandler *msgHdr, 0069 QWidget *parent, const char *objName = nullptr, 0070 QMap<QString, QString>* args = nullptr); 0071 0072 /*! Creates a new object instance using part pointed by \a className. 0073 \a widgetClass is a pseudo class used in case when the part offers more 0074 than one object type. */ 0075 Q_REQUIRED_RESULT static QObject *createObjectInstance(const QString &className, 0076 const char* objectClass, KDbMessageHandler *msgHdr, 0077 QObject *parent, const char *objName = nullptr, 0078 QMap<QString, QString>* args = nullptr); 0079 0080 /*! Creates a new KexiWindow instance. If such instance already exists, 0081 and is unique (see uniqueWindow()) it is just returned. 0082 The part knows about destroying its window instance (if it is uinque), 0083 so on another call the window will be created again. 0084 \a msgHdr is a message handler for displaying error messages. 0085 The window is assigned to the main window, 0086 and \a objName name is set. */ 0087 Q_REQUIRED_RESULT static KexiWindow *createKexiWindowInstance(const QString &className, 0088 KDbMessageHandler *msgHdr, const char *objName = nullptr); 0089 0090 /*! Creates a new modal dialog instance (QDialog or a subclass). 0091 If such instance already exists, and is unique (see uniqueWindow()) 0092 it is just returned. 0093 \a dialogClass is a pseudo class used in case when the part offers more 0094 than one dialog type. 0095 \a msgHdr is a message handler for displaying error messages. 0096 \a args is two-way optional argument: it can contain custom options used 0097 on widget's creation. Depending on implementation, the created dialog can write its 0098 state (e.g. result or status information) back to this argument. 0099 The part knows about destroying its dialog instance, (if it is uinque), 0100 so on another call the dialog will be created again. 0101 The dialog is assigned to the main window, 0102 and \a objName name is set. */ 0103 Q_REQUIRED_RESULT static QDialog *createModalDialogInstance(const QString &className, 0104 const char* dialogClass, KDbMessageHandler *msgHdr, 0105 const char *objName = nullptr, QMap<QString, QString>* args = nullptr); 0106 0107 /*! Adeded For convenience. */ 0108 Q_REQUIRED_RESULT static QDialog *createModalDialogInstance(const QString &className, 0109 KDbMessageHandler *msgHdr, const char *objName = nullptr, 0110 QMap<QString, QString>* args = nullptr); 0111 0112 /*! Executes a command \a commandName (usually nonvisual) using part pointed by \a className. 0113 The result can be put into the \a args. \return true on successful calling. */ 0114 static bool executeCommand(const QString &className, 0115 const char* commandName, QMap<QString, QString>* args = 0); 0116 0117 /*! \return internal part pointed by \a className. Shouldn't be usable. */ 0118 static KexiInternalPart* part(KDbMessageHandler *msgHdr, const QString &className); 0119 0120 /*! \return true if the part can create only one (unique) window. */ 0121 bool createsUniqueWindow() const; 0122 0123 void setCreatesUniqueWindow(bool set); 0124 0125 /*! \return true if the part creation has been cancelled (eg. by a user) 0126 so it wasn't an error. Internal part's impelmentation should set it to true when needed. 0127 False by default. */ 0128 bool cancelled() const; 0129 0130 void setCancelled(bool set); 0131 0132 protected: 0133 /*! Used internally */ 0134 KexiWindow *findOrCreateKexiWindow(const char *objName); 0135 0136 /*! Reimplement this if your internal part has to return objects. */ 0137 Q_REQUIRED_RESULT virtual QObject *createObject(const char* objectClass, 0138 QObject * parent, const char * objName = nullptr, 0139 QMap<QString, QString>* args = nullptr); 0140 0141 /*! Reimplement this if your internal part has to return widgets 0142 or QDialog objects. */ 0143 Q_REQUIRED_RESULT virtual QWidget *createWidget(const char* widgetClass, 0144 QWidget * parent, const char * objName = nullptr, 0145 QMap<QString, QString>* args = nullptr); 0146 0147 /*! Reimplement this if your internal part has to return a view object. */ 0148 Q_REQUIRED_RESULT virtual KexiView *createView(QWidget * parent, const char *objName = nullptr); 0149 0150 /*! Reimplement this if your internal part has to execute a command \a commandName 0151 (usually nonvisual). Arguments are put into \a args and the result can be put into the \a args. 0152 \return true on successful calling. */ 0153 virtual bool executeCommand(const char* commandName, QMap<QString, QString>* args = 0); 0154 0155 private: 0156 0157 Q_DISABLE_COPY(KexiInternalPart) 0158 0159 class Private; 0160 Private* const d; 0161 }; 0162 0163 #endif