1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #ifndef PROPERTYEDITORVALUE_H
34 #define PROPERTYEDITORVALUE_H
37 #include <QDeclarativePropertyMap>
38 #include <qdeclarative.h>
39 #include <modelnode.h>
40 #include <qmlitemnode.h>
41 #include <rewritertransaction.h>
43 class PropertyEditorValue;
45 class PropertyEditorNodeWrapper : public QObject {
48 Q_PROPERTY(bool exists READ exists NOTIFY existsChanged)
49 Q_PROPERTY(QDeclarativePropertyMap* properties READ properties NOTIFY propertiesChanged)
50 Q_PROPERTY(QString type READ type NOTIFY typeChanged)
53 PropertyEditorNodeWrapper(QObject *parent=0);
54 PropertyEditorNodeWrapper(PropertyEditorValue* parent);
57 QDeclarativePropertyMap* properties();
58 QmlDesigner::ModelNode parentModelNode() const;
59 QString propertyName() const;
62 void add(const QString &type = QString());
64 void changeValue(const QString &name);
69 void propertiesChanged();
75 QmlDesigner::ModelNode m_modelNode;
76 QDeclarativePropertyMap m_valuesPropertyMap;
77 PropertyEditorValue* m_editorValue;
80 class PropertyEditorValue : public QObject
83 Q_PROPERTY(QVariant value READ value WRITE setValueWithEmit NOTIFY valueChangedQml)
84 Q_PROPERTY(QString expression READ expression WRITE setExpressionWithEmit NOTIFY expressionChanged FINAL)
85 Q_PROPERTY(bool isInModel READ isInModel NOTIFY valueChangedQml FINAL)
86 Q_PROPERTY(bool isInSubState READ isInSubState NOTIFY valueChangedQml FINAL)
87 Q_PROPERTY(bool isBound READ isBound NOTIFY isBoundChanged FINAL)
88 Q_PROPERTY(bool isValid READ isValid NOTIFY isValidChanged FINAL)
89 Q_PROPERTY(QString name READ name FINAL)
90 Q_PROPERTY(PropertyEditorNodeWrapper* complexNode READ complexNode NOTIFY complexNodeChanged FINAL)
93 PropertyEditorValue(QObject *parent=0);
95 QVariant value() const;
96 void setValueWithEmit(const QVariant &value);
97 void setValue(const QVariant &value);
99 QString expression() const;
100 void setExpressionWithEmit(const QString &expression);
101 void setExpression(const QString &expression);
103 bool isInSubState() const;
105 bool isInModel() const;
107 bool isBound() const;
108 bool isValid() const;
110 void setIsValid(bool valid);
112 QString name() const;
113 void setName(const QString &name);
115 QmlDesigner::ModelNode modelNode() const;
116 void setModelNode(const QmlDesigner::ModelNode &modelNode);
118 PropertyEditorNodeWrapper* complexNode();
120 static void registerDeclarativeTypes();
126 void valueChanged(const QString &name, const QVariant&);
127 void valueChangedQml();
129 void expressionChanged(const QString &name);
131 void modelStateChanged();
132 void modelNodeChanged();
133 void complexNodeChanged();
134 void isBoundChanged();
135 void isValidChanged();
138 QmlDesigner::ModelNode m_modelNode;
140 QString m_expression;
145 bool m_isValid; // if the property value belongs to a non-existing complexProperty it is invalid
146 PropertyEditorNodeWrapper *m_complexNode;
149 QML_DECLARE_TYPE(PropertyEditorValue)
150 QML_DECLARE_TYPE(PropertyEditorNodeWrapper)
151 QML_DECLARE_TYPE(QDeclarativePropertyMap)
154 #endif // PROPERTYEDITORVALUE_H