#1830 AppFwk : Move members to private and use getter functions

This commit is contained in:
Magne Sjaastad 2017-09-01 10:39:40 +02:00
parent 7181584657
commit 5e6547c0c5
7 changed files with 72 additions and 24 deletions

View File

@ -1178,7 +1178,7 @@ void RimEclipseResultDefinition::removePerCellFaceOptionItems(QList<caf::PdmOpti
std::vector<int> indicesToRemove;
for (int i = 0; i < optionItems.size(); i++)
{
QString text = optionItems[i].optionUiText;
QString text = optionItems[i].optionUiText();
if (RiaDefines::isPerCellFaceResult(text))
{

View File

@ -29,7 +29,7 @@ void caf::PdmFieldUiCap<FieldType>::setValueFromUiEditor(const QVariant& uiValue
uint optionIndex = uiValue.toUInt();
CAF_ASSERT(optionIndex < static_cast<unsigned int>(m_optionEntryCache.size()));
QVariant optionVariantValue = m_optionEntryCache[optionIndex].value;
QVariant optionVariantValue = m_optionEntryCache[optionIndex].value();
typename FieldType::FieldDataType fieldValue;
PdmUiFieldSpecialization<typename FieldType::FieldDataType>::setFromVariant(optionVariantValue, fieldValue);
@ -55,7 +55,7 @@ void caf::PdmFieldUiCap<FieldType>::setValueFromUiEditor(const QVariant& uiValue
unsigned int opIdx = selectedIndexes[i].toUInt();
if (opIdx < static_cast<unsigned int>(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<PdmOptionItemInfo> caf::PdmFieldUiCap<FieldType>::valueOptions(bool* useOp
bool isFound = false;
for(unsigned int opIdx = 0; opIdx < static_cast<unsigned int>(m_optionEntryCache.size()); ++opIdx)
{
if(PdmUiFieldSpecialization<typename FieldType::FieldDataType>::isDataElementEqual(valuesSelectedInField[i], m_optionEntryCache[opIdx].value))
if(PdmUiFieldSpecialization<typename FieldType::FieldDataType>::isDataElementEqual(valuesSelectedInField[i], m_optionEntryCache[opIdx].value()))
{
isFound = true;
}

View File

@ -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<caf::PdmObjectHandle>(obj));
m_value = QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(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<PdmOptionItemInfo>& 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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -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<typename T>
static bool findValues (const QList<PdmOptionItemInfo>& optionList , QVariant fieldValue,
std::vector<unsigned int>& 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<PdmOptionItemInfo>& 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<PdmOptionItemInfo>& optionList, Q
{
for (unsigned int opIdx = 0; opIdx < static_cast<unsigned int>(optionList.size()); ++opIdx)
{
if (PdmUiFieldSpecialization<T>::isDataElementEqual(optionList[opIdx].value, fieldValue))
if (PdmUiFieldSpecialization<T>::isDataElementEqual(optionList[opIdx].value(), fieldValue))
{
foundIndexes.push_back(opIdx);
break;

View File

@ -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());
}

View File

@ -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
{

View File

@ -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;