Implemented rename file feature for generic projects.

Change-Id: I195c48c5eaa458bdb537a8de4d7b71f17a704f41
Reviewed-by: Thorbjørn Lindeijer
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
Andre Hartmann
2011-10-24 21:42:11 +02:00
committed by Daniel Teske
parent a5543b8920
commit 6de2b28130
3 changed files with 21 additions and 4 deletions

View File

@@ -190,6 +190,22 @@ bool GenericProject::setFiles(const QStringList &filePaths)
return saveRawFileList(newList);
}
bool GenericProject::renameFile(const QString &filePath, const QString &newFilePath)
{
QStringList newList = m_rawFileList;
QHash<QString, QString>::iterator i = m_rawListEntries.find(filePath);
if (i != m_rawListEntries.end()) {
int index = newList.indexOf(i.value());
if (index != -1) {
QDir baseDir(QFileInfo(m_fileName).dir());
newList.replace(index, baseDir.relativeFilePath(newFilePath));
}
}
return saveRawFileList(newList);
}
void GenericProject::parseProject(RefreshOptions options)
{
if (options & Files) {

View File

@@ -97,6 +97,7 @@ public:
bool addFiles(const QStringList &filePaths);
bool removeFiles(const QStringList &filePaths);
bool setFiles(const QStringList &filePaths);
bool renameFile(const QString &filePath, const QString &newFilePath);
enum RefreshOptions {
Files = 0x01,

View File

@@ -175,7 +175,8 @@ QList<ProjectExplorer::ProjectNode::ProjectAction> GenericProjectNode::supported
return QList<ProjectAction>()
<< AddNewFile
<< AddExistingFile
<< RemoveFile;
<< RemoveFile
<< Rename;
}
bool GenericProjectNode::canAddSubProject(const QString &proFilePath) const
@@ -226,9 +227,8 @@ bool GenericProjectNode::renameFile(const ProjectExplorer::FileType fileType,
const QString &filePath, const QString &newFilePath)
{
Q_UNUSED(fileType)
Q_UNUSED(filePath)
Q_UNUSED(newFilePath)
return false;
return m_project->renameFile(filePath, newFilePath);
}
QList<ProjectExplorer::RunConfiguration *> GenericProjectNode::runConfigurationsFor(Node *node)