Commit 35684652 authored by David Thompson's avatar David Thompson
Browse files

Fix #363 .

Always create a phrase model inside resource- and reference-item GUIs.
parent 4732d64f
Pipeline #187880 passed with stages
in 24 minutes and 27 seconds
......@@ -53,7 +53,8 @@ void updateLabel(QLabel* lbl, const QString& txt, bool ok)
lbl->update();
}
nlohmann::json jcfg = { { "Name", "RefItem" }, { "Type", "smtk::view::ReferenceItemPhraseModel" },
nlohmann::json defaultConfiguration = { { "Name", "RefItem" },
{ "Type", "smtk::view::ReferenceItemPhraseModel" },
{ "Component",
{ { "Name", "Details" }, { "Attributes", { { "TopLevel", true }, { "Title", "Resources" } } },
{ "Children",
......@@ -368,14 +369,14 @@ smtk::view::PhraseModelPtr qtReferenceItem::createPhraseModel() const
if (refItem && refItem->numberOfRequiredValues() < 2 &&
((!refItem->isExtensible()) || (refItem->isExtensible() && refItem->maxNumberOfValues() == 1)))
{
json jj = jcfg;
json jj = defaultConfiguration;
jj["Component"]["Children"][0]["Children"][1]["Children"][0]["Attributes"]["SingleSelect"] =
true;
phraseModelConfig = jj;
}
else
{
phraseModelConfig = jcfg;
phraseModelConfig = defaultConfiguration;
}
auto phraseModel =
m_itemInfo.uiManager()->viewManager()->phraseModelFactory().createFromConfiguration(
......
......@@ -20,6 +20,7 @@
#include "smtk/view/PhraseModelFactory.h"
#include "smtk/view/ResourcePhraseModel.h"
#include "smtk/view/SubphraseGenerator.h"
#include "smtk/view/json/jsonView.h"
#include "smtk/attribute/ResourceItem.h"
#include "smtk/attribute/ResourceItemDefinition.h"
......@@ -31,6 +32,26 @@ namespace smtk
namespace extension
{
namespace
{
nlohmann::json defaultConfiguration = { { "Name", "RefItem" },
{ "Type", "smtk::view::ResourcePhraseModel" },
{ "Component",
{ { "Name", "Details" }, { "Attributes", { { "TopLevel", true }, { "Title", "Resources" } } },
{ "Children",
{ { { "Name", "PhraseModel" },
{ "Attributes", { { "Type", "smtk::view::ResourcePhraseModel" } } },
{ "Children",
{ { { "Name", "SubphraseGenerator" }, { "Attributes", { { "Type", "none" } } } },
{ { "Name", "Badges" },
{ "Children",
{ { { "Name", "Badge" },
{ "Attributes",
{ { "Type",
"smtk::extension::qt::MembershipBadge" } } } } } } } } } } } } } } };
}
qtItem* qtResourceItem::createItemWidget(const qtAttributeItemInfo& info)
{
// So we support this type of item?
......@@ -74,6 +95,14 @@ smtk::view::PhraseModelPtr qtResourceItem::createPhraseModel() const
auto phraseModel =
m_itemInfo.uiManager()->viewManager()->phraseModelFactory().createFromConfiguration(
m_itemInfo.baseView()->getObject().get());
if (!phraseModel ||
!m_p->m_phraseModel->badges().findBadgeOfType<smtk::extension::qt::MembershipBadge>())
{
smtk::view::ConfigurationPtr config = defaultConfiguration;
phraseModel =
m_itemInfo.uiManager()->viewManager()->phraseModelFactory().createFromConfiguration(
config.get());
}
phraseModel->root()->findDelegate()->setModel(phraseModel);
auto def = std::dynamic_pointer_cast<const smtk::attribute::ResourceItemDefinition>(
m_itemInfo.item()->definition());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment