Fixed value display bug.
This commit is contained in:
45
bcvalue.cpp
45
bcvalue.cpp
@@ -31,6 +31,7 @@
|
||||
|
||||
|
||||
#include <QMetaEnum>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <bcvalue.h>
|
||||
|
||||
@@ -208,6 +209,8 @@ double BCValue::calcMinMaxRatio() const
|
||||
|
||||
bool BCValue::valuesForSlider( int& value, int& min, int& max ) const
|
||||
{
|
||||
value = min = max = 0;
|
||||
|
||||
// min & max sind vorraussetzung für den slider
|
||||
if( !_optMin.has_value() || !_optMax.has_value() )
|
||||
return false;
|
||||
@@ -225,6 +228,7 @@ bool BCValue::valuesForSlider( int& value, int& min, int& max ) const
|
||||
|
||||
}
|
||||
|
||||
|
||||
void BCValue::dumpValue() const
|
||||
{
|
||||
|
||||
@@ -235,4 +239,43 @@ void BCValue::dumpValue() const
|
||||
|
||||
}
|
||||
|
||||
/// ----
|
||||
QString BCValue::toString() const
|
||||
{
|
||||
QString result;
|
||||
QTextStream stream(&result);
|
||||
|
||||
stream << *this;
|
||||
|
||||
/*
|
||||
qDebug() << "DeviceID: " << _deviceID << " Register: " << _registerID << " state:" " << state << " << " label: " << _label;
|
||||
qDebug() << "formattedValue: " << formatValue() << " min: " << _optMin << " max: " << _optMax << " factor: " << _factor << " ValueType: " << (char)_valueType << " ";
|
||||
qDebug() << "indexRow: " << _indexRow << " isWord: " << isWord() << " isRO: " << isReadOnly();
|
||||
qDebug();
|
||||
*/
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Generischer Operator für ALLE Q_GADGETs
|
||||
inline QTextStream& operator<<(QTextStream& out, const BCValue& obj)
|
||||
{
|
||||
const QMetaObject* meta = &obj.staticMetaObject;
|
||||
|
||||
out << meta->className() << " { ";
|
||||
|
||||
// Iteriere über alle Properties (Reflection)
|
||||
for (int i = 0; i < meta->propertyCount(); ++i) {
|
||||
QMetaProperty prop = meta->property(i);
|
||||
const char* propName = prop.name();
|
||||
QVariant val = prop.readOnGadget(&obj);
|
||||
|
||||
out << propName << ": " << val.toString();
|
||||
|
||||
if (i < meta->propertyCount() - 1) out << ", ";
|
||||
}
|
||||
out << " }";
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user