1 /* This file is part of the KDE project 2 Copyright (C) 2005 Cedric Pasteur <cedric.pasteur@free.fr> 3 Copyright (C) 2004-2005 Jarosław Staniek <staniek@kde.org> 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 KEXIDBDOUBLESPINBOX_H 22 #define KEXIDBDOUBLESPINBOX_H 23 24 #include "kexiformdataiteminterface.h" 25 #include <formeditor/FormWidgetInterface.h> 26 27 #include <QDoubleSpinBox> 28 29 //! @short A db-aware int spin box 30 class KEXIFORMUTILS_EXPORT KexiDBDoubleSpinBox : public KDoubleSpinBox, 31 public KexiFormDataItemInterface 32 { 33 Q_OBJECT 34 Q_PROPERTY(QString dataSource READ dataSource WRITE setDataSource) 35 Q_PROPERTY(QString dataSourcePartClass READ dataSourcePluginId WRITE setDataSourcePluginId) 36 Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly) 37 38 public: 39 explicit KexiDBDoubleSpinBox(QWidget *parent); 40 virtual ~KexiDBDoubleSpinBox(); 41 dataSource()42 inline QString dataSource() const { 43 return KexiFormDataItemInterface::dataSource(); 44 } dataSourcePluginId()45 inline QString dataSourcePluginId() const { 46 return KexiFormDataItemInterface::dataSourcePluginId(); 47 } 48 virtual QVariant value(); 49 virtual void setInvalidState(const QString& displayText); 50 51 //! \return true if editor's value is null (not empty) 52 //! Used for checking if a given constraint within table of form is met. 53 virtual bool valueIsNull(); 54 55 //! \return true if editor's value is empty (not necessary null). 56 //! Only few data types can accept "EMPTY" property 57 //! (use KDbField::hasEmptyProperty() to check this). 58 //! Used for checking if a given constraint within table or form is met. 59 virtual bool valueIsEmpty(); 60 61 /*! \return 'readOnly' flag for this widget. */ 62 virtual bool isReadOnly() const; 63 64 /*! \return the view widget of this item, e.g. line edit widget. */ 65 virtual QWidget* widget(); 66 67 virtual bool cursorAtStart(); 68 virtual bool cursorAtEnd(); 69 virtual void clear(); 70 71 public Q_SLOTS: 72 virtual void setEnabled(bool enabled); setDataSource(const QString & ds)73 inline void setDataSource(const QString &ds) { 74 KexiFormDataItemInterface::setDataSource(ds); 75 } setDataSourcePluginId(const QString & pluginId)76 inline void setDataSourcePluginId(const QString &pluginId) { 77 KexiFormDataItemInterface::setDataSourcePluginId(pluginId); 78 } 79 void slotValueChanged(); 80 virtual void setReadOnly(bool set); 81 82 protected: 83 virtual void setValueInternal(const QVariant& add, bool removeOld); 84 85 private: 86 bool m_invalidState; 87 }; 88 89 #endif 90