Updated ValueHandling.

This commit is contained in:
Christoph Holzheuer
2026-01-07 17:13:35 +01:00
parent 7d43b0a694
commit 3bdc491830
17 changed files with 152 additions and 150 deletions

View File

@@ -81,29 +81,20 @@ void BCValueModel::takeValueList(BCValueList& newValueList)
* @param newValue Der neue sichtbare Zahlenwert, formatiert als QString, optionall
*/
void BCValueModel::onValueUpdated( int row, BCValue::State state, const QString& newVisisbleValue )
void BCValueModel::updateValue(int row, BCValue::Flag state, uint32_t rawValue )
{
if( row > -1 && row < _valueList.size() )
{
const BCValue& value = *(_valueList[row].get());
QModelIndex idx = index(row,1);
//qDebug();
//qDebug() << " --- OLD:"<< newVisisbleValue;
//value.dumpValue();
value.flags = state;
value.rawUIntValue = rawValue;
value.state = state;
if( !newVisisbleValue.isEmpty() && newVisisbleValue != value.visibleValue )
{
value.visibleValue = newVisisbleValue;
}
//qDebug() << " --- NEW: " << newVisisbleValue;
//value.dumpValue();
QModelIndex idx1 = index(row,1);
QModelIndex idx2 = index(row,2);
// wir schicken auf jeden fall einen update request
emit dataChanged(idx, idx, {Qt::DisplayRole, Qt::EditRole});
emit dataChanged(idx1, idx2, {Qt::DisplayRole, Qt::EditRole});
}
}
@@ -161,9 +152,9 @@ QVariant BCValueModel::data(const QModelIndex& index, int role) const
if( col == 1)
{
if( role == Qt::DisplayRole )
return QString("%1 %2").arg( value.visibleValue, value.unitLabel);
return QString("%1 %2").arg( value.formatValue(), value.unitLabel);
return value.visibleValue;
return value.formatValue();
}
return QVariant();
@@ -199,23 +190,19 @@ Qt::ItemFlags BCValueModel::flags(const QModelIndex& index) const
}
bool BCValueModel::setData(const QModelIndex& index, const QVariant& value, int role)
bool BCValueModel::setData(const QModelIndex& index, const QVariant& variant, int role)
{
// __fix!
if (index.isValid() && role == Qt::EditRole)
{
BCValuePtr item = _valueList[index.row()];
BCValuePtr value = _valueList[index.row()];
// Wir erwarten hier nur den Value-Teil (vom Slider/Editor)
// Checken ob Int oder Double
if (value.canConvert<double>())
if (variant.canConvert<int>())
{
item->visibleValue = value.toString();
value->rawUIntValue = variant.toInt();
}
_valueList[index.row()] = item;
emit dataChanged(index, index, {Qt::DisplayRole, Qt::EditRole});
return true;
}