kexidbcombobox.h
1/* This file is part of the KDE project
2 Copyright (C) 2006-2007 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 KexiDBComboBox_H
21#define KexiDBComboBox_H
22
23#include "kexidbutils.h"
24#include "kexidbautofield.h"
25#include <widget/tableview/kexicomboboxbase.h>
26
28
34class KEXIFORMUTILS_EXPORT KexiDBComboBox :
36{
37 TQ_OBJECT
38
39 TQ_PROPERTY( bool editable READ isEditable WRITE setEditable )
40 //properties from KexiDBAutoField that should not be visible:
41 TQ_OVERRIDE(TQColor paletteBackgroundColor READ paletteBackgroundColor WRITE setPaletteBackgroundColor DESIGNABLE true RESET unsetPalette)
42 TQ_OVERRIDE(TQColor foregroundLabelColor DESIGNABLE false)
43 TQ_OVERRIDE(TQColor backgroundLabelColor DESIGNABLE false)
44 TQ_OVERRIDE(bool autoCaption DESIGNABLE false)
45
46 public:
47 KexiDBComboBox(TQWidget *parent, const char *name=0, bool designMode = true);
48 virtual ~KexiDBComboBox();
49
51 virtual KexiTableViewColumn *column() const { return 0; }
52
54 virtual KexiDB::Field *field() const { return KexiDBAutoField::field(); }
55
57 virtual TQVariant origValue() const { return m_origValue; }
58
59 void setEditable(bool set);
60 bool isEditable() const;
61
62 virtual void setLabelPosition(LabelPosition position);
63
64 virtual TQVariant value() { return KexiComboBoxBase::value(); }
65
66 virtual TQVariant visibleValue();
67
69 virtual bool valueChanged();
70
71 virtual TQSize sizeHint() const;
72
75 virtual void setColumnInfo(KexiDB::QueryColumnInfo* cinfo);
76
80
84
85 const TQColor & paletteBackgroundColor() const { return KexiDBAutoField::paletteBackgroundColor(); }
86
88 virtual void setPaletteBackgroundColor( const TQColor & color );
89
93 virtual void undoChanges();
94
95 public slots:
96 void slotRowAccepted(KexiTableItem *item, int row);
97 void slotItemSelected(KexiTableItem* item) { KexiComboBoxBase::slotItemSelected(item); }
98
99 protected slots:
100 void slotInternalEditorValueChanged(const TQVariant& v)
102
103 protected:
104 TQRect buttonGeometry() const;
105
106 virtual void paintEvent( TQPaintEvent * );
107
108 virtual void mousePressEvent( TQMouseEvent *e );
109
110 void mouseDoubleClickEvent( TQMouseEvent *e );
111
112 virtual bool eventFilter( TQObject *o, TQEvent *e );
113
115 TQRect editorGeometry() const;
116
119 virtual void createEditor();
120
122 virtual void styleChange( TQStyle& oldStyle );
123
125 virtual void fontChange( const TQFont & oldFont );
126
127 virtual bool subwidgetStretchRequired(KexiDBAutoField* autoField) const;
128
130 virtual TQWidget *internalEditor() const { return /*WidgetWithSubpropertiesInterface*/m_subwidget; }
131
133 virtual void moveCursorToEndInInternalEditor();
134
136 virtual void selectAllInInternalEditor();
137
139 virtual void setValueInInternalEditor(const TQVariant& value);
140
142 virtual TQVariant valueFromInternalEditor();
143
145 virtual void editRequested();
146
148 virtual void acceptRequested();
149
152 virtual TQPoint mapFromParentToGlobal(const TQPoint& pos) const;
153
155 virtual int popupWidthHint() const;
156
157 virtual void setValueInternal(const TQVariant& add, bool removeOld);
158
160 virtual void setVisibleValueInternal(const TQVariant& value);
161
162 bool handleMousePressEvent(TQMouseEvent *e);
163
164 bool handleKeyPressEvent(TQKeyEvent *ke);
165
167 virtual void beforeSignalValueChanged();
168
169 virtual KexiComboBoxPopup *popup() const;
170 virtual void setPopup(KexiComboBoxPopup *popup);
171
176 virtual bool keyPressed(TQKeyEvent *ke);
177
178 class Private;
179 Private * const d;
180};
181
182#endif
A base class for handling data-aware combo boxes. This class is used by KexiComboBoxTableEdit and Kex...
virtual TQVariant valueFromInternalEditor()=0
Implement this to return value from the internal editor.
virtual void moveCursorToEndInInternalEditor()=0
Implement this to perform "move cursor to end" in the internal editor.
virtual void editRequested()=0
Implement this as signal.
virtual void slotItemSelected(KexiTableItem *)
Call this from slot.
virtual TQVariant value()
Note: Generally in current implementation this is integer > 0; may be null if no value is set.
virtual void setValueInInternalEditor(const TQVariant &value)=0
Implement this to perform "set value" in the internal editor.
virtual TQPoint mapFromParentToGlobal(const TQPoint &pos) const =0
Implement this to return a position pos mapped from parent (e.g.
virtual void slotRowAccepted(KexiTableItem *item, int row)
Call this from slot.
virtual int popupWidthHint() const =0
Implement this to return a hint for popup width.
virtual void acceptRequested()=0
Implement this as signal.
void slotInternalEditorValueChanged(const TQVariant &v)
Call this from slot.
virtual void selectAllInInternalEditor()=0
Implement this to perform "select all" in the internal editor.
Internal class for displaying popup table view.
Universal "Auto Field" widget for Kexi forms.
virtual void setLabelPosition(LabelPosition position)
virtual void setColumnInfo(KexiDB::QueryColumnInfo *cinfo)
const TQColor & paletteBackgroundColor() const
Reimplemented to return internal editor's color.
virtual bool valueChanged()
virtual bool keyPressed(TQKeyEvent *ke)
virtual void setPaletteBackgroundColor(const TQColor &color)
Reimplemented to set internal editor's color.
virtual void createEditor()
virtual void setValueInternal(const TQVariant &add, bool removeOld)
Combo box widget for Kexi forms.
virtual TQVariant value()
virtual KexiTableViewColumn * column() const
Implemented for KexiComboBoxBase: form has no 'related data' model (only the full database model)
virtual TQVariant origValue() const
Implemented for KexiComboBoxBase.
virtual TQWidget * internalEditor() const
Implemented for KexiComboBoxBase.
virtual KexiDB::Field * field() const
Implemented for KexiComboBoxBase.
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
virtual void setVisibleValueInternal(const TQVariant &value)
virtual KexiDB::Field * field() const =0
virtual void beforeSignalValueChanged()
virtual TQVariant visibleValue()
virtual void setVisibleColumnInfo(KexiDB::QueryColumnInfo *cinfo)
virtual KexiDB::QueryColumnInfo * visibleColumnInfo() const