kexi

kexicomboboxtableedit.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2002   Peter Simonsson <psn@linux.se>
00003    Copyright (C) 2003-2006 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 _KEXICOMBOBOXTABLEEDIT_H_
00022 #define _KEXICOMBOBOXTABLEEDIT_H_
00023 
00024 #include "kexidb/field.h"
00025 #include "kexiinputtableedit.h"
00026 #include "kexicomboboxbase.h"
00027 #include <kexidb/lookupfieldschema.h>
00028 
00029 class KPushButton;
00030 class KLineEdit;
00031 class KexiComboBoxPopup;
00032 class KexiTableItem;
00033 class KexiTableViewColumn;
00034 
00037 class KexiComboBoxTableEdit : public KexiInputTableEdit, public KexiComboBoxBase
00038 {
00039     Q_OBJECT
00040 
00041     public:
00042         KexiComboBoxTableEdit(KexiTableViewColumn &column, QWidget *parent=0);
00043         virtual ~KexiComboBoxTableEdit();
00044 
00046         virtual KexiTableViewColumn *column() const { return m_column; }
00047 
00049         virtual KexiDB::Field *field() const { return m_column->field(); }
00050 
00052         virtual QVariant origValue() const { return m_origValue; }
00053 
00054         virtual void setValueInternal(const QVariant& add, bool removeOld)
00055             { KexiComboBoxBase::setValueInternal(add, removeOld); }
00056 
00057         virtual QVariant value() { return KexiComboBoxBase::value(); }
00058 
00059         virtual void clear();
00060 
00061         virtual bool valueChanged();
00062 
00063         virtual QVariant visibleValue();
00064 
00066         virtual void resize(int w, int h);
00067 
00068         virtual void showFocus( const QRect& r, bool readOnly );
00069 
00070         virtual void hideFocus();
00071 
00072         virtual void paintFocusBorders( QPainter *p, QVariant &cal, int x, int y, int w, int h );
00073 
00078         virtual void setupContents( QPainter *p, bool focused, const QVariant& val, 
00079             QString &txt, int &align, int &x, int &y_offset, int &w, int &h );
00080 
00082         virtual bool handleKeyPress( QKeyEvent *ke, bool editorActive );
00083 
00084         virtual int widthForValue( QVariant &val, const QFontMetrics &fm );
00085     
00086         virtual void hide();
00087         virtual void show();
00088 
00090         virtual QSize totalSize() const;
00091 
00092         virtual void createInternalEditor(KexiDB::QuerySchema& schema);
00093 
00095         virtual void handleAction(const QString& actionName);
00096 
00100         virtual void handleCopyAction(const QVariant& value, const QVariant& visibleValue);
00101 
00102     public slots:
00104         virtual void moveCursorToEnd();
00105 
00107         virtual void moveCursorToStart();
00108 
00110         virtual void selectAll();
00111 
00112     protected slots:
00113         void slotButtonClicked();
00114         void slotRowAccepted(KexiTableItem *item, int row) { KexiComboBoxBase::slotRowAccepted(item, row); }
00115         void slotItemSelected(KexiTableItem* item) { KexiComboBoxBase::slotItemSelected(item); }
00116         void slotInternalEditorValueChanged(const QVariant& v)
00117             { KexiComboBoxBase::slotInternalEditorValueChanged(v); }
00118         void slotLineEditTextChanged(const QString& s);
00119         void slotPopupHidden();
00120 
00121     protected:
00123         void updateFocus( const QRect& r );
00124 
00125         virtual bool eventFilter( QObject *o, QEvent *e );
00126 
00128         virtual QWidget *internalEditor() const;
00129 
00131         virtual void moveCursorToEndInInternalEditor();
00132 
00134         virtual void selectAllInInternalEditor();
00135 
00137         virtual void setValueInInternalEditor(const QVariant& value);
00138 
00140         virtual QVariant valueFromInternalEditor();
00141 
00143         virtual void editRequested() { KexiInputTableEdit::editRequested(); }
00144 
00146         virtual void acceptRequested() { KexiInputTableEdit::acceptRequested(); }
00147 
00149         virtual QPoint mapFromParentToGlobal(const QPoint& pos) const;
00150 
00152         virtual int popupWidthHint() const;
00153 
00155         virtual void updateButton();
00156 
00157         virtual KexiComboBoxPopup *popup() const;
00158         virtual void setPopup(KexiComboBoxPopup *popup);
00159 
00160         class Private;
00161         Private *d;
00162 };
00163 
00164 KEXI_DECLARE_CELLEDITOR_FACTORY_ITEM(KexiComboBoxEditorFactoryItem)
00165 
00166 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys