mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Use subset of enums
Use setEnumSubset instead of calculateValueOptions
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "cafAssert.h"
|
||||
#include "cafPdmFieldHandle.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
@@ -103,7 +104,7 @@ namespace caf
|
||||
/// contains a valid value when the constructor is done.
|
||||
///
|
||||
/// CAF_PDM_InitField( &m_enum2Field, "Enum2Field", MyEnumType::T6, "Subset using setEnumSubset()" );
|
||||
/// caf::AppEnum<MyEnumType>::setEnumSubset( m_enum2Field.keyword(), { MyEnumType::T2, MyEnumType::T6 } );
|
||||
/// caf::AppEnum<MyEnumType>::setEnumSubset( &m_enum2Field, { MyEnumType::T2, MyEnumType::T6 } );
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
@@ -128,7 +129,11 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
static void setEnumSubset( QString fieldKeyword, std::vector<T> subset ) { m_enumSubset[fieldKeyword] = subset; }
|
||||
static void setEnumSubset( caf::PdmFieldHandle* fieldKeyword, std::vector<T> subset )
|
||||
{
|
||||
if ( !fieldKeyword ) return;
|
||||
m_enumSubset[fieldKeyword->keyword()] = subset;
|
||||
}
|
||||
static std::vector<T> enumSubset( QString fieldKeyword )
|
||||
{
|
||||
auto it = m_enumSubset.find( fieldKeyword );
|
||||
|
||||
@@ -31,7 +31,7 @@ ApplicationEnum::ApplicationEnum()
|
||||
|
||||
// Enum field displaying a subset of the defined enums using the static function setEnumSubset()
|
||||
CAF_PDM_InitField( &m_enum2Field, "Enum2Field", MyEnumType::T6, "Subset using setEnumSubset()" );
|
||||
caf::AppEnum<MyEnumType>::setEnumSubset( m_enum2Field.keyword(), { MyEnumType::T2, MyEnumType::T6 } );
|
||||
caf::AppEnum<MyEnumType>::setEnumSubset( &m_enum2Field, { MyEnumType::T2, MyEnumType::T6 } );
|
||||
|
||||
// Enum field displaying a subset of the defined enums using calculateValueOptions()
|
||||
CAF_PDM_InitFieldNoDefault( &m_enum3Field, "Enum3Field", "Subset using calculateValueOptions()" );
|
||||
|
||||
Reference in New Issue
Block a user