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 
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 
00076 
00084         virtual bool execute(KexiPart::Item* item, QObject* sender = 0) {
00085             Q_UNUSED(item);
00086             Q_UNUSED(sender);
00087             return false;
00088         }
00089 
00097         inline int supportedViewModes() const { return m_supportedViewModes; }
00098 
00105         inline int supportedUserViewModes() const { return m_supportedUserViewModes; }
00106 
00108 
00111         KexiDialogBase* openInstance(KexiMainWindow *win, KexiPart::Item &item, 
00112             int viewMode = Kexi::DataViewMode, QMap<QString,QString>* staticObjectArgs = 0);
00113 
00115 
00129         virtual bool remove(KexiMainWindow *win, KexiPart::Item & item);
00130 
00142         virtual tristate rename(KexiMainWindow *win, KexiPart::Item &item, const QString& newName);
00143 
00148         virtual KexiDialogTempData* createTempData(KexiDialogBase* dialog);
00149 
00152         virtual KexiViewBase* createView(QWidget *parent, KexiDialogBase* dialog, 
00153             KexiPart::Item &item, int viewMode = Kexi::DataViewMode, QMap<QString,QString>* staticObjectArgs = 0) = 0;
00154 
00159         QCString instanceName() const;
00160 
00164         QString instanceCaption() const;
00165 
00166         inline Info *info() const { return m_info; }
00167 
00170         inline GUIClient *guiClient() const { return m_guiClient; }
00171 
00174         inline GUIClient *instanceGuiClient(int mode = 0) const
00175             { return m_instanceGuiClients[mode]; }
00176 
00177 #if 0
00178 
00182         virtual DataSource *dataSource() { return 0; }
00183 #endif
00184 
00186         KActionCollection* actionCollectionForMode(int viewMode) const;
00187 
00188         const Kexi::ObjectStatus& lastOperationStatus() const { return m_status; }
00189 
00204         virtual QString i18nMessage(const QCString& englishMessage, 
00205             KexiDialogBase* dlg) const;
00206 
00207     signals: 
00208         void newObjectRequest( KexiPart::Info *info );
00209 
00210     protected slots:
00211         void slotCreate();
00212 
00213     protected:
00215         Part(QObject* parent, StaticInfo *info);
00216 
00217 //      virtual KexiDialogBase* createInstance(KexiMainWindow *win, const KexiPart::Item &item, int viewMode = Kexi::DataViewMode) = 0;
00218 
00221         void createGUIClients(KexiMainWindow *win);
00222 
00223 #if 0
00224 
00229         virtual void initPartActions( KActionCollection * ) {};
00230 
00243         virtual void initInstanceActions( int mode, KActionCollection *col ) {};
00244 #endif
00245 
00246         virtual void initPartActions();
00247         virtual void initInstanceActions();
00248 
00249         virtual KexiDB::SchemaData* loadSchemaData(KexiDialogBase *dlg, 
00250             const KexiDB::SchemaData& sdata, int viewMode);
00251 
00252         bool loadDataBlock( KexiDialogBase *dlg, QString &dataString, const QString& dataID = QString::null);
00253 
00259         KAction* createSharedAction(int mode, const QString &text, 
00260             const QString &pix_name, const KShortcut &cut, const char *name, 
00261             const char *subclassName = 0);
00262 
00264         KAction* createSharedToggleAction(int mode, const QString &text,
00265             const QString &pix_name, const KShortcut &cut, const char *name);
00266 
00272         KAction* createSharedPartAction(const QString &text, 
00273             const QString &pix_name, const KShortcut &cut, const char *name,
00274             const char *subclassName = 0);
00275 
00278         KAction* createSharedPartToggleAction(const QString &text,
00279             const QString &pix_name, const KShortcut &cut, const char *name);
00280 
00281         void setActionAvailable(const char *action_name, bool avail);
00282 
00283         inline void setInfo(Info *info) { m_info = info; }
00284 
00291         virtual void setupCustomPropertyPanelTabs(KTabWidget *tab, KexiMainWindow* mainWin);
00292 
00296         QMap<QString,QString> m_names;
00297 
00300         int m_supportedViewModes;
00301 
00305         int m_supportedUserViewModes;
00306 
00307         Info *m_info;
00308         GUIClient *m_guiClient;
00309         QIntDict<GUIClient> m_instanceGuiClients;
00310         KexiMainWindow* m_mainWin;
00311         Kexi::ObjectStatus m_status;
00312 
00317         int m_registeredPartID;
00318 
00321         bool m_newObjectsAreDirty : 1;
00322 
00323         PartPrivate *d;
00324 
00325     friend class Manager;
00326     friend class ::KexiMainWindow;
00327     friend class ::KexiMainWindowImpl;
00328     friend class GUIClient;
00329 };
00330 
00331 }
00332 
00333 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys