diff --git a/bcdeviceview.cpp b/bcdeviceview.cpp index 790f1be..19bc748 100644 --- a/bcdeviceview.cpp +++ b/bcdeviceview.cpp @@ -30,6 +30,8 @@ ***************************************************************************/ +#include + #include #include @@ -44,18 +46,13 @@ BCDeviceView::BCDeviceView(QWidget *parent) // __fix! ziemlich wildes ge-pointere, hier _itemDelegate = new BCAnimatedDelegate( _valueModel.getValueList(), this); setItemDelegate( _itemDelegate ); - - qDebug() << " --- View size I: " << this->size(); - } void BCDeviceView::setDeviceID( BCDevice::ID deviceID ) { - qDebug() << " --- View size II: " << this->size(); - - _devideID = deviceID; + _devideID = deviceID; } BCDevice::ID BCDeviceView::getDeviceID() const @@ -64,7 +61,9 @@ BCDevice::ID BCDeviceView::getDeviceID() const } - +/** + * @brief Gibt eine Referenz auf der ValueList zurück. + */ const BCValueList& BCDeviceView::getValueListX() { @@ -72,8 +71,10 @@ const BCValueList& BCDeviceView::getValueListX() } - -// __FIX ist das ok so? +/** + * @brief SLOT, der aufgerufen wird, wenn die ValueList vom XML-Lader fertig geladen wurde. + * Die DeviceView nimmt die ValueList dann in Besitz. + */ void BCDeviceView::onValueListReady( BCDevice::ID deviceID, BCValueList valueList ) { qDebug() << " --- onValueListReady: " << deviceID << ": " << valueList.size(); @@ -81,11 +82,28 @@ void BCDeviceView::onValueListReady( BCDevice::ID deviceID, BCValueList valueLis _valueModel.takeValueList( valueList ); } + +/** + * @brief SLOT, der aufgerufen wird, wenn ein Value geändert wurde. Gibt dem ItemDelegate Bescheid. + */ + void BCDeviceView::onValueUpdated(int index, BCValue::State state, const QString& newVisibleValue ) { _valueModel.onValueUpdated( index, state, newVisibleValue); _itemDelegate->onHighlightRow( index ); - } +void BCDeviceView::resizeEvent(QResizeEvent *event) +{ + // Zuerst die Basisklasse aufrufen (Wichtig für Layouts!) + QWidget::resizeEvent(event); + + // Berechnung: 40% der aktuellen Breite + // Tipp: viewport()->width() ist genauer als width(), da es Scrollbars rausrechnet! + int totalWidth = viewport()->width(); + int col0Width = static_cast(totalWidth * 0.60); + + // Setzen der Breite + horizontalHeader()->resizeSection(0, col0Width); +} diff --git a/bcdeviceview.h b/bcdeviceview.h index 7898806..c9f021a 100644 --- a/bcdeviceview.h +++ b/bcdeviceview.h @@ -64,6 +64,8 @@ public slots: protected: + void resizeEvent(QResizeEvent *event) override; + BCDevice::ID _devideID{BCDevice::ID::Invalid}; BCValueModel _valueModel; BCAnimatedDelegate* _itemDelegate{}; diff --git a/bcmainwindow.ui b/bcmainwindow.ui index 4a6cb67..c66cb4e 100644 --- a/bcmainwindow.ui +++ b/bcmainwindow.ui @@ -71,9 +71,15 @@ 64 + + true + true + + _buttonGroup + @@ -93,9 +99,15 @@ 64 + + true + true + + _buttonGroup + @@ -115,9 +127,18 @@ 64 + + true + + + true + true + + _buttonGroup + @@ -229,7 +250,7 @@ 0 - 0 + 2 @@ -388,4 +409,7 @@ + + + diff --git a/bcxmlloader.cpp b/bcxmlloader.cpp index c1a8204..fabd87f 100644 --- a/bcxmlloader.cpp +++ b/bcxmlloader.cpp @@ -59,11 +59,7 @@ void BCXmlLoader::loadXmlBikeData( const QString& fileName ) } qDebug().noquote() << parts.join(" "); }; - /* - QString fileName = QFileDialog::getOpenFileName(this, "XML öffnen", "", "XML Files (*.xml)"); - if (fileName.isEmpty()) - return; - */ + QMetaEnum bcDeviceEnum{QMetaEnum::fromType()}; @@ -92,7 +88,7 @@ void BCXmlLoader::loadXmlBikeData( const QString& fileName ) if (token == QXmlStreamReader::StartElement) { QString deviceType = _xml.attributes().value("Type"_L1).toString(); - printAttrs (_xml); + //printAttrs (_xml); // Wir wollen die Device-ID aus dem XML Tag ermitteln const char* deviceKey = _xml.attributes().value("Type"_L1).toLatin1().constData(); bool ok; @@ -109,22 +105,13 @@ void BCXmlLoader::loadXmlBikeData( const QString& fileName ) } } - - /* - if (xml.hasError()) - { - QMessageBox::critical(nullptr, "Parsing Fehler", xml.errorString()); - } - else - { - m_model->setDevices(parsedValues); - } - */ - - // create & add new model to the model map - } +/** + * @brief Lädt deie Daten des BionX eBikes + * @param deviceID + */ + void BCXmlLoader::loadXmlBikeDeviceData(BCDevice::ID deviceID) { auto printAttrs = [](const QXmlStreamReader& xml) @@ -138,7 +125,7 @@ void BCXmlLoader::loadXmlBikeDeviceData(BCDevice::ID deviceID) printAttrs (_xml); Q_ASSERT(_xml.isStartElement() && _xml.name() == "Device"_L1); - qDebug() << " XXX ---------------"; + // temporäre Wertliste für neues Device BCValueList currentValues; diff --git a/doc/Install.on.pi.txt b/doc/Install.on.pi.txt index 14b4970..d367b4b 100644 --- a/doc/Install.on.pi.txt +++ b/doc/Install.on.pi.txt @@ -27,6 +27,43 @@ sudo apt purge modemmanager // --- +sudo apt install \ + qt6-declarative-dev \ + qt6-tools-dev \ + qt6-tools-dev-tools \ + qt6-l10n-tools \ + qt6-scxml-dev \ + qt6-serialport-dev \ + qt6-serialbus-dev \ + qt6-connectivity-dev \ + qt6-sensors-dev \ + qt6-websockets-dev \ + qt6-webchannel-dev \ + qt6-svg-dev \ + qt6-multimedia-dev \ + qt6-charts-dev \ + qt6-wayland \ + qml6-module-qtquick-controls \ + qml6-module-qtquick-layouts \ + qml6-module-qtquick-templates \ + qml6-module-qtquick-window \ + qml6-module-qtqml-workerscript \ + qml6-module-qtcharts \ + qml6-module-qt-labs-platform \ + libqt6sql6-mysql libqt6sql6-psql libqt6sql6-sqlite \ + libqt6opengl6-dev + + sudo apt update +sudo apt install \ + qtcreator \ + qtcreator-doc \ + cmake \ + ninja-build \ + gdb \ + clang \ + clang-format + + https://github.com/MHS-Elektronik/OBD-Display sudo chgrp pi /opt @@ -36,6 +73,7 @@ https://github.com/MHS-Elektronik/OBD-Display tar -xzvf tiny_can_raspberry_790.tar.gz rm tiny_can_raspberry_790.tar.gz +sudo apt install fonts-open-sans RANT diff --git a/resources/bikeinfo.xml b/resources/bikeinfo.xml index abb0327..b3b845c 100644 --- a/resources/bikeinfo.xml +++ b/resources/bikeinfo.xml @@ -30,7 +30,7 @@ - +