Commit ca1dd200 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer

Made sure the order of the file list is maintained when removing files

Converting to a QSet and back randomizes the order of the files. Just
doing a linear scan and a QSet for speading up the contains() check
should be enough and maintains the order.
parent b170e3ba
......@@ -195,10 +195,13 @@ bool GenericProject::addFiles(const QStringList &filePaths)
bool GenericProject::removeFiles(const QStringList &filePaths)
{
// Removing using set allows O(n.log(n)) behavior
QSet<QString> newFileSet = m_files.toSet();
newFileSet.subtract(filePaths.toSet());
QStringList newFileList = newFileSet.toList();
QStringList newFileList;
QSet<QString> filesToRemove = filePaths.toSet();
foreach (const QString &file, m_files) {
if (!filesToRemove.contains(file))
newFileList.append(file);
}
return setFiles(newFileList);
}
......
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