mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-21 22:13:25 -06:00
AppFwk : Assert if two fields or groups with same name is present in PdmuiOrdering for cafPdmUiDefaultObjectEditor
This commit is contained in:
parent
94efe9b14c
commit
9db44a349a
@ -127,6 +127,12 @@ void PdmUiDefaultObjectEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
m_newGroupBoxes.clear();
|
||||
|
||||
const std::vector<PdmUiItem*>& uiItems = config.uiItems();
|
||||
|
||||
{
|
||||
std::set<QString> fieldKeywordNames;
|
||||
std::set<QString> groupNames;
|
||||
recursiveVerifyUniqueNames(uiItems, uiConfigName, &fieldKeywordNames, &groupNames);
|
||||
}
|
||||
|
||||
recursiveSetupFieldsAndGroups(uiItems, m_mainWidget, m_layout, uiConfigName);
|
||||
|
||||
@ -352,5 +358,49 @@ void PdmUiDefaultObjectEditor::recursiveSetupFieldsAndGroups(const std::vector<P
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiDefaultObjectEditor::recursiveVerifyUniqueNames(const std::vector<PdmUiItem*>& uiItems, const QString& uiConfigName, std::set<QString>* fieldKeywordNames, std::set<QString>* groupNames)
|
||||
{
|
||||
for (size_t i = 0; i < uiItems.size(); ++i)
|
||||
{
|
||||
if (uiItems[i]->isUiGroup())
|
||||
{
|
||||
PdmUiGroup* group = static_cast<PdmUiGroup*>(uiItems[i]);
|
||||
const std::vector<PdmUiItem*>& groupChildren = group->uiItems();
|
||||
|
||||
QString groupBoxKey = uiItems[i]->uiName();
|
||||
|
||||
if (groupNames->find(groupBoxKey) != groupNames->end())
|
||||
{
|
||||
// It is not supported to have two groups with identical names
|
||||
assert(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
groupNames->insert(groupBoxKey);
|
||||
}
|
||||
|
||||
recursiveVerifyUniqueNames(groupChildren, uiConfigName, fieldKeywordNames, groupNames);
|
||||
}
|
||||
else
|
||||
{
|
||||
PdmUiFieldHandle* field = dynamic_cast<PdmUiFieldHandle*>(uiItems[i]);
|
||||
|
||||
QString fieldKeyword = field->fieldHandle()->keyword();
|
||||
if (fieldKeywordNames->find(fieldKeyword) != fieldKeywordNames->end())
|
||||
{
|
||||
// It is not supported to have two fields with identical names
|
||||
assert(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldKeywordNames->insert(fieldKeyword);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // end namespace caf
|
||||
|
@ -65,7 +65,8 @@ protected:
|
||||
virtual void configureAndUpdateUi(const QString& uiConfigName);
|
||||
|
||||
private:
|
||||
void recursiveSetupFieldsAndGroups(const std::vector<PdmUiItem*>& uiItems, QWidget* parent, QGridLayout* parentLayout, const QString& uiConfigName );
|
||||
void recursiveSetupFieldsAndGroups(const std::vector<PdmUiItem*>& uiItems, QWidget* parent, QGridLayout* parentLayout, const QString& uiConfigName);
|
||||
void recursiveVerifyUniqueNames(const std::vector<PdmUiItem*>& uiItems, const QString& uiConfigName, std::set<QString>* fieldKeywordNames, std::set<QString>* groupNames);
|
||||
|
||||
std::map<QString, PdmUiFieldEditorHandle*> m_fieldViews;
|
||||
std::map<QString, QPointer<QGroupBox> > m_groupBoxes;
|
||||
|
Loading…
Reference in New Issue
Block a user