diff --git a/BionxControl.pro b/BionxControl.pro index ea8c77b..2459776 100644 --- a/BionxControl.pro +++ b/BionxControl.pro @@ -27,13 +27,13 @@ windows SOURCES += \ bc.cpp \ bcdatamanager.cpp \ - bcdatamodel.cpp \ bcdatavalue.cpp \ bcdevicepanel.cpp \ bcitemdelegate.cpp \ bclegacy.cpp \ bctoolbutton.cpp \ bctransmitter.cpp \ + bcvaluemodel.cpp \ bcvaluetype.cpp \ lib/can_drv_win.c \ bccandriver.cpp \ @@ -46,13 +46,13 @@ HEADERS += \ bccandriver.h \ bccandrivertinycan.h \ bcdatamanager.h \ - bcdatamodel.h \ bcdatavalue.h \ bcdevicepanel.h \ bcitemdelegate.h \ bcmainwindow.h \ bctoolbutton.h \ bctransmitter.h \ + bcvaluemodel.h \ bcvaluetype.h FORMS += \ diff --git a/bc.h b/bc.h index 6744cd7..8ddf5ac 100644 --- a/bc.h +++ b/bc.h @@ -30,7 +30,6 @@ ***************************************************************************/ - #ifndef BC_H #define BC_H diff --git a/bcdatamanager.cpp b/bcdatamanager.cpp index 3dc5d6d..38da79f 100644 --- a/bcdatamanager.cpp +++ b/bcdatamanager.cpp @@ -93,13 +93,14 @@ void BCDataManager::onRunnerMessage(const QString &msg) void BCDataManager::onSyncFromDevice() { qDebug() << " ---Syncing"; + /* if( _currentDeviceID != BCDevice::ID::Invalid ) { if( _valueModels.contains(_currentDeviceID) ) { - BCDataModel* model = _valueModels[_currentDeviceID]; - BCDataList& currentList = model->getValueList(); + BCValueModel* model = _valueModels[_currentDeviceID]; + BCValueList& currentList = model->getValueList(); //BCDataValue& value = currentList[4]; @@ -124,9 +125,10 @@ void BCDataManager::onSyncFromDevice() } } // if contains } +*/ } -std::optional BCDataManager::getModel(BCDevice::ID deviceID ) +std::optional BCDataManager::getModel(BCDevice::ID deviceID ) { if( _valueModels.contains( deviceID) ) return _valueModels[deviceID]; @@ -188,12 +190,13 @@ void BCDataManager::loadXmlBikeData() qDebug() << " --- Device: " << _xml.name() << ": " << deviceType << " : " << deviceID; _currentDeviceID = BCDevice::ID( deviceID.value() ); - BCDataList parsedValues; + BCValueList parsedValues; loadXmlBikeDeviceData( parsedValues ); if( parsedValues.count() ) { - BCDataModel* valueModel = new BCDataModel( this ); - valueModel->setValueList(parsedValues); + BCValueModel* valueModel = new BCValueModel( this ); + // hier lacht der blaue HASE + //valueModel->setValueList(parsedValues); _valueModels.insert( _currentDeviceID, valueModel ); } } @@ -218,7 +221,7 @@ void BCDataManager::loadXmlBikeData() } -void BCDataManager::loadXmlBikeDeviceData( BCDataList& parsedValues ) +void BCDataManager::loadXmlBikeDeviceData( BCValueList& parsedValues ) { auto printAttrs = [](const QXmlStreamReader& xml) { diff --git a/bcdatamanager.h b/bcdatamanager.h index ba67244..20398c0 100644 --- a/bcdatamanager.h +++ b/bcdatamanager.h @@ -1,38 +1,3 @@ -/*************************************************************************** - - BionxControl - Copyright © 2025 christoph holzheuer - christoph.holzheuer@gmail.com - - Using: mhs_can_drv.c -© 2011 - 2023 by MHS-Elektronik GmbH & Co. KG, Germany -Klaus Demlehner, klaus@mhs-elektronik.de - @see www.mhs-elektronik.de - - BigXionFlasher USB V 0.2.4 rev. 97 - © 2011-2013 by Thomas Koenig - @see www.bigxionflasher.org - - Bionx Bike Info - © 2018 Thorsten Schmidt (tschmidt@ts-soft.de) - @see www.ts-soft.de - - mhs_can_drv.c 3.00 - © 2011 - 2015 by MHS-Elektronik GmbH & Co. KG, Germany - Demlehner Klaus, info@mhs-elektronik.de - @see www.mhs-elektronik.de - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - @see https://github.com/bikemike/bionx-bikeinfo - - ***************************************************************************/ - - -#ifndef BCDATAMANAGER_H -#define BCDATAMANAGER_H /*************************************************************************** BionxControl @@ -65,13 +30,16 @@ Klaus Demlehner, klaus@mhs-elektronik.de ***************************************************************************/ +#ifndef BCDATAMANAGER_H +#define BCDATAMANAGER_H + #include #include #include #include #include -#include +#include #include @@ -85,11 +53,9 @@ public: BCDataManager( QObject* parent = nullptr); virtual ~BCDataManager(); - std::optional getModel(BCDevice::ID deviceID ); + std::optional getModel(BCDevice::ID deviceID ); BCTransmitter* getTransmitter(); - - public slots: void loadXmlBikeData(); @@ -119,11 +85,11 @@ protected: QString UnitType; }; - void loadXmlBikeDeviceData( BCDataList& parsedValues ); + void loadXmlBikeDeviceData( BCValueList& parsedValues ); std::optional makeDataValue( BCDevice::ID deviceID, const BCDataParams& params ); - using BCDeviceModels = QMap; + using BCDeviceModels = QMap; using BCValueTypeMap = QMap; QXmlStreamReader _xml; diff --git a/bcdatavalue.h b/bcdatavalue.h index 1016ac5..4a3f00a 100644 --- a/bcdatavalue.h +++ b/bcdatavalue.h @@ -101,7 +101,7 @@ public: Q_DECLARE_METATYPE(BCDataValue*) -using BCDataList = QVector; +using BCValueList = QList; diff --git a/bcitemdelegate.cpp b/bcitemdelegate.cpp index 95b9772..e69e931 100644 --- a/bcitemdelegate.cpp +++ b/bcitemdelegate.cpp @@ -368,9 +368,9 @@ QString BCItemDelegate::formatDisplayString(const QModelIndex& index) const QString displayStr; /* - QString label = index.data(BCDataListModel::LabelRole).toString(); - QVariant value = index.data(BCDataListModel::ValueRole); - QString unit = index.data(BCDataListModel::UnitRole).toString(); + QString label = index.data(BCValueListModel::LabelRole).toString(); + QVariant value = index.data(BCValueListModel::ValueRole); + QString unit = index.data(BCValueListModel::UnitRole).toString(); QString valueStr = value.toString(); diff --git a/bcmainwindow.cpp b/bcmainwindow.cpp index 36e58ba..e956dfc 100644 --- a/bcmainwindow.cpp +++ b/bcmainwindow.cpp @@ -57,8 +57,8 @@ BCMainWindow::BCMainWindow(QWidget *parent) // Die Daten und auch die Datenmodelle für die Views werden // vom DataManager verwaltet und an die Views weitergereicht. - auto model = _dataManager.getModel( BCDevice::ID::Console ); - _consolePanel->getValueView()->setModel( model.v ); + //auto model = _dataManager.getModel( BCDevice::ID::Console ); + //_consolePanel->getValueView()->setModel( model.v ); /* if( model) diff --git a/bcdatamodel.cpp b/bcvaluemodel.cpp similarity index 81% rename from bcdatamodel.cpp rename to bcvaluemodel.cpp index 9f04c43..e5d978f 100644 --- a/bcdatamodel.cpp +++ b/bcvaluemodel.cpp @@ -30,18 +30,17 @@ ***************************************************************************/ -#include +#include - - -BCDataModel::BCDataModel(QObject *parent) +BCValueModel::BCValueModel(QObject *parent) : QAbstractTableModel(parent) { } -void BCDataModel::addValue(const BCDataValue& val) + +void BCValueModel::addValue(const BCDataValue& val) { int row = _valueList.size(); beginInsertRows(QModelIndex(), row, row); @@ -49,32 +48,37 @@ void BCDataModel::addValue(const BCDataValue& val) endInsertRows(); } -void BCDataModel::setValueList(const BCDataList& valueList) + +/* +void BCValueModel::setValueList(BCValueList* valueList) { beginResetModel(); _valueList = valueList; endResetModel(); } +*/ -BCDataList& BCDataModel::getValueList() +/* +BCValueList& BCValueModel::getValueList() { return _valueList; } +*/ -int BCDataModel::rowCount(const QModelIndex& parent) const +int BCValueModel::rowCount(const QModelIndex& parent) const { if (parent.isValid()) return 0; return _valueList.size(); } -int BCDataModel::columnCount(const QModelIndex &parent) const +int BCValueModel::columnCount(const QModelIndex &parent) const { if (parent.isValid()) return 0; return 2; } -QVariant BCDataModel::headerData(int section, Qt::Orientation orientation, int role) const +QVariant BCValueModel::headerData(int section, Qt::Orientation orientation, int role) const { if (role != Qt::DisplayRole || orientation != Qt::Horizontal) return QVariant(); @@ -90,7 +94,7 @@ QVariant BCDataModel::headerData(int section, Qt::Orientation orientation, int r } } -QVariant BCDataModel::data(const QModelIndex& index, int role) const +QVariant BCValueModel::data(const QModelIndex& index, int role) const { /* @@ -137,7 +141,7 @@ if (!index.isValid() || index.row() >= static_cast(m_items.size())) } -Qt::ItemFlags BCDataModel::flags(const QModelIndex& index) const +Qt::ItemFlags BCValueModel::flags(const QModelIndex& index) const { if (!index.isValid()) return Qt::NoItemFlags; @@ -146,11 +150,11 @@ Qt::ItemFlags BCDataModel::flags(const QModelIndex& index) const } -bool BCDataModel::setData(const QModelIndex& index, const QVariant& value, int role) +bool BCValueModel::setData(const QModelIndex& index, const QVariant& value, int role) { if (index.isValid() && role == Qt::EditRole) { - BCDataValue item = _valueList[index.row()]; + BCDataValue& item = _valueList[index.row()]; // Wir erwarten hier nur den Value-Teil (vom Slider/Editor) // Checken ob Int oder Double diff --git a/bcdatamodel.h b/bcvaluemodel.h similarity index 70% rename from bcdatamodel.h rename to bcvaluemodel.h index f0a353e..c0be104 100644 --- a/bcdatamodel.h +++ b/bcvaluemodel.h @@ -30,33 +30,39 @@ ***************************************************************************/ - -#ifndef BCDATAMODEL_H -#define BCDATAMODEL_H +#ifndef BCVALUEMODEL_H +#define BCVALUEMODEL_H #include - #include +/** + * @brief Das BCValueModel dient als Interface zu den eigentlichen Daten, + * der BCValueList und besitzt diese. + * + * Ist das so schlau? + * + */ -class BCDataModel : public QAbstractTableModel +class BCValueModel : public QAbstractTableModel { Q_OBJECT public: - explicit BCDataModel(QObject *parent = nullptr); + explicit BCValueModel(QObject *parent = nullptr); void addValue(const BCDataValue& val); - void setValueList(const BCDataList& valueList); - BCDataList& getValueList(); + + //void setValueList(BCValueList* valueList); + //BCValueList *getValueList(); // Pure Virtual Functions von QAbstractTableModel - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent = QModelIndex()) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; // Nötig für Editierbarkeit Qt::ItemFlags flags(const QModelIndex& index) const override; @@ -64,8 +70,8 @@ public: private: - BCDataList _valueList; + BCValueList _valueList; }; -#endif // BCDATAMODEL_H +#endif // BCVALUEMODEL_H