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    Copyright (C) 2012 Oleg Kukharchuk <oleg.kuh@gmail.com>
5 
6    This program is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Library General Public
8    License as published by the Free Software Foundation; either
9    version 2 of the License, or (at your option) any later version.
10 
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Library General Public License for more details.
15 
16    You should have received a copy of the GNU Library General Public License
17    along with this program; see the file COPYING.  If not, write to
18    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20 */
21 
22 #ifndef KEXIDBPROGRESSBAR_H
23 #define KEXIDBPROGRESSBAR_H
24 
25 #include "kexiformutils_export.h"
26 #include <widget/dataviewcommon/kexiformdataiteminterface.h>
27 #include <formeditor/FormWidgetInterface.h>
28 #include <QProgressBar>
29 
30 //! @short A db-aware Progress bar
31 class KEXIFORMUTILS_EXPORT KexiDBProgressBar : public QProgressBar,
32                                                public KexiFormDataItemInterface,
33                                                public KFormDesigner::FormWidgetInterface
34 {
35     Q_OBJECT
36     Q_PROPERTY(QString dataSource READ dataSource WRITE setDataSource)
37     Q_PROPERTY(QString dataSourcePartClass READ dataSourcePluginId WRITE setDataSourcePluginId)
38 
39 public:
40     explicit KexiDBProgressBar(QWidget *parent = 0);
41     virtual ~KexiDBProgressBar();
42 
dataSource()43     inline QString dataSource() const {
44         return KexiFormDataItemInterface::dataSource();
45     }
dataSourcePluginId()46     inline QString dataSourcePluginId() const {
47         return KexiFormDataItemInterface::dataSourcePluginId();
48     }
49     virtual QVariant value();
50     virtual void setInvalidState(const QString& displayText);
51 
52     //! \return true if editor's value is null (not empty)
53     //! Used for checking if a given constraint within table of form is met.
54     virtual bool valueIsNull();
55 
56     //! \return true if editor's value is empty (not necessary null).
57     //! Only few data types can accept "EMPTY" property
58     //! (use KDbField::hasEmptyProperty() to check this).
59     //! Used for checking if a given constraint within table or form is met.
60     virtual bool valueIsEmpty();
61 
62     /*! \return 'readOnly' flag for this widget. */
63     virtual bool isReadOnly() const;
64 
65     /*! \return the view widget of this item, e.g. line edit widget. */
66     virtual QWidget* widget();
67 
68     virtual bool cursorAtStart();
69     virtual bool cursorAtEnd();
70     virtual void clear();
71 
72     virtual void  setEnabled(bool enabled);
73 
74 public Q_SLOTS:
setDataSource(const QString & ds)75     inline void setDataSource(const QString &ds) {
76         KexiFormDataItemInterface::setDataSource(ds);
77     }
setDataSourcePluginId(const QString & pluginId)78     inline void setDataSourcePluginId(const QString &pluginId) {
79         KexiFormDataItemInterface::setDataSourcePluginId(pluginId);
80     }
81     void slotValueChanged();
82     virtual void setReadOnly(bool set);
83 protected:
84     virtual void setValueInternal(const QVariant& add, bool removeOld);
85 
86 private:
87     bool m_invalidState;
88 };
89 
90 #endif
91