Commit fbd50b3b authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner.MetaInfo: fix for importDirectoryPath()

This fixes importDirectoryPath() for library imports.
For libraray imports we have to iterate over all importPaths
provided by the modelManager.

Change-Id: I68d4f0b7600e3b5d3f1c686ecb6887584cdd2031
Reviewed-by: default avatarMarco Bubke <marco.bubke@digia.com>
parent a9754611
......@@ -36,6 +36,7 @@
#include <rewriterview.h>
#include <propertyparser.h>
#include <QDir>
#include <QSharedData>
#include <QDebug>
#include <QIcon>
......@@ -45,6 +46,7 @@
#include <qmljs/qmljsbind.h>
#include <qmljs/qmljsscopechain.h>
#include <qmljs/parser/qmljsast_p.h>
#include <qmljs/qmljsmodelmanagerinterface.h>
#include <languageutils/fakemetaobject.h>
namespace QmlDesigner {
......@@ -869,11 +871,24 @@ QString NodeMetaInfoPrivate::componentFileName() const
QString NodeMetaInfoPrivate::importDirectoryPath() const
{
ModelManagerInterface *modelManager = ModelManagerInterface::instance();
if (isValid()) {
const Imports *imports = context()->imports(document());
ImportInfo importInfo = imports->info(qualfiedTypeName(), context().data());
return importInfo.path();
ImportInfo importInfo = imports->info(lookupNameComponent().last(), context().data());
if (importInfo.type() == ImportInfo::DirectoryImport) {
return importInfo.path();
} else if (importInfo.type() == ImportInfo::LibraryImport) {
if (modelManager) {
foreach (const QString &importPath, modelManager->importPaths()) {
const QString targetPath = QDir(importPath).filePath(importInfo.path());
if (QDir(targetPath).exists()) {
return targetPath;
}
}
}
}
}
return QString();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment