forked from qt-creator/qt-creator
Core: filepathify file renaming
Change-Id: I3d4f39e34e65cde3df7b7c19570e3a54d0625d53 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -136,7 +136,9 @@ public:
|
||||
}
|
||||
|
||||
RemovedFilesFromProject removeFiles(Node *, const QStringList &filePaths, QStringList *) final;
|
||||
bool renameFile(Node *, const QString &filePath, const QString &newFilePath) final;
|
||||
bool renameFile(Node *,
|
||||
const Utils::FilePath &oldFilePath,
|
||||
const Utils::FilePath &newFilePath) final;
|
||||
bool addFiles(Node *, const QStringList &filePaths, QStringList *) final;
|
||||
|
||||
FilePath filesFilePath() const { return ::FilePath::fromString(m_filesFileName); }
|
||||
@@ -391,17 +393,17 @@ bool GenericBuildSystem::setFiles(const QStringList &filePaths)
|
||||
return saveRawFileList(newList);
|
||||
}
|
||||
|
||||
bool GenericBuildSystem::renameFile(Node *, const QString &filePath, const QString &newFilePath)
|
||||
bool GenericBuildSystem::renameFile(Node *, const FilePath &oldFilePath, const FilePath &newFilePath)
|
||||
{
|
||||
QStringList newList = m_rawFileList;
|
||||
|
||||
QHash<QString, QString>::iterator i = m_rawListEntries.find(filePath);
|
||||
QHash<QString, QString>::iterator i = m_rawListEntries.find(oldFilePath.toString());
|
||||
if (i != m_rawListEntries.end()) {
|
||||
int index = newList.indexOf(i.value());
|
||||
if (index != -1) {
|
||||
QDir baseDir(projectDirectory().toString());
|
||||
newList.removeAt(index);
|
||||
insertSorted(&newList, baseDir.relativeFilePath(newFilePath));
|
||||
insertSorted(&newList, baseDir.relativeFilePath(newFilePath.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user