Resourceeditor: Enabled renaming of files in qrc

Task-number: QTCREATORBUG-15786
Change-Id: I240c58951f2b1016bef694636f923322fc164009
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Vikas Pachdha
2016-04-08 16:11:13 +02:00
parent 5e47d35fcd
commit e161b5d1cd
2 changed files with 22 additions and 0 deletions

View File

@@ -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());

View File

@@ -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);