kexitableedit.h
1/* This file is part of the KDE project
2 Copyright (C) 2002 Peter Simonsson <psn@linux.se>
3 Copyright (C) 2003-2006 Jaroslaw Staniek <js@iidea.pl>
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#ifndef _KEXITABLEEDIT_H_
22#define _KEXITABLEEDIT_H_
23
24#include <kexidataiteminterface.h>
25
26#include <tqvariant.h>
27#include <tqscrollview.h>
28
29#include "kexitableviewdata.h"
30
31namespace KexiDB {
32 class Field;
33 class QueryColumnInfo;
34}
35
39class KEXIDATATABLE_EXPORT KexiTableEdit : public TQWidget, public KexiDataItemInterface
40{
41 TQ_OBJECT
42
43
44 public:
45 KexiTableEdit(KexiTableViewColumn &column, TQWidget* parent = 0);
46
47 virtual ~KexiTableEdit();
48
51 virtual KexiDB::Field *field() const { return m_column->field(); }
52
55 virtual KexiDB::QueryColumnInfo *columnInfo() const { return m_column->columnInfo; }
56
60
63 inline KexiTableViewColumn *column() const { return m_column; }
64
70 KexiDB::Field *displayedField() const;
71
73 virtual void resize(int w, int h);
74
76 virtual TQWidget* widget() { return m_view; }
77
79 inline virtual void hideWidget() { hide(); }
80
82 inline virtual void showWidget() { show(); }
83
87 virtual void paintFocusBorders( TQPainter *p, TQVariant &cal, int x, int y, int w, int h );
88
105 virtual void setupContents( TQPainter *p, bool focused, const TQVariant& val,
106 TQString &txt, int &align, int &x, int &y_offset, int &w, int &h );
107
114 bool usesSelectedTextColor() const { return m_usesSelectedTextColor; }
115
119 virtual void paintSelectionBackground( TQPainter *p, bool focused, const TQString& txt,
120 int align, int x, int y_offset, int w, int h, const TQColor& fillColor,
121 const TQFontMetrics &fm, bool readOnly, bool fullRowSelection );
122
126 int leftMargin() const { return m_leftMargin; }
127
131 int rightMargin(bool focused) const;
132
137 virtual bool handleKeyPress( TQKeyEvent* ke, bool editorActive ) {
138 Q_UNUSED(ke); Q_UNUSED(editorActive); return false; }
139
143 virtual bool handleDoubleClick() { return false; }
144
150 virtual void handleCopyAction(const TQVariant& value, const TQVariant& visibleValue) = 0;
151
154 virtual int widthForValue( TQVariant &val, const TQFontMetrics &fm );
155
159 virtual TQSize totalSize() { return TQWidget::size(); }
160
167 virtual bool showToolTipIfNeeded(const TQVariant& value, const TQRect& rect, const TQFontMetrics& fm,
168 bool focused);
169
173 virtual void createInternalEditor(KexiDB::QuerySchema& schema) { Q_UNUSED(schema); }
174
175 signals:
176 void editRequested();
177 void cancelRequested();
178 void acceptRequested();
179
180 protected:
181 virtual bool eventFilter(TQObject* watched, TQEvent* e);
182
185 void setViewWidget(TQWidget *v);
186
189 void moveChild( TQWidget * child, int x, int y );
190
193 void repaintRelatedCell();
194
195 KexiTableViewColumn *m_column;
196 int m_leftMargin;
197 int m_rightMargin, m_rightMarginWhenFocused;
198 TQScrollView* m_scrollView;
200
201 private:
202 TQWidget* m_view;
203};
204
206#define KEXI_DECLARE_CELLEDITOR_FACTORY_ITEM(factoryclassname) \
207 class factoryclassname : public KexiCellEditorFactoryItem \
208 { \
209 public: \
210 factoryclassname(); \
211 virtual ~factoryclassname(); \
212 \
213 protected: \
214 virtual KexiTableEdit* createEditor(KexiTableViewColumn &column, TQWidget* parent = 0); \
215 };
216
218#define KEXI_CELLEDITOR_FACTORY_ITEM_IMPL(factoryclassname, itemclassname) \
219factoryclassname::factoryclassname() \
220 : KexiCellEditorFactoryItem() \
221{ \
222 m_className = "" #itemclassname ""; \
223} \
224\
225factoryclassname::~factoryclassname() \
226{} \
227\
228KexiTableEdit* factoryclassname::createEditor( \
229 KexiTableViewColumn &column, TQWidget* parent) \
230{ \
231 return new itemclassname(column, parent); \
232}
233
234#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
KexiDB::QuerySchema provides information about database query.
An interface for declaring widgets to be data-aware.
Abstract class for a cell editor. Handles cell painting and displaying the editor widget.
virtual TQSize totalSize()
virtual bool handleKeyPress(TQKeyEvent *ke, bool editorActive)
KexiTableViewColumn * column() const
virtual TQWidget * widget()
virtual void setColumnInfo(KexiDB::QueryColumnInfo *)
Implemented for KexiDataItemInterface.
bool usesSelectedTextColor() const
int leftMargin() const
virtual void hideWidget()
bool m_usesSelectedTextColor
set in ctor,
virtual KexiDB::Field * field() const
Implemented for KexiDataItemInterface.
virtual KexiDB::QueryColumnInfo * columnInfo() const
virtual void createInternalEditor(KexiDB::QuerySchema &schema)
virtual void handleCopyAction(const TQVariant &value, const TQVariant &visibleValue)=0
TQScrollView * m_scrollView
may be 0 if the parent is not a scrollview
virtual void showWidget()
virtual bool handleDoubleClick()
High-level database connectivity library with database backend drivers.