forked from qt-creator/qt-creator
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:
committed by
Daniel Teske
parent
a5543b8920
commit
6de2b28130
@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user