Hightlight lines when touched.
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include <QPushButton>
|
||||
#include <QMessageBox>
|
||||
#include <QStatusBar>
|
||||
#include <QApplication>
|
||||
|
||||
#include <bcvaluemanager.h>
|
||||
|
||||
@@ -53,7 +54,7 @@ BCValueManager::BCValueManager(QObject *parent)
|
||||
// 4. Verbindungen herstellen (Signal/Slot über Thread-Grenzen)
|
||||
|
||||
// A) Befehl senden (Manager -> Runner)
|
||||
connect(this, &BCValueManager::newCommandArrived, &_transmitter, &BCTransmitter::addCommand);
|
||||
connect(this, &BCValueManager::newCommandArrived, &_transmitter, &BCTransmitter::enqueueValue);
|
||||
|
||||
// B) Ergebnisse empfangen (Runner -> Manager)
|
||||
connect(&_transmitter, &BCTransmitter::commandFinished, this, &BCValueManager::onCommandFinished);
|
||||
@@ -136,11 +137,31 @@ void BCValueManager::onToggleConnectionState( bool connect )
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::optional<BCValueModel*> BCValueManager::getModel(const QString& key )
|
||||
void BCValueManager::onSyncFromDevice()
|
||||
{
|
||||
if( _valueModels.contains( key) )
|
||||
return _valueModels[key];
|
||||
qDebug() << " ---Syncing";
|
||||
if( _currentDeviceID != BCDevice::ID::Invalid)
|
||||
{
|
||||
|
||||
BCValueList& currentList = _valueModels[_currentDeviceID]->getValueList();
|
||||
for( BCValue& value : currentList )
|
||||
{
|
||||
qDebug() << " --- value: " << value.label;
|
||||
_transmitter.enqueueValue( value );
|
||||
emit valueTouched( value.rowInModel );
|
||||
QApplication::processEvents();
|
||||
// Thread schlafen lassen (Simulation einer blockierenden Operation)
|
||||
QThread::msleep(500);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<BCValueModel*> BCValueManager::getModel(BCDevice::ID deviceID )
|
||||
{
|
||||
if( _valueModels.contains( deviceID) )
|
||||
return _valueModels[deviceID];
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -185,25 +206,28 @@ void BCValueManager::loadBikeData()
|
||||
if (token == QXmlStreamReader::StartElement)
|
||||
{
|
||||
QString deviceType = _xml.attributes().value("Type"_L1).toString();
|
||||
qDebug() << " --- Device: " << _xml.name() << ": " << deviceType;
|
||||
printAttrs (_xml);
|
||||
const char* deviceKey = _xml.attributes().value("Type"_L1).toLatin1().constData();
|
||||
auto deviceID = _bcDeviceEnum.keyToValue64(deviceKey);
|
||||
//_currentDeviceID = BCDevice::ID( deviceID.value_or( BCDevice::ID::Invalid ) );
|
||||
_currentDeviceID = deviceID.has_value() ? BCDevice::ID( deviceID.value() ) : BCDevice::ID::Invalid;
|
||||
if(deviceID.has_value())
|
||||
{
|
||||
BCValueList parsedValues;
|
||||
qDebug() << " --- Device: " << _xml.name() << ": " << deviceType << " : " << deviceID;
|
||||
|
||||
_currentDeviceID = BCDevice::ID( deviceID.value() );
|
||||
BCValueList parsedValues;
|
||||
loadDeviceData( parsedValues );
|
||||
if( parsedValues.count() )
|
||||
{
|
||||
BCValueModel* valueModel = new BCValueModel( this );
|
||||
valueModel->setValueList(parsedValues);
|
||||
_valueModels.insert( deviceType, valueModel );
|
||||
_valueModels.insert( _currentDeviceID, valueModel );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_currentDeviceID = BCDevice::ID::Console;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user