kexi

kexipart.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2003 Lucijan Busch <lucijan@kde.org>
00003    Copyright (C) 2003-2005 Jaroslaw Staniek <js@iidea.pl>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef KEXIPART_H
00022 #define KEXIPART_H
00023 
00024 #include <qobject.h>
00025 #include <qmap.h>
00026 
00027 #include <kexiutils/tristate.h>
00028 #include "kexi.h"
00029 #include "keximainwindow.h"
00030 
00031 class KActionCollection;
00032 class KexiDialogBase;
00033 class KexiDialogTempData;
00034 class KexiViewBase;
00035 class KexiMainWindowImpl;
00036 class KAction;
00037 class KShortcut;
00038 class KTabWidget;
00039 
00040 namespace KexiPart
00041 {
00042     class Info;
00043     class Item;
00044     class GUIClient;
00045     class PartPrivate;
00046     class StaticInfo;
00047 
00049 enum ObjectTypes {
00050     TableObjectType = KexiDB::TableObjectType, 
00051     QueryObjectType = KexiDB::QueryObjectType, 
00052     FormObjectType = 3,
00053     ReportObjectType = 4,
00054     ScriptObjectType = 5,
00055     WebObjectType = 6,
00056     MacroObjectType = 7,
00057     LastObjectType = 7, //ALWAYS UPDATE THIS
00058 
00059     UserObjectType = 100 //external types
00060 };
00061 
00065 class KEXICORE_EXPORT Part : public QObject
00066 {
00067     Q_OBJECT
00068 
00069     public:
00071         Part(QObject *parent, const char *name, const QStringList &);
00073         virtual ~Part();
00074 
00083         virtual bool execute(KexiPart::Item* item, QObject* sender = 0) {
00084             Q_UNUSED(item);
00085             Q_UNUSED(sender);
00086             return false;
00087         }
00088 
00096         inline int supportedViewModes() const { return m_supportedViewModes; }
00097 
00101         KexiDialogBase* openInstance(KexiMainWindow *win, KexiPart::Item &item, 
00102             int viewMode = Kexi::DataViewMode, QMap<QString,QString>* staticObjectArgs = 0);
00103 
00118         virtual bool remove(KexiMainWindow *win, KexiPart::Item & item);
00119 
00131         virtual tristate rename(KexiMainWindow *win, KexiPart::Item &item, const QString& newName);
00132 
00137         virtual KexiDialogTempData* createTempData(KexiDialogBase* dialog);
00138 
00141         virtual KexiViewBase* createView(QWidget *parent, KexiDialogBase* dialog, 
00142             KexiPart::Item &item, int viewMode = Kexi::DataViewMode, QMap<QString,QString>* staticObjectArgs = 0) = 0;
00143 
00148         QCString instanceName() const;
00149 
00153         QString instanceCaption() const;
00154 
00155         inline Info *info() const { return m_info; }
00156 
00159         inline GUIClient *guiClient() const { return m_guiClient; }
00160 
00163         inline GUIClient *instanceGuiClient(int mode = 0) const
00164             { return m_instanceGuiClients[mode]; }
00165 
00166 #if 0
00167 
00171         virtual DataSource *dataSource() { return 0; }
00172 #endif
00173 
00175         KActionCollection* actionCollectionForMode(int viewMode) const;
00176 
00177         const Kexi::ObjectStatus& lastOperationStatus() const { return m_status; }
00178 
00193         virtual QString i18nMessage(const QCString& englishMessage, 
00194             KexiDialogBase* dlg) const;
00195 
00196     signals: 
00197         void newObjectRequest( KexiPart::Info *info );
00198 
00199     protected slots:
00200         void slotCreate();
00201 
00202     protected:
00204         Part(QObject* parent, StaticInfo *info);
00205 
00206 //      virtual KexiDialogBase* createInstance(KexiMainWindow *win, const KexiPart::Item &item, int viewMode = Kexi::DataViewMode) = 0;
00207 
00210         void createGUIClients(KexiMainWindow *win);
00211 
00212 #if 0
00213 
00218         virtual void initPartActions( KActionCollection * ) {};
00219 
00232         virtual void initInstanceActions( int mode, KActionCollection *col ) {};
00233 #endif
00234 
00235         virtual void initPartActions();
00236         virtual void initInstanceActions();
00237 
00238         virtual KexiDB::SchemaData* loadSchemaData(KexiDialogBase *dlg, 
00239             const KexiDB::SchemaData& sdata, int viewMode);
00240 
00241         bool loadDataBlock( KexiDialogBase *dlg, QString &dataString, const QString& dataID = QString::null);
00242 
00248         KAction* createSharedAction(int mode, const QString &text, 
00249             const QString &pix_name, const KShortcut &cut, const char *name, 
00250             const char *subclassName = 0);
00251 
00253         KAction* createSharedToggleAction(int mode, const QString &text,
00254             const QString &pix_name, const KShortcut &cut, const char *name);
00255 
00261         KAction* createSharedPartAction(const QString &text, 
00262             const QString &pix_name, const KShortcut &cut, const char *name,
00263             const char *subclassName = 0);
00264 
00267         KAction* createSharedPartToggleAction(const QString &text,
00268             const QString &pix_name, const KShortcut &cut, const char *name);
00269 
00270         void setActionAvailable(const char *action_name, bool avail);
00271 
00272         inline void setInfo(Info *info) { m_info = info; }
00273 
00280         virtual void setupCustomPropertyPanelTabs(KTabWidget *tab, KexiMainWindow* mainWin);
00281 
00285         QMap<QString,QString> m_names;
00286 
00289         int m_supportedViewModes;
00290 
00291         Info *m_info;
00292         GUIClient *m_guiClient;
00293         QIntDict<GUIClient> m_instanceGuiClients;
00294         KexiMainWindow* m_mainWin;
00295         Kexi::ObjectStatus m_status;
00296 
00301         int m_registeredPartID;
00302 
00305         bool m_newObjectsAreDirty : 1;
00306 
00307         PartPrivate *d;
00308 
00309     friend class Manager;
00310     friend class ::KexiMainWindow;
00311     friend class ::KexiMainWindowImpl;
00312     friend class GUIClient;
00313 };
00314 
00315 }
00316 
00317 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys