forked from qt-creator/qt-creator
Enable 'Remove file...' on Generic project
Merge-request: 783 Reviewed-by: Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
This commit is contained in:
committed by
Thorbjørn Lindeijer
parent
a39d7e8d12
commit
b170e3ba87
@@ -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)
|
||||
|
Reference in New Issue
Block a user