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-2004 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 
00027 class KPushButton;
00028 class KLineEdit;
00029 class KexiComboBoxPopup;
00030 class KexiTableItem;
00031 class KexiTableViewColumn;
00032 
00036 class KexiComboBoxTableEdit : public KexiInputTableEdit
00037 {
00038     Q_OBJECT
00039 
00040     public:
00041         KexiComboBoxTableEdit(KexiTableViewColumn &column, QScrollView *parent=0);
00042         virtual ~KexiComboBoxTableEdit();
00043 
00045         virtual QVariant value();
00046 
00047         virtual void clear();
00048 //      virtual bool cursorAtStart();
00049 //      virtual bool cursorAtEnd();
00050 
00051         virtual bool valueChanged();
00052         virtual bool valueIsNull();
00053         virtual bool valueIsEmpty();
00054 
00056         virtual void resize(int w, int h);
00057 
00058         virtual void showFocus( const QRect& r, bool readOnly );
00059 
00060         virtual void hideFocus();
00061 
00062         virtual void paintFocusBorders( QPainter *p, QVariant &cal, int x, int y, int w, int h );
00063 
00064         virtual void setupContents( QPainter *p, bool focused, QVariant val, 
00065             QString &txt, int &align, int &x, int &y_offset, int &w, int &h );
00066 
00067 //      virtual int rightMargin();
00068 
00069         virtual bool handleKeyPress( QKeyEvent *ke, bool editorActive );
00070 
00071         virtual int widthForValue( QVariant &val, QFontMetrics &fm );
00072 
00073     public:
00074         virtual void hide();
00075         virtual void show();
00076 
00078         virtual QSize totalSize() const;
00079 
00080     protected slots:
00081         void slotButtonClicked();
00082         void showPopup();
00083         void slotRowAccepted(KexiTableItem *item, int row);
00084         void slotItemSelected(KexiTableItem*);
00085         void slotLineEditTextChanged(const QString &newtext);
00086         void slotPopupHidden();
00087 
00088     protected:
00090         void updateFocus( const QRect& r );
00091 
00092         virtual void setValueInternal(const QVariant& add, bool removeOld);
00093 
00094         virtual bool eventFilter( QObject *o, QEvent *e );
00095 
00096         void updateTextForHighlightedRow();
00097 
00098 //      //! \return value (col #1 of related data) - only reasonable for 'related table data' model
00099 //      QString valueForID(const QVariant& val);
00100 
00106         QString valueForString(const QString& str, uint lookInColumn, 
00107             uint returnFromColumn, bool allowNulls = false);
00108 
00109 
00112         void setLineEditText(const QString& text);
00113 
00114         class Private;
00115         Private *d;
00116 };
00117 
00118 KEXI_DECLARE_CELLEDITOR_FACTORY_ITEM(KexiComboBoxEditorFactoryItem)
00119 
00120 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys