1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
/* This file is part of the KDE project
Copyright (C) 2004 Cedric Pasteur <[email protected]>
Copyright (C) 2004-2007 Jaroslaw Staniek <[email protected]>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KEXIFORMVIEW_H
#define KEXIFORMVIEW_H
#include <tqtimer.h>
#include <kexiviewbase.h>
#include <widget/kexidataawareview.h>
#include "kexiformpart.h"
#include <core/kexiblobbuffer.h>
class KexiFormPart;
class KexiMainWindow;
class KexiDBForm;
class KexiTableItem;
class KexiTableViewData;
class KexiFormScrollView;
namespace KexiDB { class Cursor; }
namespace KFormDesigner
{
class Container;
}
//! The KexiFormView lass provides a data-driven (record-based) form view .
/*! The KexiFormView can display data provided "by hand"
or from KexiDB-compatible database source.
This class provides a single view used inside KexiDialogBase.
It takes care of saving/loading form, of enabling actions when needed.
One KexiFormView object is instantiated for data view mode
and a second KexiFormView object is instantiated for design view mode.
@see KexiDataTable
*/
class KEXIFORMUTILS_EXPORT KexiFormView : public KexiDataAwareView
{
TQ_OBJECT
public:
enum ResizeMode {
ResizeAuto = 0,
ResizeDefault = ResizeAuto,
ResizeFixed = 1,
NoResize = 2 /*! @todo */
};
// KexiFormView(KexiMainWindow *win, TQWidget *parent, const char *name, KexiDB::Connection *conn);
KexiFormView(KexiMainWindow *mainWin, TQWidget *parent, const char *name = 0,
bool dbAware = true);
virtual ~KexiFormView();
// KexiDB::Connection* connection() { return m_conn; }
virtual TQSize preferredSizeHint(const TQSize& otherSize);
int resizeMode() const { return m_resizeMode; }
KFormDesigner::Form* form() const;
/*! Assigns \a id local (static) BLOB's identifier for \a widget widget.
Previously assigned BLOB will be usassigned.
If \a id is 0, BLOB is unassigned and no new is assigned.
This method is called when a widget supporting BLOB data
(currently, images from KexiDBImageBox, within KexiDBFactory) has BLOB assigned by identifier \a id.
BLOB identifiers are defined by KexiBLOBBuffer (KexiBLOBBuffer::self() instance).
The data collected by this method is used on form's design saving (in design mode).
Local BLOBs are retrieved KexiBLOBBuffer::self() and stored in "kexi__blobs" 'system' table.
Note that db-aware BLOBs (non local) are not handled this way.
*/
void setUnsavedLocalBLOB(TQWidget *widget, KexiBLOBBuffer::Id_t id);
public slots:
/*! Reimplemented to update resize policy. */
virtual void show();
/*! Inserts autofields onto the form at \a pos position.
\a sourceMimeType can be "kexi/table" or "kexi/query",
\a sourceName is a name of a table or query, \a fields is a list of fields to insert (one or more)
Fields are inserted using standard KFormDesigner::InsertWidgetCommand framework,
so undo/redo is available for this operation.
If multiple fields are provided, they will be aligned vertically.
If \a pos is TQPoint(-1,-1) (the default), position is computed automatically
based on a position last inserted field using this method.
If this method has not been called yet, position of TQPoint(40, 40) will be set.
Called by:
- slotHandleDropEvent() when field(s) are dropped from the data source pane onto the form
- KexiFormManager is a used clicked "Insert fields" button on the data source pane. */
void insertAutoFields(const TQString& sourceMimeType, const TQString& sourceName,
const TQStringList& fields, KFormDesigner::Container* targetContainerWidget,
const TQPoint& pos = TQPoint(-1,-1));
protected slots:
void slotPropertySetSwitched(KoProperty::Set *b, bool forceReload = false,
const TQCString& propertyToSelect = TQCString());
void slotDirty(KFormDesigner::Form *f, bool isDirty);
void slotFocus(bool in);
void slotHandleDragMoveEvent(TQDragMoveEvent* e);
//! Handles field(s) dropping from the data source pane onto the form
//! @see insertAutoFields()
void slotHandleDropEvent(TQDropEvent* e);
//moved to formmanager void slotWidgetSelected(KFormDesigner::Form *form, bool multiple);
//moved to formmanager void slotFormWidgetSelected(KFormDesigner::Form *form);
//moved to formmanager void slotNoFormSelected();
//moved to formmanager void setUndoEnabled(bool enabled);
//moved to formmanager void setRedoEnabled(bool enabled);
protected:
virtual tristate beforeSwitchTo(int mode, bool &dontStore);
virtual tristate afterSwitchFrom(int mode);
virtual KoProperty::Set* propertySet() { return m_propertySet; }
virtual KexiDB::SchemaData* storeNewData(const KexiDB::SchemaData& sdata, bool &cancel);
virtual tristate storeData(bool dontAsk = false);
KexiFormPart::TempData* tempData() const {
return dynamic_cast<KexiFormPart::TempData*>(parentDialog()->tempData()); }
KexiFormPart* formPart() const { return dynamic_cast<KexiFormPart*>(part()); }
//moved to formmanager void disableWidgetActions();
//moved to formmanager void enableFormActions();
void setForm(KFormDesigner::Form *f);
void initForm();
void loadForm();
//! Used in loadForm()
void updateAutoFieldsDataSource();
//! Used in loadForm()
void updateValuesForSubproperties();
virtual void resizeEvent ( TQResizeEvent * );
void initDataSource();
virtual void setFocusInternal();
/* // for navigator
virtual void moveToRecordRequested(uint r);
virtual void moveToLastRecordRequested();
virtual void moveToPreviousRecordRequested();
virtual void moveToNextRecordRequested();
virtual void moveToFirstRecordRequested();
virtual void addNewRecordRequested();*/
/*! Called after loading the form contents (before showing it).
Also called when the form window (KexiDialogBase) is detached
(in KMDI's Child Frame mode), because otherwise tabstop ordering can get broken. */
void updateTabStopsOrder();
/*! @internal */
void deleteQuery();
/*! @internal */
void updateDataSourcePage();
/*! Reimplemented after KexiViewBase.
Updates actions (e.g. availability). */
// todo virtual void updateActions(bool activated);
KexiDBForm *m_dbform;
KexiFormScrollView *m_scrollView;
KoProperty::Set *m_propertySet;
/*! Database cursor used for data retrieving.
It is shared between subsequent Data view sessions (just reopened on switch),
but deleted and recreated from scratch when form's "dataSource" property changed
since last form viewing (m_previousDataSourceString is used for that). */
TQString m_previousDataSourceString;
int m_resizeMode;
KexiDB::QuerySchema* m_query;
/*! True, if m_query is created as temporary object within this form.
If user selected an existing, predefined (stored) query, m_queryIsOwned will be false,
so the query object will not be destroyed. */
bool m_queryIsOwned;
KexiDB::Cursor *m_cursor;
/*! For new (empty) forms only:
Our form's area will be resized more than once.
We will resize form widget itself later (in resizeEvent()). */
int m_delayedFormContentsResizeOnShow;
//! Used in setFocusInternal()
TQGuardedPtr<TQWidget> m_setFocusInternalOnce;
/*! Stores geometry of widget recently inserted using insertAutoFields() method.
having this information, we'r eable to compute position for a newly
inserted widget in insertAutoFields() is such position has not been specified.
(the position is specified when a widget is inserted with mouse drag & dropping
but not with clicking of 'Insert fields' button from Data Source pane) */
TQRect m_widgetGeometryForRecentInsertAutoFields;
//! Used in setUnsavedLocalBLOBs()
// TQMap<TQWidget*, KexiBLOBBuffer::Id_t> m_unsavedLocalBLOBs;
};
#endif
|