diff --git a/src/plugins/resourceeditor/resourcenode.cpp b/src/plugins/resourceeditor/resourcenode.cpp index c77c2632b78..918372e036d 100644 --- a/src/plugins/resourceeditor/resourcenode.cpp +++ b/src/plugins/resourceeditor/resourcenode.cpp @@ -427,6 +427,27 @@ bool ResourceFolderNode::removeFiles(const QStringList &filePaths, QStringList * return true; } +// QTCREATORBUG-15280 +bool ResourceFolderNode::canRenameFile(const QString &filePath, const QString &newFilePath) +{ + Q_UNUSED(newFilePath) + + bool fileEntryExists = false; + ResourceFile file(m_topLevelNode->filePath().toString()); + + int index = (file.load() != Core::IDocument::OpenResult::Success) ? -1 :file.indexOfPrefix(m_prefix, m_lang); + if (index != -1) { + for (int j = 0; j < file.fileCount(index); ++j) { + if (file.file(index, j) == filePath) { + fileEntryExists = true; + break; + } + } + } + + return fileEntryExists; +} + bool ResourceFolderNode::renameFile(const QString &filePath, const QString &newFilePath) { ResourceFile file(m_topLevelNode->filePath().toString()); diff --git a/src/plugins/resourceeditor/resourcenode.h b/src/plugins/resourceeditor/resourcenode.h index 528f1879f56..d3d56becb9d 100644 --- a/src/plugins/resourceeditor/resourcenode.h +++ b/src/plugins/resourceeditor/resourcenode.h @@ -100,6 +100,7 @@ public: bool addFiles(const QStringList &filePaths, QStringList *notAdded) override; bool removeFiles(const QStringList &filePaths, QStringList *notRemoved) override; + bool canRenameFile(const QString &filePath, const QString &newFilePath) override; bool renameFile(const QString &filePath, const QString &newFilePath) override; bool renamePrefix(const QString &prefix, const QString &lang);