Commit 2181a93a authored by Kai Koehne's avatar Kai Koehne
Browse files

Let QmlProjectItem return always absolute paths

We're converting the path to absolute ones in QmlProject anyway ...
parent 20801bee
......@@ -93,12 +93,12 @@ void FileFilterBaseItem::updateFileList()
if (newFiles != m_files) {
// update watched files
foreach (const QString &file, m_files - newFiles) {
m_fsWatcher.removePath(QDir(projectDir).absoluteFilePath(file));
}
foreach (const QString &file, newFiles - m_files) {
m_fsWatcher.addPath(QDir(projectDir).absoluteFilePath(file));
}
const QSet<QString> unwatchFiles = QSet<QString>(m_files - newFiles);
const QSet<QString> watchFiles = QSet<QString>(newFiles - m_files);
if (!unwatchFiles.isEmpty())
m_fsWatcher.removePaths(unwatchFiles.toList());
if (!watchFiles.isEmpty())
m_fsWatcher.addPaths(QSet<QString>(newFiles - m_files).toList());
m_files = newFiles;
......@@ -106,13 +106,13 @@ void FileFilterBaseItem::updateFileList()
}
// update watched directories
QSet<QString> watchedDirectories = m_fsWatcher.directories().toSet();
foreach (const QString &dir, watchedDirectories - dirsToBeWatched) {
m_fsWatcher.removePath(QDir(projectDir).absoluteFilePath(dir));
}
foreach (const QString &dir, dirsToBeWatched - watchedDirectories) {
m_fsWatcher.addPath(QDir(projectDir).absoluteFilePath(dir));
}
const QSet<QString> watchedDirectories = m_fsWatcher.directories().toSet();
const QSet<QString> unwatchDirs = watchedDirectories - dirsToBeWatched;
const QSet<QString> watchDirs = dirsToBeWatched - watchedDirectories;
if (!unwatchDirs.isEmpty())
m_fsWatcher.removePaths(unwatchDirs.toList());
if (!watchDirs.isEmpty())
m_fsWatcher.addPaths(watchDirs.toList());
}
QSet<QString> FileFilterBaseItem::filesInSubTree(const QDir &rootDir, const QDir &dir, QSet<QString> *parsedDirs)
......@@ -124,7 +124,7 @@ QSet<QString> FileFilterBaseItem::filesInSubTree(const QDir &rootDir, const QDir
foreach (const QFileInfo &file, dir.entryInfoList(QDir::Files)) {
if (m_regex.exactMatch(file.fileName())) {
fileSet.insert(rootDir.relativeFilePath(file.absoluteFilePath()));
fileSet.insert(file.absoluteFilePath());
}
}
......
......@@ -78,6 +78,7 @@ void QmlProjectItem::setSourceDirectory(const QString &directoryPath)
emit sourceDirectoryChanged();
}
/* Returns list of absolute paths */
QStringList QmlProjectItem::qmlFiles() const
{
const Q_D(QmlProjectItem);
......
......@@ -49,7 +49,8 @@ void TestProject::testQmlFileFilter()
project->setSourceDirectory(testDataDir);
QStringList expectedFiles(QStringList() << "file1.qml" << "file2.qml");
QStringList expectedFiles(QStringList() << testDataDir + "/file1.qml"
<< testDataDir + "/file2.qml");
QCOMPARE(project->qmlFiles().toSet(), expectedFiles.toSet());
}
......@@ -75,7 +76,9 @@ void TestProject::testQmlFileFilter()
project->setSourceDirectory(testDataDir);
QStringList expectedFiles(QStringList() << "file1.qml" << "file2.qml" << "subdir/file3.qml");
QStringList expectedFiles(QStringList() << testDataDir + "/file1.qml"
<< testDataDir + "/file2.qml"
<< testDataDir + "/subdir/file3.qml");
QCOMPARE(project->qmlFiles().toSet(), expectedFiles.toSet());
}
......@@ -101,7 +104,7 @@ void TestProject::testQmlFileFilter()
project->setSourceDirectory(testDataDir);
QStringList expectedFiles(QStringList() << "subdir/file3.qml");
QStringList expectedFiles(QStringList() << testDataDir + "/subdir/file3.qml");
QCOMPARE(project->qmlFiles().toSet(), expectedFiles.toSet());
}
......@@ -130,7 +133,9 @@ void TestProject::testQmlFileFilter()
project->setSourceDirectory(testDataDir);
QStringList expectedFiles(QStringList() << "file1.qml" << "file2.qml" << "subdir/file3.qml");
QStringList expectedFiles(QStringList() << testDataDir + "/file1.qml"
<< testDataDir + "/file2.qml"
<< testDataDir + "/subdir/file3.qml");
QCOMPARE(project->qmlFiles().size(), 3);
QCOMPARE(project->qmlFiles().toSet(), expectedFiles.toSet());
}
......
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