diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp index 2bd122c9a4..a2d880ef3f 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -1178,7 +1178,7 @@ void RimEclipseResultDefinition::removePerCellFaceOptionItems(QList indicesToRemove; for (int i = 0; i < optionItems.size(); i++) { - QString text = optionItems[i].optionUiText; + QString text = optionItems[i].optionUiText(); if (RiaDefines::isPerCellFaceResult(text)) { diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmUiFieldCapability.inl b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmUiFieldCapability.inl index 5c84bc6d4d..14b16ac725 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmUiFieldCapability.inl +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmUiFieldCapability.inl @@ -29,7 +29,7 @@ void caf::PdmFieldUiCap::setValueFromUiEditor(const QVariant& uiValue uint optionIndex = uiValue.toUInt(); CAF_ASSERT(optionIndex < static_cast(m_optionEntryCache.size())); - QVariant optionVariantValue = m_optionEntryCache[optionIndex].value; + QVariant optionVariantValue = m_optionEntryCache[optionIndex].value(); typename FieldType::FieldDataType fieldValue; PdmUiFieldSpecialization::setFromVariant(optionVariantValue, fieldValue); @@ -55,7 +55,7 @@ void caf::PdmFieldUiCap::setValueFromUiEditor(const QVariant& uiValue unsigned int opIdx = selectedIndexes[i].toUInt(); if (opIdx < static_cast(m_optionEntryCache.size())) { - valuesToSetInField.push_back(m_optionEntryCache[opIdx].value); + valuesToSetInField.push_back(m_optionEntryCache[opIdx].value()); } } typename FieldType::FieldDataType value; @@ -220,7 +220,7 @@ QList caf::PdmFieldUiCap::valueOptions(bool* useOp bool isFound = false; for(unsigned int opIdx = 0; opIdx < static_cast(m_optionEntryCache.size()); ++opIdx) { - if(PdmUiFieldSpecialization::isDataElementEqual(valuesSelectedInField[i], m_optionEntryCache[opIdx].value)) + if(PdmUiFieldSpecialization::isDataElementEqual(valuesSelectedInField[i], m_optionEntryCache[opIdx].value())) { isFound = true; } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp index 11faa14a25..32762c01cc 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp @@ -42,14 +42,54 @@ namespace caf { +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +PdmOptionItemInfo::PdmOptionItemInfo(const QString& anOptionUiText, const QVariant& aValue, bool anIsDimmed /* = false */, QIcon anIcon /* = QIcon()*/) + : m_value(aValue), m_optionUiText(anOptionUiText), m_isDimmed(anIsDimmed), m_icon(anIcon) +{ +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- PdmOptionItemInfo::PdmOptionItemInfo(const QString& anOptionUiText, caf::PdmObjectHandle* obj, bool anIsDimmed /*= false*/, QIcon anIcon /*= QIcon()*/) - : optionUiText(anOptionUiText), isDimmed(anIsDimmed), icon(anIcon) + : m_optionUiText(anOptionUiText), m_isDimmed(anIsDimmed), m_icon(anIcon) { - value = QVariant::fromValue(caf::PdmPointer(obj)); + m_value = QVariant::fromValue(caf::PdmPointer(obj)); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString PdmOptionItemInfo::optionUiText() const +{ + return m_optionUiText; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QVariant PdmOptionItemInfo::value() const +{ + return m_value; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool PdmOptionItemInfo::isDimmed() const +{ + return m_isDimmed; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QIcon PdmOptionItemInfo::icon() const +{ + return m_icon; } //-------------------------------------------------------------------------------------------------- @@ -58,15 +98,20 @@ PdmOptionItemInfo::PdmOptionItemInfo(const QString& anOptionUiText, caf::PdmObje QStringList PdmOptionItemInfo::extractUiTexts(const QList& optionList) { QStringList texts; - int i; - for (i = 0; i < optionList.size(); ++i) + + for (auto option : optionList) { - texts.push_back(optionList[i].optionUiText); + texts.push_back(option.optionUiText()); } + return texts; } +//================================================================================================== +/// PdmUiItem +//================================================================================================== + //-------------------------------------------------------------------------------------------------- /// @@ -190,7 +235,6 @@ bool PdmUiItem::isUiReadOnly(QString uiConfigName /*= ""*/) return false; } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h index 58b2b1908d..f57dd9bd80 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h @@ -86,16 +86,14 @@ private: class PdmOptionItemInfo { public: - PdmOptionItemInfo(const QString& anOptionUiText, const QVariant& aValue, bool anIsDimmed = false, QIcon anIcon = QIcon() ) - : value(aValue), optionUiText(anOptionUiText), isDimmed(anIsDimmed), icon(anIcon) - {} - + PdmOptionItemInfo(const QString& anOptionUiText, const QVariant& aValue, bool anIsDimmed = false, QIcon anIcon = QIcon() ); PdmOptionItemInfo(const QString& anOptionUiText, caf::PdmObjectHandle* obj, bool anIsDimmed = false, QIcon anIcon = QIcon()); - QString optionUiText; - bool isDimmed; - QIcon icon; - QVariant value; + const QString optionUiText() const; + const QVariant value() const; + bool isDimmed() const; + const QIcon icon() const; + // Static utility methods to handle QList of PdmOptionItemInfo // Please regard as private to the PDM system @@ -104,6 +102,12 @@ public: template static bool findValues (const QList& optionList , QVariant fieldValue, std::vector& foundIndexes); + +private: + QString m_optionUiText; + QVariant m_value; + bool m_isDimmed; + QIcon m_icon; }; class PdmUiEditorHandle; @@ -131,7 +135,7 @@ bool PdmOptionItemInfo::findValues(const QList& optionList, Q for (int i= 0 ; i < optionList.size(); ++i) { - optionVariantAndIndexPairs.push_back(std::make_pair(optionList[i].value, i)); + optionVariantAndIndexPairs.push_back(std::make_pair(optionList[i].value(), i)); } for (int i = 0; i < valuesSelectedInField.size(); ++i) @@ -159,7 +163,7 @@ bool PdmOptionItemInfo::findValues(const QList& optionList, Q { for (unsigned int opIdx = 0; opIdx < static_cast(optionList.size()); ++opIdx) { - if (PdmUiFieldSpecialization::isDataElementEqual(optionList[opIdx].value, fieldValue)) + if (PdmUiFieldSpecialization::isDataElementEqual(optionList[opIdx].value(), fieldValue)) { foundIndexes.push_back(opIdx); break; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp index ce48122c9e..eaa82aab04 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp @@ -86,7 +86,7 @@ void PdmUiComboBoxEditor::configureAndUpdateUi(const QString& uiConfigName) { for (int i = 0; i < options.size(); i++) { - m_comboBox->addItem(options[i].icon, options[i].optionUiText); + m_comboBox->addItem(options[i].icon(), options[i].optionUiText()); } m_comboBox->setCurrentIndex(field()->uiValue().toInt()); } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp index 6dc54df6df..66851a01b5 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp @@ -235,7 +235,7 @@ void PdmUiLineEditor::configureAndUpdateUi(const QString& uiConfigName) if (!enumNames.isEmpty() && fromMenuOnly == true) { int enumValue = field()->uiValue().toInt(); - m_lineEdit->setText(enumNames[enumValue].optionUiText); + m_lineEdit->setText(enumNames[enumValue].optionUiText()); } else { diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.cpp index 3562e4bb94..ca00b61597 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.cpp @@ -230,7 +230,7 @@ QVariant PdmUiTableViewModel::data(const QModelIndex &index, int role /*= Qt::Di if (index < options.size()) { - displayText += options.at(index).optionUiText; + displayText += options.at(index).optionUiText(); } } } @@ -251,7 +251,7 @@ QVariant PdmUiTableViewModel::data(const QModelIndex &index, int role /*= Qt::Di return ""; } - return valueOptions[listIndex].optionUiText; + return valueOptions[listIndex].optionUiText(); } QVariant val;