Added ValueModel, first run.
This commit is contained in:
34
bcvalue.cpp
34
bcvalue.cpp
@@ -27,6 +27,7 @@
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include <QMetaEnum>
|
||||
|
||||
#include <bcvalue.h>
|
||||
|
||||
@@ -47,10 +48,39 @@ uint8_t BCValue::getLongValue()
|
||||
}
|
||||
|
||||
|
||||
BCValue* BCValue::makeValue(BCDevice::ID deviceI, const BCValueParams& params )
|
||||
BCValue* BCValue::makeValue( BCDevice::ID deviceID, const BCValueParams& params )
|
||||
{
|
||||
|
||||
auto setIfExists = [&]( QStringView source, optDouble& target )
|
||||
{
|
||||
if( !source.isEmpty() )
|
||||
{
|
||||
bool ok;
|
||||
double testVal = source.toDouble(&ok);
|
||||
if (ok)
|
||||
target = testVal;
|
||||
}
|
||||
};
|
||||
|
||||
static QMetaEnum s_bcValueEnum{QMetaEnum::fromType<BC::ID>()};
|
||||
|
||||
return nullptr;
|
||||
/*
|
||||
Wir brauchen:
|
||||
- eine gültige ID
|
||||
|
||||
*/
|
||||
BCValue* newValue{};
|
||||
|
||||
auto IDVal = s_bcValueEnum.keyToValue64( params.ID.toLatin1().constData() );
|
||||
if( IDVal.has_value() )
|
||||
{
|
||||
newValue = new BCValue( deviceID, BC::ID( IDVal.value() ) );
|
||||
setIfExists( params.Factor, newValue->factor );
|
||||
setIfExists( params.Min, newValue->min );
|
||||
setIfExists( params.Max, newValue->max );
|
||||
newValue->defaultValue.setValue( params.Default );
|
||||
newValue->value.setValue( params.Current );
|
||||
}
|
||||
|
||||
return newValue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user