forked from qt-creator/qt-creator
QmlDesigner.metaInfo: replace old NodeMetaInfo with new implementation
The new implementation is based on the QmlJS::Interpreter meta info system and gets its info from parsing qml and qmldumper instead of interogating QDeclarative classes. So we share this code with the Qml TextEditor and this approach is also way more flexible. It also work with different Qt versions. The meta info is now bound to a document/rewriter. The api has changed slightly. subComponentManager: cleanup The SubComponentManager does not have to provide meta info, anymore. propertyParser: cleanup Enums were never properly converted. here. metaInfo: remove old MetaInfo classes Removing the old MetaInfo classes and code
This commit is contained in:
@@ -625,7 +625,7 @@ void DesignDocumentController::paste()
|
|||||||
int offset = double(qrand()) / RAND_MAX * 20 - 10;
|
int offset = double(qrand()) / RAND_MAX * 20 - 10;
|
||||||
|
|
||||||
foreach (const ModelNode &node, selectedNodes) {
|
foreach (const ModelNode &node, selectedNodes) {
|
||||||
QString defaultProperty(targetNode.metaInfo().defaultProperty());
|
QString defaultProperty(targetNode.metaInfo().defaultPropertyName());
|
||||||
ModelNode pastedNode(view.insertModel(node));
|
ModelNode pastedNode(view.insertModel(node));
|
||||||
pastedNodeList.append(pastedNode);
|
pastedNodeList.append(pastedNode);
|
||||||
scatterItem(pastedNode, targetNode, offset);
|
scatterItem(pastedNode, targetNode, offset);
|
||||||
@@ -658,7 +658,7 @@ void DesignDocumentController::paste()
|
|||||||
|
|
||||||
targetNode = targetNode.parentProperty().parentModelNode();
|
targetNode = targetNode.parentProperty().parentModelNode();
|
||||||
|
|
||||||
QString defaultProperty(targetNode.metaInfo().defaultProperty());
|
QString defaultProperty(targetNode.metaInfo().defaultPropertyName());
|
||||||
|
|
||||||
scatterItem(pastedNode, targetNode);
|
scatterItem(pastedNode, targetNode);
|
||||||
if (targetNode.nodeListProperty(defaultProperty).isValid()) {
|
if (targetNode.nodeListProperty(defaultProperty).isValid()) {
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
#include <nodelistproperty.h>
|
#include <nodelistproperty.h>
|
||||||
#include <nodeproperty.h>
|
#include <nodeproperty.h>
|
||||||
#include <metainfo.h>
|
#include <metainfo.h>
|
||||||
#include <propertymetainfo.h>
|
|
||||||
#include <qgraphicswidget.h>
|
#include <qgraphicswidget.h>
|
||||||
#include <abstractview.h>
|
#include <abstractview.h>
|
||||||
#include <rewriterview.h>
|
#include <rewriterview.h>
|
||||||
@@ -137,7 +136,7 @@ bool NavigatorTreeModel::dropMimeData(const QMimeData *data,
|
|||||||
if (!parentNode.metaInfo().hasDefaultProperty())
|
if (!parentNode.metaInfo().hasDefaultProperty())
|
||||||
return false;
|
return false;
|
||||||
targetIndex -= visibleProperties(parentNode).count();
|
targetIndex -= visibleProperties(parentNode).count();
|
||||||
parentPropertyName = parentNode.metaInfo().defaultProperty();
|
parentPropertyName = parentNode.metaInfo().defaultPropertyName();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
parentItemIndex = parentIndex.parent();
|
parentItemIndex = parentIndex.parent();
|
||||||
@@ -482,7 +481,7 @@ void NavigatorTreeModel::removeSubTree(const ModelNode &node)
|
|||||||
void NavigatorTreeModel::moveNodesInteractive(NodeAbstractProperty parentProperty, const QList<ModelNode> &modelNodes, int targetIndex)
|
void NavigatorTreeModel::moveNodesInteractive(NodeAbstractProperty parentProperty, const QList<ModelNode> &modelNodes, int targetIndex)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
QString propertyQmlType = qmlTypeInQtContainer(parentProperty.metaInfo().type());
|
QString propertyQmlType = qmlTypeInQtContainer(parentProperty.parentModelNode().metaInfo().propertyTypeName(parentProperty.name()));
|
||||||
|
|
||||||
RewriterTransaction transaction = m_view->beginRewriterTransaction();
|
RewriterTransaction transaction = m_view->beginRewriterTransaction();
|
||||||
foreach (const ModelNode &node, modelNodes) {
|
foreach (const ModelNode &node, modelNodes) {
|
||||||
@@ -539,7 +538,7 @@ QList<ModelNode> NavigatorTreeModel::modelNodeChildren(const ModelNode &parentNo
|
|||||||
QStringList properties;
|
QStringList properties;
|
||||||
|
|
||||||
if (parentNode.metaInfo().hasDefaultProperty())
|
if (parentNode.metaInfo().hasDefaultProperty())
|
||||||
properties << parentNode.metaInfo().defaultProperty();
|
properties << parentNode.metaInfo().defaultPropertyName();
|
||||||
|
|
||||||
properties << visibleProperties(parentNode);
|
properties << visibleProperties(parentNode);
|
||||||
|
|
||||||
@@ -565,7 +564,7 @@ QString NavigatorTreeModel::qmlTypeInQtContainer(const QString &qtContainerType)
|
|||||||
if (typeName.endsWith('*'))
|
if (typeName.endsWith('*'))
|
||||||
typeName.chop(1);
|
typeName.chop(1);
|
||||||
|
|
||||||
return m_view->model()->metaInfo().fromQtTypes(typeName);
|
return typeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -573,13 +572,13 @@ QStringList NavigatorTreeModel::visibleProperties(const ModelNode &node) const
|
|||||||
{
|
{
|
||||||
QStringList propertyList;
|
QStringList propertyList;
|
||||||
|
|
||||||
foreach (const QString &propertyName, node.metaInfo().propertyNamesOnlyContainer()) {
|
foreach (const QString &propertyName, node.metaInfo().propertyNames()) {
|
||||||
if (!m_hiddenProperties.contains(propertyName) &&
|
if (node.metaInfo().propertyIsWritable(propertyName) && !m_hiddenProperties.contains(propertyName) &&
|
||||||
propertyName != node.metaInfo().defaultProperty()) { // TODO: ask the node instances
|
propertyName != node.metaInfo().defaultPropertyName()) { // TODO: ask the node instances
|
||||||
|
|
||||||
QString qmlType = qmlTypeInQtContainer(node.metaInfo().propertyType(propertyName));
|
QString qmlType = qmlTypeInQtContainer(node.metaInfo().propertyTypeName(propertyName));
|
||||||
if (node.metaInfo().metaInfo().hasNodeMetaInfo(qmlType) &&
|
if (node.model()->metaInfo(qmlType).isValid() &&
|
||||||
node.metaInfo().metaInfo().nodeMetaInfo(qmlType).isSubclassOf("QGraphicsObject", -1, -1)) {
|
node.model()->metaInfo(qmlType).isSubclassOf("QGraphicsObject", -1, -1)) {
|
||||||
propertyList.append(propertyName);
|
propertyList.append(propertyName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,13 +32,10 @@
|
|||||||
#include <nodemetainfo.h>
|
#include <nodemetainfo.h>
|
||||||
#include <metainfo.h>
|
#include <metainfo.h>
|
||||||
|
|
||||||
#include <propertymetainfo.h>
|
|
||||||
|
|
||||||
#include <invalididexception.h>
|
#include <invalididexception.h>
|
||||||
#include <rewritingexception.h>
|
#include <rewritingexception.h>
|
||||||
#include <invalidnodestateexception.h>
|
#include <invalidnodestateexception.h>
|
||||||
#include <variantproperty.h>
|
#include <variantproperty.h>
|
||||||
#include <propertymetainfo.h>
|
|
||||||
|
|
||||||
#include <bindingproperty.h>
|
#include <bindingproperty.h>
|
||||||
|
|
||||||
@@ -226,10 +223,10 @@ void PropertyEditor::NodeType::initialSetup(const QString &typeName, const QUrl
|
|||||||
{
|
{
|
||||||
QDeclarativeContext *ctxt = m_view->rootContext();
|
QDeclarativeContext *ctxt = m_view->rootContext();
|
||||||
|
|
||||||
NodeMetaInfo metaInfo = propertyEditor->model()->metaInfo().nodeMetaInfo(typeName, 4, 7);
|
NodeMetaInfo metaInfo = propertyEditor->model()->metaInfo(typeName, 4, 7);
|
||||||
|
|
||||||
foreach (const QString &propertyName, metaInfo.propertyNames())
|
foreach (const QString &propertyName, metaInfo.propertyNames())
|
||||||
setupPropertyEditorValue(propertyName, &m_backendValuesPropertyMap, propertyEditor, metaInfo.propertyType(propertyName));
|
setupPropertyEditorValue(propertyName, &m_backendValuesPropertyMap, propertyEditor, metaInfo.propertyTypeName(propertyName));
|
||||||
|
|
||||||
PropertyEditorValue *valueObject = qobject_cast<PropertyEditorValue*>(QDeclarativeMetaType::toQObject(m_backendValuesPropertyMap.value("className")));
|
PropertyEditorValue *valueObject = qobject_cast<PropertyEditorValue*>(QDeclarativeMetaType::toQObject(m_backendValuesPropertyMap.value("className")));
|
||||||
if (!valueObject)
|
if (!valueObject)
|
||||||
@@ -388,7 +385,7 @@ void PropertyEditor::changeValue(const QString &propertyName)
|
|||||||
QVariant castedValue;
|
QVariant castedValue;
|
||||||
|
|
||||||
if (fxObjectNode.modelNode().metaInfo().isValid() && fxObjectNode.modelNode().metaInfo().hasProperty(propertyName)) {
|
if (fxObjectNode.modelNode().metaInfo().isValid() && fxObjectNode.modelNode().metaInfo().hasProperty(propertyName)) {
|
||||||
castedValue = fxObjectNode.modelNode().metaInfo().nativePropertyValue(propertyName, value->value());
|
castedValue = fxObjectNode.modelNode().metaInfo().propertyCastedValue(propertyName, value->value());
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "PropertyEditor:" <<propertyName << "cannot be casted (metainfo)";
|
qWarning() << "PropertyEditor:" <<propertyName << "cannot be casted (metainfo)";
|
||||||
return ;
|
return ;
|
||||||
@@ -400,7 +397,7 @@ void PropertyEditor::changeValue(const QString &propertyName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fxObjectNode.modelNode().metaInfo().isValid() && fxObjectNode.modelNode().metaInfo().hasProperty(propertyName))
|
if (fxObjectNode.modelNode().metaInfo().isValid() && fxObjectNode.modelNode().metaInfo().hasProperty(propertyName))
|
||||||
if (fxObjectNode.modelNode().metaInfo().propertyType(propertyName) == QLatin1String("QUrl")) { //turn absolute local file paths into relative paths
|
if (fxObjectNode.modelNode().metaInfo().propertyTypeName(propertyName) == QLatin1String("QUrl")) { //turn absolute local file paths into relative paths
|
||||||
QString filePath = castedValue.toUrl().toString();
|
QString filePath = castedValue.toUrl().toString();
|
||||||
if (QFileInfo(filePath).exists() && QFileInfo(filePath).isAbsolute()) {
|
if (QFileInfo(filePath).exists() && QFileInfo(filePath).isAbsolute()) {
|
||||||
QDir fileDir(QFileInfo(model()->fileUrl().toLocalFile()).absolutePath());
|
QDir fileDir(QFileInfo(model()->fileUrl().toLocalFile()).absolutePath());
|
||||||
@@ -448,12 +445,12 @@ void PropertyEditor::changeExpression(const QString &name)
|
|||||||
PropertyEditorValue *value = qobject_cast<PropertyEditorValue*>(QDeclarativeMetaType::toQObject(m_currentType->m_backendValuesPropertyMap.value(underscoreName)));
|
PropertyEditorValue *value = qobject_cast<PropertyEditorValue*>(QDeclarativeMetaType::toQObject(m_currentType->m_backendValuesPropertyMap.value(underscoreName)));
|
||||||
|
|
||||||
if (fxObjectNode.modelNode().metaInfo().isValid() && fxObjectNode.modelNode().metaInfo().hasProperty(name)) {
|
if (fxObjectNode.modelNode().metaInfo().isValid() && fxObjectNode.modelNode().metaInfo().hasProperty(name)) {
|
||||||
if (fxObjectNode.modelNode().metaInfo().propertyType(name) == QLatin1String("QColor")) {
|
if (fxObjectNode.modelNode().metaInfo().propertyTypeName(name) == QLatin1String("QColor")) {
|
||||||
if (QColor(value->expression().remove('"')).isValid()) {
|
if (QColor(value->expression().remove('"')).isValid()) {
|
||||||
fxObjectNode.setVariantProperty(name, QColor(value->expression().remove('"')));
|
fxObjectNode.setVariantProperty(name, QColor(value->expression().remove('"')));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (fxObjectNode.modelNode().metaInfo().propertyType(name) == QLatin1String("bool")) {
|
} else if (fxObjectNode.modelNode().metaInfo().propertyTypeName(name) == QLatin1String("bool")) {
|
||||||
if (value->expression().compare("false", Qt::CaseInsensitive) == 0 || value->expression().compare("true", Qt::CaseInsensitive) == 0) {
|
if (value->expression().compare("false", Qt::CaseInsensitive) == 0 || value->expression().compare("true", Qt::CaseInsensitive) == 0) {
|
||||||
if (value->expression().compare("true", Qt::CaseInsensitive) == 0)
|
if (value->expression().compare("true", Qt::CaseInsensitive) == 0)
|
||||||
fxObjectNode.setVariantProperty(name, true);
|
fxObjectNode.setVariantProperty(name, true);
|
||||||
@@ -461,14 +458,14 @@ void PropertyEditor::changeExpression(const QString &name)
|
|||||||
fxObjectNode.setVariantProperty(name, false);
|
fxObjectNode.setVariantProperty(name, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (fxObjectNode.modelNode().metaInfo().propertyType(name) == QLatin1String("int")) {
|
} else if (fxObjectNode.modelNode().metaInfo().propertyTypeName(name) == QLatin1String("int")) {
|
||||||
bool ok;
|
bool ok;
|
||||||
int intValue = value->expression().toInt(&ok);
|
int intValue = value->expression().toInt(&ok);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
fxObjectNode.setVariantProperty(name, intValue);
|
fxObjectNode.setVariantProperty(name, intValue);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (fxObjectNode.modelNode().metaInfo().propertyType(name) == QLatin1String("qreal")) {
|
} else if (fxObjectNode.modelNode().metaInfo().propertyTypeName(name) == QLatin1String("qreal")) {
|
||||||
bool ok;
|
bool ok;
|
||||||
qreal realValue = value->expression().toFloat(&ok);
|
qreal realValue = value->expression().toFloat(&ok);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
@@ -585,7 +582,7 @@ QString templateGeneration(NodeMetaInfo type, NodeMetaInfo superType, const QmlO
|
|||||||
QString properName = name;
|
QString properName = name;
|
||||||
properName.replace(".", "_");
|
properName.replace(".", "_");
|
||||||
|
|
||||||
QString typeName = type.propertyType(name);
|
QString typeName = type.propertyTypeName(name);
|
||||||
//alias resolution only possible with instance
|
//alias resolution only possible with instance
|
||||||
if (typeName == QLatin1String("alias") && objectNode.isValid())
|
if (typeName == QLatin1String("alias") && objectNode.isValid())
|
||||||
typeName = objectNode.instanceType(name);
|
typeName = objectNode.instanceType(name);
|
||||||
@@ -650,7 +647,7 @@ void PropertyEditor::resetView()
|
|||||||
|
|
||||||
if (m_selectedNode.isValid() && !QFileInfo(qmlSpecificsFile.toLocalFile()).exists() && m_selectedNode.metaInfo().isValid()) {
|
if (m_selectedNode.isValid() && !QFileInfo(qmlSpecificsFile.toLocalFile()).exists() && m_selectedNode.metaInfo().isValid()) {
|
||||||
//do magic !!
|
//do magic !!
|
||||||
specificQmlData = templateGeneration(m_selectedNode.metaInfo(), model()->metaInfo().nodeMetaInfo(specificsClassName), m_selectedNode);
|
specificQmlData = templateGeneration(m_selectedNode.metaInfo(), model()->metaInfo(specificsClassName), m_selectedNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeType *type = m_typeHash.value(qmlFile.toString());
|
NodeType *type = m_typeHash.value(qmlFile.toString());
|
||||||
|
|||||||
@@ -34,7 +34,6 @@
|
|||||||
#include <model.h>
|
#include <model.h>
|
||||||
#include <nodemetainfo.h>
|
#include <nodemetainfo.h>
|
||||||
#include <metainfo.h>
|
#include <metainfo.h>
|
||||||
#include <propertymetainfo.h>
|
|
||||||
#include <nodeproperty.h>
|
#include <nodeproperty.h>
|
||||||
#include <qmlobjectnode.h>
|
#include <qmlobjectnode.h>
|
||||||
|
|
||||||
@@ -54,7 +53,7 @@ QVariant PropertyEditorValue::value() const
|
|||||||
{
|
{
|
||||||
QVariant returnValue = m_value;
|
QVariant returnValue = m_value;
|
||||||
if (modelNode().isValid() && modelNode().metaInfo().isValid() && modelNode().metaInfo().hasProperty(name()))
|
if (modelNode().isValid() && modelNode().metaInfo().isValid() && modelNode().metaInfo().hasProperty(name()))
|
||||||
if (modelNode().metaInfo().propertyType(name()) == QLatin1String("QUrl")) {
|
if (modelNode().metaInfo().propertyTypeName(name()) == QLatin1String("QUrl")) {
|
||||||
returnValue = returnValue.toUrl().toString();
|
returnValue = returnValue.toUrl().toString();
|
||||||
}
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
@@ -98,7 +97,7 @@ void PropertyEditorValue::setValueWithEmit(const QVariant &value)
|
|||||||
if (m_value != value) {
|
if (m_value != value) {
|
||||||
QVariant newValue = value;
|
QVariant newValue = value;
|
||||||
if (modelNode().isValid() && modelNode().metaInfo().isValid() && modelNode().metaInfo().hasProperty(name()))
|
if (modelNode().isValid() && modelNode().metaInfo().isValid() && modelNode().metaInfo().hasProperty(name()))
|
||||||
if (modelNode().metaInfo().propertyType(name()) == QLatin1String("QUrl")) {
|
if (modelNode().metaInfo().propertyTypeName(name()) == QLatin1String("QUrl")) {
|
||||||
newValue = QUrl(newValue.toString());
|
newValue = QUrl(newValue.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +271,7 @@ void PropertyEditorNodeWrapper::add(const QString &type)
|
|||||||
|
|
||||||
if ((m_editorValue && m_editorValue->modelNode().isValid())) {
|
if ((m_editorValue && m_editorValue->modelNode().isValid())) {
|
||||||
if (propertyType.isEmpty())
|
if (propertyType.isEmpty())
|
||||||
propertyType = m_editorValue->modelNode().metaInfo().propertyType(m_editorValue->name());
|
propertyType = m_editorValue->modelNode().metaInfo().propertyTypeName(m_editorValue->name());
|
||||||
while (propertyType.contains('*')) //strip star
|
while (propertyType.contains('*')) //strip star
|
||||||
propertyType.chop(1);
|
propertyType.chop(1);
|
||||||
m_modelNode = m_editorValue->modelNode().view()->createModelNode(propertyType, 4, 7);
|
m_modelNode = m_editorValue->modelNode().view()->createModelNode(propertyType, 4, 7);
|
||||||
|
|||||||
@@ -11,10 +11,8 @@ DEPENDPATH += $$PWD $$PWD/include
|
|||||||
SOURCES += $$PWD/model/abstractview.cpp \
|
SOURCES += $$PWD/model/abstractview.cpp \
|
||||||
$$PWD/instances/nodeinstanceview.cpp \
|
$$PWD/instances/nodeinstanceview.cpp \
|
||||||
$$PWD/model/rewriterview.cpp \
|
$$PWD/model/rewriterview.cpp \
|
||||||
$$PWD/metainfo/enumeratormetainfo.cpp \
|
|
||||||
$$PWD/metainfo/metainfo.cpp \
|
$$PWD/metainfo/metainfo.cpp \
|
||||||
$$PWD/metainfo/metainfoparser.cpp \
|
$$PWD/metainfo/metainfoparser.cpp \
|
||||||
$$PWD/metainfo/propertymetainfo.cpp \
|
|
||||||
$$PWD/metainfo/nodemetainfo.cpp \
|
$$PWD/metainfo/nodemetainfo.cpp \
|
||||||
$$PWD/metainfo/itemlibraryinfo.cpp \
|
$$PWD/metainfo/itemlibraryinfo.cpp \
|
||||||
$$PWD/metainfo/subcomponentmanager.cpp \
|
$$PWD/metainfo/subcomponentmanager.cpp \
|
||||||
@@ -126,11 +124,9 @@ HEADERS += $$PWD/include/corelib_global.h \
|
|||||||
$$PWD/include/abstractview.h \
|
$$PWD/include/abstractview.h \
|
||||||
$$PWD/include/nodeinstanceview.h \
|
$$PWD/include/nodeinstanceview.h \
|
||||||
$$PWD/include/rewriterview.h \
|
$$PWD/include/rewriterview.h \
|
||||||
$$PWD/include/enumeratormetainfo.h \
|
|
||||||
$$PWD/include/metainfo.h \
|
$$PWD/include/metainfo.h \
|
||||||
$$PWD/include/metainfoparser.h \
|
$$PWD/include/metainfoparser.h \
|
||||||
$$PWD/include/nodemetainfo.h \
|
$$PWD/include/nodemetainfo.h \
|
||||||
$$PWD/include/propertymetainfo.h \
|
|
||||||
$$PWD/include/itemlibraryinfo.h \
|
$$PWD/include/itemlibraryinfo.h \
|
||||||
$$PWD/model/internalproperty.h \
|
$$PWD/model/internalproperty.h \
|
||||||
$$PWD/include/modelnode.h \
|
$$PWD/include/modelnode.h \
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ namespace QmlDesigner {
|
|||||||
class Model;
|
class Model;
|
||||||
class ModelNode;
|
class ModelNode;
|
||||||
class AbstractView;
|
class AbstractView;
|
||||||
class PropertyMetaInfo;
|
|
||||||
class CORESHARED_EXPORT VariantProperty;
|
class CORESHARED_EXPORT VariantProperty;
|
||||||
class CORESHARED_EXPORT NodeListProperty;
|
class CORESHARED_EXPORT NodeListProperty;
|
||||||
class CORESHARED_EXPORT NodeAbstractProperty;
|
class CORESHARED_EXPORT NodeAbstractProperty;
|
||||||
@@ -88,7 +87,6 @@ public:
|
|||||||
ModelNode parentModelNode() const;
|
ModelNode parentModelNode() const;
|
||||||
QmlObjectNode parentQmlObjectNode() const;
|
QmlObjectNode parentQmlObjectNode() const;
|
||||||
|
|
||||||
PropertyMetaInfo metaInfo() const;
|
|
||||||
bool isDefaultProperty() const;
|
bool isDefaultProperty() const;
|
||||||
VariantProperty toVariantProperty() const;
|
VariantProperty toVariantProperty() const;
|
||||||
NodeListProperty toNodeListProperty() const;
|
NodeListProperty toNodeListProperty() const;
|
||||||
|
|||||||
@@ -1,86 +0,0 @@
|
|||||||
/**************************************************************************
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator
|
|
||||||
**
|
|
||||||
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
||||||
**
|
|
||||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
||||||
**
|
|
||||||
** Commercial Usage
|
|
||||||
**
|
|
||||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
||||||
** accordance with the Qt Commercial License Agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Nokia.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
**
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
||||||
** General Public License version 2.1 as published by the Free Software
|
|
||||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
||||||
** packaging of this file. Please review the following information to
|
|
||||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
||||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
||||||
**
|
|
||||||
** If you are unsure which license is appropriate for your use, please
|
|
||||||
** contact the sales department at http://qt.nokia.com/contact.
|
|
||||||
**
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
#ifndef ENUMERATORMETAINFO_H
|
|
||||||
#define ENUMERATORMETAINFO_H
|
|
||||||
|
|
||||||
#include "corelib_global.h"
|
|
||||||
|
|
||||||
#include <QExplicitlySharedDataPointer>
|
|
||||||
#include <QList>
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
|
||||||
|
|
||||||
class MetaInfo;
|
|
||||||
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class MetaInfoParser;
|
|
||||||
class MetaInfoPrivate;
|
|
||||||
class EnumeratorMetaInfoData;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class CORESHARED_EXPORT EnumeratorMetaInfo
|
|
||||||
{
|
|
||||||
friend class QmlDesigner::MetaInfo;
|
|
||||||
friend class QmlDesigner::Internal::MetaInfoPrivate;
|
|
||||||
friend class QmlDesigner::Internal::MetaInfoParser;
|
|
||||||
public:
|
|
||||||
EnumeratorMetaInfo();
|
|
||||||
~EnumeratorMetaInfo();
|
|
||||||
|
|
||||||
EnumeratorMetaInfo(const EnumeratorMetaInfo &other);
|
|
||||||
EnumeratorMetaInfo& operator=(const EnumeratorMetaInfo &other);
|
|
||||||
|
|
||||||
QString name() const;
|
|
||||||
QString scope() const;
|
|
||||||
bool isFlagType() const;
|
|
||||||
bool isValid() const;
|
|
||||||
QString scopeAndName(const QString &combiner = QString("::")) const;
|
|
||||||
QList<QString> elementNames() const;
|
|
||||||
int elementValue(const QString &enumeratorName) const;
|
|
||||||
QString valueToString(int value) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void setScope(const QString &scope);
|
|
||||||
void setName(const QString &name);
|
|
||||||
void setIsFlagType(bool isFlagType);
|
|
||||||
void setValid(bool valid);
|
|
||||||
void addElement(const QString &enumeratorName, int enumeratorValue);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QExplicitlySharedDataPointer<Internal::EnumeratorMetaInfoData> m_data;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // ENUMERATORMETAINFO_H
|
|
||||||
@@ -38,10 +38,7 @@
|
|||||||
#include <QtCore/QSharedPointer>
|
#include <QtCore/QSharedPointer>
|
||||||
|
|
||||||
#include <nodemetainfo.h>
|
#include <nodemetainfo.h>
|
||||||
#include "propertymetainfo.h"
|
|
||||||
#include "itemlibraryinfo.h"
|
#include "itemlibraryinfo.h"
|
||||||
#include "enumeratormetainfo.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
@@ -66,7 +63,6 @@ class CORESHARED_EXPORT MetaInfo
|
|||||||
friend class QmlDesigner::Internal::ModelPrivate;
|
friend class QmlDesigner::Internal::ModelPrivate;
|
||||||
friend class QmlDesigner::Internal::MetaInfoParser;
|
friend class QmlDesigner::Internal::MetaInfoParser;
|
||||||
friend class QmlDesigner::Internal::SubComponentManagerPrivate;
|
friend class QmlDesigner::Internal::SubComponentManagerPrivate;
|
||||||
friend class QmlDesigner::NodeMetaInfo;
|
|
||||||
friend bool QmlDesigner::operator==(const MetaInfo &, const MetaInfo &);
|
friend bool QmlDesigner::operator==(const MetaInfo &, const MetaInfo &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -74,17 +70,7 @@ public:
|
|||||||
~MetaInfo();
|
~MetaInfo();
|
||||||
MetaInfo& operator=(const MetaInfo &other);
|
MetaInfo& operator=(const MetaInfo &other);
|
||||||
|
|
||||||
bool hasNodeMetaInfo(const QString &typeName, int majorVersion = -1, int minorVersion = -1) const;
|
|
||||||
NodeMetaInfo nodeMetaInfo(const QString &typeName, int majorVersion = -1, int minorVersion = -1) const;
|
|
||||||
|
|
||||||
bool hasEnumerator(const QString &enumeratorName) const;
|
|
||||||
EnumeratorMetaInfo enumerator(const QString &enumeratorName) const;
|
|
||||||
|
|
||||||
ItemLibraryInfo *itemLibraryInfo() const;
|
ItemLibraryInfo *itemLibraryInfo() const;
|
||||||
|
|
||||||
QString fromQtTypes(const QString &type) const;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static MetaInfo global();
|
static MetaInfo global();
|
||||||
static void clearGlobal();
|
static void clearGlobal();
|
||||||
@@ -92,12 +78,6 @@ public:
|
|||||||
static void setPluginPaths(const QStringList &paths);
|
static void setPluginPaths(const QStringList &paths);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addNodeInfo(NodeMetaInfo &info);
|
|
||||||
void removeNodeInfo(NodeMetaInfo &info);
|
|
||||||
|
|
||||||
EnumeratorMetaInfo addEnumerator(const QString &enumeratorScope, const QString &enumeratorName);
|
|
||||||
EnumeratorMetaInfo addFlag(const QString &enumeratorScope, const QString &enumeratorName);
|
|
||||||
|
|
||||||
bool isGlobal() const;
|
bool isGlobal() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -55,9 +55,11 @@ class AbstractView;
|
|||||||
class WidgetQueryView;
|
class WidgetQueryView;
|
||||||
class NodeStateChangeSet;
|
class NodeStateChangeSet;
|
||||||
class MetaInfo;
|
class MetaInfo;
|
||||||
|
class NodeMetaInfo;
|
||||||
class ModelState;
|
class ModelState;
|
||||||
class NodeAnchors;
|
class NodeAnchors;
|
||||||
class AbstractProperty;
|
class AbstractProperty;
|
||||||
|
class RewriterView;
|
||||||
|
|
||||||
typedef QList<QPair<QString, QVariant> > PropertyListType;
|
typedef QList<QPair<QString, QVariant> > PropertyListType;
|
||||||
|
|
||||||
@@ -88,6 +90,7 @@ public:
|
|||||||
|
|
||||||
const MetaInfo metaInfo() const;
|
const MetaInfo metaInfo() const;
|
||||||
MetaInfo metaInfo();
|
MetaInfo metaInfo();
|
||||||
|
NodeMetaInfo metaInfo(const QString &typeName, int majorVersion = -1, int minorVersion = -1);
|
||||||
void setMetaInfo(const MetaInfo &metaInfo);
|
void setMetaInfo(const MetaInfo &metaInfo);
|
||||||
|
|
||||||
void attachView(AbstractView *view);
|
void attachView(AbstractView *view);
|
||||||
@@ -100,6 +103,8 @@ public:
|
|||||||
void addImport(const Import &import);
|
void addImport(const Import &import);
|
||||||
void removeImport(const Import &import);
|
void removeImport(const Import &import);
|
||||||
|
|
||||||
|
RewriterView *rewriterView() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Model();
|
Model();
|
||||||
|
|
||||||
|
|||||||
@@ -45,93 +45,60 @@ QT_END_NAMESPACE
|
|||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
class MetaInfo;
|
class MetaInfo;
|
||||||
|
class Model;
|
||||||
class AbstractProperty;
|
class AbstractProperty;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class MetaInfoPrivate;
|
class MetaInfoPrivate;
|
||||||
class MetaInfoParser;
|
class MetaInfoParser;
|
||||||
class NodeMetaInfoData;
|
|
||||||
class SubComponentManagerPrivate;
|
class SubComponentManagerPrivate;
|
||||||
class ItemLibraryEntryData;
|
class ItemLibraryEntryData;
|
||||||
|
class NodeMetaInfoPrivate;
|
||||||
}
|
}
|
||||||
|
|
||||||
class PropertyMetaInfo;
|
|
||||||
|
|
||||||
class CORESHARED_EXPORT NodeMetaInfo
|
class CORESHARED_EXPORT NodeMetaInfo
|
||||||
{
|
{
|
||||||
friend class QmlDesigner::MetaInfo;
|
|
||||||
friend class QmlDesigner::Internal::ItemLibraryEntryData;
|
|
||||||
friend class QmlDesigner::Internal::MetaInfoPrivate;
|
|
||||||
friend class QmlDesigner::Internal::MetaInfoParser;
|
|
||||||
friend class QmlDesigner::Internal::SubComponentManagerPrivate;
|
|
||||||
friend class QmlDesigner::AbstractProperty;
|
|
||||||
friend CORESHARED_EXPORT uint qHash(const NodeMetaInfo &nodeMetaInfo);
|
|
||||||
friend CORESHARED_EXPORT bool operator ==(const NodeMetaInfo &firstNodeInfo, const NodeMetaInfo &secondNodeInfo);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
NodeMetaInfo();
|
||||||
|
NodeMetaInfo(Model *model, QString type, int maj, int min);
|
||||||
|
|
||||||
~NodeMetaInfo();
|
~NodeMetaInfo();
|
||||||
|
|
||||||
NodeMetaInfo(const NodeMetaInfo &other);
|
NodeMetaInfo(const NodeMetaInfo &other);
|
||||||
NodeMetaInfo &operator=(const NodeMetaInfo &other);
|
NodeMetaInfo &operator=(const NodeMetaInfo &other);
|
||||||
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
MetaInfo metaInfo() const;
|
bool isComponent() const;
|
||||||
|
bool hasProperty(const QString &propertyName) const;
|
||||||
|
QStringList propertyNames() const;
|
||||||
|
QStringList directPropertyNames() const;
|
||||||
|
QString defaultPropertyName() const;
|
||||||
|
bool hasDefaultProperty() const;
|
||||||
|
QString propertyTypeName(const QString &propertyName) const;
|
||||||
|
bool propertyIsWritable(const QString &propertyName) const;
|
||||||
|
bool propertyIsListProperty(const QString &propertyName) const;
|
||||||
|
bool propertyIsEnumType(const QString &propertyName) const;
|
||||||
|
QString propertyEnumScope(const QString &propertyName) const;
|
||||||
|
QStringList propertyKeysForEnum(const QString &propertyName) const;
|
||||||
|
QVariant propertyCastedValue(const QString &propertyName, const QVariant &value) const;
|
||||||
|
|
||||||
QList<NodeMetaInfo> superClasses() const;
|
QList<NodeMetaInfo> superClasses() const;
|
||||||
NodeMetaInfo directSuperClass() const;
|
NodeMetaInfo directSuperClass() const;
|
||||||
|
|
||||||
|
|
||||||
QStringList propertyNames() const;
|
|
||||||
QStringList propertyNamesOnlyContainer() const;
|
|
||||||
QString propertyType(const QString &propertyName) const;
|
|
||||||
QVariant nativePropertyValue(const QString &propertyName, const QVariant &value) const;
|
|
||||||
|
|
||||||
QString typeName() const;
|
QString typeName() const;
|
||||||
int majorVersion() const;
|
int majorVersion() const;
|
||||||
int minorVersion() const;
|
int minorVersion() const;
|
||||||
|
|
||||||
|
QString componentSource() const;
|
||||||
|
QString componentFileName() const;
|
||||||
|
|
||||||
bool availableInVersion(int majorVersion, int minorVersion) const;
|
bool availableInVersion(int majorVersion, int minorVersion) const;
|
||||||
|
|
||||||
bool hasDefaultProperty() const;
|
|
||||||
QString defaultProperty() const;
|
|
||||||
|
|
||||||
bool hasProperty(const QString &propertyName) const;
|
|
||||||
bool isContainer() const;
|
|
||||||
bool isComponent() const;
|
|
||||||
bool isSubclassOf(const QString& type, int majorVersion, int minorVersio) const;
|
bool isSubclassOf(const QString& type, int majorVersion, int minorVersio) const;
|
||||||
|
|
||||||
QString componentString() const;
|
|
||||||
QIcon icon() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NodeMetaInfo();
|
QSharedPointer<Internal::NodeMetaInfoPrivate> m_privateData;
|
||||||
NodeMetaInfo(const MetaInfo &metaInfo);
|
|
||||||
|
|
||||||
void setInvalid();
|
|
||||||
void setType(const QString &typeName, int majorVersion, int minorVersion);
|
|
||||||
void addProperty(const PropertyMetaInfo &property);
|
|
||||||
void setIsContainer(bool isContainer);
|
|
||||||
void setIcon(const QIcon &icon);
|
|
||||||
void setQmlFile(const QString &filePath);
|
|
||||||
void setDefaultProperty(const QString &defaultProperty);
|
|
||||||
void setSuperClass(const QString &typeName, int majorVersion = -1, int minorVersion = -1);
|
|
||||||
|
|
||||||
bool hasLocalProperty(const QString &propertyName, bool resolveDotSyntax = true) const;
|
|
||||||
QHash<QString,PropertyMetaInfo> dotProperties() const;
|
|
||||||
QHash<QString,PropertyMetaInfo> properties(bool resolveDotSyntax = true) const;
|
|
||||||
PropertyMetaInfo property(const QString &propertyName, bool resolveDotSyntax = true) const;
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
QExplicitlySharedDataPointer<Internal::NodeMetaInfoData> m_data;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
CORESHARED_EXPORT uint qHash(const NodeMetaInfo &nodeMetaInfo);
|
} //QmlDesigner
|
||||||
CORESHARED_EXPORT bool operator ==(const NodeMetaInfo &firstNodeInfo,
|
|
||||||
const NodeMetaInfo &secondNodeInfo);
|
|
||||||
|
|
||||||
//QDataStream& operator<<(QDataStream& stream, const NodeMetaInfo& nodeMetaInfo);
|
|
||||||
//QDataStream& operator>>(QDataStream& stream, NodeMetaInfo& nodeMetaInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // NODEMETAINFO_H
|
#endif // NODEMETAINFO_H
|
||||||
|
|||||||
@@ -37,8 +37,6 @@
|
|||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
#include <enumeratormetainfo.h>
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
class PropertyContainer;
|
class PropertyContainer;
|
||||||
|
|||||||
@@ -1,123 +0,0 @@
|
|||||||
/**************************************************************************
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator
|
|
||||||
**
|
|
||||||
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
||||||
**
|
|
||||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
||||||
**
|
|
||||||
** Commercial Usage
|
|
||||||
**
|
|
||||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
||||||
** accordance with the Qt Commercial License Agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Nokia.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
**
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
||||||
** General Public License version 2.1 as published by the Free Software
|
|
||||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
||||||
** packaging of this file. Please review the following information to
|
|
||||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
||||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
||||||
**
|
|
||||||
** If you are unsure which license is appropriate for your use, please
|
|
||||||
** contact the sales department at http://qt.nokia.com/contact.
|
|
||||||
**
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
#ifndef PROPERTYMETAINFO_H
|
|
||||||
#define PROPERTYMETAINFO_H
|
|
||||||
|
|
||||||
#include "corelib_global.h"
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <QExplicitlySharedDataPointer>
|
|
||||||
#include <QVariant>
|
|
||||||
|
|
||||||
#include <enumeratormetainfo.h>
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
|
||||||
|
|
||||||
class AbstractProperty;
|
|
||||||
class MetaInfo;
|
|
||||||
class NodeMetaInfo;
|
|
||||||
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class MetaInfoPrivate;
|
|
||||||
class MetaInfoParser;
|
|
||||||
class PropertyMetaInfoData;
|
|
||||||
class ObjectNodeInstance;
|
|
||||||
class SubComponentManagerPrivate;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class CORESHARED_EXPORT PropertyMetaInfo
|
|
||||||
{
|
|
||||||
friend class QmlDesigner::Internal::MetaInfoPrivate;
|
|
||||||
friend class QmlDesigner::Internal::MetaInfoParser;
|
|
||||||
friend class QmlDesigner::Internal::ObjectNodeInstance;
|
|
||||||
friend class QmlDesigner::Internal::SubComponentManagerPrivate;
|
|
||||||
friend class QmlDesigner::MetaInfo;
|
|
||||||
friend class QmlDesigner::AbstractProperty;
|
|
||||||
friend class QmlDesigner::NodeMetaInfo;
|
|
||||||
public:
|
|
||||||
PropertyMetaInfo();
|
|
||||||
~PropertyMetaInfo();
|
|
||||||
|
|
||||||
PropertyMetaInfo(const PropertyMetaInfo &other);
|
|
||||||
PropertyMetaInfo& operator=(const PropertyMetaInfo &other);
|
|
||||||
|
|
||||||
bool isValid() const;
|
|
||||||
|
|
||||||
QString name() const;
|
|
||||||
QString type() const;
|
|
||||||
|
|
||||||
QVariant::Type variantTypeId() const;
|
|
||||||
|
|
||||||
bool isReadable() const;
|
|
||||||
bool isWriteable() const;
|
|
||||||
bool isResettable() const;
|
|
||||||
bool isValueType() const;
|
|
||||||
bool isListProperty() const;
|
|
||||||
|
|
||||||
bool isEnumType() const;
|
|
||||||
bool isFlagType() const;
|
|
||||||
|
|
||||||
QVariant defaultValue(const NodeMetaInfo &nodeMetaInfo) const;
|
|
||||||
bool isVisibleToPropertyEditor() const;
|
|
||||||
|
|
||||||
const EnumeratorMetaInfo enumerator() const;
|
|
||||||
|
|
||||||
QVariant castedValue(const QVariant &variant) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void setName(const QString &name);
|
|
||||||
void setType(const QString &type);
|
|
||||||
void setValid(bool isValid);
|
|
||||||
|
|
||||||
void setReadable(bool isReadable);
|
|
||||||
void setWritable(bool isWritable);
|
|
||||||
void setResettable(bool isRessetable);
|
|
||||||
|
|
||||||
void setEnumType(bool isEnumType);
|
|
||||||
void setFlagType(bool isFlagType);
|
|
||||||
|
|
||||||
void setDefaultValue(const NodeMetaInfo &nodeMetaInfo, const QVariant &value);
|
|
||||||
void setIsVisibleToPropertyEditor(bool isVisible);
|
|
||||||
|
|
||||||
void setEnumerator(const EnumeratorMetaInfo &info);
|
|
||||||
|
|
||||||
bool hasDotSubProperties() const;
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
QExplicitlySharedDataPointer<Internal::PropertyMetaInfoData> m_data;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // PROPERTYMETAINFO_H
|
|
||||||
@@ -63,7 +63,6 @@ class ModelNodePositionStorage;
|
|||||||
|
|
||||||
} //Internal
|
} //Internal
|
||||||
|
|
||||||
|
|
||||||
class CORESHARED_EXPORT RewriterView : public AbstractView
|
class CORESHARED_EXPORT RewriterView : public AbstractView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
@@ -32,7 +32,6 @@
|
|||||||
#include <nodemetainfo.h>
|
#include <nodemetainfo.h>
|
||||||
|
|
||||||
#include <invalidnodeinstanceexception.h>
|
#include <invalidnodeinstanceexception.h>
|
||||||
#include <propertymetainfo.h>
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|||||||
@@ -42,7 +42,6 @@
|
|||||||
|
|
||||||
#include <model.h>
|
#include <model.h>
|
||||||
#include <modelnode.h>
|
#include <modelnode.h>
|
||||||
#include <propertymetainfo.h>
|
|
||||||
#include <metainfo.h>
|
#include <metainfo.h>
|
||||||
|
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
@@ -698,7 +697,7 @@ CreateInstancesCommand NodeInstanceView::createCreateInstancesCommand(const QLis
|
|||||||
{
|
{
|
||||||
QVector<InstanceContainer> containerList;
|
QVector<InstanceContainer> containerList;
|
||||||
foreach(const NodeInstance &instance, instanceList) {
|
foreach(const NodeInstance &instance, instanceList) {
|
||||||
InstanceContainer container(instance.instanceId(), instance.modelNode().type(), instance.modelNode().majorVersion(), instance.modelNode().minorVersion(), instance.modelNode().metaInfo().componentString());
|
InstanceContainer container(instance.instanceId(), instance.modelNode().type(), instance.modelNode().majorVersion(), instance.modelNode().minorVersion(), instance.modelNode().metaInfo().componentFileName());
|
||||||
containerList.append(container);
|
containerList.append(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,6 @@
|
|||||||
#include <variantproperty.h>
|
#include <variantproperty.h>
|
||||||
#include <nodelistproperty.h>
|
#include <nodelistproperty.h>
|
||||||
#include <metainfo.h>
|
#include <metainfo.h>
|
||||||
#include <propertymetainfo.h>
|
|
||||||
|
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
#include "qmlgraphicsitemnodeinstance.h"
|
#include "qmlgraphicsitemnodeinstance.h"
|
||||||
|
|
||||||
#include <invalidnodeinstanceexception.h>
|
#include <invalidnodeinstanceexception.h>
|
||||||
#include <propertymetainfo.h>
|
|
||||||
|
|
||||||
#include "bindingproperty.h"
|
#include "bindingproperty.h"
|
||||||
#include "variantproperty.h"
|
#include "variantproperty.h"
|
||||||
|
|||||||
@@ -1,158 +0,0 @@
|
|||||||
/**************************************************************************
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator
|
|
||||||
**
|
|
||||||
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
||||||
**
|
|
||||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
||||||
**
|
|
||||||
** Commercial Usage
|
|
||||||
**
|
|
||||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
||||||
** accordance with the Qt Commercial License Agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Nokia.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
**
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
||||||
** General Public License version 2.1 as published by the Free Software
|
|
||||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
||||||
** packaging of this file. Please review the following information to
|
|
||||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
||||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
||||||
**
|
|
||||||
** If you are unsure which license is appropriate for your use, please
|
|
||||||
** contact the sales department at http://qt.nokia.com/contact.
|
|
||||||
**
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
#include "enumeratormetainfo.h"
|
|
||||||
|
|
||||||
#include <QSharedData>
|
|
||||||
#include <QString>
|
|
||||||
#include <QMap>
|
|
||||||
#include <QtDebug>
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
|
||||||
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class EnumeratorMetaInfoData : public QSharedData
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QString name;
|
|
||||||
QString scope;
|
|
||||||
bool isFlagType;
|
|
||||||
bool isValid;
|
|
||||||
QMap<QString, int> elements;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\class QmlDesigner::EnumeratorMetaInfo
|
|
||||||
\ingroup CoreModel
|
|
||||||
\brief The EnumeratorMetaInfo class provides meta information about an enumerator type.
|
|
||||||
|
|
||||||
TODO
|
|
||||||
|
|
||||||
\see QmlDesigner::MetaInfo, QmlDesigner::NodeMetaInfo, QmlDesigner::PropertyMetaInfo
|
|
||||||
*/
|
|
||||||
|
|
||||||
EnumeratorMetaInfo::EnumeratorMetaInfo()
|
|
||||||
: m_data(new Internal::EnumeratorMetaInfoData)
|
|
||||||
{
|
|
||||||
m_data->isFlagType = false;
|
|
||||||
m_data->isValid = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
EnumeratorMetaInfo::~EnumeratorMetaInfo()
|
|
||||||
{}
|
|
||||||
|
|
||||||
EnumeratorMetaInfo::EnumeratorMetaInfo(const EnumeratorMetaInfo &other)
|
|
||||||
: m_data(other.m_data)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
EnumeratorMetaInfo& EnumeratorMetaInfo::operator=(const EnumeratorMetaInfo &other)
|
|
||||||
{
|
|
||||||
if (this !=&other)
|
|
||||||
m_data = other.m_data;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString EnumeratorMetaInfo::name() const
|
|
||||||
{
|
|
||||||
return m_data->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString EnumeratorMetaInfo::scope() const
|
|
||||||
{
|
|
||||||
return m_data->scope;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EnumeratorMetaInfo::isValid() const
|
|
||||||
{
|
|
||||||
return m_data->isValid;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString EnumeratorMetaInfo::scopeAndName(const QString &combiner) const
|
|
||||||
{
|
|
||||||
return m_data->scope + combiner + m_data->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<QString> EnumeratorMetaInfo::elementNames() const
|
|
||||||
{
|
|
||||||
return m_data->elements.keys();
|
|
||||||
}
|
|
||||||
|
|
||||||
int EnumeratorMetaInfo::elementValue(const QString &enumeratorName) const
|
|
||||||
{
|
|
||||||
QString possibleScope = scope();
|
|
||||||
if (!possibleScope.isEmpty())
|
|
||||||
possibleScope.append("::");
|
|
||||||
QString unscoped = enumeratorName;
|
|
||||||
unscoped.remove(possibleScope);
|
|
||||||
return m_data->elements.value(unscoped, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString EnumeratorMetaInfo::valueToString(int value) const
|
|
||||||
{
|
|
||||||
return m_data->elements.key(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EnumeratorMetaInfo::setScope(const QString &scope)
|
|
||||||
{
|
|
||||||
Q_ASSERT(!scope.isEmpty());
|
|
||||||
m_data->scope = scope;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EnumeratorMetaInfo::setName(const QString &name)
|
|
||||||
{
|
|
||||||
Q_ASSERT(!name.isEmpty());
|
|
||||||
m_data->name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EnumeratorMetaInfo::addElement(const QString &enumeratorName, int enumeratorValue)
|
|
||||||
{
|
|
||||||
m_data->elements.insert(enumeratorName, enumeratorValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EnumeratorMetaInfo::isFlagType() const
|
|
||||||
{
|
|
||||||
return m_data->isFlagType;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EnumeratorMetaInfo::setIsFlagType(bool isFlagType)
|
|
||||||
{
|
|
||||||
m_data->isFlagType = isFlagType;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EnumeratorMetaInfo::setValid(bool valid)
|
|
||||||
{
|
|
||||||
m_data->isValid = valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -33,7 +33,6 @@
|
|||||||
#include "modelnode.h"
|
#include "modelnode.h"
|
||||||
#include "invalidmodelnodeexception.h"
|
#include "invalidmodelnodeexception.h"
|
||||||
#include "invalidargumentexception.h"
|
#include "invalidargumentexception.h"
|
||||||
#include "propertymetainfo.h"
|
|
||||||
#include "metainfoparser.h"
|
#include "metainfoparser.h"
|
||||||
#include "iwidgetplugin.h"
|
#include "iwidgetplugin.h"
|
||||||
|
|
||||||
@@ -43,11 +42,6 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
#include <QtAlgorithms>
|
#include <QtAlgorithms>
|
||||||
#include <QMetaProperty>
|
|
||||||
#include <QDeclarativeEngine>
|
|
||||||
|
|
||||||
#include <private/qdeclarativemetatype_p.h>
|
|
||||||
#include <private/qdeclarativeanchors_p.h>
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
debug = false
|
debug = false
|
||||||
@@ -68,22 +62,9 @@ public:
|
|||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
void loadPlugins(QDeclarativeEngine *engine);
|
|
||||||
void parseQmlTypes();
|
|
||||||
void parseNonQmlTypes();
|
|
||||||
void parseValueTypes();
|
|
||||||
void parseNonQmlClassRecursively(const QMetaObject *qMetaObject);
|
|
||||||
void parseProperties(NodeMetaInfo &nodeMetaInfo, const QMetaObject *qMetaObject) const;
|
|
||||||
void parseClassInfo(NodeMetaInfo &nodeMetaInfo, const QMetaObject *qMetaObject) const;
|
|
||||||
|
|
||||||
QList<QDeclarativeType*> qmlTypes();
|
|
||||||
void typeInfo(const QMetaObject *qMetaObject, QString *typeName, int *majorVersion = 0, int *minorVersion = 0) const;
|
|
||||||
|
|
||||||
void parseXmlFiles();
|
void parseXmlFiles();
|
||||||
|
|
||||||
QMultiHash<QString, NodeMetaInfo> m_nodeMetaInfoHash;
|
|
||||||
QHash<QString, EnumeratorMetaInfo> m_enumeratorMetaInfoHash;
|
|
||||||
QHash<QString, QString> m_QtTypesToQmlTypes;
|
|
||||||
QScopedPointer<ItemLibraryInfo> m_itemLibraryInfo;
|
QScopedPointer<ItemLibraryInfo> m_itemLibraryInfo;
|
||||||
|
|
||||||
MetaInfo *m_q;
|
MetaInfo *m_q;
|
||||||
@@ -101,49 +82,16 @@ MetaInfoPrivate::MetaInfoPrivate(MetaInfo *q) :
|
|||||||
|
|
||||||
void MetaInfoPrivate::clear()
|
void MetaInfoPrivate::clear()
|
||||||
{
|
{
|
||||||
m_nodeMetaInfoHash.clear();
|
|
||||||
m_enumeratorMetaInfoHash.clear();
|
|
||||||
m_itemLibraryInfo->clearEntries();
|
m_itemLibraryInfo->clearEntries();
|
||||||
m_isInitialized = false;
|
m_isInitialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetaInfoPrivate::initialize()
|
void MetaInfoPrivate::initialize()
|
||||||
{
|
{
|
||||||
// make sure QmlGraphicsItemsModule gets initialized, that is
|
|
||||||
// QmlGraphicsItemsModule::defineModule called
|
|
||||||
QDeclarativeEngine engine;
|
|
||||||
Q_UNUSED(engine);
|
|
||||||
|
|
||||||
loadPlugins(&engine);
|
|
||||||
parseQmlTypes();
|
|
||||||
parseNonQmlTypes();
|
|
||||||
parseValueTypes();
|
|
||||||
parseXmlFiles();
|
parseXmlFiles();
|
||||||
|
|
||||||
m_isInitialized = true;
|
m_isInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetaInfoPrivate::loadPlugins(QDeclarativeEngine *engine)
|
|
||||||
{
|
|
||||||
// hack to load plugins
|
|
||||||
QDeclarativeComponent pluginComponent(engine, 0);
|
|
||||||
|
|
||||||
QStringList pluginList;
|
|
||||||
pluginList += "import Qt 4.7";
|
|
||||||
pluginList += "import QtWebKit 1.0";
|
|
||||||
|
|
||||||
// load maybe useful plugins
|
|
||||||
pluginList += "import Qt.labs.folderlistmodel 1.0";
|
|
||||||
pluginList += "import Qt.labs.gestures 1.0";
|
|
||||||
pluginList += "import Qt.labs.particles 1.0";
|
|
||||||
pluginList += "import Qt.labs.components 1.0";
|
|
||||||
|
|
||||||
QString componentString = QString("%1\n Item {}\n").arg(pluginList.join("\n"));
|
|
||||||
|
|
||||||
|
|
||||||
pluginComponent.setData(componentString.toLatin1(), QUrl());
|
|
||||||
}
|
|
||||||
|
|
||||||
QString static inline stripPrefix(const QString &typeName)
|
QString static inline stripPrefix(const QString &typeName)
|
||||||
{
|
{
|
||||||
QStringList list = typeName.split('/');
|
QStringList list = typeName.split('/');
|
||||||
@@ -152,131 +100,6 @@ QString static inline stripPrefix(const QString &typeName)
|
|||||||
return typeName;
|
return typeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetaInfoPrivate::parseProperties(NodeMetaInfo &nodeMetaInfo, const QMetaObject *qMetaObject) const
|
|
||||||
{
|
|
||||||
Q_ASSERT_X(qMetaObject, Q_FUNC_INFO, "invalid QMetaObject");
|
|
||||||
Q_ASSERT_X(nodeMetaInfo.isValid(), Q_FUNC_INFO, "invalid NodeMetaInfo");
|
|
||||||
|
|
||||||
for (int i = qMetaObject->propertyOffset(); i < qMetaObject->propertyCount(); ++i) {
|
|
||||||
QMetaProperty qProperty = qMetaObject->property(i);
|
|
||||||
|
|
||||||
PropertyMetaInfo propertyInfo;
|
|
||||||
|
|
||||||
propertyInfo.setName(QLatin1String(qProperty.name()));
|
|
||||||
|
|
||||||
QString typeName(qProperty.typeName());
|
|
||||||
QString noStar = typeName;
|
|
||||||
bool star = false;
|
|
||||||
while (noStar.contains('*')) {//strip star
|
|
||||||
noStar.chop(1);
|
|
||||||
star = true;
|
|
||||||
}
|
|
||||||
if (m_QtTypesToQmlTypes.contains(noStar)) {
|
|
||||||
typeName = star ? m_QtTypesToQmlTypes.value(noStar) + '*' : m_QtTypesToQmlTypes.value(noStar);
|
|
||||||
//### versions
|
|
||||||
}
|
|
||||||
propertyInfo.setType(typeName);
|
|
||||||
propertyInfo.setValid(true);
|
|
||||||
propertyInfo.setReadable(qProperty.isReadable());
|
|
||||||
propertyInfo.setWritable(qProperty.isWritable());
|
|
||||||
propertyInfo.setResettable(qProperty.isResettable());
|
|
||||||
propertyInfo.setEnumType(qProperty.isEnumType());
|
|
||||||
propertyInfo.setFlagType(qProperty.isFlagType());
|
|
||||||
|
|
||||||
if (propertyInfo.isEnumType()) {
|
|
||||||
QMetaEnum qEnumerator = qProperty.enumerator();
|
|
||||||
EnumeratorMetaInfo enumerator = m_q->addEnumerator(qEnumerator.scope(), qEnumerator.name());
|
|
||||||
|
|
||||||
enumerator.setValid(qEnumerator.isValid());
|
|
||||||
enumerator.setIsFlagType(qEnumerator.isFlag());
|
|
||||||
QString scope = qEnumerator.scope();
|
|
||||||
if (m_QtTypesToQmlTypes.contains(scope))
|
|
||||||
scope = stripPrefix(m_QtTypesToQmlTypes.value(scope));
|
|
||||||
|
|
||||||
enumerator.setScope(scope);
|
|
||||||
enumerator.setName(qEnumerator.name());
|
|
||||||
for (int i = 0 ;i < qEnumerator.keyCount(); i++)
|
|
||||||
{
|
|
||||||
enumerator.addElement(qEnumerator.valueToKey(i), i);
|
|
||||||
}
|
|
||||||
|
|
||||||
propertyInfo.setEnumerator(enumerator);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
nodeMetaInfo.addProperty(propertyInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MetaInfoPrivate::parseClassInfo(NodeMetaInfo &nodeMetaInfo, const QMetaObject *qMetaObject) const
|
|
||||||
{
|
|
||||||
Q_ASSERT_X(qMetaObject, Q_FUNC_INFO, "invalid QMetaObject");
|
|
||||||
Q_ASSERT_X(nodeMetaInfo.isValid(), Q_FUNC_INFO, "invalid NodeMetaInfo");
|
|
||||||
for (int index = qMetaObject->classInfoCount() - 1 ; index >= 0 ; --index) {
|
|
||||||
QMetaClassInfo classInfo = qMetaObject->classInfo(index);
|
|
||||||
if (QLatin1String(classInfo.name()) == QLatin1String("DefaultProperty")) {
|
|
||||||
nodeMetaInfo.setDefaultProperty(classInfo.value());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MetaInfoPrivate::parseNonQmlClassRecursively(const QMetaObject *qMetaObject)
|
|
||||||
{
|
|
||||||
Q_ASSERT_X(qMetaObject, Q_FUNC_INFO, "invalid QMetaObject");
|
|
||||||
|
|
||||||
QString typeName;
|
|
||||||
int majorVersion = -1;
|
|
||||||
int minorVersion = -1;
|
|
||||||
typeInfo(qMetaObject, &typeName, &majorVersion, &minorVersion);
|
|
||||||
|
|
||||||
if (typeName.isEmpty()) {
|
|
||||||
qWarning() << "Meta type system: Registered class has no name.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
NodeMetaInfo existingInfo = m_q->nodeMetaInfo(typeName, majorVersion, minorVersion);
|
|
||||||
if (existingInfo.isValid()
|
|
||||||
&& existingInfo.majorVersion() == majorVersion
|
|
||||||
&& existingInfo.minorVersion() == minorVersion) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
NodeMetaInfo nodeMetaInfo(*m_q);
|
|
||||||
nodeMetaInfo.setType(typeName, majorVersion, minorVersion);
|
|
||||||
parseProperties(nodeMetaInfo, qMetaObject);
|
|
||||||
parseClassInfo(nodeMetaInfo, qMetaObject);
|
|
||||||
|
|
||||||
QString superTypeName;
|
|
||||||
int superTypeMajorVersion = -1;
|
|
||||||
int superTypeMinorVersion = -1;
|
|
||||||
|
|
||||||
if (qMetaObject->superClass()) {
|
|
||||||
typeInfo(qMetaObject->superClass(), &superTypeName, &superTypeMajorVersion, &superTypeMinorVersion);
|
|
||||||
nodeMetaInfo.setSuperClass(superTypeName, superTypeMajorVersion, superTypeMinorVersion);
|
|
||||||
}
|
|
||||||
if (debug)
|
|
||||||
qDebug() << "adding non qml type" << nodeMetaInfo.typeName() << nodeMetaInfo.majorVersion() << nodeMetaInfo.minorVersion()
|
|
||||||
<< ", parent type" << superTypeName << superTypeMajorVersion << superTypeMinorVersion;
|
|
||||||
|
|
||||||
m_q->addNodeInfo(nodeMetaInfo);
|
|
||||||
|
|
||||||
if (const QMetaObject *superClass = qMetaObject->superClass())
|
|
||||||
parseNonQmlClassRecursively(superClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<QDeclarativeType*> MetaInfoPrivate::qmlTypes()
|
|
||||||
{
|
|
||||||
QList<QDeclarativeType*> list;
|
|
||||||
foreach (QDeclarativeType *type, QDeclarativeMetaType::qmlTypes()) {
|
|
||||||
if (!type->qmlTypeName().startsWith("Bauhaus/")
|
|
||||||
&& !type->qmlTypeName().startsWith("QmlProject/"))
|
|
||||||
list += type;
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline bool isDepricatedQtType(const QString &typeName)
|
static inline bool isDepricatedQtType(const QString &typeName)
|
||||||
{
|
{
|
||||||
if (typeName.length() < 8)
|
if (typeName.length() < 8)
|
||||||
@@ -285,158 +108,6 @@ static inline bool isDepricatedQtType(const QString &typeName)
|
|||||||
return typeName.contains("QtQuick/");
|
return typeName.contains("QtQuick/");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetaInfoPrivate::typeInfo(const QMetaObject *qMetaObject, QString *typeName, int *majorVersion, int *minorVersion) const
|
|
||||||
{
|
|
||||||
Q_ASSERT(typeName);
|
|
||||||
|
|
||||||
if (!qMetaObject)
|
|
||||||
return;
|
|
||||||
|
|
||||||
*typeName = qMetaObject->className();
|
|
||||||
int majVersion = -1;
|
|
||||||
int minVersion = -1;
|
|
||||||
QDeclarativeType *qmlType = QDeclarativeMetaType::qmlType(qMetaObject);
|
|
||||||
if (qmlType) {
|
|
||||||
if (!qmlType->qmlTypeName().isEmpty()) {
|
|
||||||
*typeName = qmlType->qmlTypeName();
|
|
||||||
majVersion = qmlType->majorVersion();
|
|
||||||
minVersion = qmlType->minorVersion();
|
|
||||||
}
|
|
||||||
if (isDepricatedQtType(qmlType->qmlTypeName())) { //### todo there has to be an alternative
|
|
||||||
QString properTypeName = qmlType->qmlTypeName();
|
|
||||||
properTypeName.replace("QtQuick/", "Qt/");
|
|
||||||
*typeName = properTypeName;
|
|
||||||
majVersion = 1;
|
|
||||||
minVersion = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (majorVersion)
|
|
||||||
*majorVersion = majVersion;
|
|
||||||
if (minorVersion)
|
|
||||||
*minorVersion = minVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MetaInfoPrivate::parseValueTypes()
|
|
||||||
{
|
|
||||||
QStringList valueTypes;
|
|
||||||
//there is no global list of all supported value types
|
|
||||||
valueTypes << "QFont"
|
|
||||||
<< "QPoint"
|
|
||||||
<< "QPointF"
|
|
||||||
<< "QRect"
|
|
||||||
<< "QRectF"
|
|
||||||
<< "QSize"
|
|
||||||
<< "QSizeF"
|
|
||||||
<< "QVector3D"
|
|
||||||
<< "QEasingCurve";
|
|
||||||
|
|
||||||
foreach (const QString &type, valueTypes) {
|
|
||||||
NodeMetaInfo nodeMetaInfo(*m_q);
|
|
||||||
nodeMetaInfo.setType(type, -1, -1);
|
|
||||||
foreach (const QString &propertyName, VariantParser::create(type).properties()) {
|
|
||||||
PropertyMetaInfo propertyInfo;
|
|
||||||
propertyInfo.setName(propertyName);
|
|
||||||
propertyInfo.setType("real");
|
|
||||||
if (type == ("QFont")) {
|
|
||||||
if (propertyName == "bold")
|
|
||||||
propertyInfo.setType("bool");
|
|
||||||
else if (propertyName == "italic")
|
|
||||||
propertyInfo.setType("bool");
|
|
||||||
else if (propertyName == "underline")
|
|
||||||
propertyInfo.setType("bool");
|
|
||||||
else if (propertyName == "strikeout")
|
|
||||||
propertyInfo.setType("bool");
|
|
||||||
else if (propertyName == "family")
|
|
||||||
propertyInfo.setType("string");
|
|
||||||
else if (propertyName == "pixelSize")
|
|
||||||
propertyInfo.setType("int");
|
|
||||||
} else if (type == ("QPoint")) {
|
|
||||||
propertyInfo.setType("int");
|
|
||||||
} else if (type == ("QSize")) {
|
|
||||||
propertyInfo.setType("int");
|
|
||||||
} else if (type == ("QRect")) {
|
|
||||||
propertyInfo.setType("int");
|
|
||||||
} else if (type == ("QEasingCurve")) {
|
|
||||||
if (propertyName == "type") {
|
|
||||||
propertyInfo.setEnumType("true");
|
|
||||||
propertyInfo.setType("QEasingCurve::Type");
|
|
||||||
propertyInfo.setEnumerator(m_q->enumerator("QEasingCurve::Type"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
propertyInfo.setValid(true);
|
|
||||||
propertyInfo.setReadable(true);
|
|
||||||
propertyInfo.setWritable(true);
|
|
||||||
nodeMetaInfo.addProperty(propertyInfo);
|
|
||||||
}
|
|
||||||
if (debug)
|
|
||||||
qDebug() << "adding value type" << nodeMetaInfo.typeName();
|
|
||||||
m_q->addNodeInfo(nodeMetaInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MetaInfoPrivate::parseQmlTypes()
|
|
||||||
{
|
|
||||||
foreach (QDeclarativeType *qmlType, qmlTypes()) {
|
|
||||||
const QString qtTypeName(qmlType->typeName());
|
|
||||||
const QString qmlTypeName(qmlType->qmlTypeName());
|
|
||||||
|
|
||||||
if (!isDepricatedQtType(qmlType->qmlTypeName()))
|
|
||||||
m_QtTypesToQmlTypes.insert(qtTypeName, qmlTypeName);
|
|
||||||
}
|
|
||||||
foreach (QDeclarativeType *qmlType, qmlTypes()) {
|
|
||||||
const QMetaObject *qMetaObject = qmlType->metaObject();
|
|
||||||
|
|
||||||
// parseQmlTypes is called iteratively e.g. when plugins are loaded
|
|
||||||
if (m_q->hasNodeMetaInfo(qmlType->qmlTypeName(), qmlType->majorVersion(), qmlType->minorVersion()))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// we ignore the deprecated Qt/ namespace
|
|
||||||
if (isDepricatedQtType(qmlType->qmlTypeName()))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
NodeMetaInfo nodeMetaInfo(*m_q);
|
|
||||||
nodeMetaInfo.setType(qmlType->qmlTypeName(), qmlType->majorVersion(), qmlType->minorVersion());
|
|
||||||
|
|
||||||
parseProperties(nodeMetaInfo, qMetaObject);
|
|
||||||
if (qmlType->baseMetaObject() != qMetaObject) {
|
|
||||||
// type is declared with Q_DECLARE_EXTENDED_TYPE
|
|
||||||
parseProperties(nodeMetaInfo, qmlType->baseMetaObject());
|
|
||||||
}
|
|
||||||
|
|
||||||
parseClassInfo(nodeMetaInfo, qMetaObject);
|
|
||||||
|
|
||||||
QString superTypeName;
|
|
||||||
int superTypeMajorVersion = -1;
|
|
||||||
int superTypeMinorVersion = -1;
|
|
||||||
if (const QMetaObject *superClassObject = qmlType->baseMetaObject()->superClass())
|
|
||||||
typeInfo(superClassObject, &superTypeName, &superTypeMajorVersion, &superTypeMinorVersion);
|
|
||||||
|
|
||||||
if (!superTypeName.isEmpty())
|
|
||||||
nodeMetaInfo.setSuperClass(superTypeName, superTypeMajorVersion, superTypeMinorVersion);
|
|
||||||
|
|
||||||
if (debug) {
|
|
||||||
qDebug() << "adding qml type" << nodeMetaInfo.typeName() << nodeMetaInfo.majorVersion() << nodeMetaInfo.minorVersion()
|
|
||||||
<< ", super class" << superTypeName << superTypeMajorVersion << superTypeMinorVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_q->addNodeInfo(nodeMetaInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MetaInfoPrivate::parseNonQmlTypes()
|
|
||||||
{
|
|
||||||
foreach (QDeclarativeType *qmlType, qmlTypes()) {
|
|
||||||
if (qmlType->qmlTypeName().startsWith("Bauhaus/")
|
|
||||||
|| qmlType->qmlTypeName().startsWith("QmlProject/"))
|
|
||||||
continue;
|
|
||||||
if (qmlType->metaObject()->superClass())
|
|
||||||
parseNonQmlClassRecursively(qmlType->metaObject()->superClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
parseNonQmlClassRecursively(&QDeclarativeAnchors::staticMetaObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MetaInfoPrivate::parseXmlFiles()
|
void MetaInfoPrivate::parseXmlFiles()
|
||||||
{
|
{
|
||||||
Internal::WidgetPluginManager pluginManager;
|
Internal::WidgetPluginManager pluginManager;
|
||||||
@@ -444,7 +115,6 @@ void MetaInfoPrivate::parseXmlFiles()
|
|||||||
pluginManager.addPath(pluginDir);
|
pluginManager.addPath(pluginDir);
|
||||||
QList<IWidgetPlugin *> widgetPluginList = pluginManager.instances();
|
QList<IWidgetPlugin *> widgetPluginList = pluginManager.instances();
|
||||||
foreach (IWidgetPlugin *plugin, widgetPluginList) {
|
foreach (IWidgetPlugin *plugin, widgetPluginList) {
|
||||||
parseQmlTypes();
|
|
||||||
Internal::MetaInfoParser parser(*m_q);
|
Internal::MetaInfoParser parser(*m_q);
|
||||||
parser.parseFile(plugin->metaInfo());
|
parser.parseFile(plugin->metaInfo());
|
||||||
}
|
}
|
||||||
@@ -462,18 +132,6 @@ QStringList MetaInfo::s_pluginDirs;
|
|||||||
\class QmlDesigner::MetaInfo
|
\class QmlDesigner::MetaInfo
|
||||||
\ingroup CoreModel
|
\ingroup CoreModel
|
||||||
\brief The MetaInfo class provides meta information about qml types and properties.
|
\brief The MetaInfo class provides meta information about qml types and properties.
|
||||||
|
|
||||||
The MetaInfo, NodeMetaInfo, PropertyMetaInfo and EnumeratorMetaInfo
|
|
||||||
classes provide information about the (static and dynamic) qml types available in
|
|
||||||
a specific model. Just like their Model, ModelNode and AbstractProperty counterparts,
|
|
||||||
objects of these classes are handles - that means, they are implicitly shared, and
|
|
||||||
should be created on the stack.
|
|
||||||
|
|
||||||
The MetaInfo object should always be accessed via the model (see Model::metaInfo()).
|
|
||||||
Otherwise types specific to a model (like sub components) might
|
|
||||||
be missed.
|
|
||||||
|
|
||||||
\see Model::metaInfo(), QmlDesigner::NodeMetaInfo, QmlDesigner::PropertyMetaInfo, QmlDesigner::EnumeratorMetaInfo
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -510,75 +168,6 @@ MetaInfo& MetaInfo::operator=(const MetaInfo &other)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Returns whether a type with the given name is registered in the meta system.
|
|
||||||
*/
|
|
||||||
bool MetaInfo::hasNodeMetaInfo(const QString &typeName, int majorVersion, int minorVersion) const
|
|
||||||
{
|
|
||||||
foreach (const NodeMetaInfo &info, m_p->m_nodeMetaInfoHash.values(typeName)) {
|
|
||||||
if (info.availableInVersion(majorVersion, minorVersion)) { {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!isGlobal())
|
|
||||||
return global().hasNodeMetaInfo(typeName);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Returns meta information for a qml type. An invalid NodeMetaInfo object if the type is unknown.
|
|
||||||
*/
|
|
||||||
NodeMetaInfo MetaInfo::nodeMetaInfo(const QString &typeName, int majorVersion, int minorVersion) const
|
|
||||||
{
|
|
||||||
NodeMetaInfo returnInfo;
|
|
||||||
foreach (const NodeMetaInfo &info, m_p->m_nodeMetaInfoHash.values(typeName)) {
|
|
||||||
if (info.availableInVersion(majorVersion, minorVersion)) {
|
|
||||||
if (!returnInfo.isValid()
|
|
||||||
|| returnInfo.majorVersion() < info.majorVersion()
|
|
||||||
|| (returnInfo.majorVersion() == info.minorVersion()
|
|
||||||
&& returnInfo.minorVersion() < info.minorVersion()))
|
|
||||||
returnInfo = info;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!returnInfo.isValid()
|
|
||||||
&& !isGlobal())
|
|
||||||
return global().nodeMetaInfo(typeName);
|
|
||||||
|
|
||||||
return returnInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString MetaInfo::fromQtTypes(const QString &type) const
|
|
||||||
{
|
|
||||||
if (m_p->m_QtTypesToQmlTypes.contains(type))
|
|
||||||
return m_p->m_QtTypesToQmlTypes.value(type);
|
|
||||||
if (!isGlobal())
|
|
||||||
return global().fromQtTypes(type);
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Returns whether an enumerator is registered in the meta type system.
|
|
||||||
*/
|
|
||||||
bool MetaInfo::hasEnumerator(const QString &enumeratorName) const
|
|
||||||
{
|
|
||||||
return m_p->m_enumeratorMetaInfoHash.contains(enumeratorName)
|
|
||||||
|| (!isGlobal() ? global().hasEnumerator(enumeratorName) : false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Returns meta information about an enumerator. An invalid EnumeratorMetaInfo object if the enumerator is not known.
|
|
||||||
*/
|
|
||||||
EnumeratorMetaInfo MetaInfo::enumerator(const QString &enumeratorName) const
|
|
||||||
{
|
|
||||||
if (m_p->m_enumeratorMetaInfoHash.contains(enumeratorName))
|
|
||||||
return m_p->m_enumeratorMetaInfoHash.value(enumeratorName);
|
|
||||||
if (!isGlobal())
|
|
||||||
return global().enumerator(enumeratorName);
|
|
||||||
return EnumeratorMetaInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemLibraryInfo *MetaInfo::itemLibraryInfo() const
|
ItemLibraryInfo *MetaInfo::itemLibraryInfo() const
|
||||||
{
|
{
|
||||||
return m_p->m_itemLibraryInfo.data();
|
return m_p->m_itemLibraryInfo.data();
|
||||||
@@ -617,67 +206,6 @@ void MetaInfo::setPluginPaths(const QStringList &paths)
|
|||||||
s_pluginDirs = paths;
|
s_pluginDirs = paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetaInfo::addNodeInfo(NodeMetaInfo &nodeInfo)
|
|
||||||
{
|
|
||||||
if (nodeInfo.typeName().isEmpty() || nodeInfo.metaInfo() != *this)
|
|
||||||
throw new InvalidArgumentException(__LINE__, __FUNCTION__, __FILE__, QLatin1String("nodeInfo"));
|
|
||||||
|
|
||||||
|
|
||||||
m_p->m_nodeMetaInfoHash.insertMulti(nodeInfo.typeName(), nodeInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MetaInfo::removeNodeInfo(NodeMetaInfo &info)
|
|
||||||
{
|
|
||||||
if (!info.isValid()) {
|
|
||||||
qWarning() << "NodeMetaInfo is invalid";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_p->m_nodeMetaInfoHash.contains(info.typeName())
|
|
||||||
&& m_p->m_nodeMetaInfoHash.remove(info.typeName(), info)) {
|
|
||||||
|
|
||||||
foreach (const ItemLibraryEntry &entry,
|
|
||||||
m_p->m_itemLibraryInfo->entriesForType(info.typeName(), info.majorVersion(), info.minorVersion())) {
|
|
||||||
m_p->m_itemLibraryInfo->removeEntry(entry.name());
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (!isGlobal()) {
|
|
||||||
global().removeNodeInfo(info);
|
|
||||||
} else {
|
|
||||||
Q_ASSERT_X(0, Q_FUNC_INFO, "Node meta info not in db");
|
|
||||||
}
|
|
||||||
|
|
||||||
info.setInvalid();
|
|
||||||
}
|
|
||||||
|
|
||||||
EnumeratorMetaInfo MetaInfo::addEnumerator(const QString &enumeratorScope, const QString &enumeratorName)
|
|
||||||
{
|
|
||||||
Q_ASSERT(!enumeratorName.isEmpty());
|
|
||||||
|
|
||||||
EnumeratorMetaInfo enumeratorMetaInfo;
|
|
||||||
enumeratorMetaInfo.setName(enumeratorName);
|
|
||||||
enumeratorMetaInfo.setScope(enumeratorScope);
|
|
||||||
enumeratorMetaInfo.setIsFlagType(false);
|
|
||||||
enumeratorMetaInfo.setValid(true);
|
|
||||||
|
|
||||||
m_p->m_enumeratorMetaInfoHash.insert(enumeratorMetaInfo.scopeAndName(), enumeratorMetaInfo);
|
|
||||||
|
|
||||||
return enumeratorMetaInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
EnumeratorMetaInfo MetaInfo::addFlag(const QString &enumeratorScope, const QString &enumeratorName)
|
|
||||||
{
|
|
||||||
Q_ASSERT(!enumeratorName.isEmpty());
|
|
||||||
|
|
||||||
EnumeratorMetaInfo enumeratorMetaInfo;
|
|
||||||
enumeratorMetaInfo.setName(enumeratorName);
|
|
||||||
enumeratorMetaInfo.setScope(enumeratorScope);
|
|
||||||
enumeratorMetaInfo.setIsFlagType(true);
|
|
||||||
m_p->m_enumeratorMetaInfoHash.insert(enumeratorMetaInfo.scopeAndName(), enumeratorMetaInfo);
|
|
||||||
|
|
||||||
return enumeratorMetaInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MetaInfo::isGlobal() const
|
bool MetaInfo::isGlobal() const
|
||||||
{
|
{
|
||||||
return (this->m_p == s_global.m_p);
|
return (this->m_p == s_global.m_p);
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
#include "metainfoparser.h"
|
#include "metainfoparser.h"
|
||||||
#include "metainfo.h"
|
#include "metainfo.h"
|
||||||
|
|
||||||
#include "propertymetainfo.h"
|
|
||||||
#include "model/propertyparser.h"
|
#include "model/propertyparser.h"
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,443 +0,0 @@
|
|||||||
/**************************************************************************
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator
|
|
||||||
**
|
|
||||||
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
||||||
**
|
|
||||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
||||||
**
|
|
||||||
** Commercial Usage
|
|
||||||
**
|
|
||||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
||||||
** accordance with the Qt Commercial License Agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Nokia.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
**
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
||||||
** General Public License version 2.1 as published by the Free Software
|
|
||||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
||||||
** packaging of this file. Please review the following information to
|
|
||||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
||||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
||||||
**
|
|
||||||
** If you are unsure which license is appropriate for your use, please
|
|
||||||
** contact the sales department at http://qt.nokia.com/contact.
|
|
||||||
**
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
#include "propertymetainfo.h"
|
|
||||||
|
|
||||||
#include <QSharedData>
|
|
||||||
|
|
||||||
#include "invalidmetainfoexception.h"
|
|
||||||
#include "metainfo.h"
|
|
||||||
#include "modelnode.h"
|
|
||||||
|
|
||||||
#include <private/qdeclarativevaluetype_p.h>
|
|
||||||
#include <private/qdeclarativestringconverters_p.h>
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
|
||||||
|
|
||||||
namespace Internal
|
|
||||||
{
|
|
||||||
|
|
||||||
class PropertyMetaInfoData : public QSharedData
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PropertyMetaInfoData()
|
|
||||||
: QSharedData(),
|
|
||||||
isValid(false),
|
|
||||||
readable(false),
|
|
||||||
writeable(false),
|
|
||||||
resettable(false),
|
|
||||||
enumType(false),
|
|
||||||
flagType(false),
|
|
||||||
isVisible(false)
|
|
||||||
{}
|
|
||||||
|
|
||||||
EnumeratorMetaInfo enumerator;
|
|
||||||
|
|
||||||
QString name;
|
|
||||||
QString type;
|
|
||||||
bool isValid;
|
|
||||||
|
|
||||||
bool readable;
|
|
||||||
bool writeable;
|
|
||||||
bool resettable;
|
|
||||||
|
|
||||||
bool enumType;
|
|
||||||
bool flagType;
|
|
||||||
bool isVisible;
|
|
||||||
|
|
||||||
QHash<QString, QVariant> defaultValueHash;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\class QmlDesigner::PropertyMetaInfo
|
|
||||||
\ingroup CoreModel
|
|
||||||
\brief The PropertyMetaInfo class provides meta information about a qml type property.
|
|
||||||
|
|
||||||
A PropertyMetaInfo object can be NodeMetaInfo, or AbstractProperty::metaInfo.
|
|
||||||
|
|
||||||
The object can be invalid - you can check this by calling isValid().
|
|
||||||
The object is invalid if you ask for meta information for
|
|
||||||
an non-existing qml type. Also the node meta info can become invalid
|
|
||||||
if the type is deregistered from the meta type system (e.g.
|
|
||||||
a sub component qml file is deleted). Trying to call any accessor methods on an invalid
|
|
||||||
PropertyMetaInfo object will result in an InvalidMetaInfoException being thrown.
|
|
||||||
|
|
||||||
|
|
||||||
\see QmlDesigner::MetaInfo, QmlDesigner::NodeMetaInfo, QmlDesigner::EnumeratorMetaInfo
|
|
||||||
*/
|
|
||||||
|
|
||||||
PropertyMetaInfo::PropertyMetaInfo()
|
|
||||||
: m_data(new Internal::PropertyMetaInfoData)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
PropertyMetaInfo::~PropertyMetaInfo()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Creates a copy of the handle.
|
|
||||||
*/
|
|
||||||
PropertyMetaInfo::PropertyMetaInfo(const PropertyMetaInfo &other)
|
|
||||||
: m_data(other.m_data)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Copies the handle.
|
|
||||||
*/
|
|
||||||
PropertyMetaInfo &PropertyMetaInfo::operator=(const PropertyMetaInfo &other)
|
|
||||||
{
|
|
||||||
if (this != &other)
|
|
||||||
m_data = other.m_data;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Returns whether the meta information system knows about this property.
|
|
||||||
*/
|
|
||||||
bool PropertyMetaInfo::isValid() const
|
|
||||||
{
|
|
||||||
return m_data->isValid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Returns the name of the property.
|
|
||||||
*/
|
|
||||||
QString PropertyMetaInfo::name() const
|
|
||||||
{
|
|
||||||
if (!isValid()) {
|
|
||||||
Q_ASSERT_X(isValid(), Q_FUNC_INFO, "");
|
|
||||||
throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__);
|
|
||||||
}
|
|
||||||
return m_data->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Returns the type name of the property.
|
|
||||||
*/
|
|
||||||
QString PropertyMetaInfo::type() const
|
|
||||||
{
|
|
||||||
if (!isValid()) {
|
|
||||||
Q_ASSERT_X(isValid(), Q_FUNC_INFO, "");
|
|
||||||
throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__);
|
|
||||||
}
|
|
||||||
return m_data->type;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PropertyMetaInfo::isVisibleToPropertyEditor() const
|
|
||||||
{
|
|
||||||
if (!isValid()) {
|
|
||||||
Q_ASSERT_X(isValid(), Q_FUNC_INFO, "");
|
|
||||||
throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__);
|
|
||||||
}
|
|
||||||
return m_data->isVisible;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PropertyMetaInfo::setIsVisibleToPropertyEditor(bool isVisible)
|
|
||||||
{
|
|
||||||
m_data->isVisible = isVisible;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Returns the QVariant type of the property.
|
|
||||||
*/
|
|
||||||
QVariant::Type PropertyMetaInfo::variantTypeId() const
|
|
||||||
{
|
|
||||||
if (!isValid()) {
|
|
||||||
Q_ASSERT_X(isValid(), Q_FUNC_INFO, "");
|
|
||||||
throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__);
|
|
||||||
}
|
|
||||||
Q_ASSERT(!m_data->type.isEmpty());
|
|
||||||
|
|
||||||
if (m_data->type == "string")
|
|
||||||
return QVariant::String;
|
|
||||||
|
|
||||||
if (m_data->type == "color")
|
|
||||||
return QVariant::Color;
|
|
||||||
|
|
||||||
if (m_data->type == "int")
|
|
||||||
return QVariant::Int;
|
|
||||||
|
|
||||||
if (m_data->type == "url")
|
|
||||||
return QVariant::Url;
|
|
||||||
|
|
||||||
if (m_data->type == "real")
|
|
||||||
return QVariant::Double;
|
|
||||||
|
|
||||||
if (m_data->type == "bool")
|
|
||||||
return QVariant::Bool;
|
|
||||||
|
|
||||||
if (m_data->type == "date")
|
|
||||||
return QVariant::Date;
|
|
||||||
|
|
||||||
if (m_data->type == "alias")
|
|
||||||
return QVariant::UserType;
|
|
||||||
|
|
||||||
if (m_data->type == "var")
|
|
||||||
return QVariant::UserType;
|
|
||||||
|
|
||||||
|
|
||||||
return QVariant::nameToType(m_data->type.toLatin1().data());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Returns whether the propery is readable.
|
|
||||||
*/
|
|
||||||
bool PropertyMetaInfo::isReadable() const
|
|
||||||
{
|
|
||||||
if (!isValid()) {
|
|
||||||
Q_ASSERT_X(isValid(), Q_FUNC_INFO, "");
|
|
||||||
throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__);
|
|
||||||
}
|
|
||||||
return m_data->readable;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Returns whether the propery is writeable.
|
|
||||||
*/
|
|
||||||
bool PropertyMetaInfo::isWriteable() const
|
|
||||||
{
|
|
||||||
if (!isValid()) {
|
|
||||||
Q_ASSERT_X(isValid(), Q_FUNC_INFO, "");
|
|
||||||
throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__);
|
|
||||||
}
|
|
||||||
return m_data->writeable;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Returns whether the propery is resettable.
|
|
||||||
*/
|
|
||||||
bool PropertyMetaInfo::isResettable() const
|
|
||||||
{
|
|
||||||
if (!isValid()) {
|
|
||||||
Q_ASSERT_X(isValid(), Q_FUNC_INFO, "");
|
|
||||||
throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__);
|
|
||||||
}
|
|
||||||
return m_data->resettable;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Returns whether the propery is complex value type.
|
|
||||||
*/
|
|
||||||
bool PropertyMetaInfo::isValueType() const
|
|
||||||
{
|
|
||||||
if (!isValid()) {
|
|
||||||
Q_ASSERT_X(isValid(), Q_FUNC_INFO, "");
|
|
||||||
throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__);
|
|
||||||
}
|
|
||||||
|
|
||||||
QScopedPointer<QDeclarativeValueType> valueType(QDeclarativeValueTypeFactory::valueType(variantTypeId()));
|
|
||||||
return valueType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Returns whether the propery is a QDeclarativeList.
|
|
||||||
*/
|
|
||||||
bool PropertyMetaInfo::isListProperty() const
|
|
||||||
{
|
|
||||||
if (!isValid()) {
|
|
||||||
Q_ASSERT_X(isValid(), Q_FUNC_INFO, "");
|
|
||||||
throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__);
|
|
||||||
}
|
|
||||||
|
|
||||||
return type().contains("QDeclarativeList") ||
|
|
||||||
type().contains("alias"); //### this is a nasty hack - we have to get instances in to resolve this properly
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Returns whether the propery has sub properties with "." syntax e.g. font
|
|
||||||
*/
|
|
||||||
bool PropertyMetaInfo::hasDotSubProperties() const
|
|
||||||
{
|
|
||||||
if (!isValid()) {
|
|
||||||
Q_ASSERT_X(isValid(), Q_FUNC_INFO, "");
|
|
||||||
throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__);
|
|
||||||
}
|
|
||||||
|
|
||||||
return isValueType() || !isWriteable();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Returns whether the propery stores an enum value.
|
|
||||||
*/
|
|
||||||
bool PropertyMetaInfo::isEnumType() const
|
|
||||||
{
|
|
||||||
if (!isValid()) {
|
|
||||||
Q_ASSERT_X(isValid(), Q_FUNC_INFO, "");
|
|
||||||
throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__);
|
|
||||||
}
|
|
||||||
return m_data->enumType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Returns whether the propery stores a flag value.
|
|
||||||
*/
|
|
||||||
bool PropertyMetaInfo::isFlagType() const
|
|
||||||
{
|
|
||||||
if (!isValid()) {
|
|
||||||
Q_ASSERT_X(isValid(), Q_FUNC_INFO, "");
|
|
||||||
throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__);
|
|
||||||
}
|
|
||||||
return m_data->flagType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Returns a default value if there is one specified, an invalid QVariant otherwise.
|
|
||||||
*/
|
|
||||||
QVariant PropertyMetaInfo::defaultValue(const NodeMetaInfo &nodeMetaInfoArg) const
|
|
||||||
{
|
|
||||||
if (!isValid()) {
|
|
||||||
Q_ASSERT_X(isValid(), Q_FUNC_INFO, "");
|
|
||||||
throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__);
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<NodeMetaInfo> nodeMetaInfoList(nodeMetaInfoArg.superClasses());
|
|
||||||
nodeMetaInfoList.prepend(nodeMetaInfoArg);
|
|
||||||
foreach (const NodeMetaInfo &nodeMetaInfo, nodeMetaInfoList) {
|
|
||||||
if (m_data->defaultValueHash.contains(nodeMetaInfo.typeName()))
|
|
||||||
return m_data->defaultValueHash.value(nodeMetaInfo.typeName());
|
|
||||||
}
|
|
||||||
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PropertyMetaInfo::setName(const QString &name)
|
|
||||||
{
|
|
||||||
m_data->name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PropertyMetaInfo::setType(const QString &type)
|
|
||||||
{
|
|
||||||
m_data->type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PropertyMetaInfo::setValid(bool isValid)
|
|
||||||
{
|
|
||||||
m_data->isValid = isValid;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PropertyMetaInfo::setReadable(bool isReadable)
|
|
||||||
{
|
|
||||||
m_data->readable = isReadable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PropertyMetaInfo::setWritable(bool isWritable)
|
|
||||||
{
|
|
||||||
m_data->writeable = isWritable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PropertyMetaInfo::setResettable(bool isRessetable)
|
|
||||||
{
|
|
||||||
m_data->resettable = isRessetable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PropertyMetaInfo::setEnumType(bool isEnumType)
|
|
||||||
{
|
|
||||||
m_data->enumType = isEnumType;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PropertyMetaInfo::setFlagType(bool isFlagType)
|
|
||||||
{
|
|
||||||
m_data->flagType = isFlagType;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PropertyMetaInfo::setDefaultValue(const NodeMetaInfo &nodeMetaInfo, const QVariant &value)
|
|
||||||
{
|
|
||||||
m_data->defaultValueHash.insert(nodeMetaInfo.typeName(), value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PropertyMetaInfo::setEnumerator(const EnumeratorMetaInfo &info)
|
|
||||||
{
|
|
||||||
m_data->enumerator = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Returns meta information about the enumerator type, an invalid EnumeratorMetaInfo object if the property does not store enumerator values.
|
|
||||||
*/
|
|
||||||
const EnumeratorMetaInfo PropertyMetaInfo::enumerator() const
|
|
||||||
{
|
|
||||||
if (!isValid()) {
|
|
||||||
Q_ASSERT_X(isValid(), Q_FUNC_INFO, "");
|
|
||||||
throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__);
|
|
||||||
}
|
|
||||||
return m_data->enumerator;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief cast value type of QVariant parameter
|
|
||||||
|
|
||||||
If the type of the passed variant does not correspond to type(), the method tries to convert
|
|
||||||
the value according to QVariant::convert(). Returns a new QVariant with casted value type
|
|
||||||
if successful, an invalid QVariant otherwise.
|
|
||||||
|
|
||||||
\param variant the QVariant to take the value from
|
|
||||||
\returns QVariant with aligned value type, or invalid QVariant
|
|
||||||
*/
|
|
||||||
QVariant PropertyMetaInfo::castedValue(const QVariant &originalVariant) const
|
|
||||||
{
|
|
||||||
if (!isValid()) {
|
|
||||||
Q_ASSERT_X(isValid(), Q_FUNC_INFO, "");
|
|
||||||
throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__);
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant variant = originalVariant;
|
|
||||||
if (m_data->enumType) {
|
|
||||||
return variant;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant::Type typeId = variantTypeId();
|
|
||||||
|
|
||||||
if (variant.type() == QVariant::UserType && variant.userType() == ModelNode::variantUserType()) {
|
|
||||||
return variant;
|
|
||||||
} else if (typeId == QVariant::UserType && m_data->type == QLatin1String("QVariant")) {
|
|
||||||
return variant;
|
|
||||||
} else if (typeId == QVariant::UserType && m_data->type == QLatin1String("variant")) {
|
|
||||||
return variant;
|
|
||||||
} else if (typeId == QVariant::UserType && m_data->type == QLatin1String("var")) {
|
|
||||||
return variant;
|
|
||||||
} else if (variant.type() == QVariant::List && variant.type() == QVariant::List) {
|
|
||||||
// TODO: check the contents of the list
|
|
||||||
return variant;
|
|
||||||
} else if (type() == "var" || type() == "variant") {
|
|
||||||
return variant;
|
|
||||||
} else if (type() == "alias") {
|
|
||||||
// TODO: The QML compiler resolves the alias type. We probably should do the same.
|
|
||||||
return variant;
|
|
||||||
} else if (variant.convert(typeId)) {
|
|
||||||
return variant;
|
|
||||||
}
|
|
||||||
|
|
||||||
return QDeclarativeStringConverters::variantFromString(variant.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -319,11 +319,6 @@ void SubComponentManagerPrivate::unregisterQmlFile(const QFileInfo &fileInfo, co
|
|||||||
QString componentName = fileInfo.baseName();
|
QString componentName = fileInfo.baseName();
|
||||||
if (!qualifier.isEmpty())
|
if (!qualifier.isEmpty())
|
||||||
componentName = qualifier + '/' + componentName;
|
componentName = qualifier + '/' + componentName;
|
||||||
|
|
||||||
if (m_metaInfo.hasNodeMetaInfo(componentName)) {
|
|
||||||
NodeMetaInfo nodeInfo = m_metaInfo.nodeMetaInfo(componentName);
|
|
||||||
m_metaInfo.removeNodeInfo(nodeInfo);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool isDepricatedQtType(const QString &typeName)
|
static inline bool isDepricatedQtType(const QString &typeName)
|
||||||
@@ -336,7 +331,7 @@ static inline bool isDepricatedQtType(const QString &typeName)
|
|||||||
|
|
||||||
|
|
||||||
void SubComponentManagerPrivate::registerQmlFile(const QFileInfo &fileInfo, const QString &qualifier,
|
void SubComponentManagerPrivate::registerQmlFile(const QFileInfo &fileInfo, const QString &qualifier,
|
||||||
const QDeclarativeDomDocument &document, bool addToLibrary)
|
const QDeclarativeDomDocument &, bool addToLibrary)
|
||||||
{
|
{
|
||||||
QString componentName = fileInfo.baseName();
|
QString componentName = fileInfo.baseName();
|
||||||
|
|
||||||
@@ -350,66 +345,14 @@ void SubComponentManagerPrivate::registerQmlFile(const QFileInfo &fileInfo, cons
|
|||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << "SubComponentManager" << __FUNCTION__ << componentName;
|
qDebug() << "SubComponentManager" << __FUNCTION__ << componentName;
|
||||||
|
|
||||||
if (m_metaInfo.hasNodeMetaInfo(componentName) && addToLibrary) {
|
|
||||||
NodeMetaInfo nodeInfo = m_metaInfo.nodeMetaInfo(componentName);
|
|
||||||
m_metaInfo.removeNodeInfo(nodeInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
const QDeclarativeDomObject rootObject = document.rootObject();
|
|
||||||
|
|
||||||
NodeMetaInfo nodeInfo(m_metaInfo);
|
|
||||||
nodeInfo.setType(componentName, -1, -1);
|
|
||||||
nodeInfo.setQmlFile(fileInfo.filePath());
|
|
||||||
if (!isDepricatedQtType(rootObject.objectType())) {
|
|
||||||
nodeInfo.setSuperClass(rootObject.objectType(),
|
|
||||||
rootObject.objectTypeMajorVersion(),
|
|
||||||
rootObject.objectTypeMinorVersion());
|
|
||||||
} else {
|
|
||||||
QString properClassName = rootObject.objectType();
|
|
||||||
properClassName.replace("QtQuick/", "Qt/");
|
|
||||||
nodeInfo.setSuperClass(properClassName,
|
|
||||||
1,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addToLibrary) {
|
if (addToLibrary) {
|
||||||
// Add file components to the library
|
// Add file components to the library
|
||||||
ItemLibraryEntry itemLibraryEntry;
|
ItemLibraryEntry itemLibraryEntry;
|
||||||
itemLibraryEntry.setType(nodeInfo.typeName(), nodeInfo.majorVersion(), nodeInfo.minorVersion());
|
itemLibraryEntry.setType(componentName, -1, -1);
|
||||||
itemLibraryEntry.setName(componentName);
|
itemLibraryEntry.setName(componentName);
|
||||||
itemLibraryEntry.setCategory(tr("QML Components"));
|
itemLibraryEntry.setCategory(tr("QML Components"));
|
||||||
m_metaInfo.itemLibraryInfo()->addEntry(itemLibraryEntry);
|
m_metaInfo.itemLibraryInfo()->addEntry(itemLibraryEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_metaInfo.addNodeInfo(nodeInfo);
|
|
||||||
|
|
||||||
//document.rootObject().d
|
|
||||||
|
|
||||||
foreach (const QDeclarativeDomDynamicProperty &dynamicProperty, document.rootObject().dynamicProperties()) {
|
|
||||||
Q_ASSERT(!dynamicProperty.propertyName().isEmpty());
|
|
||||||
Q_ASSERT(!dynamicProperty.propertyTypeName().isEmpty());
|
|
||||||
|
|
||||||
if (dynamicProperty.isDefaultProperty())
|
|
||||||
nodeInfo.setDefaultProperty(dynamicProperty.propertyName());
|
|
||||||
|
|
||||||
PropertyMetaInfo propertyMetaInfo;
|
|
||||||
propertyMetaInfo.setName(dynamicProperty.propertyName());
|
|
||||||
propertyMetaInfo.setType(dynamicProperty.propertyTypeName());
|
|
||||||
propertyMetaInfo.setValid(true);
|
|
||||||
propertyMetaInfo.setReadable(true);
|
|
||||||
propertyMetaInfo.setWritable(true);
|
|
||||||
|
|
||||||
QDeclarativeDomProperty defaultValue = dynamicProperty.defaultValue();
|
|
||||||
if (defaultValue.value().isLiteral()) {
|
|
||||||
QVariant defaultValueVariant(defaultValue.value().toLiteral().literal());
|
|
||||||
defaultValueVariant.convert((QVariant::Type) dynamicProperty.propertyType());
|
|
||||||
propertyMetaInfo.setDefaultValue(nodeInfo, defaultValueVariant);
|
|
||||||
}
|
|
||||||
|
|
||||||
nodeInfo.addProperty(propertyMetaInfo);
|
|
||||||
}
|
|
||||||
if (!nodeInfo.hasDefaultProperty())
|
|
||||||
nodeInfo.setDefaultProperty(nodeInfo.directSuperClass().defaultProperty());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -224,21 +224,12 @@ QmlObjectNode AbstractProperty::parentQmlObjectNode() const
|
|||||||
{
|
{
|
||||||
return QmlObjectNode(parentModelNode());
|
return QmlObjectNode(parentModelNode());
|
||||||
}
|
}
|
||||||
/*!
|
|
||||||
\brief returns the metainfo instance for this property
|
|
||||||
\return metainfo instance for this property
|
|
||||||
*/
|
|
||||||
PropertyMetaInfo AbstractProperty::metaInfo() const
|
|
||||||
{
|
|
||||||
return ModelNode(m_internalNode, m_model.data(), view()).metaInfo().property(m_propertyName, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief returns whether the property is the default property for the model node.
|
\brief returns whether the property is the default property for the model node.
|
||||||
*/
|
*/
|
||||||
bool AbstractProperty::isDefaultProperty() const
|
bool AbstractProperty::isDefaultProperty() const
|
||||||
{
|
{
|
||||||
return ModelNode(m_internalNode, m_model.data(), view()).metaInfo().defaultProperty() == m_propertyName;
|
return ModelNode(m_internalNode, m_model.data(), view()).metaInfo().defaultPropertyName() == m_propertyName;
|
||||||
}
|
}
|
||||||
|
|
||||||
VariantProperty AbstractProperty::toVariantProperty() const
|
VariantProperty AbstractProperty::toVariantProperty() const
|
||||||
|
|||||||
@@ -32,7 +32,6 @@
|
|||||||
#include "internalvariantproperty.h"
|
#include "internalvariantproperty.h"
|
||||||
#include "internalnodelistproperty.h"
|
#include "internalnodelistproperty.h"
|
||||||
#include "internalnodeproperty.h"
|
#include "internalnodeproperty.h"
|
||||||
#include "propertyparser.h"
|
|
||||||
#include "internalnode_p.h"
|
#include "internalnode_p.h"
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
#include "abstractview.h"
|
#include "abstractview.h"
|
||||||
#include "nodeinstanceview.h"
|
#include "nodeinstanceview.h"
|
||||||
#include "metainfo.h"
|
#include "metainfo.h"
|
||||||
|
#include "nodemetainfo.h"
|
||||||
#include "model_p.h"
|
#include "model_p.h"
|
||||||
#include "subcomponentmanager.h"
|
#include "subcomponentmanager.h"
|
||||||
#include "variantparser.h"
|
#include "variantparser.h"
|
||||||
@@ -1374,6 +1375,11 @@ void Model::removeImport(const Import &import)
|
|||||||
m_d->removeImport(import);
|
m_d->removeImport(import);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RewriterView *Model::rewriterView() const
|
||||||
|
{
|
||||||
|
return m_d->rewriterView();
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/*!
|
/*!
|
||||||
\brief Creates a new empty model
|
\brief Creates a new empty model
|
||||||
@@ -1424,6 +1430,11 @@ const MetaInfo Model::metaInfo() const
|
|||||||
return m_d->metaInfo();
|
return m_d->metaInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NodeMetaInfo Model::metaInfo(const QString &typeName, int majorVersion, int minorVersion)
|
||||||
|
{
|
||||||
|
return NodeMetaInfo(this, typeName, majorVersion, minorVersion);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets a specific Metainfo on this Model
|
\brief Sets a specific Metainfo on this Model
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -730,16 +730,14 @@ bool ModelNode::hasAnySubModelNodes() const
|
|||||||
return !nodeAbstractProperties().isEmpty();
|
return !nodeAbstractProperties().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief returns the meta info of the node
|
|
||||||
\return meta info of the node
|
|
||||||
*/
|
|
||||||
const NodeMetaInfo ModelNode::metaInfo() const
|
const NodeMetaInfo ModelNode::metaInfo() const
|
||||||
{
|
{
|
||||||
if (!isValid()) {
|
if (!isValid()) {
|
||||||
Q_ASSERT_X(isValid(), Q_FUNC_INFO, "model node is invalid");
|
Q_ASSERT_X(isValid(), Q_FUNC_INFO, "model node is invalid");
|
||||||
throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);
|
throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);
|
||||||
}
|
}
|
||||||
return model()->metaInfo().nodeMetaInfo(type(), majorVersion(), minorVersion());
|
|
||||||
|
return NodeMetaInfo(model(), type(), majorVersion(), minorVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief has a node the selection of the model
|
/*! \brief has a node the selection of the model
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ void NodeAbstractProperty::reparentHere(const ModelNode &modelNode)
|
|||||||
if (internalNode()->hasProperty(name()) && !internalNode()->property(name())->isNodeAbstractProperty())
|
if (internalNode()->hasProperty(name()) && !internalNode()->property(name())->isNodeAbstractProperty())
|
||||||
reparentHere(modelNode, isNodeListProperty());
|
reparentHere(modelNode, isNodeListProperty());
|
||||||
else
|
else
|
||||||
reparentHere(modelNode, metaInfo().isListProperty()); //we could use the metasystem instead?
|
reparentHere(modelNode, parentModelNode().metaInfo().propertyIsListProperty(name())); //we could use the metasystem instead?
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeAbstractProperty::reparentHere(const ModelNode &modelNode, bool isNodeList)
|
void NodeAbstractProperty::reparentHere(const ModelNode &modelNode, bool isNodeList)
|
||||||
|
|||||||
@@ -40,23 +40,16 @@ namespace QmlDesigner {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
namespace PropertyParser {
|
namespace PropertyParser {
|
||||||
|
|
||||||
static QVariant fromEnum(const QString &string, const QString &type, const MetaInfo &metaInfo)
|
static QVariant fromEnum(const QString &string, const QString &, const MetaInfo &)
|
||||||
{
|
{
|
||||||
if (string.isEmpty())
|
if (string.isEmpty())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
// TODO Use model metainfo
|
return QVariant(string);
|
||||||
EnumeratorMetaInfo enumerator = metaInfo.enumerator(type);
|
|
||||||
int value = enumerator.elementValue(string);
|
|
||||||
return QVariant(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant read(const QString &typeStr, const QString &str, const MetaInfo &metaInfo)
|
QVariant read(const QString &typeStr, const QString &str, const MetaInfo &)
|
||||||
{
|
{
|
||||||
if (metaInfo.hasEnumerator(typeStr)) {
|
|
||||||
return fromEnum(str, typeStr, metaInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
return read(typeStr, str);
|
return read(typeStr, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -459,7 +459,7 @@ bool QmlObjectNode::hasDefaultProperty() const
|
|||||||
|
|
||||||
QString QmlObjectNode::defaultProperty() const
|
QString QmlObjectNode::defaultProperty() const
|
||||||
{
|
{
|
||||||
return modelNode().metaInfo().defaultProperty();
|
return modelNode().metaInfo().defaultPropertyName();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlObjectNode::setParent(QmlObjectNode newParent)
|
void QmlObjectNode::setParent(QmlObjectNode newParent)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
#include "nodelistproperty.h"
|
#include "nodelistproperty.h"
|
||||||
#include "qmltextgenerator.h"
|
#include "qmltextgenerator.h"
|
||||||
#include "variantproperty.h"
|
#include "variantproperty.h"
|
||||||
#include <propertymetainfo.h>
|
#include <nodemetainfo.h>
|
||||||
#include "model.h"
|
#include "model.h"
|
||||||
|
|
||||||
using namespace QmlDesigner;
|
using namespace QmlDesigner;
|
||||||
@@ -95,8 +95,11 @@ QString QmlTextGenerator::toQml(const AbstractProperty &property, int indentDept
|
|||||||
if (property.name() == QLatin1String("id"))
|
if (property.name() == QLatin1String("id"))
|
||||||
return stringValue;
|
return stringValue;
|
||||||
|
|
||||||
if (variantProperty.metaInfo().isValid() && variantProperty.metaInfo().isEnumType()) {
|
if (false) {
|
||||||
return variantProperty.metaInfo().enumerator().scope() + '.' + stringValue;
|
}
|
||||||
|
if (variantProperty.parentModelNode().metaInfo().isValid() &&
|
||||||
|
variantProperty.parentModelNode().metaInfo().propertyIsEnumType(variantProperty.name())) {
|
||||||
|
return variantProperty.parentModelNode().metaInfo().propertyEnumScope(variantProperty.name()) + '.' + stringValue;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
switch (value.type()) {
|
switch (value.type()) {
|
||||||
|
|||||||
@@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
#include "nodeabstractproperty.h"
|
#include "nodeabstractproperty.h"
|
||||||
#include "nodelistproperty.h"
|
#include "nodelistproperty.h"
|
||||||
#include "propertymetainfo.h"
|
|
||||||
#include "nodemetainfo.h"
|
#include "nodemetainfo.h"
|
||||||
#include "rewriteaction.h"
|
#include "rewriteaction.h"
|
||||||
|
|
||||||
@@ -327,7 +326,7 @@ bool MoveNodeRewriteAction::execute(QmlRefactoring &refactoring,
|
|||||||
const int newTrailingNodeLocation = m_newTrailingNode.isValid() ? positionStore.nodeOffset(m_newTrailingNode) : -1;
|
const int newTrailingNodeLocation = m_newTrailingNode.isValid() ? positionStore.nodeOffset(m_newTrailingNode) : -1;
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
bool inDefaultProperty = (m_movingNode.parentProperty().parentModelNode().metaInfo().defaultProperty() == m_movingNode.parentProperty().name());
|
bool inDefaultProperty = (m_movingNode.parentProperty().parentModelNode().metaInfo().defaultPropertyName() == m_movingNode.parentProperty().name());
|
||||||
|
|
||||||
result = refactoring.moveObjectBeforeObject(movingNodeLocation, newTrailingNodeLocation, inDefaultProperty);
|
result = refactoring.moveObjectBeforeObject(movingNodeLocation, newTrailingNodeLocation, inDefaultProperty);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
|||||||
Reference in New Issue
Block a user