Enable 'Remove file...' on Generic project

Merge-request: 783
Reviewed-by: Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
This commit is contained in:
Kevin Michel
2009-06-30 14:07:07 +02:00
committed by Thorbjørn Lindeijer
parent a39d7e8d12
commit b170e3ba87
3 changed files with 26 additions and 8 deletions

View File

@@ -168,19 +168,16 @@ static QStringList readLines(const QString &absoluteFileName)
return lines;
}
bool GenericProject::addFiles(const QStringList &filePaths)
bool GenericProject::setFiles(const QStringList &filePaths)
{
// Make sure we can open the file for writing
QFile file(filesFileName());
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
return false;
QStringList newFileList = m_files;
newFileList.append(filePaths);
QTextStream stream(&file);
QDir baseDir(QFileInfo(m_fileName).dir());
foreach (const QString &filePath, newFileList)
foreach (const QString &filePath, filePaths)
stream << baseDir.relativeFilePath(filePath) << QLatin1Char('\n');
file.close();
@@ -188,6 +185,24 @@ bool GenericProject::addFiles(const QStringList &filePaths)
return true;
}
bool GenericProject::addFiles(const QStringList &filePaths)
{
QStringList newFileList = m_files;
newFileList.append(filePaths);
return setFiles(newFileList);
}
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();
return setFiles(newFileList);
}
void GenericProject::parseProject(RefreshOptions options)
{
if (options & Files)