Commit b170e3ba authored by Kevin Michel's avatar Kevin Michel Committed by Thorbjørn Lindeijer

Enable 'Remove file...' on Generic project

Merge-request: 783
Reviewed-by: default avatarThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
parent a39d7e8d
......@@ -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)
......
......@@ -94,7 +94,9 @@ public:
QString buildParser(const QString &buildConfiguration) const;
ProjectExplorer::ToolChain *toolChain() const;
bool setFiles(const QStringList &filePaths);
bool addFiles(const QStringList &filePaths);
bool removeFiles(const QStringList &filePaths);
enum RefreshOptions {
Files = 0x01,
......
......@@ -167,7 +167,8 @@ bool GenericProjectNode::hasTargets() const
QList<ProjectExplorer::ProjectNode::ProjectAction> GenericProjectNode::supportedActions() const
{
return QList<ProjectAction>()
<< AddFile;
<< AddFile
<< RemoveFile;
}
bool GenericProjectNode::addSubProjects(const QStringList &proFilePaths)
......@@ -195,9 +196,9 @@ bool GenericProjectNode::removeFiles(const ProjectExplorer::FileType fileType,
const QStringList &filePaths, QStringList *notRemoved)
{
Q_UNUSED(fileType);
Q_UNUSED(filePaths);
Q_UNUSED(notRemoved);
return false;
return m_project->removeFiles(filePaths);
}
bool GenericProjectNode::renameFile(const ProjectExplorer::FileType fileType,
......
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