From e161b5d1cdc310fb932a8c9f92435efadcb53f9d Mon Sep 17 00:00:00 2001 From: Vikas Pachdha Date: Fri, 8 Apr 2016 16:11:13 +0200 Subject: [PATCH] Resourceeditor: Enabled renaming of files in qrc Task-number: QTCREATORBUG-15786 Change-Id: I240c58951f2b1016bef694636f923322fc164009 Reviewed-by: Tobias Hunger --- src/plugins/resourceeditor/resourcenode.cpp | 21 +++++++++++++++++++++ src/plugins/resourceeditor/resourcenode.h | 1 + 2 files changed, 22 insertions(+) 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);