kexi

kexicomboboxbase.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2002 Peter Simonsson <psn@linux.se>
00003    Copyright (C) 2003-2007 Jaroslaw Staniek <js@iidea.pl>
00004 
00005    This program is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this program; see the file COPYING.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #ifndef _KEXICOMBOBOXBASE_H_
00022 #define _KEXICOMBOBOXBASE_H_
00023 
00024 #include "kexidb/field.h"
00025 #include "kexiinputtableedit.h"
00026 #include <kexidb/lookupfieldschema.h>
00027 
00028 class KPushButton;
00029 class KLineEdit;
00030 class KexiComboBoxPopup;
00031 class KexiTableItem;
00032 class KexiTableViewColumn;
00033 
00037 class KEXIDATATABLE_EXPORT KexiComboBoxBase
00038 {
00039     public:
00040         KexiComboBoxBase();
00041         virtual ~KexiComboBoxBase();
00042 
00044         virtual KexiTableViewColumn *column() const = 0;
00045 
00047         virtual KexiDB::Field *field() const = 0;
00048 
00050         virtual QVariant origValue() const = 0;
00051 
00053         virtual QVariant value();
00054 
00055         virtual QVariant visibleValue();
00056 
00058         virtual void clear();
00059 
00060         virtual tristate valueChangedInternal();
00061         virtual bool valueIsNull();
00062         virtual bool valueIsEmpty();
00063 
00064     public:
00065         virtual void hide();
00066 
00067         void createPopup(bool show);
00068 
00069         void showPopup();
00070         
00072         virtual void slotRowAccepted(KexiTableItem *item, int row);
00073         
00075         virtual void slotItemSelected(KexiTableItem*);
00076 
00078         void slotInternalEditorValueChanged(const QVariant &v);
00079 
00081         virtual QWidget *internalEditor() const = 0;
00082 
00083     protected:
00084         virtual void setValueInternal(const QVariant& add, bool removeOld);
00085 
00088         KexiTableItem* selectItemForEnteredValueInLookupTable(const QVariant& v);
00089 
00095         QString valueForString(const QString& str, int* row, uint lookInColumn, 
00096             uint returnFromColumn, bool allowNulls = false);
00097 
00100         void setValueOrTextInInternalEditor(const QVariant& value); //QString& text);
00101 
00103         KexiDB::LookupFieldSchema* lookupFieldSchema() const;
00104 
00105         int rowToHighlightForLookupTable() const;
00106 
00108         virtual void moveCursorToEndInInternalEditor() = 0;
00109 
00111         virtual void selectAllInInternalEditor() = 0;
00112 
00114         virtual void setValueInInternalEditor(const QVariant& value) = 0;
00115 
00117         virtual QVariant valueFromInternalEditor() = 0;
00118 
00120         virtual void editRequested() = 0;
00121 
00123         virtual void acceptRequested() = 0;
00124 
00127         virtual QPoint mapFromParentToGlobal(const QPoint& pos) const = 0;
00128 
00130         virtual int popupWidthHint() const = 0;
00131 
00134         virtual void updateButton() {}
00135 
00136         virtual KexiComboBoxPopup *popup() const = 0;
00137         virtual void setPopup(KexiComboBoxPopup *popup) = 0;
00138 
00139         virtual QVariant visibleValueForLookupField();
00140 
00141         void updateTextForHighlightedRow();
00142 
00143         bool handleKeyPressForPopup( QKeyEvent *ke );
00144 
00145         void acceptPopupSelection();
00146 
00148         void undoChanges();
00149 
00150         QVariant m_visibleValue;
00151 
00152         QVariant m_userEnteredValue; 
00153     
00154         bool m_internalEditorValueChanged : 1; 
00155         bool m_slotInternalEditorValueChanged_enabled : 1; 
00156         bool m_setValueOrTextInInternalEditor_enabled : 1; 
00157         bool m_mouseBtnPressedWhenPopupVisible : 1; 
00158         bool m_insideCreatePopup : 1; 
00159         bool m_updatePopupSelectionOnShow : 1; 
00160 
00161 
00162         bool m_moveCursorToEndInInternalEditor_enabled : 1;
00163         bool m_selectAllInInternalEditor_enabled : 1;
00164         bool m_setValueInInternalEditor_enabled : 1;
00165         bool m_setVisibleValueOnSetValueInternal : 1; 
00166 
00167 
00168 };
00169 
00170 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys