mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
AppFwk : ToolBarEditor : Enable support for all field editor types
This commit is contained in:
parent
a6470e0415
commit
1e70551a27
@ -51,6 +51,7 @@
|
|||||||
#include "cafPdmObjectHandle.h"
|
#include "cafPdmObjectHandle.h"
|
||||||
#include "cafPdmUiObjectHandle.h"
|
#include "cafPdmUiObjectHandle.h"
|
||||||
#include "cafPdmUiFieldHandle.h"
|
#include "cafPdmUiFieldHandle.h"
|
||||||
|
#include "cafPdmUiFieldEditorHelper.h"
|
||||||
|
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
@ -101,60 +102,23 @@ void PdmUiToolBarEditor::configureAndUpdateUi(const QString& uiConfigName)
|
|||||||
|
|
||||||
if (it == m_fieldViews.end())
|
if (it == m_fieldViews.end())
|
||||||
{
|
{
|
||||||
/*
|
caf::PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||||
|
|
||||||
//Code used to support other editor types than bool
|
if (uiFieldHandle)
|
||||||
//Not tested
|
|
||||||
|
|
||||||
// If editor type is specified, find in factory
|
|
||||||
if (!field->uiEditorTypeName(uiConfigName).isEmpty())
|
|
||||||
{
|
{
|
||||||
fieldEditor = caf::Factory<PdmUiFieldEditorHandle, QString>::instance()->create(field->uiEditorTypeName(uiConfigName));
|
if (uiFieldHandle->uiValue().type() == QVariant::Bool)
|
||||||
|
{
|
||||||
|
// Special handling of bool values into tool button editors
|
||||||
|
|
||||||
|
QString editorTypeName = caf::PdmUiToolButtonEditor::uiEditorTypeName();
|
||||||
|
fieldEditor = caf::Factory<PdmUiFieldEditorHandle, QString>::instance()->create(editorTypeName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Find the default field editor
|
fieldEditor = caf::PdmUiFieldEditorHelper::fieldEditorForField(field->uiCapability(), uiConfigName);
|
||||||
|
|
||||||
QString editorTypeName = qStringTypeName(*field);
|
|
||||||
|
|
||||||
// Handle a single value field with valueOptions: Make a combobox
|
|
||||||
|
|
||||||
QVariant::Type qtType = field->uiValue().type();
|
|
||||||
|
|
||||||
if (field->uiValue().type() != QVariant::List)
|
|
||||||
{
|
|
||||||
bool useOptionsOnly = true;
|
|
||||||
QList<PdmOptionItemInfo> options = field->valueOptions(&useOptionsOnly);
|
|
||||||
|
|
||||||
if (!options.empty())
|
|
||||||
{
|
|
||||||
editorTypeName = caf::PdmUiComboBoxEditor::uiEditorTypeName();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field->uiValue().type() == QVariant::Bool)
|
|
||||||
{
|
|
||||||
// Special handling of bool values into tool button editors
|
|
||||||
|
|
||||||
editorTypeName = caf::PdmUiToolButtonEditor::uiEditorTypeName();
|
|
||||||
}
|
|
||||||
|
|
||||||
fieldEditor = caf::Factory<PdmUiFieldEditorHandle, QString>::instance()->create(editorTypeName);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
caf::PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
|
||||||
|
|
||||||
QString editorTypeName;
|
|
||||||
if (uiFieldHandle && uiFieldHandle->uiValue().type() == QVariant::Bool)
|
|
||||||
{
|
|
||||||
// Special handling of bool values into tool button editors
|
|
||||||
|
|
||||||
editorTypeName = caf::PdmUiToolButtonEditor::uiEditorTypeName();
|
|
||||||
}
|
|
||||||
|
|
||||||
fieldEditor = caf::Factory<PdmUiFieldEditorHandle, QString>::instance()->create(editorTypeName);
|
|
||||||
|
|
||||||
if (fieldEditor)
|
if (fieldEditor)
|
||||||
{
|
{
|
||||||
m_fieldViews[field->keyword()] = fieldEditor;
|
m_fieldViews[field->keyword()] = fieldEditor;
|
||||||
@ -164,7 +128,6 @@ void PdmUiToolBarEditor::configureAndUpdateUi(const QString& uiConfigName)
|
|||||||
fieldEditor->setField(uiFieldHandle);
|
fieldEditor->setField(uiFieldHandle);
|
||||||
fieldEditor->updateUi(uiConfigName);
|
fieldEditor->updateUi(uiConfigName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,14 +161,6 @@ void PdmUiToolBarEditor::setFields(std::vector<caf::PdmFieldHandle*>& fields)
|
|||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
for (size_t i = 0; i < fields.size(); i++)
|
|
||||||
{
|
|
||||||
caf::PdmUiFieldHandle* uiFieldHandle = fields[i]->uiCapability();
|
|
||||||
|
|
||||||
// Supports only bool fields
|
|
||||||
CAF_ASSERT(uiFieldHandle->uiValue().type() == QVariant::Bool);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_fields = fields;
|
m_fields = fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user