Commit b0ec3c13 authored by Daniel Teske's avatar Daniel Teske Committed by hjk
Browse files

Use Utils::FileName in Qt4ProFileNode



Change-Id: I6c0702caa2259e8fcaae48d1ac91622398ce7696
Reviewed-by: default avatarYuchen Deng <loaden@gmail.com>
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 16e97f0d
......@@ -305,13 +305,13 @@ struct InternalNode
// ...
// and afterwards calls compress() which merges directory nodes with single children, i.e. to
// * /absolute/path
void create(const QString &projectDir, const QStringList &newFilePaths, ProjectExplorer::FileType type)
void create(const QString &projectDir, const QSet<Utils::FileName> &newFilePaths, ProjectExplorer::FileType type)
{
static const QChar separator = QChar('/');
const QString projectDirWithSeparator = projectDir + separator;
int projectDirWithSeparatorLength = projectDirWithSeparator.length();
foreach (const QString &file, newFilePaths) {
QString fileWithoutPrefix;
foreach (const Utils::FileName &file, newFilePaths) {
Utils::FileName fileWithoutPrefix;
bool isRelative;
if (file.startsWith(projectDirWithSeparator)) {
isRelative = true;
......@@ -320,7 +320,7 @@ struct InternalNode
isRelative = false;
fileWithoutPrefix = file;
}
QStringList parts = fileWithoutPrefix.split(separator, QString::SkipEmptyParts);
QStringList parts = fileWithoutPrefix.toString().split(separator, QString::SkipEmptyParts);
#ifndef Q_OS_WIN
if (!isRelative && parts.count() > 0)
parts[0].prepend(separator);
......@@ -344,7 +344,7 @@ struct InternalNode
}
path += separator;
} else { // key is filename
currentNode->files.append(file);
currentNode->files.append(file.toString());
}
}
}
......@@ -513,9 +513,9 @@ QStringList Qt4PriFileNode::fullVPaths(const QStringList &baseVPaths, QtSupport:
return vPaths;
}
static QSet<QString> recursiveEnumerate(const QString &folder)
static QSet<Utils::FileName> recursiveEnumerate(const QString &folder)
{
QSet<QString> result;
QSet<Utils::FileName> result;
QFileInfo fi(folder);
if (fi.isDir()) {
QDir dir(folder);
......@@ -525,22 +525,14 @@ static QSet<QString> recursiveEnumerate(const QString &folder)
if (file.isDir())
result += recursiveEnumerate(file.absoluteFilePath());
else
result += file.absoluteFilePath();
result += Utils::FileName(file);
}
} else if (fi.exists()) {
result << folder;
result << Utils::FileName(fi);
}
return result;
}
QSet<QString> lowercaseAll(QSet<QString> strings)
{
QSet<QString> result;
foreach (const QString &s, strings)
result << s.toLower();
return result;
}
void Qt4PriFileNode::update(ProFile *includeFileExact, QtSupport::ProFileReader *readerExact, ProFile *includeFileCumlative, QtSupport::ProFileReader *readerCumulative)
{
// add project file node
......@@ -583,7 +575,7 @@ void Qt4PriFileNode::update(ProFile *includeFileExact, QtSupport::ProFileReader
++it;
} else {
// move files directly to m_recursiveEnumerateFiles
m_recursiveEnumerateFiles << *it;
m_recursiveEnumerateFiles << Utils::FileName::fromString(*it);
it = folders.erase(it);
}
} else {
......@@ -598,10 +590,7 @@ void Qt4PriFileNode::update(ProFile *includeFileExact, QtSupport::ProFileReader
foreach (const QString &folder, folders) {
m_recursiveEnumerateFiles += recursiveEnumerate(folder);
}
#ifdef Q_OS_WIN
m_recursiveEnumerateFiles = lowercaseAll(m_recursiveEnumerateFiles);
#endif
QMap<FileType, QSet<QString> > foundFiles;
QMap<FileType, QSet<Utils::FileName> > foundFiles;
QStringList baseVPathsExact;
if (includeFileExact)
......@@ -617,20 +606,21 @@ void Qt4PriFileNode::update(ProFile *includeFileExact, QtSupport::ProFileReader
FileType type = fileTypes.at(i).type;
QStringList qmakeVariables = varNames(type);
QSet<QString> newFilePaths;
QSet<Utils::FileName> newFilePaths;
foreach (const QString &qmakeVariable, qmakeVariables) {
if (includeFileExact) {
QStringList vPathsExact = fullVPaths(baseVPathsExact, readerExact, type, qmakeVariable, projectDir);
newFilePaths += readerExact->absoluteFileValues(qmakeVariable, projectDir, vPathsExact, includeFileExact).toSet();
QStringList tmp = readerExact->absoluteFileValues(qmakeVariable, projectDir, vPathsExact, includeFileExact);
foreach (const QString &t, tmp)
newFilePaths += Utils::FileName::fromString(t);
}
if (includeFileCumlative) {
QStringList vPathsCumulative = fullVPaths(baseVPathsCumulative, readerCumulative, type, qmakeVariable, projectDir);
newFilePaths += readerCumulative->absoluteFileValues(qmakeVariable, projectDir, vPathsCumulative, includeFileCumlative).toSet();
QStringList tmp = readerCumulative->absoluteFileValues(qmakeVariable, projectDir, vPathsCumulative, includeFileCumlative);
foreach (const QString &t, tmp)
newFilePaths += Utils::FileName::fromString(t);
}
}
#ifdef Q_OS_WIN
newFilePaths = lowercaseAll(newFilePaths);
#endif
foundFiles[type] = newFilePaths;
m_recursiveEnumerateFiles.subtract(newFilePaths);
......@@ -638,7 +628,7 @@ void Qt4PriFileNode::update(ProFile *includeFileExact, QtSupport::ProFileReader
for (int i = 0; i < fileTypes.size(); ++i) {
FileType type = fileTypes.at(i).type;
QSet<QString> newFilePaths = filterFilesProVariables(type, foundFiles[type]);
QSet<Utils::FileName> newFilePaths = filterFilesProVariables(type, foundFiles[type]);
newFilePaths += filterFilesRecursiveEnumerata(type, m_recursiveEnumerateFiles);
// We only need to save this information if
......@@ -656,7 +646,7 @@ void Qt4PriFileNode::update(ProFile *includeFileExact, QtSupport::ProFileReader
subfolder->displayName = fileTypes.at(i).typeName;
contents.subnodes.insert(subfolder->fullPath, subfolder);
// create the hierarchy with subdirectories
subfolder->create(m_projectDir, newFilePaths.toList(), type);
subfolder->create(m_projectDir, newFilePaths, type);
}
}
......@@ -689,18 +679,18 @@ void Qt4PriFileNode::folderChanged(const QString &folder)
changedFolder.append(QLatin1Char('/'));
// Collect all the files
QSet<QString> newFiles;
QSet<Utils::FileName> newFiles;
newFiles += recursiveEnumerate(changedFolder);
foreach (const QString &file, m_recursiveEnumerateFiles) {
foreach (const Utils::FileName &file, m_recursiveEnumerateFiles) {
if (!file.startsWith(changedFolder))
newFiles.insert(file);
}
QSet<QString> addedFiles = newFiles;
QSet<Utils::FileName> addedFiles = newFiles;
addedFiles.subtract(m_recursiveEnumerateFiles);
QSet<QString> removedFiles = m_recursiveEnumerateFiles;
QSet<Utils::FileName> removedFiles = m_recursiveEnumerateFiles;
removedFiles.subtract(newFiles);
if (addedFiles.isEmpty() && removedFiles.isEmpty())
......@@ -713,8 +703,8 @@ void Qt4PriFileNode::folderChanged(const QString &folder)
const QVector<Qt4NodeStaticData::FileTypeData> &fileTypes = qt4NodeStaticData()->fileTypeData;
for (int i = 0; i < fileTypes.size(); ++i) {
FileType type = fileTypes.at(i).type;
QSet<QString> add = filterFilesRecursiveEnumerata(type, addedFiles);
QSet<QString> remove = filterFilesRecursiveEnumerata(type, removedFiles);
QSet<Utils::FileName> add = filterFilesRecursiveEnumerata(type, addedFiles);
QSet<Utils::FileName> remove = filterFilesRecursiveEnumerata(type, removedFiles);
if (!add.isEmpty() || !remove.isEmpty()) {
// Scream :)
......@@ -739,7 +729,7 @@ void Qt4PriFileNode::folderChanged(const QString &folder)
subfolder->displayName = fileTypes.at(i).typeName;
contents.subnodes.insert(subfolder->fullPath, subfolder);
// create the hierarchy with subdirectories
subfolder->create(m_projectDir, m_files[type].toList(), type);
subfolder->create(m_projectDir, m_files[type], type);
}
}
......@@ -825,7 +815,7 @@ QList<ProjectNode::ProjectAction> Qt4PriFileNode::supportedActions(Node *node) c
// work on a subset of the file types according to project type.
actions << AddNewFile;
if (m_recursiveEnumerateFiles.contains(node->path())) {
if (m_recursiveEnumerateFiles.contains(Utils::FileName::fromString(node->path()))) {
actions << EraseFile;
} else {
actions << RemoveFile;
......@@ -1268,36 +1258,36 @@ QStringList Qt4PriFileNode::dynamicVarNames(QtSupport::ProFileReader *readerExac
return result;
}
QSet<QString> Qt4PriFileNode::filterFilesProVariables(ProjectExplorer::FileType fileType, const QSet<QString> &files)
QSet<Utils::FileName> Qt4PriFileNode::filterFilesProVariables(ProjectExplorer::FileType fileType, const QSet<Utils::FileName> &files)
{
if (fileType != ProjectExplorer::QMLType && fileType != ProjectExplorer::UnknownFileType)
return files;
QSet<QString> result;
QSet<Utils::FileName> result;
if (fileType != ProjectExplorer::QMLType && fileType != ProjectExplorer::UnknownFileType)
return result;
if (fileType == ProjectExplorer::QMLType) {
foreach (const QString &file, files)
foreach (const Utils::FileName &file, files)
if (file.endsWith(".qml"))
result << file;
} else {
foreach (const QString &file, files)
foreach (const Utils::FileName &file, files)
if (!file.endsWith(".qml"))
result << file;
}
return result;
}
QSet<QString> Qt4PriFileNode::filterFilesRecursiveEnumerata(ProjectExplorer::FileType fileType, const QSet<QString> &files)
QSet<Utils::FileName> Qt4PriFileNode::filterFilesRecursiveEnumerata(ProjectExplorer::FileType fileType, const QSet<Utils::FileName> &files)
{
QSet<QString> result;
QSet<Utils::FileName> result;
if (fileType != ProjectExplorer::QMLType && fileType != ProjectExplorer::UnknownFileType)
return result;
if(fileType == ProjectExplorer::QMLType) {
foreach (const QString &file, files)
foreach (const Utils::FileName &file, files)
if (file.endsWith(".qml"))
result << file;
} else {
foreach (const QString &file, files)
foreach (const Utils::FileName &file, files)
if (!file.endsWith(".qml"))
result << file;
}
......
......@@ -35,6 +35,7 @@
#include "qt4projectmanager_global.h"
#include <utils/fileutils.h>
#include <coreplugin/ifile.h>
#include <projectexplorer/projectnodes.h>
......@@ -163,8 +164,8 @@ protected:
void clear();
static QStringList varNames(FileType type);
static QStringList dynamicVarNames(QtSupport::ProFileReader *readerExact, QtSupport::ProFileReader *readerCumulative);
static QSet<QString> filterFilesProVariables(ProjectExplorer::FileType fileType, const QSet<QString> &files);
static QSet<QString> filterFilesRecursiveEnumerata(ProjectExplorer::FileType fileType, const QSet<QString> &files);
static QSet<Utils::FileName> filterFilesProVariables(ProjectExplorer::FileType fileType, const QSet<Utils::FileName> &files);
static QSet<Utils::FileName> filterFilesRecursiveEnumerata(ProjectExplorer::FileType fileType, const QSet<Utils::FileName> &files);
enum ChangeType {
AddToProFile,
......@@ -202,8 +203,8 @@ private:
// Memory is cheap...
// TODO (really that cheap?)
QMap<ProjectExplorer::FileType, QSet<QString> > m_files;
QSet<QString> m_recursiveEnumerateFiles;
QMap<ProjectExplorer::FileType, QSet<Utils::FileName> > m_files;
QSet<Utils::FileName> m_recursiveEnumerateFiles;
QSet<QString> m_watchedFolders;
bool m_includedInExactParse;
......
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