kexi

kexidataiteminterface.h
1/* This file is part of the KDE project
2 Copyright (C) 2005-2006 Jaroslaw Staniek <js@iidea.pl>
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KEXIDATAITEMINTERFACE_H
21#define KEXIDATAITEMINTERFACE_H
22
23#include <tqvariant.h>
24#include <tqwidget.h>
25#include <tqguardedptr.h>
26
28namespace KexiDB {
29 class Field;
30 class QueryColumnInfo;
31}
32
34class KEXICORE_EXPORT KexiDataItemChangesListener
35{
36 public:
37 KexiDataItemChangesListener();
38 virtual ~KexiDataItemChangesListener();
39
42 virtual void valueChanged(KexiDataItemInterface* item) = 0;
43
47 virtual bool cursorAtNewRow() const = 0;
48};
49
51class KEXICORE_EXPORT KexiDataItemInterface
52{
53 public:
54 KexiDataItemInterface();
55 virtual ~KexiDataItemInterface();
56
69 void setValue(const TQVariant& value, const TQVariant& add = TQVariant(), bool removeOld = false,
70 const TQVariant* visibleValue = 0);
71
73 virtual KexiDB::Field *field() const = 0;
74
76 virtual KexiDB::QueryColumnInfo* columnInfo() const = 0;
77
79 virtual void setColumnInfo(KexiDB::QueryColumnInfo* cinfo) = 0;
80
82 virtual void installListener(KexiDataItemChangesListener* listener);
83
84// //! Sets value \a value for a widget.
85// //! Just calls setValueInternal(), but also blocks valueChanged()
86// //! as you we don't want to react on our own change
87// void setValue(const TQVariant& value);
88
90 virtual TQVariant value() = 0;
91
97 virtual bool valueIsValid();
98
101 virtual bool valueIsNull() = 0;
102
107 virtual bool valueIsEmpty() = 0;
108
112 virtual TQVariant visibleValue() { return TQVariant(); }
113
117 virtual bool isReadOnly() const { return false; }
118
120 virtual TQWidget* widget() = 0;
121
123 virtual void hideWidget() { if (widget()) widget()->hide(); }
124
126 virtual void showWidget() { if (widget()) widget()->show(); }
127
129 virtual bool valueChanged();
130
134 virtual bool cursorAtStart() = 0;
135
139 virtual bool cursorAtEnd() = 0;
140
143 virtual void moveCursorToEnd() {};
144
147 virtual void moveCursorToStart() {};
148
151 virtual void selectAll() {};
152
154 virtual void clear() = 0;
155
160 inline bool hasFocusableWidget() const { return m_hasFocusableWidget; }
161
168 virtual void showFocus( const TQRect& r, bool readOnly );
169
173 virtual void hideFocus();
174
179 virtual void clickedOnContents();
180
184 bool acceptEditorAfterDeleteContents() const { return m_acceptEditorAfterDeleteContents; }
185
186 inline virtual void setFocus() { if (widget()) widget()->setFocus(); }
187
188 bool cursorAtNewRow();
189
195 void setParentDataItemInterface(KexiDataItemInterface* parentDataItemInterface);
196
199 inline KexiDataItemInterface* parentInterface() const { return m_parentDataItemInterface; }
200
204 virtual void handleAction(const TQString& actionName) { Q_UNUSED(actionName); }
205
206 protected:
212 virtual void setValueInternal(const TQVariant& add, bool removeOld) = 0;
213
218 virtual void setVisibleValueInternal(const TQVariant& value);
219
220// //! Sets value \a value for a widget.
221// //! Implement this method to allow setting value for this widget item.
222// virtual void setValueInternal(const TQVariant& value) = 0;
223
227 virtual void signalValueChanged();
228
232 virtual void beforeSignalValueChanged() {};
233
234 KexiDataItemChangesListener* listener();
235
236//moved to KexiFormDataItemInterface: TQString m_dataSource;
237 TQGuardedPtr<TQObject> m_listenerObject;
238 KexiDataItemChangesListener* m_listener;
239 bool m_listenerIsTQObject;
240 TQVariant m_origValue;
241
243 KexiDataItemInterface* m_parentDataItemInterface;
244 bool m_hasFocusableWidget : 1;
245 bool m_disable_signalValueChanged : 1;
246 bool m_acceptEditorAfterDeleteContents : 1;
247};
248
249#endif
Meta-data for a field.
Definition field.h:73
Helper class that assigns additional information for the column in a query.
Definition queryschema.h:49
An helper class used to react on KexiDataItemInterface objects' changes.
virtual void valueChanged(KexiDataItemInterface *item)=0
virtual bool cursorAtNewRow() const =0
An interface for declaring widgets to be data-aware.
virtual bool cursorAtEnd()=0
virtual bool cursorAtStart()=0
virtual void setColumnInfo(KexiDB::QueryColumnInfo *cinfo)=0
Used internally to set column information.
virtual bool isReadOnly() const
virtual void setVisibleValueInternal(const TQVariant &value)
virtual TQVariant value()=0
KexiDataItemInterface * parentInterface() const
virtual bool valueIsNull()=0
virtual bool valueIsEmpty()=0
void setValue(const TQVariant &value, const TQVariant &add=TQVariant(), bool removeOld=false, const TQVariant *visibleValue=0)
virtual void handleAction(const TQString &actionName)
virtual void setValueInternal(const TQVariant &add, bool removeOld)=0
virtual KexiDB::Field * field() const =0
KexiDataItemInterface * m_parentDataItemInterface
virtual void installListener(KexiDataItemChangesListener *listener)
Sets listener. No need to reimplement this.
virtual KexiDB::QueryColumnInfo * columnInfo() const =0
virtual void clear()=0
clears item's data, so the data will contain NULL data
bool acceptEditorAfterDeleteContents() const
virtual void beforeSignalValueChanged()
virtual TQWidget * widget()=0
virtual TQVariant visibleValue()
High-level database connectivity library with database backend drivers.