summaryrefslogtreecommitdiff
path: root/src/plugins/qmljstools
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2011-01-20 11:03:23 +0100
committerChristian Kamm <christian.d.kamm@nokia.com>2011-01-20 11:04:00 +0100
commit8ab2735368a679fe0feb9f395106c6f9e346f224 (patch)
treee859abae31d4c79c5da02d55196e97589cddf231 /src/plugins/qmljstools
parentabff92c0fbfba5fdd5edfe8d3fce91726bc2e7a6 (diff)
downloadqt-creator-8ab2735368a679fe0feb9f395106c6f9e346f224.tar.gz
QmlJS: Be more efficient when looking for QML libraries.
Reviewed-by: Erik Verbruggen
Diffstat (limited to 'src/plugins/qmljstools')
-rw-r--r--src/plugins/qmljstools/qmljsmodelmanager.cpp65
1 files changed, 37 insertions, 28 deletions
diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp
index d3da19329e..e8a3e8845f 100644
--- a/src/plugins/qmljstools/qmljsmodelmanager.cpp
+++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp
@@ -357,9 +357,7 @@ static void findNewLibraryImports(const Document::Ptr &doc, const Snapshot &snap
if (import.type() != Interpreter::ImportInfo::LibraryImport)
continue;
foreach (const QString &importPath, importPaths) {
- QDir dir(importPath);
- dir.cd(import.name());
- const QString targetPath = dir.absolutePath();
+ const QString targetPath = QDir(importPath).filePath(import.name());
// if we know there is a library, done
if (snapshot.libraryInfo(targetPath).isValid())
@@ -367,30 +365,37 @@ static void findNewLibraryImports(const Document::Ptr &doc, const Snapshot &snap
if (newLibraries->contains(targetPath))
break;
- // if there is a qmldir file, we found a new library!
- if (dir.exists("qmldir")) {
- QFile qmldirFile(dir.filePath("qmldir"));
- qmldirFile.open(QFile::ReadOnly);
- QString qmldirData = QString::fromUtf8(qmldirFile.readAll());
-
- QmlDirParser qmldirParser;
- qmldirParser.setSource(qmldirData);
- qmldirParser.parse();
-
- const QString libraryPath = QFileInfo(qmldirFile).absolutePath();
- newLibraries->insert(libraryPath);
- modelManager->updateLibraryInfo(libraryPath,
- LibraryInfo(qmldirParser));
-
- // scan the qml files in the library
- foreach (const QmlDirParser::Component &component, qmldirParser.components()) {
- if (! component.fileName.isEmpty()) {
- QFileInfo componentFileInfo(dir.filePath(component.fileName));
- const QString path = componentFileInfo.absolutePath();
- if (! scannedPaths->contains(path)) {
- *importedFiles += qmlFilesInDirectory(path);
- scannedPaths->insert(path);
- }
+ // check for a qmldir file
+ const QDir targetDir(targetPath);
+ QFile qmldirFile(targetDir.filePath(QLatin1String("qmldir")));
+ if (!qmldirFile.exists())
+ continue;
+
+#ifdef Q_OS_WIN
+ // QTCREATORBUG-3402 - be case sensitive even here?
+#endif
+
+ // found a new library!
+ qmldirFile.open(QFile::ReadOnly);
+ QString qmldirData = QString::fromUtf8(qmldirFile.readAll());
+
+ QmlDirParser qmldirParser;
+ qmldirParser.setSource(qmldirData);
+ qmldirParser.parse();
+
+ const QString libraryPath = QFileInfo(qmldirFile).absolutePath();
+ newLibraries->insert(libraryPath);
+ modelManager->updateLibraryInfo(libraryPath,
+ LibraryInfo(qmldirParser));
+
+ // scan the qml files in the library
+ foreach (const QmlDirParser::Component &component, qmldirParser.components()) {
+ if (! component.fileName.isEmpty()) {
+ const QFileInfo componentFileInfo(targetDir.filePath(component.fileName));
+ const QString path = QDir::cleanPath(componentFileInfo.absolutePath());
+ if (! scannedPaths->contains(path)) {
+ *importedFiles += qmlFilesInDirectory(path);
+ scannedPaths->insert(path);
}
}
}
@@ -544,7 +549,11 @@ void ModelManager::updateImportPaths()
QMapIterator<ProjectExplorer::Project *, ProjectInfo> it(m_projects);
while (it.hasNext()) {
it.next();
- m_allImportPaths += it.value().importPaths;
+ foreach (const QString &path, it.value().importPaths) {
+ const QString canonicalPath = QFileInfo(path).canonicalFilePath();
+ if (!canonicalPath.isEmpty())
+ m_allImportPaths += canonicalPath;
+ }
}
m_allImportPaths += m_defaultImportPaths;
m_allImportPaths.removeDuplicates();