[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [calligra/kexi-widgets-okukharchuk] kexi: Kexi DB widgets implemention (KexiDBCommandLinkButton, Kex
From: Oleg Kukharchuk <oleg.kuh () gmail ! com>
Date: 2012-06-02 17:26:11
Message-ID: 20120602172611.3A751A60C4 () git ! kde ! org
[Download RAW message or body]
Git commit 86ccec0413f1e4879ebe3be1fd3399e65365eff8 by Oleg Kukharchuk.
Committed on 02/06/2012 at 19:13.
Pushed by okukharchuk into branch 'kexi-widgets-okukharchuk'.
Kexi DB widgets implemention (KexiDBCommandLinkButton, KexiDBSlider and
KexiDBProgressBar)
REVIEW: 105120
FIXED-IN: 2.5.0
DIGEST: 3 new Kexi widgets (KexiDBCommandLinkButton, KexiDBSlider and \
KexiDBProgressBar)
M +2 -1 kexi/formeditor/kexiformeventhandler.cpp
M +1 -1 kexi/kexiutils/KexiCommandLinkButton.h
M +3 -0 kexi/plugins/forms/CMakeLists.txt
M +75 -2 kexi/plugins/forms/kexidbfactory.cpp
M +3 -0 kexi/plugins/forms/kexiformmanager.cpp
M +3 -0 kexi/plugins/forms/kexiformpartinstui.rc
M +1 -1 kexi/plugins/forms/kexiformview.cpp
A +32 -0 kexi/plugins/forms/widgets/kexidbcommandlinkbutton.cpp [License: \
LGPL (v2+)] A +66 -0 kexi/plugins/forms/widgets/kexidbcommandlinkbutton.h \
[License: LGPL (v2+)] A +110 -0 kexi/plugins/forms/widgets/kexidbprogressbar.cpp \
[License: LGPL (v2+)] A +92 -0 kexi/plugins/forms/widgets/kexidbprogressbar.h \
[License: LGPL (v2+)] A +113 -0 kexi/plugins/forms/widgets/kexidbslider.cpp \
[License: LGPL (v2+)] A +92 -0 kexi/plugins/forms/widgets/kexidbslider.h \
[License: LGPL (v2+)]
http://commits.kde.org/calligra/86ccec0413f1e4879ebe3be1fd3399e65365eff8
diff --git a/kexi/formeditor/kexiformeventhandler.cpp \
b/kexi/formeditor/kexiformeventhandler.cpp index dbfcd66..195a63f 100644
--- a/kexi/formeditor/kexiformeventhandler.cpp
+++ b/kexi/formeditor/kexiformeventhandler.cpp
@@ -158,8 +158,9 @@ void KexiFormEventHandler::setMainWidgetForEventHandling(QWidget* \
mainWidget) //! @todo look for other widgets too
QList<QWidget*> widgets(m_mainWidget->findChildren<QWidget*>());
foreach(QWidget *widget, widgets) {
- if (!widget->inherits("KexiPushButton"))
+ if (!widget->inherits("QPushButton") ){
continue;
+ }
bool ok;
KexiFormEventAction::ActionData data;
data.string = widget->property("onClickAction").toString();
diff --git a/kexi/kexiutils/KexiCommandLinkButton.h \
b/kexi/kexiutils/KexiCommandLinkButton.h index 210681a..e5270ea 100644
--- a/kexi/kexiutils/KexiCommandLinkButton.h
+++ b/kexi/kexiutils/KexiCommandLinkButton.h
@@ -21,7 +21,7 @@
#ifndef KEXICOMMANDLINKBUTTON_H
#define KEXICOMMANDLINKBUTTON_H
-#include <kexiutils_export.h>
+#include <kexiutils/kexiutils_export.h>
#include <QPushButton>
diff --git a/kexi/plugins/forms/CMakeLists.txt b/kexi/plugins/forms/CMakeLists.txt
index 3d9f268..588fae9 100644
--- a/kexi/plugins/forms/CMakeLists.txt
+++ b/kexi/plugins/forms/CMakeLists.txt
@@ -89,6 +89,9 @@ set(kexiformutils_LIB_SRCS
widgets/kexidbcheckbox.cpp
widgets/kexidbtextedit.cpp
widgets/kexidbcombobox.cpp
+ widgets/kexidbcommandlinkbutton.cpp
+ widgets/kexidbslider.cpp
+ widgets/kexidbprogressbar.cpp
)
#obsolete widgets/kexidbdoublespinbox.cpp
diff --git a/kexi/plugins/forms/kexidbfactory.cpp \
b/kexi/plugins/forms/kexidbfactory.cpp index 8f53bf9..4d84123 100644
--- a/kexi/plugins/forms/kexidbfactory.cpp
+++ b/kexi/plugins/forms/kexidbfactory.cpp
@@ -41,6 +41,7 @@
#include <kexidb/utils.h>
#include <kexidb/connection.h>
#include <kexiutils/utils.h>
+#include <kexiutils/KexiCommandLinkButton.h>
#include <widget/properties/KexiCustomPropertyFactory.h>
#include <widget/utils/kexicontextmenuutils.h>
#include <kexi_global.h>
@@ -58,6 +59,9 @@
#include "widgets/kexidbcombobox.h"
#include "widgets/kexipushbutton.h"
#include "widgets/kexidbform.h"
+#include "widgets/kexidbcommandlinkbutton.h"
+#include "widgets/kexidbslider.h"
+#include "widgets/kexidbprogressbar.h"
#ifndef KEXI_NO_SUBFORM
# include "widgets/kexidbsubform.h"
#endif
@@ -307,6 +311,41 @@ KexiDBFactory::KexiDBFactory(QObject *parent, const QVariantList \
&) wi->setInheritedClassName("KPushButton");
addClass(wi);
}
+ {
+ KFormDesigner::WidgetInfo* wi = new KFormDesigner::WidgetInfo(this);
+ wi->setClassName("KexiDBCommandLinkButton");
+ wi->setPixmap("button");
+ wi->setName(i18n("Link Button"));
+ wi->setNamePrefix(
+ i18nc("Widget name. This string will be used to name widgets of this \
class. " + "It must _not_ contain white spaces and non latin1 \
characters.", "linkButton")); + wi->setDescription(i18n("A Link button for \
executing actions")); + addClass(wi);
+ }
+ {
+ KexiDataAwareWidgetInfo* wi = new KexiDataAwareWidgetInfo(this);
+ wi->setPixmap("slider");
+ wi->setClassName("KexiDBSlider");
+ wi->setName(i18n("Slider"));
+ wi->setNamePrefix(
+ i18nc("Widget name. This string will be used to name widgets of this \
class. " + "It must _not_ contain white spaces and non latin1 \
characters.", "slider")); + wi->setDescription(i18n("A Slider widget"));
+ addClass(wi);
+ }
+ {
+ KexiDataAwareWidgetInfo* wi = new KexiDataAwareWidgetInfo(this);
+ wi->setPixmap("progress-bar");
+ wi->setClassName("KexiDBProgressBar");
+ wi->setName(i18n("Progress Bar"));
+ wi->setNamePrefix(
+ i18nc("Widget name. This string will be used to name widgets of this \
class. " + "It must _not_ contain white spaces and non latin1 \
characters.", "progressBar")); + wi->setDescription(i18n("A Progress Bar \
widget")); + addClass(wi);
+ }
+
+
m_propDesc["formName"] = i18n("Form Name");
m_propDesc["onClickAction"] = i18n("On Click");
@@ -413,6 +452,12 @@ KexiDBFactory::createWidget(const QByteArray &c, QWidget *p, \
const char *n, #endif
else if (c == "KexiDBCheckBox")
w = new KexiDBCheckBox(text, p);
+ else if (c == "KexiDBSlider") {
+ w = new KexiDBSlider(p);
+ } else if (c == "KexiDBProgressBar") {
+ w = new KexiDBProgressBar(p);
+ }
+
else if (c == "KexiDBComboBox")
w = new KexiDBComboBox(p);
/* else if(c == "KexiDBTimeEdit")
@@ -427,6 +472,9 @@ KexiDBFactory::createWidget(const QByteArray &c, QWidget *p, \
const char *n, // w = new KexiDBDoubleSpinBox(p, n);
else if (c == "KPushButton" || c == "KexiPushButton")
w = new KexiPushButton(text, p);
+ else if (c == "KexiDBCommandLinkButton" || c == "KexiCommandLinkButton") {
+ w = new KexiDBCommandLinkButton(text, QString(), p);
+ }
if (w)
w->setObjectName(n);
@@ -518,6 +566,18 @@ KexiDBFactory::startInlineEditing(InlineEditorCreationArguments& \
args) #endif
return true;
}
+ // KexiDBCommandLinkButton
+ else if (args.classname == "KexiDBCommandLinkButton" ){
+ KexiDBCommandLinkButton \
*linkButton=static_cast<KexiDBCommandLinkButton*>(args.widget); + QStyleOption \
option; + option.initFrom(linkButton);
+ args.text = linkButton->text();
+ const QRect r(linkButton->style()->subElementRect(
+ QStyle::SE_PushButtonContents, &option, linkButton));
+ args.geometry = QRect(linkButton->x() + r.x(), linkButton->y() + r.y(), \
r.width(), r.height()); + return true;
+
+ }
else if (args.classname == "KexiDBLabel") {
KexiDBLabel *label = static_cast<KexiDBLabel*>(args.widget);
//2.0 m_widget = w;
@@ -632,7 +692,6 @@ KexiDBFactory::isPropertyVisibleInternal(const QByteArray& \
classname, QWidget *w {
//general
bool ok = true;
-
if (classname == "KexiPushButton") {
ok = property != "isDragEnabled"
#ifdef KEXI_NO_UNFINISHED
@@ -643,7 +702,21 @@ KexiDBFactory::isPropertyVisibleInternal(const QByteArray& \
classname, QWidget *w && property != "stdItem" /*! @todo reenable stdItem */
#endif
;
- } else if (classname == "KexiDBLineEdit")
+ } else if (classname == "KexiDBCommandLinkButton") {
+ ok = property != "isDragEnabled"
+#ifdef KEXI_NO_UNFINISHED
+ && property != "onClickAction" /*! @todo reenable */
+ && property != "onClickActionOption" /*! @todo reenable */
+ && property != "iconSet" /*! @todo reenable */
+ && property != "iconSize" /*! @todo reenable */
+ && property != "stdItem" /*! @todo reenable stdItem */
+#endif
+ ;
+ } else if (classname == "KexiDBSlider") {
+ ok = property != "focusPolicy";
+ } else if (classname == "KexiDBProgressBar") {
+ ok = property != "focusPolicy";
+ } else if (classname == "KexiDBLineEdit")
ok = property != "urlDropsEnabled"
&& property != "vAlign"
&& property != "echoMode"
diff --git a/kexi/plugins/forms/kexiformmanager.cpp \
b/kexi/plugins/forms/kexiformmanager.cpp index 9b202fc..521dfb6 100644
--- a/kexi/plugins/forms/kexiformmanager.cpp
+++ b/kexi/plugins/forms/kexiformmanager.cpp
@@ -260,6 +260,9 @@ void KexiFormManager::createActions(KActionCollection* \
collection) #ifdef CAN_USE_MARBLE
<< "library_widget_MapBrowserWidget"
#endif
+ << "library_widget_KexiDBSlider"
+ << "library_widget_KexiDBProgressBar"
+ << "library_widget_KexiDBCommandLinkButton"
<< QString() //sep
;
KexiMainWindowIface *win = KexiMainWindowIface::global();
diff --git a/kexi/plugins/forms/kexiformpartinstui.rc \
b/kexi/plugins/forms/kexiformpartinstui.rc index 75f233f..eb08152 100644
--- a/kexi/plugins/forms/kexiformpartinstui.rc
+++ b/kexi/plugins/forms/kexiformpartinstui.rc
@@ -38,9 +38,12 @@
<Action name="library_widget_KexiDBLineEdit"/>
<Action name="library_widget_KexiDBTextEdit"/>
<Action name="library_widget_KPushButton"/>
+ <Action name="library_widget_KexiDBCommandLinkButton"/>
<Action name="library_widget_KexiDBComboBox"/>
<!-- Action name="library_widget_QRadioButton"/ -->
<Action name="library_widget_KexiDBCheckBox"/>
+ <Action name="library_widget_KexiDBSlider"/>
+ <Action name="library_widget_KexiDBProgressBar"/>
<Action name="library_widget_Spacer"/>
<Action name="library_widget_Line"/>
<Separator/>
diff --git a/kexi/plugins/forms/kexiformview.cpp \
b/kexi/plugins/forms/kexiformview.cpp index b814c63..618e2c1 100644
--- a/kexi/plugins/forms/kexiformview.cpp
+++ b/kexi/plugins/forms/kexiformview.cpp
@@ -1453,7 +1453,7 @@ void KexiFormView::updateActionsInternal()
widget_assign_action->setEnabled(
viewMode()==Kexi::DesignViewMode
&& selectedWidget
- && (wClass == "QPushButton" || wClass == "KPushButton" || wClass == \
"KexiPushButton") + && (wClass == "QPushButton" || wClass == "KPushButton" \
|| wClass == "KexiPushButton" || wClass == "KexiDBCommandLinkButton") );
}
#ifdef KEXI_DEBUG_GUI
diff --git a/kexi/plugins/forms/widgets/kexidbcommandlinkbutton.cpp \
b/kexi/plugins/forms/widgets/kexidbcommandlinkbutton.cpp new file mode 100644
index 0000000..69b47e8
--- /dev/null
+++ b/kexi/plugins/forms/widgets/kexidbcommandlinkbutton.cpp
@@ -0,0 +1,32 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Cedric Pasteur <cedric.pasteur@free.fr>
+ Copyright (C) 2004-2005 Jarosław Staniek <staniek@kde.org>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include "kexidbcommandlinkbutton.h"
+
+KexiDBCommandLinkButton::KexiDBCommandLinkButton(const QString & text, const QString \
&description, QWidget * parent) + : KexiCommandLinkButton(text, parent)
+{
+}
+
+KexiDBCommandLinkButton::~KexiDBCommandLinkButton()
+{
+}
+
+#include "kexidbcommandlinkbutton.moc"
diff --git a/kexi/plugins/forms/widgets/kexidbcommandlinkbutton.h \
b/kexi/plugins/forms/widgets/kexidbcommandlinkbutton.h new file mode 100644
index 0000000..dc96f19
--- /dev/null
+++ b/kexi/plugins/forms/widgets/kexidbcommandlinkbutton.h
@@ -0,0 +1,66 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Cedric Pasteur <cedric.pasteur@free.fr>
+ Copyright (C) 2004-2006 Jarosław Staniek <staniek@kde.org>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KexiDBCommandLinkButton_H
+#define KexiDBCommandLinkButton_H
+
+#include <kexiutils/KexiCommandLinkButton.h>
+#include <formeditor/kexiformeventhandler.h>
+#include <formeditor/FormWidgetInterface.h>
+
+//! @short Push Button widget for Kexi forms
+class KEXIFORMUTILS_EXPORT KexiDBCommandLinkButton : public KexiCommandLinkButton,
+ public \
KFormDesigner::FormWidgetInterface +{
+ Q_OBJECT
+ Q_PROPERTY(QString onClickAction READ onClickAction WRITE setOnClickAction)
+ Q_PROPERTY(QString onClickActionOption READ onClickActionOption WRITE \
setOnClickActionOption) +
+public:
+ KexiDBCommandLinkButton ( const QString & text, const QString &description, \
QWidget * parent ); + ~KexiDBCommandLinkButton();
+
+public slots:
+ //! action string for "on click" event
+ //! @see KexiFormPart::slotAssignAction()
+ //! @see KexiFormEventAction::ActionData
+ QString onClickAction() const {
+ return m_onClickActionData.string;
+ }
+ void setOnClickAction(const QString& actionString) {
+ m_onClickActionData.string = actionString;
+ }
+
+ /*! action option allowing to select whether the object should be opened
+ data view mode or printed, etc.
+ @see KexiFormPart::slotAssignAction()
+ @see KexiFormEventAction::ActionData */
+ QString onClickActionOption() const {
+ return m_onClickActionData.option;
+ }
+ void setOnClickActionOption(const QString& option) {
+ m_onClickActionData.option = option;
+ }
+
+protected:
+ KexiFormEventAction::ActionData m_onClickActionData;
+};
+
+#endif
diff --git a/kexi/plugins/forms/widgets/kexidbprogressbar.cpp \
b/kexi/plugins/forms/widgets/kexidbprogressbar.cpp new file mode 100644
index 0000000..28cf7c1
--- /dev/null
+++ b/kexi/plugins/forms/widgets/kexidbprogressbar.cpp
@@ -0,0 +1,110 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Cedric Pasteur <cedric.pasteur@free.fr>
+ Copyright (C) 2004-2005 Jarosław Staniek <staniek@kde.org>
+ Copyright (C) 2012 Oleg Kukharchuk <oleg.kuh@gmail.com>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include "kexidbprogressbar.h"
+
+
+KexiDBProgressBar::KexiDBProgressBar(QWidget *parent)
+ :QProgressBar(parent), KexiFormDataItemInterface()
+{
+}
+
+KexiDBProgressBar::~KexiDBProgressBar()
+{
+}
+
+void KexiDBProgressBar::setInvalidState(const QString& displayText)
+{
+ m_invalidState = true;
+ setEnabled(false);
+//! @todo move this to KexiDataItemInterface::setInvalidStateInternal() ?
+ if (focusPolicy() & Qt::TabFocus)
+ setFocusPolicy(Qt::ClickFocus);
+ QProgressBar::setValue(minimum());
+}
+
+void
+KexiDBProgressBar::setEnabled(bool enabled)
+{
+ // prevent the user from reenabling the widget when it is in invalid state
+ if (enabled && m_invalidState)
+ return;
+ QProgressBar::setEnabled(enabled);
+}
+
+void KexiDBProgressBar::setValueInternal(const QVariant&, bool)
+{
+ QProgressBar::setValue(m_origValue.toInt());
+}
+
+QVariant
+KexiDBProgressBar::value()
+{
+ return QProgressBar::value();
+}
+
+void KexiDBProgressBar::slotValueChanged()
+{
+ // read only widget
+}
+
+bool KexiDBProgressBar::valueIsNull()
+{
+ return false;
+}
+
+bool KexiDBProgressBar::valueIsEmpty()
+{
+ return false;
+}
+
+bool KexiDBProgressBar::isReadOnly() const
+{
+ return true;
+}
+
+void KexiDBProgressBar::setReadOnly(bool set)
+{
+ Q_UNUSED(set);
+}
+
+QWidget*
+KexiDBProgressBar::widget()
+{
+ return this;
+}
+
+bool KexiDBProgressBar::cursorAtStart()
+{
+ return false;
+}
+
+bool KexiDBProgressBar::cursorAtEnd()
+{
+ return false;
+}
+
+void KexiDBProgressBar::clear()
+{
+ //read only widget
+}
+
+#include "kexidbprogressbar.moc"
diff --git a/kexi/plugins/forms/widgets/kexidbprogressbar.h \
b/kexi/plugins/forms/widgets/kexidbprogressbar.h new file mode 100644
index 0000000..0617508
--- /dev/null
+++ b/kexi/plugins/forms/widgets/kexidbprogressbar.h
@@ -0,0 +1,92 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Cedric Pasteur <cedric.pasteur@free.fr>
+ Copyright (C) 2004-2005 Jarosław Staniek <staniek@kde.org>
+ Copyright (C) 2012 Oleg Kukharchuk <oleg.kuh@gmail.com>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KexiDBProgressBar_H
+#define KexiDBProgressBar_H
+
+#include <widget/dataviewcommon/kexiformdataiteminterface.h>
+#include <formeditor/FormWidgetInterface.h>
+#include <knuminput.h>
+#include <QProgressBar>
+
+//! @short A db-aware Progress bar
+class KEXIFORMUTILS_EXPORT KexiDBProgressBar : public QProgressBar,
+ public KexiFormDataItemInterface,
+ public \
KFormDesigner::FormWidgetInterface +{
+ Q_OBJECT
+ Q_PROPERTY(QString dataSource READ dataSource WRITE setDataSource)
+ Q_PROPERTY(QString dataSourcePartClass READ dataSourcePartClass WRITE \
setDataSourcePartClass) +// Q_PROPERTY(bool readOnly READ isReadOnly WRITE \
setReadOnly) +
+public:
+ KexiDBProgressBar(QWidget *parent);
+ virtual ~KexiDBProgressBar();
+
+ inline QString dataSource() const {
+ return KexiFormDataItemInterface::dataSource();
+ }
+ inline QString dataSourcePartClass() const {
+ return KexiFormDataItemInterface::dataSourcePartClass();
+ }
+ virtual QVariant value();
+ virtual void setInvalidState(const QString& displayText);
+
+ //! \return true if editor's value is null (not empty)
+ //! Used for checking if a given constraint within table of form is met.
+ virtual bool valueIsNull();
+
+ //! \return true if editor's value is empty (not necessary null).
+ //! Only few data types can accept "EMPTY" property
+ //! (use KexiDB::Field::hasEmptyProperty() to check this).
+ //! Used for checking if a given constraint within table or form is met.
+ virtual bool valueIsEmpty();
+
+ /*! \return 'readOnly' flag for this widget. */
+ virtual bool isReadOnly() const;
+
+ /*! \return the view widget of this item, e.g. line edit widget. */
+ virtual QWidget* widget();
+
+ virtual bool cursorAtStart();
+ virtual bool cursorAtEnd();
+ virtual void clear();
+
+ virtual void setEnabled(bool enabled);
+
+public slots:
+ inline void setDataSource(const QString &ds) {
+ KexiFormDataItemInterface::setDataSource(ds);
+ }
+ inline void setDataSourcePartClass(const QString &partClass) {
+ KexiFormDataItemInterface::setDataSourcePartClass(partClass);
+ }
+ void slotValueChanged();
+ virtual void setReadOnly(bool set);
+
+protected:
+ virtual void setValueInternal(const QVariant& add, bool removeOld);
+
+private:
+ bool m_invalidState;
+};
+
+#endif
diff --git a/kexi/plugins/forms/widgets/kexidbslider.cpp \
b/kexi/plugins/forms/widgets/kexidbslider.cpp new file mode 100644
index 0000000..a8300c2
--- /dev/null
+++ b/kexi/plugins/forms/widgets/kexidbslider.cpp
@@ -0,0 +1,113 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Cedric Pasteur <cedric.pasteur@free.fr>
+ Copyright (C) 2004-2005 Jarosław Staniek <staniek@kde.org>
+ Copyright (C) 2012 Oleg Kukharchuk <oleg.kuh@gmail.com>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include "kexidbslider.h"
+
+#include <knumvalidator.h>
+
+KexiDBSlider::KexiDBSlider(QWidget *parent)
+ :QSlider(parent) , KexiFormDataItemInterface()
+{
+ connect(this, SIGNAL(valueChanged(int)), this, SLOT(slotValueChanged()));
+}
+
+KexiDBSlider::~KexiDBSlider()
+{
+}
+
+void KexiDBSlider::setInvalidState(const QString& displayText)
+{
+ m_invalidState = true;
+ setEnabled(false);
+ setReadOnly(true);
+//! @todo move this to KexiDataItemInterface::setInvalidStateInternal() ?
+ if (focusPolicy() & Qt::TabFocus)
+ setFocusPolicy(Qt::ClickFocus);
+ QSlider::setValue(minimum());
+}
+
+void
+KexiDBSlider::setEnabled(bool enabled)
+{
+ // prevent the user from reenabling the widget when it is in invalid state
+ if (enabled && m_invalidState)
+ return;
+ QSlider::setEnabled(enabled);
+}
+
+void KexiDBSlider::setValueInternal(const QVariant&, bool)
+{
+ QSlider::setValue(m_origValue.toInt());
+}
+
+QVariant
+KexiDBSlider::value()
+{
+ return QSlider::value();
+}
+
+void KexiDBSlider::slotValueChanged()
+{
+ signalValueChanged();
+}
+
+bool KexiDBSlider::valueIsNull()
+{
+ return false;
+}
+
+bool KexiDBSlider::valueIsEmpty()
+{
+ return false;
+}
+
+bool KexiDBSlider::isReadOnly() const
+{
+ return !isEnabled();
+}
+
+void KexiDBSlider::setReadOnly(bool set)
+{
+ setEnabled( !set );
+}
+
+QWidget*
+KexiDBSlider::widget()
+{
+ return this;
+}
+
+bool KexiDBSlider::cursorAtStart()
+{
+ return false; //! \todo ?
+}
+
+bool KexiDBSlider::cursorAtEnd()
+{
+ return false; //! \todo ?
+}
+
+void KexiDBSlider::clear()
+{
+ QSlider::setValue(minimum());
+}
+
+#include "kexidbslider.moc"
diff --git a/kexi/plugins/forms/widgets/kexidbslider.h \
b/kexi/plugins/forms/widgets/kexidbslider.h new file mode 100644
index 0000000..5889d0b
--- /dev/null
+++ b/kexi/plugins/forms/widgets/kexidbslider.h
@@ -0,0 +1,92 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Cedric Pasteur <cedric.pasteur@free.fr>
+ Copyright (C) 2004-2005 Jarosław Staniek <staniek@kde.org>
+ Copyright (C) 2012 Oleg Kukharchuk <oleg.kuh@gmail.com>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KexiDBSlider_H
+#define KexiDBSlider_H
+
+#include <widget/dataviewcommon/kexiformdataiteminterface.h>
+#include <formeditor/FormWidgetInterface.h>
+#include <knuminput.h>
+#include <QSlider>
+
+//! @short A db-aware slider
+class KEXIFORMUTILS_EXPORT KexiDBSlider : public QSlider,
+ public KexiFormDataItemInterface,
+ public KFormDesigner::FormWidgetInterface
+{
+ Q_OBJECT
+ Q_PROPERTY(QString dataSource READ dataSource WRITE setDataSource)
+ Q_PROPERTY(QString dataSourcePartClass READ dataSourcePartClass WRITE \
setDataSourcePartClass) + Q_PROPERTY(bool readOnly READ isReadOnly WRITE \
setReadOnly) +
+public:
+ KexiDBSlider(QWidget *parent);
+ virtual ~KexiDBSlider();
+
+ inline QString dataSource() const {
+ return KexiFormDataItemInterface::dataSource();
+ }
+ inline QString dataSourcePartClass() const {
+ return KexiFormDataItemInterface::dataSourcePartClass();
+ }
+ virtual QVariant value();
+ virtual void setInvalidState(const QString& displayText);
+
+ //! \return true if editor's value is null (not empty)
+ //! Used for checking if a given constraint within table of form is met.
+ virtual bool valueIsNull();
+
+ //! \return true if editor's value is empty (not necessary null).
+ //! Only few data types can accept "EMPTY" property
+ //! (use KexiDB::Field::hasEmptyProperty() to check this).
+ //! Used for checking if a given constraint within table or form is met.
+ virtual bool valueIsEmpty();
+
+ /*! \return 'readOnly' flag for this widget. */
+ virtual bool isReadOnly() const;
+
+ /*! \return the view widget of this item, e.g. line edit widget. */
+ virtual QWidget* widget();
+
+ virtual bool cursorAtStart();
+ virtual bool cursorAtEnd();
+ virtual void clear();
+
+ virtual void setEnabled(bool enabled);
+
+public slots:
+ inline void setDataSource(const QString &ds) {
+ KexiFormDataItemInterface::setDataSource(ds);
+ }
+ inline void setDataSourcePartClass(const QString &partClass) {
+ KexiFormDataItemInterface::setDataSourcePartClass(partClass);
+ }
+ void slotValueChanged();
+ virtual void setReadOnly(bool set);
+
+protected:
+ virtual void setValueInternal(const QVariant& add, bool removeOld);
+
+private:
+ bool m_invalidState : 1;
+};
+
+#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic