File indexing completed on 2024-05-12 16:39:52

0001 /* This file is part of the KDE project
0002    Copyright (C) 2006 Jarosław Staniek <staniek@kde.org>
0003 
0004    This program is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License as published by the Free Software Foundation; either
0007    version 2 of the License, or (at your option) any later version.
0008 
0009    This program is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    Library General Public License for more details.
0013 
0014    You should have received a copy of the GNU Library General Public License
0015    along with this program; see the file COPYING.  If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #ifndef WIDGETWITHSUBPROPERTIESINTERFACE_H
0021 #define WIDGETWITHSUBPROPERTIESINTERFACE_H
0022 
0023 #include "kformdesigner_export.h"
0024 
0025 #include <QWidget>
0026 #include <QVariant>
0027 #include <QSet>
0028 
0029 namespace KFormDesigner
0030 {
0031 
0032 //! An interface for declaring form widgets to have subproperties.
0033 /*! Currently used in KexiDBAutoField to allow editing specific properties
0034  of its internal editor. For example, if the autofield is of type Image Box,
0035  the Image Box widget has some specific properties like "lineWidth".
0036  Such properties are provided by the parent KexiDBAutoField object as subproperties. */
0037 class KFORMDESIGNER_EXPORT WidgetWithSubpropertiesInterface
0038 {
0039 public:
0040     WidgetWithSubpropertiesInterface();
0041     virtual ~WidgetWithSubpropertiesInterface();
0042 
0043     //! Sets \a widget subwidget handling subproperties. Setting 0 clears subwidget.
0044 //! @todo maybe someone wants to add more than one widget here?
0045     void setSubwidget(QWidget *widget);
0046 
0047     //! \return the assigned subwidget.
0048     QWidget* subwidget() const;
0049 
0050     //! \return a set of subproperties available for this widget.
0051     QSet<QByteArray> subproperties() const;
0052 
0053     //! \return a metaproperty for a widget's subproperty
0054     //! or invalid metaproperty if there is no such subproperty.
0055     QMetaProperty findMetaSubproperty(const char * name) const;
0056 
0057     //! \return a value of widget's subproperty. \a ok is set to true on success
0058     //! and to false on failure.
0059     QVariant subproperty(const char * name, bool *ok) const;
0060 
0061     //! Sets a subproperty value \a value for a subproperty \a name
0062     //! \return true on successful setting and false when there
0063     //! is no such a subproperty in the subwidget or QObject::setProperty() failed.
0064     bool setSubproperty(const char * name, const QVariant & value);
0065 
0066 private:
0067     class Private;
0068     Private* const d;
0069 };
0070 }
0071 
0072 #endif