forked from qt-creator/qt-creator
QmlDesigner.MetaInfo: fix handling of enum scopes
The codel model does not provide enum scopes at the moment. As a fallback we use class names, but this fails if we use the original cpp class name from the <cpp> package. For this reason we always try to find an export with a package different from <cpp>. As a final solution the code model should be able to provide the enum scopes. Task-number: QTCREATORBUG-10114 Change-Id: I15396c83590426ab0b9b55c8646a89c8d5712683 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
This commit is contained in:
@@ -40,6 +40,7 @@
|
|||||||
#include <qmljs/qmljsscopechain.h>
|
#include <qmljs/qmljsscopechain.h>
|
||||||
#include <qmljs/parser/qmljsast_p.h>
|
#include <qmljs/parser/qmljsast_p.h>
|
||||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||||
|
#include <languageutils/fakemetaobject.h>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
@@ -775,8 +776,20 @@ QString NodeMetaInfoPrivate::propertyEnumScope(const PropertyName &propertyName)
|
|||||||
return QString();
|
return QString();
|
||||||
const CppComponentValue *definedIn = 0;
|
const CppComponentValue *definedIn = 0;
|
||||||
qmlObjectValue->getEnum(propertyType(propertyName), &definedIn);
|
qmlObjectValue->getEnum(propertyType(propertyName), &definedIn);
|
||||||
if (definedIn)
|
if (definedIn) {
|
||||||
|
QString nonCppPackage;
|
||||||
|
foreach (const LanguageUtils::FakeMetaObject::Export &qmlExport, definedIn->metaObject()->exports()) {
|
||||||
|
if (qmlExport.package != QLatin1String("<cpp>"))
|
||||||
|
nonCppPackage = qmlExport.package;
|
||||||
|
}
|
||||||
|
|
||||||
|
const LanguageUtils::FakeMetaObject::Export qmlExport =
|
||||||
|
definedIn->metaObject()->exportInPackage(nonCppPackage);
|
||||||
|
if (qmlExport.isValid())
|
||||||
|
return qmlExport.type;
|
||||||
|
|
||||||
return definedIn->className();
|
return definedIn->className();
|
||||||
|
}
|
||||||
|
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user