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     LastObjectType = 6, //ALWAYS UPDATE THIS
00057 
00058     UserObjectType = 100 //external types
00059 };
00060 
00064 class KEXICORE_EXPORT Part : public QObject
00065 {
00066     Q_OBJECT
00067 
00068     public:
00070         Part(QObject *parent, const char *name, const QStringList &);
00072         virtual ~Part();
00073 
00081         virtual KAction* action(const QString& actionuri, QObject* object = 0) {
00082             Q_UNUSED(actionuri);
00083             Q_UNUSED(object);
00084             return 0;
00085         }
00086 
00094         inline int supportedViewModes() const { return m_supportedViewModes; }
00095 
00099         KexiDialogBase* openInstance(KexiMainWindow *win, KexiPart::Item &item, 
00100             int viewMode = Kexi::DataViewMode, QMap<QString,QString>* staticObjectArgs = 0);
00101 
00116         virtual bool remove(KexiMainWindow *win, KexiPart::Item & item);
00117 
00129         virtual tristate rename(KexiMainWindow *win, KexiPart::Item &item, const QString& newName);
00130 
00135         virtual KexiDialogTempData* createTempData(KexiDialogBase* dialog);
00136 
00139         virtual KexiViewBase* createView(QWidget *parent, KexiDialogBase* dialog, 
00140             KexiPart::Item &item, int viewMode = Kexi::DataViewMode, QMap<QString,QString>* staticObjectArgs = 0) = 0;
00141 
00146         QCString instanceName() const;
00147 
00151         QString instanceCaption() const;
00152 
00153         inline Info *info() const { return m_info; }
00154 
00157         inline GUIClient *guiClient() const { return m_guiClient; }
00158 
00161         inline GUIClient *instanceGuiClient(int mode = 0) const
00162             { return m_instanceGuiClients[mode]; }
00163 
00164 #if 0
00165 
00169         virtual DataSource *dataSource() { return 0; }
00170 #endif
00171 
00172         KActionCollection* actionCollectionForMode(int viewMode) const;
00173 
00174         const Kexi::ObjectStatus& lastOperationStatus() const { return m_status; }
00175 
00190         virtual QString i18nMessage(const QCString& englishMessage, 
00191             KexiDialogBase* dlg) const;
00192 
00193     signals: 
00194         void newObjectRequest( KexiPart::Info *info );
00195 
00196     protected slots:
00197         void slotCreate();
00198 
00199     protected:
00201         Part(QObject* parent, StaticInfo *info);
00202 
00203 //      virtual KexiDialogBase* createInstance(KexiMainWindow *win, const KexiPart::Item &item, int viewMode = Kexi::DataViewMode) = 0;
00204 
00207         void createGUIClients(KexiMainWindow *win);
00208 
00209 #if 0
00210 
00215         virtual void initPartActions( KActionCollection * ) {};
00216 
00229         virtual void initInstanceActions( int mode, KActionCollection *col ) {};
00230 #endif
00231 
00232         virtual void initPartActions();
00233         virtual void initInstanceActions();
00234 
00235         virtual KexiDB::SchemaData* loadSchemaData(KexiDialogBase *dlg, 
00236             const KexiDB::SchemaData& sdata, int viewMode);
00237 
00238         bool loadDataBlock( KexiDialogBase *dlg, QString &dataString, const QString& dataID = QString::null);
00239 
00245         KAction* createSharedAction(int mode, const QString &text, 
00246             const QString &pix_name, const KShortcut &cut, const char *name, 
00247             const char *subclassName = 0);
00248 
00250         KAction* createSharedToggleAction(int mode, const QString &text,
00251             const QString &pix_name, const KShortcut &cut, const char *name);
00252 
00258         KAction* createSharedPartAction(const QString &text, 
00259             const QString &pix_name, const KShortcut &cut, const char *name,
00260             const char *subclassName = 0);
00261 
00264         KAction* createSharedPartToggleAction(const QString &text,
00265             const QString &pix_name, const KShortcut &cut, const char *name);
00266 
00267         void setActionAvailable(const char *action_name, bool avail);
00268 
00269         inline void setInfo(Info *info) { m_info = info; }
00270 
00277         virtual void setupCustomPropertyPanelTabs(KTabWidget *tab, KexiMainWindow* mainWin);
00278 
00282         QMap<QString,QString> m_names;
00283 
00286         int m_supportedViewModes;
00287 
00288         Info *m_info;
00289         GUIClient *m_guiClient;
00290         QIntDict<GUIClient> m_instanceGuiClients;
00291         KexiMainWindow* m_mainWin;
00292         Kexi::ObjectStatus m_status;
00293 
00298         int m_registeredPartID;
00299 
00302         bool m_newObjectsAreDirty : 1;
00303 
00304         PartPrivate *d;
00305 
00306     friend class Manager;
00307     friend class ::KexiMainWindow;
00308     friend class ::KexiMainWindowImpl;
00309     friend class GUIClient;
00310 };
00311 
00312 }
00313 
00314 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys