kexi
kexidbcombobox.h
00001 /* This file is part of the KDE project 00002 Copyright (C) 2006-2007 Jaroslaw Staniek <js@iidea.pl> 00003 00004 This program is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this program; see the file COPYING. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef KexiDBComboBox_H 00021 #define KexiDBComboBox_H 00022 00023 #include "kexidbutils.h" 00024 #include "kexidbautofield.h" 00025 #include <widget/tableview/kexicomboboxbase.h> 00026 00028 00034 class KEXIFORMUTILS_EXPORT KexiDBComboBox : 00035 public KexiDBAutoField, public KexiComboBoxBase 00036 { 00037 Q_OBJECT 00038 Q_PROPERTY( bool editable READ isEditable WRITE setEditable ) 00039 //properties from KexiDBAutoField that should not be visible: 00040 Q_OVERRIDE(QColor paletteBackgroundColor READ paletteBackgroundColor WRITE setPaletteBackgroundColor DESIGNABLE true RESET unsetPalette) 00041 Q_OVERRIDE(QColor foregroundLabelColor DESIGNABLE false) 00042 Q_OVERRIDE(QColor backgroundLabelColor DESIGNABLE false) 00043 Q_OVERRIDE(bool autoCaption DESIGNABLE false) 00044 00045 public: 00046 KexiDBComboBox(QWidget *parent, const char *name=0, bool designMode = true); 00047 virtual ~KexiDBComboBox(); 00048 00050 virtual KexiTableViewColumn *column() const { return 0; } 00051 00053 virtual KexiDB::Field *field() const { return KexiDBAutoField::field(); } 00054 00056 virtual QVariant origValue() const { return m_origValue; } 00057 00058 void setEditable(bool set); 00059 bool isEditable() const; 00060 00061 virtual void setLabelPosition(LabelPosition position); 00062 00063 virtual QVariant value() { return KexiComboBoxBase::value(); } 00064 00065 virtual QVariant visibleValue(); 00066 00068 virtual bool valueChanged(); 00069 00070 virtual QSize sizeHint() const; 00071 00074 virtual void setColumnInfo(KexiDB::QueryColumnInfo* cinfo); 00075 00078 virtual void setVisibleColumnInfo(KexiDB::QueryColumnInfo* cinfo); 00079 00082 virtual KexiDB::QueryColumnInfo* visibleColumnInfo() const; 00083 00084 const QColor & paletteBackgroundColor() const { return KexiDBAutoField::paletteBackgroundColor(); } 00085 00087 virtual void setPaletteBackgroundColor( const QColor & color ); 00088 00092 virtual void undoChanges(); 00093 00094 public slots: 00095 void slotRowAccepted(KexiTableItem *item, int row); 00096 void slotItemSelected(KexiTableItem* item) { KexiComboBoxBase::slotItemSelected(item); } 00097 00098 protected slots: 00099 void slotInternalEditorValueChanged(const QVariant& v) 00100 { KexiComboBoxBase::slotInternalEditorValueChanged(v); } 00101 00102 protected: 00103 QRect buttonGeometry() const; 00104 00105 virtual void paintEvent( QPaintEvent * ); 00106 00107 virtual void mousePressEvent( QMouseEvent *e ); 00108 00109 void mouseDoubleClickEvent( QMouseEvent *e ); 00110 00111 virtual bool eventFilter( QObject *o, QEvent *e ); 00112 00114 QRect editorGeometry() const; 00115 00118 virtual void createEditor(); 00119 00121 virtual void styleChange( QStyle& oldStyle ); 00122 00124 virtual void fontChange( const QFont & oldFont ); 00125 00126 virtual bool subwidgetStretchRequired(KexiDBAutoField* autoField) const; 00127 00129 virtual QWidget *internalEditor() const { return /*WidgetWithSubpropertiesInterface*/m_subwidget; } 00130 00132 virtual void moveCursorToEndInInternalEditor(); 00133 00135 virtual void selectAllInInternalEditor(); 00136 00138 virtual void setValueInInternalEditor(const QVariant& value); 00139 00141 virtual QVariant valueFromInternalEditor(); 00142 00144 virtual void editRequested(); 00145 00147 virtual void acceptRequested(); 00148 00151 virtual QPoint mapFromParentToGlobal(const QPoint& pos) const; 00152 00154 virtual int popupWidthHint() const; 00155 00156 virtual void setValueInternal(const QVariant& add, bool removeOld); 00157 00159 virtual void setVisibleValueInternal(const QVariant& value); 00160 00161 bool handleMousePressEvent(QMouseEvent *e); 00162 00163 bool handleKeyPressEvent(QKeyEvent *ke); 00164 00166 virtual void beforeSignalValueChanged(); 00167 00168 virtual KexiComboBoxPopup *popup() const; 00169 virtual void setPopup(KexiComboBoxPopup *popup); 00170 00175 virtual bool keyPressed(QKeyEvent *ke); 00176 00177 class Private; 00178 Private * const d; 00179 }; 00180 00181 #endif