kexi

kexidbform.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Lucijan Busch <lucijan@kde.org>
00003    Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
00004    Copyright (C) 2005-2006 Jaroslaw Staniek <js@iidea.pl>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020 */
00021 #ifndef KEXIDBFORM_H
00022 #define KEXIDBFORM_H
00023 
00024 #include <qpixmap.h>
00025 
00026 #include <formeditor/form.h>
00027 #include "../kexiformdataiteminterface.h"
00028 
00029 #ifdef KEXI_USE_GRADIENT_WIDGET
00030 #include <kexigradientwidget.h>
00031 # define KexiDBFormBase KexiGradientWidget
00032 #else
00033 # define KexiDBFormBase QWidget
00034 #endif
00035 
00036 class KexiDataAwareObjectInterface;
00037 class KexiFormScrollView;
00038 
00039 #define SET_FOCUS_USING_REASON(widget, reason) \
00040     { QEvent fe( QEvent::FocusIn ); \
00041     QFocusEvent::setReason(reason); \
00042     QApplication::sendEvent( widget, &fe ); \
00043     QFocusEvent::resetReason(); }
00044 
00045 #define UNSET_FOCUS_USING_REASON(widget, reason) \
00046     { QEvent fe( QEvent::FocusOut ); \
00047     QFocusEvent::setReason(reason); \
00048     QApplication::sendEvent( widget, &fe ); \
00049     QFocusEvent::resetReason(); }
00050 
00052 class KEXIFORMUTILS_EXPORT KexiDBForm : 
00053     public KexiDBFormBase,
00054     public KFormDesigner::FormWidget,
00055     public KexiFormDataItemInterface
00056 {
00057     Q_OBJECT
00058     Q_PROPERTY(QString dataSource READ dataSource WRITE setDataSource DESIGNABLE true)
00059     Q_PROPERTY(QCString dataSourceMimeType READ dataSourceMimeType WRITE setDataSourceMimeType DESIGNABLE true)
00060     Q_PROPERTY(bool autoTabStops READ autoTabStops WRITE setAutoTabStops DESIGNABLE true)
00061     //original "size" property is not designable, so here's a custom (not storable) replacement
00062     Q_PROPERTY( QSize sizeInternal READ sizeInternal WRITE resizeInternal DESIGNABLE true STORED false )
00063     public:
00064         KexiDBForm(QWidget *parent, KexiDataAwareObjectInterface* dataAwareObject, const char *name="kexi_dbform");
00065         virtual ~KexiDBForm();
00066 
00067         KexiDataAwareObjectInterface* dataAwareObject() const;
00068 
00069         inline QString dataSource() const { return KexiFormDataItemInterface::dataSource(); }
00070         inline QCString dataSourceMimeType() const { return KexiFormDataItemInterface::dataSourceMimeType(); }
00071 
00073         QVariant value() { return QVariant(); }
00074 
00075         virtual void setInvalidState( const QString& displayText );
00076 
00077         virtual void drawRect(const QRect& r, int type);
00078         virtual void drawRects(const QValueList<QRect> &list, int type);
00079         virtual void initBuffer();
00080         virtual void clearForm();
00081         virtual void highlightWidgets(QWidget *from, QWidget *to/*, const QPoint &p*/);
00082 
00083         virtual QSize sizeHint() const;
00084 
00085         bool autoTabStops() const;
00086 
00087         QPtrList<QWidget>* orderedFocusWidgets() const;
00088 
00089         QPtrList<QWidget>* orderedDataAwareWidgets() const;
00090         
00091         void updateTabStopsOrder(KFormDesigner::Form* form);
00092 
00093         void updateTabStopsOrder();
00094 
00095         virtual bool eventFilter ( QObject * watched, QEvent * e );
00096 
00097         virtual bool valueIsNull();
00098         virtual bool valueIsEmpty();
00099         virtual bool isReadOnly() const;
00100         virtual QWidget* widget();
00101         virtual bool cursorAtStart();
00102         virtual bool cursorAtEnd();
00103         virtual void clear();
00104 
00105         bool preview() const;
00106 
00107         virtual void setCursor( const QCursor & cursor );
00108 
00109     public slots:
00110         void setAutoTabStops(bool set);
00111         inline void setDataSource(const QString &ds) { KexiFormDataItemInterface::setDataSource(ds); }
00112         inline void setDataSourceMimeType(const QCString &ds) { KexiFormDataItemInterface::setDataSourceMimeType(ds); }
00113 
00115         virtual void setReadOnly( bool readOnly );
00116 
00118         QSize sizeInternal() const { return KexiDBFormBase::size(); }
00119 
00121         void resizeInternal(const QSize& s) { KexiDBFormBase::resize(s); }
00122 
00123     signals:
00124         void handleDragMoveEvent(QDragMoveEvent *e);
00125         void handleDropEvent(QDropEvent *e);
00126 
00127     protected:
00129         virtual void setValueInternal(const QVariant&, bool) {}
00130 
00131         virtual void dragMoveEvent( QDragMoveEvent *e );
00132         virtual void dropEvent( QDropEvent *e );
00133 
00135         void updateReadOnlyFlags();
00136 //      virtual void paintEvent( QPaintEvent * );
00137 
00140         KexiFormDataItemInterface *editedItem;
00141 
00142         class Private;
00143         Private *d;
00144 
00145         friend class KexiFormScrollView;
00146 };
00147 
00148 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys