forked from qt-creator/qt-creator
ResourceNode: Add some tests for actual node types
Change-Id: I20297df727adf2058583b64975e7a6848bc80263 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -229,7 +229,8 @@ void ResourceEditorPlugin::onRefresh()
|
|||||||
|
|
||||||
void ResourceEditorPlugin::addPrefixContextMenu()
|
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());
|
PrefixLangDialog dialog(tr("Add Prefix"), QString(), QString(), Core::ICore::mainWindow());
|
||||||
if (dialog.exec() != QDialog::Accepted)
|
if (dialog.exec() != QDialog::Accepted)
|
||||||
return;
|
return;
|
||||||
@@ -241,7 +242,8 @@ void ResourceEditorPlugin::addPrefixContextMenu()
|
|||||||
|
|
||||||
void ResourceEditorPlugin::removePrefixContextMenu()
|
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(),
|
if (QMessageBox::question(Core::ICore::mainWindow(),
|
||||||
tr("Remove Prefix"),
|
tr("Remove Prefix"),
|
||||||
tr("Remove prefix %1 and all its files?").arg(rfn->displayName()))
|
tr("Remove prefix %1 and all its files?").arg(rfn->displayName()))
|
||||||
@@ -253,7 +255,8 @@ void ResourceEditorPlugin::removePrefixContextMenu()
|
|||||||
|
|
||||||
void ResourceEditorPlugin::removeNonExisting()
|
void ResourceEditorPlugin::removeNonExisting()
|
||||||
{
|
{
|
||||||
ResourceTopLevelNode *topLevel = static_cast<ResourceTopLevelNode *>(ProjectTree::currentNode());
|
auto topLevel = dynamic_cast<ResourceTopLevelNode *>(ProjectTree::currentNode());
|
||||||
|
QTC_ASSERT(topLevel, return);
|
||||||
topLevel->removeNonExistingFiles();
|
topLevel->removeNonExistingFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,7 +267,8 @@ void ResourceEditorPlugin::renameFileContextMenu()
|
|||||||
|
|
||||||
void ResourceEditorPlugin::removeFileContextMenu()
|
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();
|
QString path = rfn->filePath().toString();
|
||||||
FolderNode *parent = rfn->parentFolderNode();
|
FolderNode *parent = rfn->parentFolderNode();
|
||||||
if (!parent->removeFiles(QStringList() << path))
|
if (!parent->removeFiles(QStringList() << path))
|
||||||
@@ -280,19 +284,22 @@ void ResourceEditorPlugin::openEditorContextMenu()
|
|||||||
|
|
||||||
void ResourceEditorPlugin::copyPathContextMenu()
|
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());
|
QApplication::clipboard()->setText(QLatin1String(resourcePrefix) + node->qrcPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceEditorPlugin::copyUrlContextMenu()
|
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());
|
QApplication::clipboard()->setText(QLatin1String(urlPrefix) + node->qrcPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceEditorPlugin::renamePrefixContextMenu()
|
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());
|
PrefixLangDialog dialog(tr("Rename Prefix"), node->prefix(), node->lang(), Core::ICore::mainWindow());
|
||||||
if (dialog.exec() != QDialog::Accepted)
|
if (dialog.exec() != QDialog::Accepted)
|
||||||
@@ -350,7 +357,8 @@ void ResourceEditorPlugin::updateContextActions()
|
|||||||
m_copyUrl->setEnabled(isResourceFile);
|
m_copyUrl->setEnabled(isResourceFile);
|
||||||
m_copyUrl->setVisible(isResourceFile);
|
m_copyUrl->setVisible(isResourceFile);
|
||||||
if (isResourceFile) {
|
if (isResourceFile) {
|
||||||
ResourceFileNode *fileNode = static_cast<ResourceFileNode *>(node);
|
auto fileNode = dynamic_cast<ResourceFileNode *>(node);
|
||||||
|
QTC_ASSERT(fileNode, return);
|
||||||
QString qrcPath = fileNode->qrcPath();
|
QString qrcPath = fileNode->qrcPath();
|
||||||
m_copyPath->setParameter(QLatin1String(resourcePrefix) + qrcPath);
|
m_copyPath->setParameter(QLatin1String(resourcePrefix) + qrcPath);
|
||||||
m_copyUrl->setParameter(QLatin1String(urlPrefix) + qrcPath);
|
m_copyUrl->setParameter(QLatin1String(urlPrefix) + qrcPath);
|
||||||
|
@@ -304,10 +304,10 @@ ProjectExplorer::FolderNode::AddNewInformation ResourceTopLevelNode::addNewInfor
|
|||||||
// The ResourceFolderNode '/' defers to us, as otherwise
|
// The ResourceFolderNode '/' defers to us, as otherwise
|
||||||
// two nodes would be responsible for '/'
|
// two nodes would be responsible for '/'
|
||||||
// Thus also return a high priority for it
|
// Thus also return a high priority for it
|
||||||
if (ResourceFolderNode *rfn = dynamic_cast<ResourceFolderNode *>(context))
|
if (auto rfn = dynamic_cast<ResourceFolderNode *>(context))
|
||||||
if (rfn->prefix() == QLatin1String("/") && rfn->parentFolderNode() == this)
|
if (rfn->prefix() == QLatin1String("/") && rfn->parentFolderNode() == this)
|
||||||
p = 120;
|
p = 120;
|
||||||
if (SimpleResourceFolderNode *rfn = dynamic_cast<SimpleResourceFolderNode *>(context))
|
if (auto rfn = dynamic_cast<SimpleResourceFolderNode *>(context))
|
||||||
if (rfn->prefix() == QLatin1String("/") && rfn->resourceNode() == this)
|
if (rfn->prefix() == QLatin1String("/") && rfn->resourceNode() == this)
|
||||||
p = 120;
|
p = 120;
|
||||||
}
|
}
|
||||||
@@ -456,7 +456,7 @@ ProjectExplorer::FolderNode::AddNewInformation ResourceFolderNode::addNewInforma
|
|||||||
if (context == this)
|
if (context == this)
|
||||||
p = 120;
|
p = 120;
|
||||||
|
|
||||||
if (SimpleResourceFolderNode *sfn = dynamic_cast<SimpleResourceFolderNode *>(context)) {
|
if (auto sfn = dynamic_cast<SimpleResourceFolderNode *>(context)) {
|
||||||
if (sfn->prefixNode() == this)
|
if (sfn->prefixNode() == this)
|
||||||
p = 120;
|
p = 120;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user