QSapecNG
 All Classes Functions Enumerations Properties
qtvariantproperty.h
00001 /****************************************************************************
00002 **
00003 ** This file is part of a Qt Solutions component.
00004 ** 
00005 ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
00006 ** 
00007 ** Contact:  Qt Software Information (qt-info@nokia.com)
00008 ** 
00009 ** Commercial Usage  
00010 ** Licensees holding valid Qt Commercial licenses may use this file in
00011 ** accordance with the Qt Solutions Commercial License Agreement provided
00012 ** with the Software or, alternatively, in accordance with the terms
00013 ** contained in a written agreement between you and Nokia.
00014 ** 
00015 ** GNU Lesser General Public License Usage
00016 ** Alternatively, this file may be used under the terms of the GNU Lesser
00017 ** General Public License version 2.1 as published by the Free Software
00018 ** Foundation and appearing in the file LICENSE.LGPL included in the
00019 ** packaging of this file.  Please review the following information to
00020 ** ensure the GNU Lesser General Public License version 2.1 requirements
00021 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
00022 ** 
00023 ** In addition, as a special exception, Nokia gives you certain
00024 ** additional rights. These rights are described in the Nokia Qt LGPL
00025 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
00026 ** package.
00027 ** 
00028 ** GNU General Public License Usage 
00029 ** Alternatively, this file may be used under the terms of the GNU
00030 ** General Public License version 3.0 as published by the Free Software
00031 ** Foundation and appearing in the file LICENSE.GPL included in the
00032 ** packaging of this file.  Please review the following information to
00033 ** ensure the GNU General Public License version 3.0 requirements will be
00034 ** met: http://www.gnu.org/copyleft/gpl.html.
00035 ** 
00036 ** Please note Third Party Software included with Qt Solutions may impose
00037 ** additional restrictions and it is the user's responsibility to ensure
00038 ** that they have met the licensing requirements of the GPL, LGPL, or Qt
00039 ** Solutions Commercial license and the relevant license of the Third
00040 ** Party Software they are using.
00041 ** 
00042 ** If you are unsure which license is appropriate for your use, please
00043 ** contact the sales department at qt-sales@nokia.com.
00044 ** 
00045 ****************************************************************************/
00046 
00047 /****************************************************************************
00048 **
00049 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
00050 ** Contact: Qt Software Information (qt-info@nokia.com)
00051 **
00052 ** This file is part of the tools applications of the Qt Toolkit.
00053 **
00054 ** $QT_BEGIN_LICENSE:LGPL$
00055 ** No Commercial Usage
00056 ** This file contains pre-release code and may not be distributed.
00057 ** You may use this file in accordance with the terms and conditions
00058 ** contained in the either Technology Preview License Agreement or the
00059 ** Beta Release License Agreement.
00060 **
00061 ** GNU Lesser General Public License Usage
00062 ** Alternatively, this file may be used under the terms of the GNU Lesser
00063 ** General Public License version 2.1 as published by the Free Software
00064 ** Foundation and appearing in the file LICENSE.LGPL included in the
00065 ** packaging of this file.  Please review the following information to
00066 ** ensure the GNU Lesser General Public License version 2.1 requirements
00067 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
00068 **
00069 ** In addition, as a special exception, Nokia gives you certain
00070 ** additional rights. These rights are described in the Nokia Qt LGPL
00071 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
00072 ** package.
00073 **
00074 ** GNU General Public License Usage
00075 ** Alternatively, this file may be used under the terms of the GNU
00076 ** General Public License version 3.0 as published by the Free Software
00077 ** Foundation and appearing in the file LICENSE.GPL included in the
00078 ** packaging of this file.  Please review the following information to
00079 ** ensure the GNU General Public License version 3.0 requirements will be
00080 ** met: http://www.gnu.org/copyleft/gpl.html.
00081 **
00082 ** If you are unsure which license is appropriate for your use, please
00083 ** contact the sales department at qt-sales@nokia.com.
00084 ** $QT_END_LICENSE$
00085 **
00086 ****************************************************************************/
00087 
00088 #ifndef QTVARIANTPROPERTY_H
00089 #define QTVARIANTPROPERTY_H
00090 
00091 #include "qtpropertybrowser.h"
00092 #include <QtCore/QVariant>
00093 #include <QtGui/QIcon>
00094 
00095 #if QT_VERSION >= 0x040400
00096 QT_BEGIN_NAMESPACE
00097 #endif
00098 
00099 typedef QMap<int, QIcon> QtIconMap;
00100 
00101 class QtVariantPropertyManager;
00102 class QtVariantPropertyPrivate;
00103 
00104 class QT_QTPROPERTYBROWSER_EXPORT QtVariantProperty : public QtProperty
00105 {
00106 public:
00107     ~QtVariantProperty();
00108     QVariant value() const;
00109     QVariant attributeValue(const QString &attribute) const;
00110     int valueType() const;
00111     int propertyType() const;
00112 
00113     void setValue(const QVariant &value);
00114     void setAttribute(const QString &attribute, const QVariant &value);
00115 protected:
00116     QtVariantProperty(QtVariantPropertyManager *manager);
00117 private:
00118     friend class QtVariantPropertyManager;
00119     QtVariantPropertyPrivate *d_ptr;
00120 };
00121 
00122 class QtVariantPropertyManagerPrivate;
00123 
00124 class QT_QTPROPERTYBROWSER_EXPORT QtVariantPropertyManager : public QtAbstractPropertyManager
00125 {
00126     Q_OBJECT
00127 public:
00128     QtVariantPropertyManager(QObject *parent = 0);
00129     ~QtVariantPropertyManager();
00130 
00131     virtual QtVariantProperty *addProperty(int propertyType, const QString &name = QString());
00132 
00133     int propertyType(const QtProperty *property) const;
00134     int valueType(const QtProperty *property) const;
00135     QtVariantProperty *variantProperty(const QtProperty *property) const;
00136 
00137     virtual bool isPropertyTypeSupported(int propertyType) const;
00138     virtual int valueType(int propertyType) const;
00139     virtual QStringList attributes(int propertyType) const;
00140     virtual int attributeType(int propertyType, const QString &attribute) const;
00141 
00142     virtual QVariant value(const QtProperty *property) const;
00143     virtual QVariant attributeValue(const QtProperty *property, const QString &attribute) const;
00144 
00145     static int enumTypeId();
00146     static int flagTypeId();
00147     static int groupTypeId();
00148     static int iconMapTypeId();
00149 public Q_SLOTS:
00150     virtual void setValue(QtProperty *property, const QVariant &val);
00151     virtual void setAttribute(QtProperty *property,
00152                 const QString &attribute, const QVariant &value);
00153 Q_SIGNALS:
00154     void valueChanged(QtProperty *property, const QVariant &val);
00155     void attributeChanged(QtProperty *property,
00156                 const QString &attribute, const QVariant &val);
00157 protected:
00158     virtual bool hasValue(const QtProperty *property) const;
00159     QString valueText(const QtProperty *property) const;
00160     QIcon valueIcon(const QtProperty *property) const;
00161     virtual void initializeProperty(QtProperty *property);
00162     virtual void uninitializeProperty(QtProperty *property);
00163     virtual QtProperty *createProperty();
00164 private:
00165     QtVariantPropertyManagerPrivate *d_ptr;
00166     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, int))
00167     Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int))
00168     Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int))
00169     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, double))
00170     Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, double, double))
00171     Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, double))
00172     Q_PRIVATE_SLOT(d_func(), void slotDecimalsChanged(QtProperty *, int))
00173     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, bool))
00174     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QString &))
00175     Q_PRIVATE_SLOT(d_func(), void slotRegExpChanged(QtProperty *, const QRegExp &))
00176     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QDate &))
00177     Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QDate &, const QDate &))
00178     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QTime &))
00179     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QDateTime &))
00180     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QKeySequence &))
00181     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QChar &))
00182     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QLocale &))
00183     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QPoint &))
00184     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QPointF &))
00185     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSize &))
00186     Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QSize &, const QSize &))
00187     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSizeF &))
00188     Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QSizeF &, const QSizeF &))
00189     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QRect &))
00190     Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty *, const QRect &))
00191     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QRectF &))
00192     Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty *, const QRectF &))
00193     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QColor &))
00194     Q_PRIVATE_SLOT(d_func(), void slotEnumNamesChanged(QtProperty *, const QStringList &))
00195     Q_PRIVATE_SLOT(d_func(), void slotEnumIconsChanged(QtProperty *, const QMap<int, QIcon> &))
00196     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSizePolicy &))
00197     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QFont &))
00198     Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QCursor &))
00199     Q_PRIVATE_SLOT(d_func(), void slotFlagNamesChanged(QtProperty *, const QStringList &))
00200 
00201     Q_PRIVATE_SLOT(d_func(), void slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))
00202     Q_PRIVATE_SLOT(d_func(), void slotPropertyRemoved(QtProperty *, QtProperty *))
00203     Q_DECLARE_PRIVATE(QtVariantPropertyManager)
00204     Q_DISABLE_COPY(QtVariantPropertyManager)
00205 };
00206 
00207 class QtVariantEditorFactoryPrivate;
00208 
00209 class QT_QTPROPERTYBROWSER_EXPORT QtVariantEditorFactory : public QtAbstractEditorFactory<QtVariantPropertyManager>
00210 {
00211     Q_OBJECT
00212 public:
00213     QtVariantEditorFactory(QObject *parent = 0);
00214     ~QtVariantEditorFactory();
00215 protected:
00216     void connectPropertyManager(QtVariantPropertyManager *manager);
00217     QWidget *createEditor(QtVariantPropertyManager *manager, QtProperty *property,
00218                 QWidget *parent);
00219     void disconnectPropertyManager(QtVariantPropertyManager *manager);
00220 private:
00221     QtVariantEditorFactoryPrivate *d_ptr;
00222     Q_DECLARE_PRIVATE(QtVariantEditorFactory)
00223     Q_DISABLE_COPY(QtVariantEditorFactory)
00224 };
00225 
00226 #if QT_VERSION >= 0x040400
00227 QT_END_NAMESPACE
00228 #endif
00229 
00230 Q_DECLARE_METATYPE(QIcon)
00231 Q_DECLARE_METATYPE(QtIconMap)
00232 #endif
 All Classes Functions Enumerations Properties