File indexing completed on 2024-05-12 04:35:14

0001 /****************************************************************************
0002 **
0003 ** Copyright (C) 2016 The Qt Company Ltd.
0004 ** Contact: https://www.qt.io/licensing/
0005 **
0006 ** This file is part of the tools applications of the Qt Toolkit.
0007 **
0008 ** $QT_BEGIN_LICENSE:LGPL$
0009 ** Commercial License Usage
0010 ** Licensees holding valid commercial Qt licenses may use this file in
0011 ** accordance with the commercial license agreement provided with the
0012 ** Software or, alternatively, in accordance with the terms contained in
0013 ** a written agreement between you and The Qt Company. For licensing terms
0014 ** and conditions see https://www.qt.io/terms-conditions. For further
0015 ** information use the contact form at https://www.qt.io/contact-us.
0016 **
0017 ** GNU Lesser General Public License Usage
0018 ** Alternatively, this file may be used under the terms of the GNU Lesser
0019 ** General Public License version 3 as published by the Free Software
0020 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
0021 ** packaging of this file. Please review the following information to
0022 ** ensure the GNU Lesser General Public License version 3 requirements
0023 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
0024 **
0025 ** GNU General Public License Usage
0026 ** Alternatively, this file may be used under the terms of the GNU
0027 ** General Public License version 2.0 or (at your option) the GNU General
0028 ** Public license version 3 or any later version approved by the KDE Free
0029 ** Qt Foundation. The licenses are as published by the Free Software
0030 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
0031 ** included in the packaging of this file. Please review the following
0032 ** information to ensure the GNU General Public License requirements will
0033 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
0034 ** https://www.gnu.org/licenses/gpl-3.0.html.
0035 **
0036 ** $QT_END_LICENSE$
0037 **
0038 ****************************************************************************/
0039 
0040 #ifndef QTVARIANTPROPERTY_H
0041 #define QTVARIANTPROPERTY_H
0042 
0043 #include "qtpropertybrowser.h"
0044 #include <QtCore/QVariant>
0045 #include <QtGui/QIcon>
0046 
0047 QT_BEGIN_NAMESPACE
0048 
0049 typedef QMap<int, QIcon> QtIconMap;
0050 
0051 class QtVariantPropertyManager;
0052 
0053 class QT_QTPROPERTYBROWSER_EXPORT QtVariantProperty : public QtProperty
0054 {
0055 public:
0056     ~QtVariantProperty();
0057     QVariant value() const;
0058     QVariant attributeValue(const QString &attribute) const;
0059     int valueType() const;
0060     int propertyType() const;
0061 
0062     void setValue(const QVariant &value);
0063     void setAttribute(const QString &attribute, const QVariant &value);
0064 protected:
0065     QtVariantProperty(QtVariantPropertyManager *manager);
0066 private:
0067     friend class QtVariantPropertyManager;
0068     QScopedPointer<class QtVariantPropertyPrivate> d_ptr;
0069 };
0070 
0071 class QT_QTPROPERTYBROWSER_EXPORT QtVariantPropertyManager : public QtAbstractPropertyManager
0072 {
0073     Q_OBJECT
0074 public:
0075     QtVariantPropertyManager(QObject *parent = 0);
0076     ~QtVariantPropertyManager();
0077 
0078     virtual QtVariantProperty *addProperty(int propertyType, const QString &name = QString());
0079 
0080     int propertyType(const QtProperty *property) const;
0081     int valueType(const QtProperty *property) const;
0082     QtVariantProperty *variantProperty(const QtProperty *property) const;
0083 
0084     virtual bool isPropertyTypeSupported(int propertyType) const;
0085     virtual int valueType(int propertyType) const;
0086     virtual QStringList attributes(int propertyType) const;
0087     virtual int attributeType(int propertyType, const QString &attribute) const;
0088 
0089     virtual QVariant value(const QtProperty *property) const;
0090     virtual QVariant attributeValue(const QtProperty *property, const QString &attribute) const;
0091 
0092     static int enumTypeId();
0093     static int flagTypeId();
0094     static int groupTypeId();
0095     static int iconMapTypeId();
0096 public Q_SLOTS:
0097     virtual void setValue(QtProperty *property, const QVariant &val);
0098     virtual void setAttribute(QtProperty *property,
0099                 const QString &attribute, const QVariant &value);
0100 Q_SIGNALS:
0101     void valueChanged(QtProperty *property, const QVariant &val);
0102     void attributeChanged(QtProperty *property,
0103                 const QString &attribute, const QVariant &val);
0104 protected:
0105     virtual bool hasValue(const QtProperty *property) const;
0106     QString valueText(const QtProperty *property) const;
0107     QIcon valueIcon(const QtProperty *property) const;
0108     virtual void initializeProperty(QtProperty *property);
0109     virtual void uninitializeProperty(QtProperty *property);
0110     virtual QtProperty *createProperty();
0111 private:
0112     QScopedPointer<class QtVariantPropertyManagerPrivate> d_ptr;
0113     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, int))
0114     Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int))
0115     Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int))
0116     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, double))
0117     Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, double, double))
0118     Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, double))
0119     Q_PRIVATE_SLOT(d_func(), void slotDecimalsChanged(QtProperty *, int))
0120     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, bool))
0121     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QString &))
0122     Q_PRIVATE_SLOT(d_func(), void slotRegExpChanged(QtProperty *, const QRegExp &))
0123     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QDate &))
0124     Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QDate &, const QDate &))
0125     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QTime &))
0126     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QDateTime &))
0127     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QKeySequence &))
0128     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QChar &))
0129     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QLocale &))
0130     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QPoint &))
0131     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QPointF &))
0132     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSize &))
0133     Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QSize &, const QSize &))
0134     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSizeF &))
0135     Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QSizeF &, const QSizeF &))
0136     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QRect &))
0137     Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty *, const QRect &))
0138     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QRectF &))
0139     Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty *, const QRectF &))
0140     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QColor &))
0141     Q_PRIVATE_SLOT(d_func(), void slotEnumNamesChanged(QtProperty *, const QStringList &))
0142     Q_PRIVATE_SLOT(d_func(), void slotEnumIconsChanged(QtProperty *, const QMap<int, QIcon> &))
0143     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSizePolicy &))
0144     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QFont &))
0145     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QCursor &))
0146     Q_PRIVATE_SLOT(d_func(), void slotFlagNamesChanged(QtProperty *, const QStringList &))
0147 
0148     Q_PRIVATE_SLOT(d_func(), void slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))
0149     Q_PRIVATE_SLOT(d_func(), void slotPropertyRemoved(QtProperty *, QtProperty *))
0150     Q_DECLARE_PRIVATE(QtVariantPropertyManager)
0151     Q_DISABLE_COPY(QtVariantPropertyManager)
0152 };
0153 
0154 class QT_QTPROPERTYBROWSER_EXPORT QtVariantEditorFactory : public QtAbstractEditorFactory<QtVariantPropertyManager>
0155 {
0156     Q_OBJECT
0157 public:
0158     QtVariantEditorFactory(QObject *parent = 0);
0159     ~QtVariantEditorFactory();
0160 protected:
0161     void connectPropertyManager(QtVariantPropertyManager *manager);
0162     QWidget *createEditor(QtVariantPropertyManager *manager, QtProperty *property,
0163                 QWidget *parent);
0164     void disconnectPropertyManager(QtVariantPropertyManager *manager);
0165 private:
0166     QScopedPointer<class QtVariantEditorFactoryPrivate> d_ptr;
0167     Q_DECLARE_PRIVATE(QtVariantEditorFactory)
0168     Q_DISABLE_COPY(QtVariantEditorFactory)
0169 };
0170 
0171 QT_END_NAMESPACE
0172 
0173 Q_DECLARE_METATYPE(QIcon)
0174 Q_DECLARE_METATYPE(QtIconMap)
0175 #endif