aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/resourceeditor/resourceeditorplugin.cpp
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2017-02-28 10:55:29 +0100
committerhjk <hjk@qt.io>2017-02-28 11:32:32 +0000
commit28b6c4f6716bf8756a72f703d04e3c9ab0a3f41c (patch)
treeb015db8b760572f6633fd9bbf8b6450b59fdf26e /src/plugins/resourceeditor/resourceeditorplugin.cpp
parenta2b47b7da274580c40df2fb474d4b65a6865a1df (diff)
ResourceNode: Add some tests for actual node types
Change-Id: I20297df727adf2058583b64975e7a6848bc80263 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/resourceeditor/resourceeditorplugin.cpp')
-rw-r--r--src/plugins/resourceeditor/resourceeditorplugin.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/plugins/resourceeditor/resourceeditorplugin.cpp b/src/plugins/resourceeditor/resourceeditorplugin.cpp
index 21060c6ae7..16a5a35a18 100644
--- a/src/plugins/resourceeditor/resourceeditorplugin.cpp
+++ b/src/plugins/resourceeditor/resourceeditorplugin.cpp
@@ -229,7 +229,8 @@ void ResourceEditorPlugin::onRefresh()
void ResourceEditorPlugin::addPrefixContextMenu()
{
- auto topLevel = static_cast<ResourceTopLevelNode *>(ProjectTree::currentNode());
+ auto topLevel = dynamic_cast<ResourceTopLevelNode *>(ProjectTree::currentNode());
+ QTC_ASSERT(topLevel, return);
PrefixLangDialog dialog(tr("Add Prefix"), QString(), QString(), Core::ICore::mainWindow());
if (dialog.exec() != QDialog::Accepted)
return;
@@ -241,7 +242,8 @@ void ResourceEditorPlugin::addPrefixContextMenu()
void ResourceEditorPlugin::removePrefixContextMenu()
{
- ResourceFolderNode *rfn = static_cast<ResourceFolderNode *>(ProjectTree::currentNode());
+ auto rfn = dynamic_cast<ResourceFolderNode *>(ProjectTree::currentNode());
+ QTC_ASSERT(rfn, return);
if (QMessageBox::question(Core::ICore::mainWindow(),
tr("Remove Prefix"),
tr("Remove prefix %1 and all its files?").arg(rfn->displayName()))
@@ -253,7 +255,8 @@ void ResourceEditorPlugin::removePrefixContextMenu()
void ResourceEditorPlugin::removeNonExisting()
{
- ResourceTopLevelNode *topLevel = static_cast<ResourceTopLevelNode *>(ProjectTree::currentNode());
+ auto topLevel = dynamic_cast<ResourceTopLevelNode *>(ProjectTree::currentNode());
+ QTC_ASSERT(topLevel, return);
topLevel->removeNonExistingFiles();
}
@@ -264,7 +267,8 @@ void ResourceEditorPlugin::renameFileContextMenu()
void ResourceEditorPlugin::removeFileContextMenu()
{
- ResourceFolderNode *rfn = static_cast<ResourceFolderNode *>(ProjectTree::currentNode());
+ auto rfn = dynamic_cast<ResourceFolderNode *>(ProjectTree::currentNode());
+ QTC_ASSERT(rfn, return);
QString path = rfn->filePath().toString();
FolderNode *parent = rfn->parentFolderNode();
if (!parent->removeFiles(QStringList() << path))
@@ -280,19 +284,22 @@ void ResourceEditorPlugin::openEditorContextMenu()
void ResourceEditorPlugin::copyPathContextMenu()
{
- ResourceFileNode *node = static_cast<ResourceFileNode *>(ProjectTree::currentNode());
+ auto node = dynamic_cast<ResourceFileNode *>(ProjectTree::currentNode());
+ QTC_ASSERT(node, return);
QApplication::clipboard()->setText(QLatin1String(resourcePrefix) + node->qrcPath());
}
void ResourceEditorPlugin::copyUrlContextMenu()
{
- ResourceFileNode *node = static_cast<ResourceFileNode *>(ProjectTree::currentNode());
+ auto node = dynamic_cast<ResourceFileNode *>(ProjectTree::currentNode());
+ QTC_ASSERT(node, return);
QApplication::clipboard()->setText(QLatin1String(urlPrefix) + node->qrcPath());
}
void ResourceEditorPlugin::renamePrefixContextMenu()
{
- ResourceFolderNode *node = static_cast<ResourceFolderNode *>(ProjectTree::currentNode());
+ auto node = dynamic_cast<ResourceFolderNode *>(ProjectTree::currentNode());
+ QTC_ASSERT(node, return);
PrefixLangDialog dialog(tr("Rename Prefix"), node->prefix(), node->lang(), Core::ICore::mainWindow());
if (dialog.exec() != QDialog::Accepted)
@@ -350,7 +357,8 @@ void ResourceEditorPlugin::updateContextActions()
m_copyUrl->setEnabled(isResourceFile);
m_copyUrl->setVisible(isResourceFile);
if (isResourceFile) {
- ResourceFileNode *fileNode = static_cast<ResourceFileNode *>(node);
+ auto fileNode = dynamic_cast<ResourceFileNode *>(node);
+ QTC_ASSERT(fileNode, return);
QString qrcPath = fileNode->qrcPath();
m_copyPath->setParameter(QLatin1String(resourcePrefix) + qrcPath);
m_copyUrl->setParameter(QLatin1String(urlPrefix) + qrcPath);