1 /* This file is part of the KDE project 2 Copyright (C) 2012-2013 Oleg Kukharchuk <oleg.kuh@gmail.com> 3 Copyright (C) 2005 Cedric Pasteur <cedric.pasteur@free.fr> 4 Copyright (C) 2004-2006 Jarosław Staniek <staniek@kde.org> 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 KEXIDBCOMMANDLINKBUTTON_H 23 #define KEXIDBCOMMANDLINKBUTTON_H 24 25 #include "kexiformutils_export.h" 26 #include <widget/dataviewcommon/kexiformdataiteminterface.h> 27 #include <kexiutils/KexiCommandLinkButton.h> 28 #include <formeditor/kexiformeventhandler.h> 29 #include <formeditor/FormWidgetInterface.h> 30 31 class KexiDBCommandLinkButtonPrivate; 32 33 //! @short Push Button widget for Kexi forms 34 class KEXIFORMUTILS_EXPORT KexiDBCommandLinkButton : public KexiCommandLinkButton, 35 public KexiFormDataItemInterface, 36 public KFormDesigner::FormWidgetInterface 37 { 38 Q_OBJECT 39 Q_PROPERTY(QString onClickAction READ onClickAction WRITE setOnClickAction) 40 Q_PROPERTY(QString onClickActionOption READ onClickActionOption WRITE setOnClickActionOption) 41 Q_PROPERTY(QString dataSource READ dataSource WRITE setDataSource) 42 Q_PROPERTY(QString dataSourcePartClass READ dataSourcePluginId WRITE setDataSourcePluginId) 43 44 public: 45 KexiDBCommandLinkButton(const QString &text, const QString &description, QWidget * parent = 0); 46 virtual ~KexiDBCommandLinkButton(); 47 dataSource()48 inline QString dataSource() const { 49 return KexiFormDataItemInterface::dataSource(); 50 } dataSourcePluginId()51 inline QString dataSourcePluginId() const { 52 return KexiFormDataItemInterface::dataSourcePluginId(); 53 } 54 55 virtual QVariant value(); 56 57 virtual bool valueIsNull(); 58 59 virtual bool valueIsEmpty(); 60 61 //! always false 62 virtual bool cursorAtStart(); 63 64 //! always false 65 virtual bool cursorAtEnd(); 66 67 virtual void clear(); 68 69 virtual void setInvalidState(const QString& displayText); 70 71 virtual bool isReadOnly() const; 72 public Q_SLOTS: 73 //! action string for "on click" event 74 //! @see KexiFormPart::slotAssignAction() 75 //! @see KexiFormEventAction::ActionData 76 QString onClickAction() const; 77 78 void setOnClickAction(const QString& actionString); 79 80 /*! action option allowing to select whether the object should be opened 81 data view mode or printed, etc. 82 @see KexiFormPart::slotAssignAction() 83 @see KexiFormEventAction::ActionData */ 84 QString onClickActionOption() const; 85 86 void setOnClickActionOption(const QString& option); 87 88 //! Sets the datasource to \a ds setDataSource(const QString & ds)89 inline void setDataSource(const QString &ds) { 90 KexiFormDataItemInterface::setDataSource(ds); 91 } 92 setDataSourcePluginId(const QString & pluginId)93 inline void setDataSourcePluginId(const QString &pluginId) { 94 KexiFormDataItemInterface::setDataSourcePluginId(pluginId); 95 } 96 virtual void setReadOnly(bool readOnly); 97 98 protected: 99 //! Sets value \a value for a widget. 100 virtual void setValueInternal(const QVariant& add, bool removeOld); 101 102 friend class KexiDBCommanLinkButtonPrivate; 103 KexiDBCommandLinkButtonPrivate * const d; 104 }; 105 106 #endif 107