kexi

kexidialogbase.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2003 Lucijan Busch <lucijan@kde.org>
00003    Copyright (C) 2003-2004 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 KEXIDIALOGBASE_H
00022 #define KEXIDIALOGBASE_H
00023 
00024 #include "kexipartguiclient.h"
00025 #include "kexiactionproxy.h"
00026 #include "kexi.h"
00027 #include "kexipart.h"
00028 
00029 #include <qguardedptr.h>
00030 
00031 #include <kmdichildview.h>
00032 #include <kxmlguiclient.h>
00033 
00034 class QWidgetStack;
00035 class KexiMainWindow;
00036 class KexiViewBase;
00037 class KActionCollection;
00038 class KexiContextHelpInfo;
00039 namespace KexiPart {
00040     class Part;
00041 }
00042 
00043 namespace KoProperty {
00044     class Set;
00045 }
00046 
00048 
00049 class KEXICORE_EXPORT KexiDialogTempData : public QObject
00050 {
00051     public:
00052     KexiDialogTempData(QObject* parent)
00053      : QObject(parent, "KexiDialogTempData")
00054      , proposeOpeningInTextViewModeBecauseOfProblems(false)
00055     {}
00068     bool proposeOpeningInTextViewModeBecauseOfProblems : 1;
00069 };
00070 
00072 
00075 class KEXICORE_EXPORT KexiDialogBase :
00076     public KMdiChildView,
00077     public KexiActionProxy,
00078     public Kexi::ObjectStatus
00079 {
00080     Q_OBJECT
00081 
00082     public:
00083         KexiDialogBase(KexiMainWindow *parent, const QString &caption = QString::null);
00084         virtual ~KexiDialogBase();
00085 
00086         bool isRegistered();
00087 
00089         KexiViewBase *selectedView() const;
00090 
00093         KexiViewBase *viewForMode(int mode) const;
00094 
00096         void addView(KexiViewBase *view);
00097 
00100 //      virtual QWidget* mainWidget() = 0;
00101 
00103         virtual QSize minimumSizeHint() const;
00104 
00106         virtual QSize sizeHint() const;
00107 
00108         KexiMainWindow  *mainWin() { return m_parentWindow; }
00109 
00110         //js todo: maybe remove this since it's often the same as partItem()->identifier()?:
00111 
00116         void setId(int id) { m_id = id; }
00117 
00121         int id() const;
00122 
00124         inline KexiPart::Part* part() const { return m_part; }
00125 
00127         KexiPart::Item *partItem() const { return m_item; }
00128 
00131         KexiPart::GUIClient* commonGUIClient() const;
00132 
00135         KexiPart::GUIClient* guiClient() const;
00136 
00140 //js removed        bool tryClose(bool dontSaveChanges);
00141 
00144         virtual QString itemIcon();
00145 
00151         bool supportsViewMode( int mode ) const { return m_supportedViewModes & mode; }
00152 
00154         int currentViewMode() const { return m_currentViewMode; }
00155 
00162         tristate switchToViewMode( int newViewMode );
00163 
00164         void setContextHelp(const QString& caption, const QString& text, const QString& iconName);
00165 
00167         virtual bool eventFilter(QObject *obj, QEvent *e);
00168 
00172         virtual void attachToGUIClient();
00173         virtual void detachFromGUIClient();
00174 
00180         bool dirty() const;
00181 
00184         KexiViewBase* viewThatRecentlySetDirtyFlag() const { return m_viewThatRecentlySetDirtyFlag; }
00185 
00192         bool neverSaved() const;
00193 
00196         KoProperty::Set *propertySet();
00197 
00198         KexiDB::SchemaData* schemaData() const { return m_schemaData; }
00200 //      QString caption() const;
00201 
00203         KexiDialogTempData *tempData() const { return m_tempData; }
00204 
00205 //      /*! Used by KexiViewBase subclasses. Sets temporary data shared between views. */
00206 //      void setTempData( KexiDialogTempData* data ) { m_tempData = data; }
00207 
00210         void activate();
00211 
00214         void deactivate();
00215 
00216     public slots:
00217         virtual void setFocus();
00218 
00219         void updateCaption();
00220 
00227         tristate storeData(bool dontAsk = false);
00228 
00237         tristate storeNewData();
00238 
00242         void sendDetachedStateToCurrentView();
00243 
00247         void sendAttachedStateToCurrentView();
00248 
00249     signals:
00250         void updateContextHelp();
00251 
00253         void closing();
00254 
00257         void dirtyChanged(KexiDialogBase*);
00258 
00259     protected slots:
00261         void setDirty(bool dirty);
00262 
00263     protected:
00267         tristate switchToViewMode( int newViewMode, QMap<QString,QString>* staticObjectArgs );
00268 
00269         void registerDialog();
00270 
00271         virtual void closeEvent( QCloseEvent * e );
00272 
00274         void addView(KexiViewBase *view, int mode);
00275 
00276         int m_supportedViewModes;
00277         int m_openedViewModes;
00278         int m_currentViewMode;
00279 
00280         inline QWidgetStack * stack() const { return m_stack; }
00281 
00283         void dirtyChanged(KexiViewBase* view);
00284 #if 0
00285 
00289         bool loadDataBlock( QString &dataString, const QString& dataID = QString::null);
00290 
00297         bool storeDataBlock( const QString &dataString, const QString& dataID = QString::null );
00298 
00304         bool removeDataBlock( QString &dataString, const QString& dataID = QString::null);
00305 
00309         bool storeDataBlock_internal( const QString &dataString, int o_id, const QString& dataID );
00310 #endif
00311 //      void setError(const QString& message, const QString& details);
00312 
00313     private:
00314         KexiMainWindow *m_parentWindow;
00315         bool m_isRegistered;
00316 #ifdef KEXI_NO_CTXT_HELP
00317         KexiContextHelpInfo *m_contextHelpInfo;
00318 #endif
00319         int m_id;
00320         QGuardedPtr<KexiPart::Part> m_part;
00321         KexiPart::Item *m_item;
00322         QWidgetStack *m_stack;
00323         QString m_origCaption; 
00324         KexiDB::SchemaData* m_schemaData;
00325         QGuardedPtr<KexiViewBase> m_newlySelectedView; 
00326 
00327 
00328         QGuardedPtr<KexiViewBase> m_viewThatRecentlySetDirtyFlag; 
00329         QGuardedPtr<KexiDialogTempData> m_tempData; 
00330 
00333         int m_creatingViewsMode;
00334 
00335         bool m_destroying : 1; 
00336         bool m_disableDirtyChanged; 
00337 
00338         friend class KexiMainWindow;
00339 //      friend class KexiMainWindowImpl;
00340         friend class KexiPart::Part;
00341         friend class KexiInternalPart;
00342         friend class KexiViewBase;
00343 };
00344 
00345 #endif
00346 
KDE Home | KDE Accessibility Home | Description of Access Keys