Made 'syncFromDevice' work again.
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
|
||||
#include "qassert.h"
|
||||
#include <bcmainwindow.h>
|
||||
#include <bcitemdelegate.h>
|
||||
#include <bcdelegate.h>
|
||||
#include <ui_bcmainwindow.h>
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ BCMainWindow::BCMainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
{
|
||||
// WICHTIG: Registriere sowohl das Struct als auch die LISTE des Structs
|
||||
qRegisterMetaType<BCDataValue>("BCDataValue");
|
||||
qRegisterMetaType<QList<BCDataValue>>("BCValueList");
|
||||
qRegisterMetaType<BCValue>("BCValue");
|
||||
qRegisterMetaType<QList<BCValue>>("BCValueList");
|
||||
|
||||
setupUi(this);
|
||||
initMainWindow();
|
||||
@@ -121,14 +121,14 @@ void BCMainWindow::initMainWindow()
|
||||
|
||||
|
||||
/*
|
||||
BCItemDelegate* _delegate = new BCItemDelegate( _valueView);
|
||||
BCDelegate* _delegate = new BCDelegate( _valueView);
|
||||
//_delegate = new AnimatedDelegate(_valueView );
|
||||
_valueView->setItemDelegate( _delegate );
|
||||
|
||||
|
||||
// Verwendung:
|
||||
|
||||
connect(_delegate, &BCItemDelegate::viewUpdateNeeded, _valueView->viewport(), QOverload<>::of(&QWidget::update));
|
||||
connect(_delegate, &BCDelegate::viewUpdateNeeded, _valueView->viewport(), QOverload<>::of(&QWidget::update));
|
||||
|
||||
|
||||
//_valueView->setItemDelegate(_delegate);
|
||||
@@ -139,7 +139,7 @@ void BCMainWindow::initMainWindow()
|
||||
|
||||
// besser: model::emit dataChanged
|
||||
// also: emit dataChanged(index, index, {Qt::DisplayRole, Qt::EditRole, ValueRole});
|
||||
connect( &_dataManager, &BCMainWindow::valueTouched, _delegate, &BCItemDelegate::onHighlightRow );
|
||||
connect( &_dataManager, &BCMainWindow::valueTouched, _delegate, &BCDelegate::onHighlightRow );
|
||||
connect( _connectButton, &QPushButton::clicked, transmitter, &BCTransmitter::onToggleConnectionState );
|
||||
connect( _syncButton, &QPushButton::clicked, &_dataManager, &BCMainWindow::onSyncFromDevice );
|
||||
*/
|
||||
@@ -147,9 +147,11 @@ void BCMainWindow::initMainWindow()
|
||||
|
||||
// besser: model::emit dataChanged
|
||||
// also: emit dataChanged(index, index, {Qt::DisplayRole, Qt::EditRole, ValueRole});
|
||||
//connect( &_dataManager, &BCMainWindow::valueTouched, _delegate, &BCItemDelegate::onHighlightRow );
|
||||
//connect( &_dataManager, &BCMainWindow::valueTouched, _delegate, &BCDelegate::onHighlightRow );
|
||||
connect( _connectButton, &QPushButton::clicked, &_transmitter, &BCTransmitter::onToggleConnectionState );
|
||||
connect( _syncButton, &QPushButton::clicked, this, &BCMainWindow::onSyncFromDevice );
|
||||
connect( &_transmitter, &BCTransmitter::valueUpdated, this, &BCMainWindow::onValueUpdated );
|
||||
|
||||
// die Daten des eBikes laden
|
||||
_dataManager.loadXmlBikeData(":/bikeinfo.xml"_L1);
|
||||
|
||||
@@ -191,7 +193,7 @@ void BCMainWindow::onValueListReady( BCDevice::ID deviceID )
|
||||
void BCMainWindow::onShowDevicePanel( BCDevice::ID deviceID )
|
||||
{
|
||||
qDebug() << " --- onShowDevicePanel:" << deviceID;
|
||||
if( _devicePanels.contains( deviceID ) )
|
||||
if( _devicePanels.contains( deviceID ) )
|
||||
{
|
||||
BCDevicePanel* nxtPanel = _devicePanels[deviceID];
|
||||
if( nxtPanel != _currentPanel )
|
||||
@@ -220,9 +222,16 @@ void BCMainWindow::onConnectButtonToggled(bool checked )
|
||||
//_dataManager.setDriverConnectionState( checked );
|
||||
}
|
||||
|
||||
void BCMainWindow::onvalueStateChanged(int id, bool success)
|
||||
void BCMainWindow::onValueUpdated(BCDevice::ID deviceID, int index, BC::State state, const QString& newValue )
|
||||
{
|
||||
qDebug() << "[Manager] Command" << id << "finished. Success:" << success;
|
||||
qDebug() << "Reply: from: " << deviceID << " at: " << index << "finished. Success:" << state << " on:" << newValue;
|
||||
if( _devicePanels.contains( deviceID ) )
|
||||
{
|
||||
BCDevicePanel& panel = *_devicePanels[deviceID];
|
||||
panel.getValueModel().onValueUpdated( index, state, newValue );
|
||||
}
|
||||
|
||||
//_devicePanels;
|
||||
}
|
||||
|
||||
void BCMainWindow::onRunnerMessage(const QString &msg)
|
||||
@@ -232,7 +241,7 @@ void BCMainWindow::onRunnerMessage(const QString &msg)
|
||||
|
||||
|
||||
|
||||
|
||||
// __fix move this to devicePanel
|
||||
void BCMainWindow::onSyncFromDevice()
|
||||
{
|
||||
|
||||
@@ -240,11 +249,11 @@ void BCMainWindow::onSyncFromDevice()
|
||||
|
||||
qDebug() << " ---Syncing";
|
||||
|
||||
const BCValueList& currentList =_currentPanel->getValueList();
|
||||
const BCValueList& currentList =_currentPanel->getValueListX();
|
||||
|
||||
// alle einzeln? echt jetzt?
|
||||
|
||||
for( const BCDataValue& value : currentList )
|
||||
for( const BCValue& value : currentList )
|
||||
{
|
||||
qDebug() << " --- value: " << value.label;
|
||||
|
||||
@@ -254,7 +263,7 @@ void BCMainWindow::onSyncFromDevice()
|
||||
//_transmitter.enqueueValueCommand( value );
|
||||
emit sendValueCommand( BC::OpID::ReadValue, &value);
|
||||
|
||||
emit valueTouched( value.rowInModel );
|
||||
emit valueTouched( value.indexRow );
|
||||
|
||||
bc::processEventsFor(500);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user