15
15
You should have received a copy of the GNU Library General Public License
16
16
along with this program; see the file COPYING. If not, write to
17
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
Boston, MA 02111-1307, USA.
17
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
* Boston, MA 02110-1301, USA.
21
21
#ifndef _KEXITABLEEDIT_H_
42
43
KexiTableEdit(KexiTableViewColumn &column, QScrollView* parent = 0, const char* name = 0);
43
// KexiTableEdit(KexiDB::Field &f, QScrollView* parent = 0, const char* name = 0);
45
45
virtual ~KexiTableEdit();
47
/* moved to KexiDataItemInterface*/
48
/*! Just initializes \a value, and calls init(const QString& add, bool removeOld).
49
If \a removeOld is true, current value is set up as \a add.
50
If \a removeOld if false, current value is set up as \a value + \a add.
51
\a value is stored as 'old value' -it'd be usable in the future
52
(e.g. Combo Box editor can use old value if current value does not
53
match any item on the list).
54
Called by KexiTableView and others. */
55
/* void init(const QVariant& value, const QString& add, bool removeOld = false);
57
//! \return true if editor's value is changed (compared to original value)
58
virtual bool valueChanged();
60
//! \return true if editor's value is null (not empty)
61
virtual bool valueIsNull() = 0;
63
//! \return true if editor's value is empty (not null).
64
//! Only few field types can accept "EMPTY" property
65
//! (check this with KexiDB::Field::hasEmptyProperty()),
66
virtual bool valueIsEmpty() = 0;
69
/* moved to KexiDataItemInterface
70
virtual QVariant value(bool &ok) = 0;
73
47
//! Implemented for KexiDataItemInterface.
74
48
//! \return field information for this item
75
49
virtual KexiDB::Field *field() const { return m_column->field(); }
51
/*! A rich field information for db-aware data.
52
For not-db-aware data it is always 0 (use field() instead. */
53
virtual KexiDB::QueryColumnInfo *columnInfo() const { return m_column->fieldinfo; }
77
55
//! Implemented for KexiDataItemInterface.
78
56
//! Does nothing because instead KexiTableViewColumn is used to get field's schema.
79
virtual void setField(KexiDB::Field *field) { }
57
virtual void setColumnInfo(KexiDB::QueryColumnInfo *) { }
81
59
//! \return column information for this item
82
60
//! (extended information, comparing to field()).
83
61
inline KexiTableViewColumn *column() const { return m_column; }
85
//moved to KexiDataItemInterface
86
/*! \return true if internal editor's cursor (whatever that means, eg. line edit cursor)
87
is at the beginning of editor's contents. This can inform table view that
88
after pressing "left arrow" key should stop editing and move to cell at the left
89
hand of the current cell. */
90
// virtual bool cursorAtStart() = 0;
92
//moved to KexiDataItemInterface
93
/*! \return true if internal editor's cursor (whatever that means, eg. line edit cursor)
94
is at the end of editor's contents. This can inform table view that
95
after pressing "right arrow" key should stop editing and move to cell at the right
96
hand of the current cell. */
97
// virtual bool cursorAtEnd() = 0;
99
63
/*! Reimplemented: resizes a view(). */
100
64
virtual void resize(int w, int h);
108
72
/*! Shows item's widget, if available. */
109
73
inline virtual void showWidget() { show(); }
111
//moved to KexiDataItemInterface
112
//! clears editor's data, so the data will contain NULL data
113
// virtual void clear() = 0;
115
//moved to KexiDataItemInterface
117
/*! Displays additional elements that are needed for indicating that the current cell
118
is selected. For example, combobox editor (KexiComboBoxTableEdit) moves and shows
119
dropdown button. \a r is the rectangle for the cell.
120
For reimplementation. By default does nothing. */
121
virtual void showFocus( const QRect& r );
123
/*! Hides additional elements that are needed for indicating that the current cell
125
For reimplementation. By default does nothing. */
126
virtual void hideFocus();
129
75
/*! Paints a border for the cell described by \a x, \a y, \a w, \a h on \a p painter.
130
76
The cell's value is \a val (may be usefull if you want to reimplement this method).
153
99
bool readOnly, bool fullRowSelection );
155
101
/*! Sometimes, editor can contain non-standard margin, for example combobox editor contains
156
dropdown button at the right side. \returns left margin's size;
102
dropdown button at the right side. \return left margin's size;
157
103
0 by default. For reimplementation. */
158
104
int leftMargin() const { return m_leftMargin; }
160
106
/*! Sometimes, editor can contain non-standard margin, for example combobox editor contains
161
dropdown button at the right side. \returns right margin;s size;
107
dropdown button at the right side. \return right margin;s size;
162
108
0 by default. For reimplementation. */
163
109
int rightMargin() const { return m_rightMargin; }
177
123
returns QWidget::size(). */
178
124
virtual QSize totalSize() { return QWidget::size(); }
180
//moved to KexiDataItemInterface
181
/*! \return true if this editor offers a widget (e.g. line edit) that we can move focus to.
182
Editor for boolean values has this set to false (see KexiBoolTableEdit).
183
You can override this flag by changing m_hasFocusableWidget in your subclass' constructor. */
184
// inline bool hasFocusableWidget() const { return m_hasFocusableWidget; }
186
//moved to KexiDataItemInterface
187
/*! Allows to define reaction for clicking on cell's contents.
188
Currently it's used for editor of type boolean, where we want to toggle true/false
189
on single mouse click. \sa hasFocusableWidget(), KexiBoolTableEdit.
190
Default implementation does nothing. */
191
// virtual void clickedOnContents() {};
193
//moved to KexiDataItemInterface
194
/*! \return true if editing should be accepted immediately after
195
deleting contents for the cell (usually using Delete key).
196
This flag is false by default, and is true e.g. for date, time and datetime types. */
197
// bool acceptEditorAfterDeleteContents() const { return m_acceptEditorAfterDeleteContents; }
200
127
void editRequested();
201
128
void cancelRequested();
202
129
void acceptRequested();
206
//moved to KexiDataItemInterface
207
/*! Initializes this editor with \a add value, which should be somewhat added to the current
208
value (already storted in m_origValue).
209
If \a removeOld is true, a value should be set to \a add, otherwise
210
-it should be set to current \a m_origValue + \a add, if possible.
212
virtual void init(const QVariant& add, bool removeOld) = 0;
214
132
virtual bool eventFilter(QObject* watched, QEvent* e);
216
134
/*! Sets \a v as view widget for this editor. The view will be assigned as focus proxy
222
140
void moveChild( QWidget * child, int x, int y ) {
223
141
m_scrollView->moveChild(child, x, y); }
225
// virtual void paintEvent( QPaintEvent *pe );
226
//moved to KexiDataItemInterface: QVariant m_origValue;
227
143
KexiTableViewColumn *m_column;
228
// KexiDB::Field *m_field;
229
// int m_type; //! one of KexiDB::Field
230
144
int m_leftMargin;
231
145
int m_rightMargin;
233
146
QScrollView* m_scrollView;
235
//moved to KexiDataItemInterface: bool m_hasFocusableWidget : 1;
236
//moved to KexiDataItemInterface: bool m_acceptEditorAfterDeleteContents : 1;
152
//! Declaration of cell editor factory
153
#define KEXI_DECLARE_CELLEDITOR_FACTORY_ITEM(factoryclassname) \
154
class factoryclassname : public KexiCellEditorFactoryItem \
157
factoryclassname(); \
158
virtual ~factoryclassname(); \
161
virtual KexiTableEdit* createEditor(KexiTableViewColumn &column, QScrollView* parent = 0); \
164
//! Implementation of cell editor factory
165
#define KEXI_CELLEDITOR_FACTORY_ITEM_IMPL(factoryclassname, itemclassname) \
166
factoryclassname::factoryclassname() \
167
: KexiCellEditorFactoryItem() \
170
factoryclassname::~factoryclassname() \
173
KexiTableEdit* factoryclassname::createEditor( \
174
KexiTableViewColumn &column, QScrollView* parent) \
176
return new itemclassname(column, parent); \