1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #ifndef PROPERTYEDITORVALUE_H
35 #define PROPERTYEDITORVALUE_H
38 #include <QDeclarativePropertyMap>
39 #include <qdeclarative.h>
40 #include <modelnode.h>
41 #include <qmlitemnode.h>
42 #include <rewritertransaction.h>
44 class PropertyEditorValue;
46 class PropertyEditorNodeWrapper : public QObject {
49 Q_PROPERTY(bool exists READ exists NOTIFY existsChanged)
50 Q_PROPERTY(QDeclarativePropertyMap* properties READ properties NOTIFY propertiesChanged)
51 Q_PROPERTY(QString type READ type NOTIFY typeChanged)
54 PropertyEditorNodeWrapper(QObject *parent=0);
55 PropertyEditorNodeWrapper(PropertyEditorValue* parent);
58 QDeclarativePropertyMap* properties();
59 QmlDesigner::ModelNode parentModelNode() const;
60 QString propertyName() const;
63 void add(const QString &type = QString());
65 void changeValue(const QString &name);
70 void propertiesChanged();
76 QmlDesigner::ModelNode m_modelNode;
77 QDeclarativePropertyMap m_valuesPropertyMap;
78 PropertyEditorValue* m_editorValue;
81 class PropertyEditorValue : public QObject
84 Q_PROPERTY(QVariant value READ value WRITE setValueWithEmit NOTIFY valueChangedQml)
85 Q_PROPERTY(QString expression READ expression WRITE setExpressionWithEmit NOTIFY expressionChanged FINAL)
86 Q_PROPERTY(bool isInModel READ isInModel NOTIFY valueChangedQml FINAL)
87 Q_PROPERTY(bool isInSubState READ isInSubState NOTIFY valueChangedQml FINAL)
88 Q_PROPERTY(bool isBound READ isBound NOTIFY isBoundChanged FINAL)
89 Q_PROPERTY(bool isValid READ isValid NOTIFY isValidChanged FINAL)
90 Q_PROPERTY(QString name READ name FINAL)
91 Q_PROPERTY(PropertyEditorNodeWrapper* complexNode READ complexNode NOTIFY complexNodeChanged FINAL)
94 PropertyEditorValue(QObject *parent=0);
96 QVariant value() const;
97 void setValueWithEmit(const QVariant &value);
98 void setValue(const QVariant &value);
100 QString expression() const;
101 void setExpressionWithEmit(const QString &expression);
102 void setExpression(const QString &expression);
104 bool isInSubState() const;
106 bool isInModel() const;
108 bool isBound() const;
109 bool isValid() const;
111 void setIsValid(bool valid);
113 QString name() const;
114 void setName(const QString &name);
116 QmlDesigner::ModelNode modelNode() const;
117 void setModelNode(const QmlDesigner::ModelNode &modelNode);
119 PropertyEditorNodeWrapper* complexNode();
121 static void registerDeclarativeTypes();
127 void valueChanged(const QString &name, const QVariant&);
128 void valueChangedQml();
130 void expressionChanged(const QString &name);
132 void modelStateChanged();
133 void modelNodeChanged();
134 void complexNodeChanged();
135 void isBoundChanged();
136 void isValidChanged();
139 QmlDesigner::ModelNode m_modelNode;
141 QString m_expression;
146 bool m_isValid; // if the property value belongs to a non-existing complexProperty it is invalid
147 PropertyEditorNodeWrapper *m_complexNode;
150 QML_DECLARE_TYPE(PropertyEditorValue)
151 QML_DECLARE_TYPE(PropertyEditorNodeWrapper)
152 QML_DECLARE_TYPE(QDeclarativePropertyMap)
155 #endif // PROPERTYEDITORVALUE_H