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.
This commit is contained in:
Thorbjørn Lindeijer
2009-06-30 15:00:30 +02:00
parent b170e3ba87
commit ca1dd20036

View File

@@ -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);
}