kexi

kexicomboboxbase.h
1/* This file is part of the KDE project
2 Copyright (C) 2002 Peter Simonsson <psn@linux.se>
3 Copyright (C) 2003-2007 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 _KEXICOMBOBOXBASE_H_
22#define _KEXICOMBOBOXBASE_H_
23
24#include "kexidb/field.h"
25#include "kexiinputtableedit.h"
26#include <kexidb/lookupfieldschema.h>
27
28class KPushButton;
29class KLineEdit;
31class KexiTableItem;
33
37class KEXIDATATABLE_EXPORT KexiComboBoxBase
38{
39 public:
40 KexiComboBoxBase();
41 virtual ~KexiComboBoxBase();
42
44 virtual KexiTableViewColumn *column() const = 0;
45
47 virtual KexiDB::Field *field() const = 0;
48
50 virtual TQVariant origValue() const = 0;
51
53 virtual TQVariant value();
54
55 virtual TQVariant visibleValue();
56
58 virtual void clear();
59
60 virtual tristate valueChangedInternal();
61 virtual bool valueIsNull();
62 virtual bool valueIsEmpty();
63
64 public:
65 virtual void hide();
66
67 void createPopup(bool show);
68
69 void showPopup();
70
72 virtual void slotRowAccepted(KexiTableItem *item, int row);
73
75 virtual void slotItemSelected(KexiTableItem*);
76
78 void slotInternalEditorValueChanged(const TQVariant &v);
79
81 virtual TQWidget *internalEditor() const = 0;
82
83 protected:
84 virtual void setValueInternal(const TQVariant& add, bool removeOld);
85
88 KexiTableItem* selectItemForEnteredValueInLookupTable(const TQVariant& v);
89
95 TQString valueForString(const TQString& str, int* row, uint lookInColumn,
96 uint returnFromColumn, bool allowNulls = false);
97
100 void setValueOrTextInInternalEditor(const TQVariant& value); //TQString& text);
101
104
106
109
111 virtual void selectAllInInternalEditor() = 0;
112
114 virtual void setValueInInternalEditor(const TQVariant& value) = 0;
115
117 virtual TQVariant valueFromInternalEditor() = 0;
118
120 virtual void editRequested() = 0;
121
123 virtual void acceptRequested() = 0;
124
127 virtual TQPoint mapFromParentToGlobal(const TQPoint& pos) const = 0;
128
130 virtual int popupWidthHint() const = 0;
131
134 virtual void updateButton() {}
135
136 virtual KexiComboBoxPopup *popup() const = 0;
137 virtual void setPopup(KexiComboBoxPopup *popup) = 0;
138
139 virtual TQVariant visibleValueForLookupField();
140
141 void updateTextForHighlightedRow();
142
143 bool handleKeyPressForPopup( TQKeyEvent *ke );
144
145 void acceptPopupSelection();
146
148 void undoChanges();
149
150 TQVariant m_visibleValue;
151
153
162 bool m_moveCursorToEndInInternalEditor_enabled : 1;
163 bool m_selectAllInInternalEditor_enabled : 1;
164 bool m_setValueInInternalEditor_enabled : 1;
168};
169
170#endif
bool m_mouseBtnPressedWhenPopupVisible
Used only by KexiComboBoxTableEdit.
TQVariant m_userEnteredValue
value (usually a text) entered by hand (by the user)
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 KexiTableViewColumn * column() const =0
virtual TQWidget * internalEditor() const =0
Implement this to return the internal editor.
virtual TQVariant value()
Note: Generally in current implementation this is integer > 0; may be null if no value is set.
bool m_setVisibleValueOnSetValueInternal
KexiTableItem * selectItemForEnteredValueInLookupTable(const TQVariant &v)
virtual void setValueInInternalEditor(const TQVariant &value)=0
Implement this to perform "set value" in the internal editor.
void setValueOrTextInInternalEditor(const TQVariant &value)
void createPopup(bool show)
virtual TQPoint mapFromParentToGlobal(const TQPoint &pos) const =0
virtual TQVariant origValue() const =0
virtual void slotRowAccepted(KexiTableItem *item, int row)
Call this from slot.
virtual void clear()
Reimplement this and call this impl.: used to clear internal editor.
virtual int popupWidthHint() const =0
Implement this to return a hint for popup width.
bool m_setValueOrTextInInternalEditor_enabled
Used in setValueOrTextInInternalEditor() and slotItemSelected().
KexiDB::LookupFieldSchema * lookupFieldSchema() const
virtual void acceptRequested()=0
Implement this as signal.
TQString valueForString(const TQString &str, int *row, uint lookInColumn, uint returnFromColumn, bool allowNulls=false)
bool m_internalEditorValueChanged
true if user has text or other value inside editor
virtual void setValueInternal(const TQVariant &add, bool removeOld)
virtual void updateButton()
virtual KexiDB::Field * field() const =0
void slotInternalEditorValueChanged(const TQVariant &v)
Call this from slot.
bool m_slotInternalEditorValueChanged_enabled
Used in slotInternalEditorValueChanged().
bool m_insideCreatePopup
true if we're inside createPopup(); used in slotItemSelected()
virtual void selectAllInInternalEditor()=0
Implement this to perform "select all" in the internal editor.
int rowToHighlightForLookupTable() const
Internal class for displaying popup table view.
Meta-data for a field.
Definition field.h:73
Provides information about lookup field's setup.
3-state logical type with three values: true, false and cancelled and convenient operators.
Definition tristate.h:100