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 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 
00046 class KEXIFORMUTILS_EXPORT KexiDBForm : 
00047     public KexiDBFormBase,
00048     public KFormDesigner::FormWidget,
00049     public KexiFormDataItemInterface
00050 {
00051     Q_OBJECT
00052     Q_PROPERTY(QString dataSource READ dataSource WRITE setDataSource DESIGNABLE true)
00053     Q_PROPERTY(QCString dataSourceMimeType READ dataSourceMimeType WRITE setDataSourceMimeType DESIGNABLE true)
00054     Q_PROPERTY(bool autoTabStops READ autoTabStops WRITE setAutoTabStops DESIGNABLE true)
00055     //original "size" property is not designable, so here's a custom (not storable) replacement
00056     Q_PROPERTY( QSize sizeInternal READ sizeInternal WRITE resizeInternal DESIGNABLE true STORED false )
00057     public:
00058         KexiDBForm(QWidget *parent, KexiDataAwareObjectInterface* dataAwareObject, const char *name="kexi_dbform");
00059         virtual ~KexiDBForm();
00060 
00061         KexiDataAwareObjectInterface* dataAwareObject() const;
00062 
00063         inline QString dataSource() const { return KexiFormDataItemInterface::dataSource(); }
00064         inline QCString dataSourceMimeType() const { return KexiFormDataItemInterface::dataSourceMimeType(); }
00065 
00067         QVariant value() { return QVariant(); }
00068 
00069         virtual void setInvalidState( const QString& displayText );
00070 
00071         virtual void drawRect(const QRect& r, int type);
00072         virtual void drawRects(const QValueList<QRect> &list, int type);
00073         virtual void initBuffer();
00074         virtual void clearForm();
00075         virtual void highlightWidgets(QWidget *from, QWidget *to/*, const QPoint &p*/);
00076 
00077         virtual QSize sizeHint() const;
00078 
00079         bool autoTabStops() const;
00080 
00081         QPtrList<QWidget>* orderedFocusWidgets() const;
00082 
00083         QPtrList<QWidget>* orderedDataAwareWidgets() const;
00084         
00085         int indexForDataItem( KexiDataItemInterface* item ) const;
00086 
00087         void updateTabStopsOrder(KFormDesigner::Form* form);
00088 
00089         void updateTabStopsOrder();
00090 
00091         virtual bool eventFilter ( QObject * watched, QEvent * e );
00092 
00093         virtual bool valueIsNull();
00094         virtual bool valueIsEmpty();
00095         virtual bool isReadOnly() const;
00096         virtual QWidget* widget();
00097         virtual bool cursorAtStart();
00098         virtual bool cursorAtEnd();
00099         virtual void clear();
00100 
00101         bool preview() const;
00102 
00103         virtual void setCursor( const QCursor & cursor );
00104 
00105     public slots:
00106         void setAutoTabStops(bool set);
00107         inline void setDataSource(const QString &ds) { KexiFormDataItemInterface::setDataSource(ds); }
00108         inline void setDataSourceMimeType(const QCString &ds) { KexiFormDataItemInterface::setDataSourceMimeType(ds); }
00109 
00111         QSize sizeInternal() const { return KexiDBFormBase::size(); }
00112 
00114         void resizeInternal(const QSize& s) { KexiDBFormBase::resize(s); }
00115 
00116     signals:
00117         void handleDragMoveEvent(QDragMoveEvent *e);
00118         void handleDropEvent(QDropEvent *e);
00119 
00120     protected:
00122         virtual void setValueInternal(const QVariant&, bool) {}
00123 
00124         virtual void dragMoveEvent( QDragMoveEvent *e );
00125         virtual void dropEvent( QDropEvent *e );
00126 
00127 //      virtual void paintEvent( QPaintEvent * );
00128 
00131         KexiFormDataItemInterface *editedItem;
00132 
00133         class Private;
00134         Private *d;
00135 
00136         friend class KexiFormScrollView;
00137 };
00138 
00139 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys