mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-23 23:13:39 -06:00
Replaced uiField() and xmlField() with uiCapability() and xmlCapability()
This commit is contained in:
parent
a88b3cac83
commit
57e363896f
@ -2068,7 +2068,7 @@ void RiaApplication::regressionTestConfigureProject()
|
||||
{
|
||||
resvView->faultCollection->setShowFaultsOutsideFilters(false);
|
||||
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiField(&resvView->faultResultSettings->showCustomFaultResult);
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = resvView->faultResultSettings->showCustomFaultResult.uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
uiFieldHandle->setValueFromUi(false);
|
||||
|
@ -224,10 +224,10 @@ void RimCommandIssueFieldChanged::redo()
|
||||
if (pdmObject)
|
||||
{
|
||||
caf::PdmFieldHandle* fieldHandle = findFieldByKeyword(pdmObject, this->fieldName);
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiField(fieldHandle);
|
||||
|
||||
if (uiFieldHandle)
|
||||
if (fieldHandle && fieldHandle->uiCapability())
|
||||
{
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = fieldHandle->uiCapability();
|
||||
QVariant variantValue(this->fieldValueToApply);
|
||||
uiFieldHandle->setValueFromUi(variantValue);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ void RimMockModelSettings::fieldChangedByUi(const caf::PdmFieldHandle* changedFi
|
||||
{
|
||||
totalCellCount = cellCountX * cellCountY * cellCountZ;
|
||||
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiField(&totalCellCount);
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = totalCellCount.uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
uiFieldHandle->updateConnectedEditors();
|
||||
|
@ -1116,7 +1116,7 @@ void RimUiTreeModelPdm::setObjectToggleStateForSelection(QModelIndexList selecte
|
||||
{
|
||||
caf::PdmField<bool>* field = dynamic_cast<caf::PdmField<bool>* >(uiObjectHandle->objectToggleField());
|
||||
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiField(field);
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
if (state == RimUiTreeView::TOGGLE_ON) uiFieldHandle->setValueFromUi(true);
|
||||
@ -1142,7 +1142,7 @@ void RimUiTreeModelPdm::setObjectToggleStateForSelection(QModelIndexList selecte
|
||||
{
|
||||
caf::PdmField<bool>* field = dynamic_cast<caf::PdmField<bool>* >(uiObjectHandleChild->objectToggleField());
|
||||
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiField(field);
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
if (state == RimUiTreeView::TOGGLE_ON) uiFieldHandle->setValueFromUi(true);
|
||||
|
@ -270,14 +270,14 @@ void RimView::setMeshOnlyDrawstyle()
|
||||
{
|
||||
if (isGridVisualizationMode())
|
||||
{
|
||||
uiField(&meshMode)->setValueFromUi(FULL_MESH);
|
||||
meshMode.uiCapability()->setValueFromUi(FULL_MESH);
|
||||
}
|
||||
else
|
||||
{
|
||||
uiField(&meshMode)->setValueFromUi(FAULTS_MESH);
|
||||
meshMode.uiCapability()->setValueFromUi(FAULTS_MESH);
|
||||
}
|
||||
|
||||
uiField(&surfaceMode)->setValueFromUi(NO_SURFACE);
|
||||
surfaceMode.uiCapability()->setValueFromUi(NO_SURFACE);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -287,13 +287,13 @@ void RimView::setMeshSurfDrawstyle()
|
||||
{
|
||||
if (isGridVisualizationMode())
|
||||
{
|
||||
uiField(&surfaceMode)->setValueFromUi(SURFACE);
|
||||
uiField(&meshMode)->setValueFromUi(FULL_MESH);
|
||||
surfaceMode.uiCapability()->setValueFromUi(SURFACE);
|
||||
meshMode.uiCapability()->setValueFromUi(FULL_MESH);
|
||||
}
|
||||
else
|
||||
{
|
||||
uiField(&surfaceMode)->setValueFromUi(FAULTS);
|
||||
uiField(&meshMode)->setValueFromUi(FAULTS_MESH);
|
||||
surfaceMode.uiCapability()->setValueFromUi(FAULTS);
|
||||
meshMode.uiCapability()->setValueFromUi(FAULTS_MESH);
|
||||
}
|
||||
}
|
||||
|
||||
@ -309,14 +309,14 @@ void RimView::setFaultMeshSurfDrawstyle()
|
||||
// Mesh SF SF SF
|
||||
if (this->isGridVisualizationMode())
|
||||
{
|
||||
uiField(&surfaceMode)->setValueFromUi(SURFACE);
|
||||
surfaceMode.uiCapability()->setValueFromUi(SURFACE);
|
||||
}
|
||||
else
|
||||
{
|
||||
uiField(&surfaceMode)->setValueFromUi(FAULTS);
|
||||
surfaceMode.uiCapability()->setValueFromUi(FAULTS);
|
||||
}
|
||||
|
||||
uiField(&meshMode)->setValueFromUi(FAULTS_MESH);
|
||||
meshMode.uiCapability()->setValueFromUi(FAULTS_MESH);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -326,14 +326,14 @@ void RimView::setSurfOnlyDrawstyle()
|
||||
{
|
||||
if (isGridVisualizationMode())
|
||||
{
|
||||
uiField(&surfaceMode)->setValueFromUi(SURFACE);
|
||||
surfaceMode.uiCapability()->setValueFromUi(SURFACE);
|
||||
}
|
||||
else
|
||||
{
|
||||
uiField(&surfaceMode)->setValueFromUi(FAULTS);
|
||||
surfaceMode.uiCapability()->setValueFromUi(FAULTS);
|
||||
}
|
||||
|
||||
uiField(&meshMode)->setValueFromUi(NO_MESH);
|
||||
meshMode.uiCapability()->setValueFromUi(NO_MESH);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -344,13 +344,13 @@ void RimView::setShowFaultsOnly(bool showFaults)
|
||||
if (showFaults)
|
||||
{
|
||||
m_previousGridModeMeshLinesWasFaults = meshMode() == FAULTS_MESH;
|
||||
if (surfaceMode() != NO_SURFACE) uiField(&surfaceMode)->setValueFromUi(FAULTS);
|
||||
if (meshMode() != NO_MESH) uiField(&meshMode)->setValueFromUi(FAULTS_MESH);
|
||||
if (surfaceMode() != NO_SURFACE) surfaceMode.uiCapability()->setValueFromUi(FAULTS);
|
||||
if (meshMode() != NO_MESH) meshMode.uiCapability()->setValueFromUi(FAULTS_MESH);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (surfaceMode() != NO_SURFACE) uiField(&surfaceMode)->setValueFromUi(SURFACE);
|
||||
if (meshMode() != NO_MESH) uiField(&meshMode)->setValueFromUi(m_previousGridModeMeshLinesWasFaults ? FAULTS_MESH: FULL_MESH);
|
||||
if (surfaceMode() != NO_SURFACE) surfaceMode.uiCapability()->setValueFromUi(SURFACE);
|
||||
if (meshMode() != NO_MESH) meshMode.uiCapability()->setValueFromUi(m_previousGridModeMeshLinesWasFaults ? FAULTS_MESH : FULL_MESH);
|
||||
}
|
||||
}
|
||||
|
||||
@ -359,7 +359,7 @@ void RimView::setShowFaultsOnly(bool showFaults)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimView::setSurfaceDrawstyle()
|
||||
{
|
||||
if (surfaceMode() != NO_SURFACE) uiField(&surfaceMode)->setValueFromUi(SURFACE);
|
||||
if (surfaceMode() != NO_SURFACE) surfaceMode.uiCapability()->setValueFromUi(SURFACE);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -1491,7 +1491,7 @@ void RiuMainWindow::slotFramerateChanged(double frameRate)
|
||||
{
|
||||
if (RiaApplication::instance()->activeReservoirView() != NULL)
|
||||
{
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiField(&RiaApplication::instance()->activeReservoirView()->maximumFrameRate);
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = RiaApplication::instance()->activeReservoirView()->maximumFrameRate.uiCapability();
|
||||
uiFieldHandle->setValueFromUi(QVariant(frameRate));
|
||||
}
|
||||
}
|
||||
@ -1754,7 +1754,7 @@ void RiuMainWindow::slotToggleFaultLabelsAction(bool showLabels)
|
||||
RimEclipseView* activeRiv = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
|
||||
if (!activeRiv) return;
|
||||
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiField(&activeRiv->faultCollection->showFaultLabel);
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = activeRiv->faultCollection->showFaultLabel.uiCapability();
|
||||
uiFieldHandle->setValueFromUi(showLabels);
|
||||
|
||||
refreshDrawStyleActions();
|
||||
@ -1885,7 +1885,7 @@ void RiuMainWindow::slotScaleChanged(int scaleValue)
|
||||
{
|
||||
if (RiaApplication::instance()->activeReservoirView())
|
||||
{
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiField(&RiaApplication::instance()->activeReservoirView()->scaleZ);
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = RiaApplication::instance()->activeReservoirView()->scaleZ.uiCapability();
|
||||
uiFieldHandle->setValueFromUi(scaleValue);
|
||||
}
|
||||
}
|
||||
@ -2116,7 +2116,7 @@ void RiuMainWindow::slotAddWellCellsToRangeFilterAction(bool doAdd)
|
||||
caf::AppEnum<RimEclipseWellCollection::WellCellsRangeFilterType> rangeAddType;
|
||||
rangeAddType = doAdd ? RimEclipseWellCollection::RANGE_ADD_INDIVIDUAL : RimEclipseWellCollection::RANGE_ADD_NONE;
|
||||
|
||||
caf::PdmUiFieldHandle* pdmUiFieldHandle = uiField(&riv->wellCollection()->wellCellsToRangeFilterMode);
|
||||
caf::PdmUiFieldHandle* pdmUiFieldHandle = riv->wellCollection()->wellCellsToRangeFilterMode.uiCapability();
|
||||
if (pdmUiFieldHandle)
|
||||
{
|
||||
pdmUiFieldHandle->setValueFromUi(static_cast<unsigned int>(rangeAddType.index()));
|
||||
|
@ -275,7 +275,7 @@ void RiuViewerCommands::slotHideFault()
|
||||
RimFault* rimFault = eclipseView->faultCollection()->findFaultByName(faultName);
|
||||
if (rimFault)
|
||||
{
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiField(&rimFault->showFault);
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = rimFault->showFault.uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
uiFieldHandle->setValueFromUi(!rimFault->showFault);
|
||||
|
@ -896,7 +896,7 @@ void WellSelectionPage::buildWellTreeView()
|
||||
if (oilRegion->selected)
|
||||
{
|
||||
caf::PdmObjectGroup* regGroup = new caf::PdmObjectGroup;
|
||||
regGroup->setUiName(uiField(oilRegion->userDescriptionField())->uiValue().toString());
|
||||
regGroup->setUiName(oilRegion->userDescriptionField()->uiCapability()->uiValue().toString());
|
||||
|
||||
m_regionsWithVisibleWells->objects.push_back(regGroup);
|
||||
|
||||
@ -906,7 +906,7 @@ void WellSelectionPage::buildWellTreeView()
|
||||
if (oilField->selected)
|
||||
{
|
||||
caf::PdmObjectGroup* fieldGroup = new caf::PdmObjectGroup;
|
||||
fieldGroup->setUiName(uiField(oilField->userDescriptionField())->uiValue().toString());
|
||||
fieldGroup->setUiName(oilField->userDescriptionField()->uiCapability()->uiValue().toString());
|
||||
|
||||
regGroup->objects.push_back(fieldGroup);
|
||||
|
||||
|
@ -57,7 +57,7 @@ QString CmdFieldChangeExec::name()
|
||||
{
|
||||
QString fieldText;
|
||||
|
||||
PdmUiFieldHandle* uiFieldHandle = uiField(field);
|
||||
PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
fieldText = QString("Change field '%1'").arg(uiFieldHandle->uiName());
|
||||
@ -91,8 +91,8 @@ void CmdFieldChangeExec::redo()
|
||||
return;
|
||||
}
|
||||
|
||||
PdmUiFieldHandle* uiFieldHandle = uiField(field);
|
||||
PdmXmlFieldHandle* xmlFieldHandle = xmlField(field);
|
||||
PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||
PdmXmlFieldHandle* xmlFieldHandle = field->xmlCapability();
|
||||
if (uiFieldHandle && xmlFieldHandle)
|
||||
{
|
||||
if (m_commandData->m_redoFieldValueSerialized.isEmpty())
|
||||
@ -140,8 +140,8 @@ void CmdFieldChangeExec::undo()
|
||||
return;
|
||||
}
|
||||
|
||||
PdmUiFieldHandle* uiFieldHandle = uiField(field);
|
||||
PdmXmlFieldHandle* xmlFieldHandle = xmlField(field);
|
||||
PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||
PdmXmlFieldHandle* xmlFieldHandle = field->xmlCapability();
|
||||
if (uiFieldHandle && xmlFieldHandle)
|
||||
{
|
||||
QXmlStreamReader xmlStream(m_commandData->m_undoFieldValueSerialized);
|
||||
|
@ -109,7 +109,7 @@ void CmdUiCommandSystemImpl::fieldChangedCommand(PdmFieldHandle* editorField, co
|
||||
for (int i = 0; i < fieldsToUpdate.size(); i++)
|
||||
{
|
||||
PdmFieldHandle* field = fieldsToUpdate[i];
|
||||
PdmUiFieldHandle* uiFieldHandle = uiField(field);
|
||||
PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
QVariant fieldCurrentUiValue = uiFieldHandle->uiValue();
|
||||
|
@ -77,9 +77,9 @@ void CmdAddItemExec::redo()
|
||||
PdmFieldHandle* field = PdmReferenceHelper::fieldFromReference(m_commandData->m_rootObject, m_commandData->m_pathToField);
|
||||
|
||||
PdmChildArrayFieldHandle* listField = dynamic_cast<PdmChildArrayFieldHandle*>(field);
|
||||
if (listField && xmlField(field))
|
||||
if (listField && field->xmlCapability())
|
||||
{
|
||||
QString classKeyword = xmlField(field)->childClassKeyword();
|
||||
QString classKeyword = field->xmlCapability()->childClassKeyword();
|
||||
|
||||
if (classKeyword.isEmpty()) return;
|
||||
|
||||
|
@ -68,5 +68,17 @@ bool PdmFieldHandle::hasPtrReferencedObjects()
|
||||
return (ptrReffedObjs.size() > 0);
|
||||
}
|
||||
|
||||
// These two functions can be used when PdmCore is used standalone without PdmUi/PdmXml
|
||||
/*
|
||||
PdmUiFieldHandle* PdmFieldHandle::uiCapability()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PdmXmlFieldHandle* PdmFieldHandle::xmlCapability()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
*/
|
||||
|
||||
} // End of namespace caf
|
||||
|
@ -8,6 +8,8 @@ namespace caf
|
||||
{
|
||||
|
||||
class PdmObjectHandle;
|
||||
class PdmUiFieldHandle;
|
||||
class PdmXmlFieldHandle;
|
||||
|
||||
//==================================================================================================
|
||||
/// Base class for all fields, making it possible to handle them generically
|
||||
@ -39,6 +41,9 @@ public:
|
||||
template <typename CapabilityType>
|
||||
CapabilityType* capability();
|
||||
|
||||
PdmUiFieldHandle* uiCapability();
|
||||
PdmXmlFieldHandle* xmlCapability();
|
||||
|
||||
private:
|
||||
PDM_DISABLE_COPY_AND_ASSIGN(PdmFieldHandle);
|
||||
|
||||
|
@ -57,6 +57,7 @@ class QXmlStreamWriter;
|
||||
#include "cafPdmXmlObjectHandle.h"
|
||||
#include "cafPdmXmlObjectHandleMacros.h"
|
||||
|
||||
#include "cafPdmFieldHandle.h"
|
||||
#include "cafInternalPdmUiFieldCapability.h"
|
||||
#include "cafInternalPdmXmlFieldCapability.h"
|
||||
|
||||
@ -153,7 +154,7 @@ public:
|
||||
{
|
||||
addField(field, keyword);
|
||||
|
||||
PdmUiFieldHandle* uiFieldHandle = uiField(field);
|
||||
PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
uiFieldHandle->setUiItemInfo(fieldDescription);
|
||||
|
@ -8,16 +8,6 @@
|
||||
namespace caf
|
||||
{
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
PdmUiFieldHandle* uiField(PdmFieldHandle* field)
|
||||
{
|
||||
if (!field) return NULL;
|
||||
PdmUiFieldHandle* uiField = field->capability<PdmUiFieldHandle>();
|
||||
return uiField;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -64,5 +54,15 @@ void PdmUiFieldHandle::updateConnectedUiEditors(PdmFieldHandle* field)
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Implementation of uiCapability() defined in cafPdmFieldHandle.h
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
PdmUiFieldHandle* PdmFieldHandle::uiCapability()
|
||||
{
|
||||
PdmUiFieldHandle* uiField = capability<PdmUiFieldHandle>();
|
||||
assert(uiField);
|
||||
|
||||
return uiField;
|
||||
}
|
||||
|
||||
} // End of namespace caf
|
||||
|
@ -33,6 +33,5 @@ private:
|
||||
PdmFieldHandle* m_owner;
|
||||
};
|
||||
|
||||
PdmUiFieldHandle* uiField(PdmFieldHandle* field);
|
||||
|
||||
} // End of namespace caf
|
||||
|
@ -47,7 +47,7 @@ void PdmUiObjectHandle::uiOrdering(QString uiConfigName, PdmUiOrdering& uiOrderi
|
||||
m_owner->fields(fields);
|
||||
for (size_t i = 0; i < fields.size(); ++i)
|
||||
{
|
||||
PdmUiFieldHandle * field = uiField(fields[i]);
|
||||
PdmUiFieldHandle * field = fields[i]->uiCapability();
|
||||
if (!uiOrdering.contains(field))
|
||||
{
|
||||
uiOrdering.add(field->fieldHandle());
|
||||
@ -114,7 +114,7 @@ void PdmUiObjectHandle::addDefaultUiTreeChildren(PdmUiTreeOrdering* uiTreeOrderi
|
||||
{
|
||||
if (fields[fIdx]->hasChildObjects() && !uiTreeOrdering->containsField(fields[fIdx]))
|
||||
{
|
||||
if (uiField(fields[fIdx])->isUiHidden() && !uiField(fields[fIdx])->isUiChildrenHidden())
|
||||
if (fields[fIdx]->uiCapability()->isUiHidden() && !fields[fIdx]->uiCapability()->isUiChildrenHidden())
|
||||
{
|
||||
std::vector<PdmObjectHandle*> children;
|
||||
fields[fIdx]->childObjects(&children);
|
||||
@ -127,7 +127,7 @@ void PdmUiObjectHandle::addDefaultUiTreeChildren(PdmUiTreeOrdering* uiTreeOrderi
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!uiField(fields[fIdx])->isUiHidden())
|
||||
else if (!fields[fIdx]->uiCapability()->isUiHidden())
|
||||
{
|
||||
uiTreeOrdering->add(fields[fIdx]);
|
||||
}
|
||||
@ -162,7 +162,7 @@ void PdmUiObjectHandle::expandUiTree(PdmUiTreeOrdering* root, QString uiConfigNa
|
||||
{
|
||||
if (!root->ignoreSubTree())
|
||||
{
|
||||
if (root->isRepresentingField() && !uiField(root->field())->isUiChildrenHidden(uiConfigName))
|
||||
if (root->isRepresentingField() && !root->field()->uiCapability()->isUiChildrenHidden(uiConfigName))
|
||||
{
|
||||
std::vector<PdmObjectHandle*> fieldsChildObjects;
|
||||
root->field()->childObjects(&fieldsChildObjects);
|
||||
@ -196,7 +196,7 @@ void PdmUiObjectHandle::updateUiIconFromToggleField()
|
||||
{
|
||||
if (objectToggleField())
|
||||
{
|
||||
PdmUiFieldHandle* uiFieldHandle = uiField(objectToggleField());
|
||||
PdmUiFieldHandle* uiFieldHandle = objectToggleField()->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
bool active = uiFieldHandle->uiValue().toBool();
|
||||
|
@ -93,7 +93,7 @@ bool PdmUiOrdering::contains(const PdmUiItem* item)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiOrdering::add(const PdmFieldHandle* field)
|
||||
{
|
||||
PdmUiFieldHandle* uiItem = uiField(const_cast<PdmFieldHandle*>(field));
|
||||
PdmUiFieldHandle* uiItem = const_cast<PdmFieldHandle*>(field)->uiCapability();
|
||||
assert(uiItem);
|
||||
m_ordering.push_back(uiItem);
|
||||
}
|
||||
|
@ -251,8 +251,8 @@ PdmUiItem* PdmUiTreeOrdering::uiItem() const
|
||||
PdmUiItem* PdmUiTreeOrdering::activeItem() const
|
||||
{
|
||||
if (isRepresentingObject()) return uiObj(m_object);
|
||||
if (isRepresentingField()) return uiField(m_field);
|
||||
if (isDisplayItemOnly()) return m_uiItem;
|
||||
if (isRepresentingField()) return m_field->uiCapability();
|
||||
if (isDisplayItemOnly()) return m_uiItem;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -8,15 +8,6 @@
|
||||
namespace caf
|
||||
{
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
PdmXmlFieldHandle* xmlField(PdmFieldHandle* field)
|
||||
{
|
||||
if (!field) return NULL;
|
||||
PdmXmlFieldHandle* xmlField = field->capability<PdmXmlFieldHandle>();
|
||||
return xmlField;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -58,4 +49,15 @@ QString PdmXmlFieldHandle::childClassKeyword()
|
||||
return m_childClassKeyword;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Implementation of uiCapability() defined in cafPdmFieldHandle.h
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
PdmXmlFieldHandle* PdmFieldHandle::xmlCapability()
|
||||
{
|
||||
PdmXmlFieldHandle* xmlField = capability<PdmXmlFieldHandle>();
|
||||
assert(xmlField);
|
||||
|
||||
return xmlField;
|
||||
}
|
||||
|
||||
} // End of namespace caf
|
||||
|
@ -51,8 +51,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
PdmXmlFieldHandle* xmlField(PdmFieldHandle* field);
|
||||
|
||||
} // End of namespace caf
|
||||
|
||||
#include "cafInternalPdmXmlFieldCapability.h"
|
||||
|
@ -57,9 +57,9 @@ void PdmXmlObjectHandle::readFields(QXmlStreamReader& xmlStream, PdmObjectFactor
|
||||
QString name = xmlStream.name().toString();
|
||||
|
||||
PdmFieldHandle* fieldHandle = m_owner->findField(name);
|
||||
PdmXmlFieldHandle* xmlFieldHandle = xmlField(fieldHandle);
|
||||
if (xmlFieldHandle)
|
||||
if (fieldHandle && fieldHandle->xmlCapability())
|
||||
{
|
||||
PdmXmlFieldHandle* xmlFieldHandle = fieldHandle->xmlCapability();
|
||||
if (xmlFieldHandle->isIOReadable())
|
||||
{
|
||||
// readFieldData assumes that the xmlStream points to first token of field content.
|
||||
@ -114,7 +114,7 @@ void PdmXmlObjectHandle::writeFields(QXmlStreamWriter& xmlStream)
|
||||
m_owner->fields(fields);
|
||||
for (size_t it = 0; it < fields.size(); ++it)
|
||||
{
|
||||
PdmXmlFieldHandle* field = xmlField(fields[it]);
|
||||
PdmXmlFieldHandle* field = fields[it]->xmlCapability();
|
||||
if (field && field->isIOWritable())
|
||||
{
|
||||
QString keyword = field->fieldHandle()->keyword();
|
||||
|
@ -163,7 +163,7 @@ QVariant caf::UiListViewModelPdm::data(const QModelIndex &index, int role /*= Qt
|
||||
fieldIndex = index.column();
|
||||
}
|
||||
|
||||
PdmUiFieldHandle* uiFieldHandle = uiField(fields[fieldIndex]);
|
||||
PdmUiFieldHandle* uiFieldHandle = fields[fieldIndex]->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
return uiFieldHandle->uiValue();
|
||||
|
@ -174,11 +174,11 @@ void PdmUiTableViewEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
}
|
||||
}
|
||||
|
||||
if (m_pdmListField && uiField(m_pdmListField))
|
||||
if (m_pdmListField && m_pdmListField->uiCapability())
|
||||
{
|
||||
QString text = "";
|
||||
m_tableHeadingIcon->setPixmap(uiField(m_pdmListField)->uiIcon(uiConfigName).pixmap(16, 16));
|
||||
m_tableHeading->setText(uiField(m_pdmListField)->uiName(uiConfigName));
|
||||
m_tableHeadingIcon->setPixmap(m_pdmListField->uiCapability()->uiIcon(uiConfigName).pixmap(16, 16));
|
||||
m_tableHeading->setText(m_pdmListField->uiCapability()->uiName(uiConfigName));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -194,8 +194,12 @@ void PdmUiTableViewEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
void PdmUiTableViewEditor::setListField(PdmChildArrayFieldHandle* pdmListField)
|
||||
{
|
||||
m_pdmListField = pdmListField;
|
||||
caf::PdmUiFieldHandle* uifield = uiField(m_pdmListField);
|
||||
|
||||
caf::PdmUiFieldHandle* uifield = NULL;
|
||||
if (m_pdmListField)
|
||||
{
|
||||
uifield = m_pdmListField->uiCapability();
|
||||
}
|
||||
this->bindToPdmItem(uifield);
|
||||
|
||||
if (!m_pdmListField)
|
||||
@ -398,10 +402,10 @@ void PdmUiTableViewEditor::updateSelectionManagerFromTableSelection()
|
||||
{
|
||||
QModelIndex mi = modelIndexList[i];
|
||||
PdmFieldHandle* pdmFieldHandle = m_tableModelPdm->getField(mi);
|
||||
PdmUiFieldHandle* uiFieldHandle = uiField(pdmFieldHandle);
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
items.push_back(uiFieldHandle);
|
||||
|
||||
if (pdmFieldHandle && pdmFieldHandle->uiCapability())
|
||||
{
|
||||
items.push_back(pdmFieldHandle->uiCapability());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ QVariant PdmUiTableViewModel::headerData(int section, Qt::Orientation orientatio
|
||||
{
|
||||
if (orientation == Qt::Horizontal)
|
||||
{
|
||||
PdmUiFieldHandle* uiFieldHandle = uiField(getField(createIndex(0, section)));
|
||||
PdmUiFieldHandle* uiFieldHandle = getField(createIndex(0, section))->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
return uiFieldHandle->uiName(m_currentConfigName);
|
||||
@ -143,7 +143,7 @@ Qt::ItemFlags PdmUiTableViewModel::flags(const QModelIndex &index) const
|
||||
}
|
||||
|
||||
PdmFieldHandle* field = getField(index);
|
||||
PdmUiFieldHandle* uiFieldHandle = uiField(field);
|
||||
PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
if (uiFieldHandle->isUiReadOnly(m_currentConfigName))
|
||||
@ -169,7 +169,7 @@ bool PdmUiTableViewModel::setData(const QModelIndex &index, const QVariant &valu
|
||||
bool toggleOn = (value == Qt::Checked);
|
||||
PdmFieldHandle* field = getField(index);
|
||||
|
||||
PdmUiFieldHandle* uiFieldHandle = uiField(field);
|
||||
PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||
PdmUiCommandSystemProxy::instance()->setUiValueToField(uiFieldHandle, toggleOn);
|
||||
|
||||
return true;
|
||||
@ -187,7 +187,7 @@ QVariant PdmUiTableViewModel::data(const QModelIndex &index, int role /*= Qt::Di
|
||||
if (role == Qt::DisplayRole || role == Qt::EditRole)
|
||||
{
|
||||
PdmFieldHandle* fieldHandle = getField(index);
|
||||
PdmUiFieldHandle* uiFieldHandle = uiField(fieldHandle);
|
||||
PdmUiFieldHandle* uiFieldHandle = fieldHandle->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
bool fromMenuOnly = false;
|
||||
@ -243,7 +243,7 @@ QVariant PdmUiTableViewModel::data(const QModelIndex &index, int role /*= Qt::Di
|
||||
{
|
||||
if (isRepresentingBoolean(index))
|
||||
{
|
||||
PdmUiFieldHandle* uiFieldHandle = uiField(getField(index));
|
||||
PdmUiFieldHandle* uiFieldHandle = getField(index)->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
QVariant val = uiFieldHandle->uiValue();
|
||||
@ -456,10 +456,9 @@ PdmUiFieldEditorHandle* PdmUiTableViewModel::getEditor(const QModelIndex &index)
|
||||
editor = it->second;
|
||||
if (editor)
|
||||
{
|
||||
PdmUiFieldHandle* uiFieldHandle = uiField(field);
|
||||
if (uiFieldHandle)
|
||||
if (field)
|
||||
{
|
||||
editor->setField(uiFieldHandle);
|
||||
editor->setField(field->uiCapability());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -544,10 +543,9 @@ PdmObjectHandle* PdmUiTableViewModel::pdmObjectForRow(int row) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool PdmUiTableViewModel::isRepresentingBoolean(const QModelIndex &index) const
|
||||
{
|
||||
PdmUiFieldHandle* uiFieldHandle = uiField(getField(index));
|
||||
if (uiFieldHandle)
|
||||
if (getField(index))
|
||||
{
|
||||
QVariant val = uiFieldHandle->uiValue();
|
||||
QVariant val = getField(index)->uiCapability()->uiValue();
|
||||
if (val.type() == QVariant::Bool)
|
||||
{
|
||||
return true;
|
||||
|
@ -144,7 +144,7 @@ void PdmUiToolBarEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
}
|
||||
*/
|
||||
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiField(field);
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||
|
||||
QString editorTypeName;
|
||||
if (uiFieldHandle && uiFieldHandle->uiValue().type() == QVariant::Bool)
|
||||
@ -181,7 +181,7 @@ void PdmUiToolBarEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
// See Qt doc for QToolBar::insertWidget
|
||||
QAction* action = m_actions[i];
|
||||
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiField(field);
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
action->setEnabled(!uiFieldHandle->isUiReadOnly(uiConfigName));
|
||||
@ -201,7 +201,7 @@ void PdmUiToolBarEditor::setFields(std::vector<caf::PdmFieldHandle*>& fields)
|
||||
|
||||
for (size_t i = 0; i < fields.size(); i++)
|
||||
{
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiField(fields[i]);
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = fields[i]->uiCapability();
|
||||
|
||||
// Supports only bool fields
|
||||
assert(uiFieldHandle->uiValue().type() == QVariant::Bool);
|
||||
|
@ -484,7 +484,7 @@ QVariant PdmUiTreeViewModel::data(const QModelIndex &index, int role ) const
|
||||
bool isDisplayOnly = uitreeOrdering->isDisplayItemOnly();
|
||||
|
||||
// MODTODO
|
||||
//assert (uitreeOrdering->isValid()); // Tree generation has some error.
|
||||
//assert (uitreeOrdering->isValid()); // Tree generation has some error.
|
||||
|
||||
if (role == Qt::DisplayRole || role == Qt::EditRole)
|
||||
{
|
||||
@ -495,7 +495,7 @@ QVariant PdmUiTreeViewModel::data(const QModelIndex &index, int role ) const
|
||||
{
|
||||
if (pdmUiObject->userDescriptionField())
|
||||
{
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiField(pdmUiObject->userDescriptionField());
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = pdmUiObject->userDescriptionField()->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
return uiFieldHandle->uiValue();
|
||||
@ -559,7 +559,7 @@ QVariant PdmUiTreeViewModel::data(const QModelIndex &index, int role ) const
|
||||
PdmUiObjectHandle* pdmUiObj = uiObj(uitreeOrdering->object());
|
||||
if (pdmUiObj && pdmUiObj->objectToggleField())
|
||||
{
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiField(pdmUiObj->objectToggleField());
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = pdmUiObj->objectToggleField()->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
bool isToggledOn = uiFieldHandle->uiValue().toBool();
|
||||
@ -603,7 +603,7 @@ bool PdmUiTreeViewModel::setData(const QModelIndex &index, const QVariant &value
|
||||
{
|
||||
if (role == Qt::EditRole && uiObject->userDescriptionField())
|
||||
{
|
||||
PdmUiFieldHandle* userDescriptionUiField = uiField(uiObject->userDescriptionField());
|
||||
PdmUiFieldHandle* userDescriptionUiField = uiObject->userDescriptionField()->uiCapability();
|
||||
if (userDescriptionUiField)
|
||||
{
|
||||
userDescriptionUiField->setValueFromUi(value);
|
||||
@ -615,7 +615,7 @@ bool PdmUiTreeViewModel::setData(const QModelIndex &index, const QVariant &value
|
||||
{
|
||||
bool toggleOn = (value == Qt::Checked);
|
||||
|
||||
PdmUiFieldHandle* toggleUiField = uiField(uiObject->objectToggleField());
|
||||
PdmUiFieldHandle* toggleUiField = uiObject->objectToggleField()->uiCapability();
|
||||
if (toggleUiField)
|
||||
{
|
||||
toggleUiField->setValueFromUi(value);
|
||||
@ -649,7 +649,7 @@ Qt::ItemFlags PdmUiTreeViewModel::flags(const QModelIndex &index) const
|
||||
PdmUiObjectHandle* pdmUiObject = uiObj(treeItem->object());
|
||||
if (pdmUiObject)
|
||||
{
|
||||
if (pdmUiObject->userDescriptionField() && !uiField(pdmUiObject->userDescriptionField())->isUiReadOnly())
|
||||
if (pdmUiObject->userDescriptionField() && !pdmUiObject->userDescriptionField()->uiCapability()->isUiReadOnly())
|
||||
{
|
||||
flagMask = flagMask | Qt::ItemIsEditable;
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ QVariant UiTreeModelPdm::data(const QModelIndex &index, int role /*= Qt::Display
|
||||
{
|
||||
if (children[cIdx] == obj)
|
||||
{
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiField(fields[i]);
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = fields[i]->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
parentField = uiFieldHandle;
|
||||
@ -225,7 +225,7 @@ QVariant UiTreeModelPdm::data(const QModelIndex &index, int role /*= Qt::Display
|
||||
{
|
||||
if (uiObject->userDescriptionField())
|
||||
{
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiField(uiObject->userDescriptionField());
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiObject->userDescriptionField()->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
return uiFieldHandle->uiValue();
|
||||
@ -279,7 +279,7 @@ QVariant UiTreeModelPdm::data(const QModelIndex &index, int role /*= Qt::Display
|
||||
{
|
||||
if (uiObject && uiObject->objectToggleField())
|
||||
{
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiField(uiObject->objectToggleField());
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiObject->objectToggleField()->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
bool isToggledOn = uiFieldHandle->uiValue().toBool();
|
||||
@ -332,7 +332,7 @@ bool UiTreeModelPdm::setData(const QModelIndex &index, const QVariant &value, in
|
||||
{
|
||||
if (role == Qt::EditRole && uiObject->userDescriptionField())
|
||||
{
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiField(uiObject->userDescriptionField());
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiObject->userDescriptionField()->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
uiFieldHandle->setValueFromUi(value);
|
||||
@ -346,7 +346,7 @@ bool UiTreeModelPdm::setData(const QModelIndex &index, const QVariant &value, in
|
||||
{
|
||||
bool toggleOn = (value == Qt::Checked);
|
||||
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiField(uiObject->objectToggleField());
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiObject->objectToggleField()->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
uiFieldHandle->setValueFromUi(toggleOn);
|
||||
@ -378,7 +378,7 @@ Qt::ItemFlags UiTreeModelPdm::flags(const QModelIndex &index) const
|
||||
PdmUiObjectHandle* uiObject = uiObj(treeItem->dataObject());
|
||||
if (uiObject)
|
||||
{
|
||||
if (uiObject->userDescriptionField() && !uiField(uiObject->userDescriptionField())->isUiReadOnly())
|
||||
if (uiObject->userDescriptionField() && !uiObject->userDescriptionField()->uiCapability()->isUiReadOnly())
|
||||
{
|
||||
flagMask = flagMask | Qt::ItemIsEditable;
|
||||
}
|
||||
@ -647,7 +647,7 @@ PdmUiTreeItem* UiTreeItemBuilderPdm::buildViewItems(PdmUiTreeItem* parentTreeIte
|
||||
// a more general ui tree building method is in place.
|
||||
|
||||
caf::PdmFieldHandle* parentField = object->parentField();
|
||||
if (parentField && uiField(parentField) && uiField(parentField)->isUiHidden())
|
||||
if (parentField && parentField->uiCapability() && parentField->uiCapability()->isUiHidden())
|
||||
{
|
||||
objectTreeItem = parentTreeItem;
|
||||
}
|
||||
@ -667,7 +667,7 @@ PdmUiTreeItem* UiTreeItemBuilderPdm::buildViewItems(PdmUiTreeItem* parentTreeIte
|
||||
// Fix for hidden legend definitions. There is only one visible legend definition, the others reside in a hidden container
|
||||
// Todo: This is a Hack. Must be rewritten when a more general ui tree building method is in place.
|
||||
// See comment at top of this method.
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiField(field);
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||
if (uiFieldHandle && uiFieldHandle->isUiChildrenHidden())
|
||||
{
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user