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-2007 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 
00040 class KEXIFORMUTILS_EXPORT KexiDBForm : 
00041     public KexiDBFormBase,
00042     public KFormDesigner::FormWidget,
00043     public KexiFormDataItemInterface
00044 {
00045     Q_OBJECT
00046     Q_PROPERTY(QString dataSource READ dataSource WRITE setDataSource DESIGNABLE true)
00047     Q_PROPERTY(QCString dataSourceMimeType READ dataSourceMimeType WRITE setDataSourceMimeType DESIGNABLE true)
00048     Q_PROPERTY(bool autoTabStops READ autoTabStops WRITE setAutoTabStops DESIGNABLE true)
00049     //original "size" property is not designable, so here's a custom (not storable) replacement
00050     Q_PROPERTY( QSize sizeInternal READ sizeInternal WRITE resizeInternal DESIGNABLE true STORED false )
00051     public:
00052         KexiDBForm(QWidget *parent, KexiDataAwareObjectInterface* dataAwareObject, const char *name="kexi_dbform");
00053         virtual ~KexiDBForm();
00054 
00055         KexiDataAwareObjectInterface* dataAwareObject() const;
00056 
00057         inline QString dataSource() const { return KexiFormDataItemInterface::dataSource(); }
00058         inline QCString dataSourceMimeType() const { return KexiFormDataItemInterface::dataSourceMimeType(); }
00059 
00061         QVariant value() { return QVariant(); }
00062 
00063         virtual void setInvalidState( const QString& displayText );
00064 
00065         virtual void drawRect(const QRect& r, int type);
00066         virtual void drawRects(const QValueList<QRect> &list, int type);
00067         virtual void initBuffer();
00068         virtual void clearForm();
00069         virtual void highlightWidgets(QWidget *from, QWidget *to/*, const QPoint &p*/);
00070 
00071         virtual QSize sizeHint() const;
00072 
00073         bool autoTabStops() const;
00074 
00075         QPtrList<QWidget>* orderedFocusWidgets() const;
00076 
00077         QPtrList<QWidget>* orderedDataAwareWidgets() const;
00078         
00079         void updateTabStopsOrder(KFormDesigner::Form* form);
00080 
00081         void updateTabStopsOrder();
00082 
00083         virtual bool eventFilter ( QObject * watched, QEvent * e );
00084 
00085         virtual bool valueIsNull();
00086         virtual bool valueIsEmpty();
00087         virtual bool isReadOnly() const;
00088         virtual QWidget* widget();
00089         virtual bool cursorAtStart();
00090         virtual bool cursorAtEnd();
00091         virtual void clear();
00092 
00093         bool preview() const;
00094 
00095         virtual void setCursor( const QCursor & cursor );
00096 
00097     public slots:
00098         void setAutoTabStops(bool set);
00099         inline void setDataSource(const QString &ds) { KexiFormDataItemInterface::setDataSource(ds); }
00100         inline void setDataSourceMimeType(const QCString &ds) { KexiFormDataItemInterface::setDataSourceMimeType(ds); }
00101 
00103         virtual void setReadOnly( bool readOnly );
00104 
00106         QSize sizeInternal() const { return KexiDBFormBase::size(); }
00107 
00109         void resizeInternal(const QSize& s) { KexiDBFormBase::resize(s); }
00110 
00111     signals:
00112         void handleDragMoveEvent(QDragMoveEvent *e);
00113         void handleDropEvent(QDropEvent *e);
00114 
00115     protected:
00117         virtual void setValueInternal(const QVariant&, bool) {}
00118 
00120         virtual void dragMoveEvent( QDragMoveEvent *e );
00121 
00123         virtual void dropEvent( QDropEvent *e );
00124 
00126         void updateReadOnlyFlags();
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