1
/* This file is part of the KDE project
2
Copyright (C) 2004 Lucijan Busch <lucijan@kde.org>
3
Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
4
Copyright (C) 2005-2009 Jarosław Staniek <staniek@kde.org>
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Library General Public
8
License as published by the Free Software Foundation; either
9
version 2 of the License, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Library General Public License for more details.
16
You should have received a copy of the GNU Library General Public License
17
along with this library; see the file COPYING.LIB. If not, write to
18
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
* Boston, MA 02110-1301, USA.
25
#include <QDragMoveEvent>
29
#include <formeditor/form.h>
30
#include <formeditor/FormWidget.h>
31
#include <formeditor/FormWidgetInterface.h>
32
#include "kexiformdataiteminterface.h"
34
class KexiDataAwareObjectInterface;
35
class KexiFormScrollView;
37
//! @short A DB-aware form widget, acting as form's toplevel widget
38
class KEXIFORMUTILS_EXPORT KexiDBForm : public QWidget,
39
public KFormDesigner::FormWidget,
40
public KexiFormDataItemInterface,
41
public KFormDesigner::FormWidgetInterface
44
Q_PROPERTY(QString dataSource READ dataSource WRITE setDataSource)
45
Q_PROPERTY(QString dataSourcePartClass READ dataSourcePartClass WRITE setDataSourcePartClass)
46
Q_PROPERTY(bool autoTabStops READ autoTabStops WRITE setAutoTabStops)
47
//original "size" property is not designable, so here's a custom (not storable) replacement
48
Q_PROPERTY(QSize sizeInternal READ sizeInternal WRITE resizeInternal STORED false)
50
KexiDBForm(QWidget *parent, KexiDataAwareObjectInterface* dataAwareObject);
51
virtual ~KexiDBForm();
53
KexiDataAwareObjectInterface* dataAwareObject() const;
55
inline QString dataSource() const {
56
return KexiFormDataItemInterface::dataSource();
58
inline QString dataSourcePartClass() const {
59
return KexiFormDataItemInterface::dataSourcePartClass();
67
virtual void setInvalidState(const QString& displayText);
69
virtual void drawRect(const QRect& r, int type);
70
virtual void drawRects(const QList<QRect> &list, int type);
71
virtual void initBuffer();
72
virtual void clearForm();
73
virtual void highlightWidgets(QWidget *from, QWidget *to/*, const QPoint &p*/);
75
virtual QSize sizeHint() const;
77
bool autoTabStops() const;
79
QList<QWidget*>* orderedFocusWidgets() const;
81
QList<QWidget*>* orderedDataAwareWidgets() const;
83
void updateTabStopsOrder(KFormDesigner::Form* form);
85
void updateTabStopsOrder();
87
virtual bool eventFilter(QObject * watched, QEvent * e);
89
virtual bool valueIsNull();
90
virtual bool valueIsEmpty();
91
virtual bool isReadOnly() const;
92
virtual QWidget* widget();
93
virtual bool cursorAtStart();
94
virtual bool cursorAtEnd();
99
// virtual void setCursor(const QCursor & cursor);
102
void setAutoTabStops(bool set);
103
inline void setDataSource(const QString &ds) {
104
KexiFormDataItemInterface::setDataSource(ds);
106
inline void setDataSourcePartClass(const QString &partClass) {
107
KexiFormDataItemInterface::setDataSourcePartClass(partClass);
110
//! This implementation just disables read only widget
111
virtual void setReadOnly(bool readOnly);
113
//! @internal for sizeInternal property
114
QSize sizeInternal() const {
115
return QWidget::size();
118
//! @internal for sizeInternal property
119
void resizeInternal(const QSize& s) {
124
void handleDragMoveEvent(QDragMoveEvent *e);
125
void handleDropEvent(QDropEvent *e);
129
virtual void setValueInternal(const QVariant&, bool) {}
131
//! Used to emit handleDragMoveEvent() signal needed to control dragging over the container's surface
132
virtual void dragMoveEvent(QDragMoveEvent *e);
134
//! Used to emit handleDropEvent() signal needed to control dropping on the container's surface
135
virtual void dropEvent(QDropEvent *e);
137
//! called from KexiFormScrollView::initDataContents()
138
void updateReadOnlyFlags();
139
// virtual void paintEvent( QPaintEvent * );
141
//! Points to a currently edited data item.
142
//! It is cleared when the focus is moved to other
143
KexiFormDataItemInterface *editedItem;
148
friend class KexiFormScrollView;