Made 'syncFromDevice' work again.

This commit is contained in:
2025-12-28 22:48:18 +01:00
parent 517dcceb81
commit b7d4441d56
20 changed files with 167 additions and 916 deletions

View File

@@ -40,7 +40,7 @@ BCValueModel::BCValueModel(QObject *parent)
}
void BCValueModel::addValue(const BCDataValue& val)
void BCValueModel::addValue(const BCValue& val)
{
int row = _valueList.size();
beginInsertRows(QModelIndex(), row, row);
@@ -49,7 +49,7 @@ void BCValueModel::addValue(const BCDataValue& val)
}
const BCValueList& BCValueModel::getValueList()
const BCValueList& BCValueModel::getValueList() const
{
return _valueList;
}
@@ -63,6 +63,33 @@ void BCValueModel::takeValueList(BCValueList& newValueList)
endResetModel();
}
void BCValueModel::onValueUpdated( int row, BC::State state, const QString& newValue )
{
qDebug() << " Panel update: " << newValue;
const BCValueList& valueList = getValueList();
if( row > -1 && row < valueList.size() )
{
bool valueChanged = false;
const BCValue& value = valueList[row];
if( value.state != state )
{
valueChanged = true;
value.state = state;
}
if( !newValue.isEmpty() && newValue != value.visibleValue )
{
valueChanged = true;
value.visibleValue = newValue;
}
if( valueChanged )
{
QModelIndex idx = index(row,1);
emit dataChanged(idx, idx, {Qt::DisplayRole});
}
}
}
int BCValueModel::rowCount(const QModelIndex& parent) const
{
@@ -125,8 +152,8 @@ if (!index.isValid() || index.row() >= static_cast<int>(m_items.size()))
if (!index.isValid() || row >= _valueList.size())
return QVariant();
BCDataValue& entry = const_cast<BCDataValue&>(_valueList.at( row ));
entry.rowInModel = row;
BCValue& entry = const_cast<BCValue&>(_valueList.at( row ));
entry.indexRow = row;
if (role == Qt::DisplayRole || role == Qt::EditRole)
{
@@ -153,7 +180,7 @@ bool BCValueModel::setData(const QModelIndex& index, const QVariant& value, int
{
if (index.isValid() && role == Qt::EditRole)
{
BCDataValue& item = _valueList[index.row()];
BCValue& item = _valueList[index.row()];
// Wir erwarten hier nur den Value-Teil (vom Slider/Editor)
// Checken ob Int oder Double