summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp20
-rw-r--r--tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp64
-rw-r--r--tests/auto/qml/qmldesigner/coretests/tst_testcore.h1
3 files changed, 80 insertions, 5 deletions
diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
index e71f7781f9..a00bb6bcdc 100644
--- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
+++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
@@ -437,9 +437,15 @@ NodeMetaInfoPrivate::NodeMetaInfoPrivate(Model *model, QString type, int maj, in
if (objectValue) {
const CppComponentValue *qmlValue = value_cast<CppComponentValue>(objectValue);
if (qmlValue) {
- m_majorVersion = qmlValue->componentVersion().majorVersion();
- m_minorVersion = qmlValue->componentVersion().minorVersion();
- m_qualfiedTypeName = qmlValue->moduleName() + '.' + qmlValue->className();
+ if (m_majorVersion == -1 && m_minorVersion == -1) {
+ m_majorVersion = qmlValue->componentVersion().majorVersion();
+ m_minorVersion = qmlValue->componentVersion().minorVersion();
+ m_qualfiedTypeName = qmlValue->moduleName() + '.' + qmlValue->className();
+ } else if (m_majorVersion == qmlValue->componentVersion().majorVersion() && m_minorVersion == qmlValue->componentVersion().minorVersion()) {
+ m_qualfiedTypeName = qmlValue->moduleName() + '.' + qmlValue->className();
+ } else {
+ return;
+ }
} else {
m_isComponent = true;
}
@@ -477,8 +483,12 @@ const QmlJS::CppComponentValue *NodeMetaInfoPrivate::getCppComponentValue() cons
if (import.info.path() != module)
continue;
const Value *lookupResult = import.object->lookupMember(type, context());
- if ((value = value_cast<CppComponentValue>(lookupResult)))
- return value;
+ const CppComponentValue *cppValue = value_cast<CppComponentValue>(lookupResult);
+ if (cppValue
+ && (m_majorVersion == -1 || m_majorVersion == cppValue->componentVersion().majorVersion())
+ && (m_minorVersion == -1 || m_minorVersion == cppValue->componentVersion().minorVersion())
+ )
+ return cppValue;
}
return 0;
diff --git a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp
index 8c905cf1ff..f69bac1afd 100644
--- a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp
+++ b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp
@@ -4034,6 +4034,70 @@ void tst_TestCore::testMetaInfoEnums()
QApplication::processEvents();
}
+void tst_TestCore::testMetaInfoQtQuick1Vs2()
+{
+ char qmlString[] = "import QtQuick 2.0\n"
+ "Rectangle {\n"
+ "id: root;\n"
+ "width: 200;\n"
+ "height: 200;\n"
+ "color: \"white\";\n"
+ "Text {\n"
+ "id: text1\n"
+ "text: \"Hello World\"\n"
+ "anchors.centerIn: parent\n"
+ "Item {\n"
+ "id: item\n"
+ "}\n"
+ "}\n"
+ "Rectangle {\n"
+ "id: rectangle;\n"
+ "gradient: Gradient {\n"
+ "GradientStop {\n"
+ "position: 0\n"
+ "color: \"white\"\n"
+ "}\n"
+ "GradientStop {\n"
+ "position: 1\n"
+ "color: \"black\"\n"
+ "}\n"
+ "}\n"
+ "}\n"
+ "Text {\n"
+ "text: \"text\"\n"
+ "x: 66\n"
+ "y: 43\n"
+ "width: 80\n"
+ "height: 20\n"
+ "id: text2\n"
+ "}\n"
+ "}\n";
+
+ QPlainTextEdit textEdit;
+ textEdit.setPlainText(qmlString);
+ NotIndentingTextEditModifier textModifier(&textEdit);
+
+ QScopedPointer<Model> model(Model::create("QtQuick.Item"));
+ QVERIFY(model.data());
+
+ QScopedPointer<TestRewriterView> testRewriterView(new TestRewriterView());
+ testRewriterView->setTextModifier(&textModifier);
+
+ model->attachView(testRewriterView.data());
+
+ ModelNode rootModelNode = testRewriterView->rootModelNode();
+ QVERIFY(rootModelNode.isValid());
+ QCOMPARE(rootModelNode.type(), QString("QtQuick.Rectangle"));
+
+ QVERIFY(!model->metaInfo("Rectangle", 1, 0).isValid());
+ QVERIFY(model->metaInfo("Rectangle", -1, -1).isValid());
+ QVERIFY(model->metaInfo("Rectangle", 2, 0).isValid());
+
+ QVERIFY(!model->metaInfo("QtQuick.Rectangle", 1, 0).isValid());
+ QVERIFY(model->metaInfo("QtQuick.Rectangle", -1, -1).isValid());
+ QVERIFY(model->metaInfo("QtQuick.Rectangle", 2, 0).isValid());
+}
+
void tst_TestCore::testMetaInfoProperties()
{
QScopedPointer<Model> model(createModel("QtQuick.Text"));
diff --git a/tests/auto/qml/qmldesigner/coretests/tst_testcore.h b/tests/auto/qml/qmldesigner/coretests/tst_testcore.h
index 2a2cafad30..159bd5744c 100644
--- a/tests/auto/qml/qmldesigner/coretests/tst_testcore.h
+++ b/tests/auto/qml/qmldesigner/coretests/tst_testcore.h
@@ -61,6 +61,7 @@ private slots:
void testMetaInfoEnums();
void testMetaInfoProperties();
void testMetaInfoDotProperties();
+ void testMetaInfoQtQuick1Vs2();
void testMetaInfoListProperties();
void testQtQuick20Basic();
void testQtQuick20BasicRectangle();