Commit 4a338a51 authored by hjk's avatar hjk

genericproject: pass an essentially temporary variable as parameter

parent 3df1d524
......@@ -116,8 +116,10 @@ void GenericProjectNode::refresh()
filesInPath[relativeFilePath].append(absoluteFileName);
}
FolderByName folderByName;
foreach (const QString &filePath, filePaths) {
FolderNode *folder = findOrCreateFolderByName(filePath);
QStringList components = filePath.split(QLatin1Char('/'));
FolderNode *folder = findOrCreateFolderByName(&folderByName, components, components.size());
QList<FileNode *> fileNodes;
foreach (const QString &file, filesInPath.value(filePath)) {
......@@ -128,13 +130,12 @@ void GenericProjectNode::refresh()
addFileNodes(fileNodes, folder);
}
m_folderByName.clear();
}
ProjectExplorer::FolderNode *GenericProjectNode::findOrCreateFolderByName(const QStringList &components, int end)
ProjectExplorer::FolderNode *GenericProjectNode::findOrCreateFolderByName
(FolderByName *folderByName, const QStringList &components, int end)
{
if (! end)
if (!end)
return 0;
QString folderName;
......@@ -148,28 +149,22 @@ ProjectExplorer::FolderNode *GenericProjectNode::findOrCreateFolderByName(const
if (component.isEmpty())
return this;
else if (FolderNode *folder = m_folderByName.value(folderName))
else if (FolderNode *folder = folderByName->value(folderName))
return folder;
const QString baseDir = QFileInfo(path()).path();
FolderNode *folder = new FolderNode(baseDir + QLatin1Char('/') + folderName);
folder->setDisplayName(component);
m_folderByName.insert(folderName, folder);
folderByName->insert(folderName, folder);
FolderNode *parent = findOrCreateFolderByName(components, end - 1);
if (! parent)
FolderNode *parent = findOrCreateFolderByName(folderByName, components, end - 1);
if (!parent)
parent = this;
addFolderNodes(QList<FolderNode*>() << folder, parent);
return folder;
}
ProjectExplorer::FolderNode *GenericProjectNode::findOrCreateFolderByName(const QString &filePath)
{
QStringList components = filePath.split(QLatin1Char('/'));
return findOrCreateFolderByName(components, components.length());
}
bool GenericProjectNode::hasBuildTargets() const
{
return true;
......
......@@ -84,13 +84,13 @@ public:
void refresh();
private:
FolderNode *findOrCreateFolderByName(const QString &filePath);
FolderNode *findOrCreateFolderByName(const QStringList &components, int end);
typedef QHash<QString, FolderNode *> FolderByName;
FolderNode *findOrCreateFolderByName(FolderByName *folderByName,
const QStringList &components, int end);
private:
GenericProject *m_project;
Core::IFile *m_projectFile;
QHash<QString, FolderNode *> m_folderByName;
};
} // namespace Internal
......
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