From 679bff5e265cdee38fe37d27ef482122ae3b39b4 Mon Sep 17 00:00:00 2001 From: "DIASPORA\\chris" Date: Mon, 29 Dec 2025 23:29:56 +0100 Subject: [PATCH] Cleanups in ui. --- BionxControl.pro | 9 +- bc.h | 51 +++++------ bcitemdelegate.cpp => bcanimateddelegate.cpp | 26 +++--- bcitemdelegate.h => bcanimateddelegate.h | 10 +-- bcdevicepanel.ui | 95 -------------------- bcdevicepanel.cpp => bcdeviceview.cpp | 48 +++++----- bcdevicepanel.h => bcdeviceview.h | 23 +++-- bcmainwindow.cpp | 20 ++--- bcmainwindow.h | 8 +- bcmainwindow.ui | 25 +++--- bcvaluemodel.cpp | 20 ++--- bcvaluemodel.h | 4 +- 12 files changed, 119 insertions(+), 220 deletions(-) rename bcitemdelegate.cpp => bcanimateddelegate.cpp (88%) rename bcitemdelegate.h => bcanimateddelegate.h (92%) delete mode 100644 bcdevicepanel.ui rename bcdevicepanel.cpp => bcdeviceview.cpp (53%) rename bcdevicepanel.h => bcdeviceview.h (75%) diff --git a/BionxControl.pro b/BionxControl.pro index a883f5a..2f83ab0 100644 --- a/BionxControl.pro +++ b/BionxControl.pro @@ -26,9 +26,9 @@ windows SOURCES += \ bc.cpp \ + bcanimateddelegate.cpp \ bcdatamanager.cpp \ - bcdevicepanel.cpp \ - bcitemdelegate.cpp \ + bcdeviceview.cpp \ bclegacy.cpp \ bctransmitter.cpp \ bcvalue.cpp \ @@ -42,11 +42,11 @@ SOURCES += \ HEADERS += \ bc.h \ + bcanimateddelegate.h \ bccandriver.h \ bccandrivertinycan.h \ bcdatamanager.h \ - bcdevicepanel.h \ - bcitemdelegate.h \ + bcdeviceview.h \ bcmainwindow.h \ bctransmitter.h \ bcvalue.h \ @@ -54,7 +54,6 @@ HEADERS += \ bcvaluetype.h FORMS += \ - bcdevicepanel.ui \ bcmainwindow.ui # Default rules for deployment. diff --git a/bc.h b/bc.h index cddbcc9..ad3fff0 100644 --- a/bc.h +++ b/bc.h @@ -723,45 +723,45 @@ public: Reg_Sensor_Config_Ramp_Up_Steps_Hi = 0x12, Reg_Sensor_Config_Ramp_Up_Steps_Lo = 0x13, - Reg_Sensor_Config_Decay_Delay_Hi = 0x14, - Reg_Sensor_Config_Decay_Delay_Lo = 0x15, + Reg_Sensor_Config_Decay_Delay_Hi = 0x14, + Reg_Sensor_Config_Decay_Delay_Lo = 0x15, - Reg_Sensor_Config_Decay_Steps_Hi = 0x16, - Reg_Sensor_Config_Decay_Steps_Lo = 0x17, + Reg_Sensor_Config_Decay_Steps_Hi = 0x16, + Reg_Sensor_Config_Decay_Steps_Lo = 0x17, - Reg_Sensor_Config_Speed_Threshold_Hi = 0x18, - Reg_Sensor_Config_Speed_Threshold_Lo = 0x19, + Reg_Sensor_Config_Speed_Threshold_Hi = 0x18, + Reg_Sensor_Config_Speed_Threshold_Lo = 0x19, - Reg_Sensor_Config_Ramp_Active_Over_Threshold = 0x1a, + Reg_Sensor_Config_Ramp_Active_Over_Threshold = 0x1a, - Reg_Sensor_Status_Torque_Voltage = 0x1b, // Torque Sensor Voltage + Reg_Sensor_Status_Torque_Voltage = 0x1b, // Torque Sensor Voltage - Reg_Sensor_Status_Cadence = 0x1c, // Number Of Turns Per Minutes Made With The Pedals + Reg_Sensor_Status_Cadence = 0x1c, // Number Of Turns Per Minutes Made With The Pedals - Reg_Sensor_Status_Output_Voltage = 0x1d, // Voltage Output To The Motor's Gauge Sensor + Reg_Sensor_Status_Output_Voltage = 0x1d, // Voltage Output To The Motor's Gauge Sensor - Reg_Sensor_Status_Pulse_Counter = 0x1e, // Pulse Counter. Increases When Back Pedaling And Decreases When Forward Pedaling + Reg_Sensor_Status_Pulse_Counter = 0x1e, // Pulse Counter. Increases When Back Pedaling And Decreases When Forward Pedaling - Reg_Sensor_Config_Input_Offset = 0x40, // Permit To Offset The Input Value Of The Torque Sensor From +1.64 To -1.65v + Reg_Sensor_Config_Input_Offset = 0x40, // Permit To Offset The Input Value Of The Torque Sensor From +1.64 To -1.65v - Reg_Sensor_Sn_Location = 0x71, // Location + Reg_Sensor_Sn_Location = 0x71, // Location - Reg_Sensor_Sn_Year = 0x72, // Mfd. Year - Reg_Sensor_Sn_Month = 0x73, // Mfd. Month - Reg_Sensor_Sn_Day = 0x74, // Mfd. Day + Reg_Sensor_Sn_Year = 0x72, // Mfd. Year + Reg_Sensor_Sn_Month = 0x73, // Mfd. Month + Reg_Sensor_Sn_Day = 0x74, // Mfd. Day - Reg_Sensor_Sn_Pn_Hi = 0x75, // Partnumber - Reg_Sensor_Sn_Pn_Lo = 0x76, + Reg_Sensor_Sn_Pn_Hi = 0x75, // Partnumber + Reg_Sensor_Sn_Pn_Lo = 0x76, - Reg_Sensor_Sn_Item_Hi = 0x77, // Serial Number - Reg_Sensor_Sn_Item_Lo = 0x78, + Reg_Sensor_Sn_Item_Hi = 0x77, // Serial Number + Reg_Sensor_Sn_Item_Lo = 0x78, - Reg_Sensor_Rev_Hw = 0x80, // Hardware Version - Reg_Sensor_Rev_Sw = 0x81, // Software Version + Reg_Sensor_Rev_Hw = 0x80, // Hardware Version + Reg_Sensor_Rev_Sw = 0x81, // Software Version - Reg_Sensor_Config_Mode = 0x82, // 0-Thune, 1-Fag + Reg_Sensor_Config_Mode = 0x82, // 0-Thune, 1-Fag - Reg_Sensor_Rev_Sub = 0x83 // Software Subversion + Reg_Sensor_Rev_Sub = 0x83 // Software Subversion }; Q_ENUM(ID) @@ -803,9 +803,6 @@ namespace BCTags inline constexpr auto Max = "Max"_L1; inline constexpr auto Factor = "Factor"_L1; - inline constexpr auto ValueTag = "Wert"_L1; - inline constexpr auto LabelTag = "Bezeichnung"_L1; - } #endif // BC_H diff --git a/bcitemdelegate.cpp b/bcanimateddelegate.cpp similarity index 88% rename from bcitemdelegate.cpp rename to bcanimateddelegate.cpp index 7873f76..11028ce 100644 --- a/bcitemdelegate.cpp +++ b/bcanimateddelegate.cpp @@ -43,20 +43,20 @@ #include #include -#include "bcitemdelegate.h" +#include "bcanimateddelegate.h" #include "bcvalue.h" -BCItemDelegate::BCItemDelegate(const BCValueList& valueList, QTableView* view) +BCAnimatedDelegate::BCAnimatedDelegate(const BCValueList& valueList, QTableView* view) : QStyledItemDelegate{view}, _valueList{valueList}, _view{view} { } /* -QString BCItemDelegate::displayText(const QVariant& dataValue, const QLocale& locale) const +QString BCAnimatedDelegate::displayText(const QVariant& dataValue, const QLocale& locale) const { // Wir prüfen, ob im Variant unser Struct steckt if (dataValue.canConvert()) @@ -79,7 +79,7 @@ QString BCItemDelegate::displayText(const QVariant& dataValue, const QLocale& lo */ -QWidget *BCItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const +QWidget *BCAnimatedDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const { QVariant rawData = index.data(Qt::EditRole); //if (!rawData.canConvert()) @@ -129,7 +129,7 @@ QWidget *BCItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewIte */ } -void BCItemDelegate::setEditorData(QWidget *editor, const QModelIndex& index) const +void BCAnimatedDelegate::setEditorData(QWidget *editor, const QModelIndex& index) const { // Daten vom Model in den Editor laden const BCValue& bc = *index.data(Qt::EditRole).value(); @@ -148,7 +148,7 @@ void BCItemDelegate::setEditorData(QWidget *editor, const QModelIndex& index) co } } -void BCItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex& index) const +void BCAnimatedDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex& index) const { // Daten vom Editor zurück ins Model speichern (Beim Schließen) QSlider *slider = editor->findChild("slider"); @@ -161,13 +161,13 @@ void BCItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, co } } -void BCItemDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex& index) const +void BCAnimatedDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex& index) const { // __fix! editor->setGeometry(option.rect); } -QSize BCItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex& index) const +QSize BCAnimatedDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex& index) const { return QStyledItemDelegate::sizeHint(option,index); /* @@ -181,7 +181,7 @@ QSize BCItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelI } -void BCItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index) const +void BCAnimatedDelegate::paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { // 1. Standard-Zeichnen (Text, Hintergrund, Selection) durchführen @@ -236,7 +236,7 @@ if (opacity > 0.01) */ -void BCItemDelegate::paintHighlightRow(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const +void BCAnimatedDelegate::paintHighlightRow(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { painter->save(); painter->setRenderHint(QPainter::Antialiasing); @@ -274,7 +274,7 @@ void BCItemDelegate::paintHighlightRow(QPainter* painter, const QStyleOptionView } -void BCItemDelegate::onHighlightRow(int row) +void BCAnimatedDelegate::onHighlightRow(int row) { qDebug() << " --- should highlight: " << row; @@ -323,7 +323,7 @@ void BCItemDelegate::onHighlightRow(int row) } // Optional: alle Highlights sofort clearen -void BCItemDelegate::clearAllHighlights() +void BCAnimatedDelegate::clearAllHighlights() { for(auto* anim : std::as_const(m_rowAnimations)) { @@ -339,7 +339,7 @@ void BCItemDelegate::clearAllHighlights() } } -void BCItemDelegate::updateRow(int row) +void BCAnimatedDelegate::updateRow(int row) { if (_view && _view->model() && row >= 0) { diff --git a/bcitemdelegate.h b/bcanimateddelegate.h similarity index 92% rename from bcitemdelegate.h rename to bcanimateddelegate.h index b88ad5e..90e05e3 100644 --- a/bcitemdelegate.h +++ b/bcanimateddelegate.h @@ -30,8 +30,8 @@ ***************************************************************************/ -#ifndef BCITEMDELEGATE_H -#define BCITEMDELEGATE_H +#ifndef BCANIMATEDDELEGATE_H +#define BCANIMATEDDELEGATE_H #include @@ -40,13 +40,13 @@ class QVariantAnimation; class QTableView; class BCValueList; -class BCItemDelegate : public QStyledItemDelegate +class BCAnimatedDelegate : public QStyledItemDelegate { Q_OBJECT public: - explicit BCItemDelegate(const BCValueList& valueList, QTableView* view ); + explicit BCAnimatedDelegate(const BCValueList& valueList, QTableView* view ); // QString displayText(const QVariant& dataValue, const QLocale& locale) const override; @@ -106,4 +106,4 @@ private: }; -#endif // BCITEMDELEGATE_H +#endif // BCANIMATEDDELEGATE_H diff --git a/bcdevicepanel.ui b/bcdevicepanel.ui deleted file mode 100644 index a7a7a14..0000000 --- a/bcdevicepanel.ui +++ /dev/null @@ -1,95 +0,0 @@ - - - BCDevicePanel - - - - 0 - 0 - 400 - 300 - - - - Form - - - - - - Fitze! - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 30 - - - - TextLabel - - - - - - - false - - - background-color:#eeeeee - - - QFrame::Shape::NoFrame - - - QFrame::Shadow::Plain - - - 0 - - - Qt::ScrollBarPolicy::ScrollBarAsNeeded - - - Qt::ScrollBarPolicy::ScrollBarAlwaysOff - - - QAbstractScrollArea::SizeAdjustPolicy::AdjustToContents - - - false - - - Qt::PenStyle::NoPen - - - true - - - true - - - - - - - - diff --git a/bcdevicepanel.cpp b/bcdeviceview.cpp similarity index 53% rename from bcdevicepanel.cpp rename to bcdeviceview.cpp index ecd2c76..6292321 100644 --- a/bcdevicepanel.cpp +++ b/bcdeviceview.cpp @@ -30,72 +30,64 @@ ***************************************************************************/ -#include -#include +#include +#include -BCDevicePanel::BCDevicePanel(QWidget *parent) - : QWidget(parent) +BCDeviceView::BCDeviceView(QWidget *parent) + : QTableView(parent) { - setupUi(this); - _valueView->setModel( &_valueModel ); - //_valueView->resizeColumnsToContents(); - //_valueView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); + + setModel( &_valueModel ); + //resizeColumnsToContents(); + //horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); // __fix! ziemlich wildes ge-pointere, hier - _itemDelegate = new BCItemDelegate( _valueModel.getValueList(), _valueView); - _valueView->setItemDelegate( _itemDelegate ); + _itemDelegate = new BCAnimatedDelegate( _valueModel.getValueList(), this); + setItemDelegate( _itemDelegate ); } - -void BCDevicePanel::setHeaderText( const QString& headerText) +void BCDeviceView::setHeaderLabel( const QString& headerText) { - _headerLabel->setText( headerText ); + _valueModel.setHeaderLabel( headerText ); } -QString BCDevicePanel::getHeaderText() const -{ - return _headerLabel->text(); -} -void BCDevicePanel::setDeviceID( BCDevice::ID deviceID ) +void BCDeviceView::setDeviceID( BCDevice::ID deviceID ) { _devideID = deviceID; } -BCDevice::ID BCDevicePanel::getDeviceID() const +BCDevice::ID BCDeviceView::getDeviceID() const { return _devideID; } -QTableView* BCDevicePanel::getValueView() -{ - return _valueView; -} -const BCValueList& BCDevicePanel::getValueListX() + +const BCValueList& BCDeviceView::getValueListX() { return _valueModel.getValueList(); } /* -BCValueModel& BCDevicePanel::getValueModel() +BCValueModel& BCDeviceView::getValueModel() { return _valueModel; } */ // __FIX ist das ok so? -void BCDevicePanel::onValueListReady( BCDevice::ID deviceID, BCValueList valueList ) +void BCDeviceView::onValueListReady( BCDevice::ID deviceID, BCValueList valueList ) { - qDebug() << " --- onValueListReady: " << getHeaderText() <<" : " << deviceID << ": " << valueList.size(); + qDebug() << " --- onValueListReady: " << deviceID << ": " << valueList.size(); if(_devideID == deviceID) _valueModel.takeValueList( valueList ); } -void BCDevicePanel::onValueUpdated(int index, BC::State state, const QString& newVisibleValue ) +void BCDeviceView::onValueUpdated(int index, BC::State state, const QString& newVisibleValue ) { _valueModel.onValueUpdated( index,state,newVisibleValue); _itemDelegate->onHighlightRow( index ); diff --git a/bcdevicepanel.h b/bcdeviceview.h similarity index 75% rename from bcdevicepanel.h rename to bcdeviceview.h index 7319782..8ba640a 100644 --- a/bcdevicepanel.h +++ b/bcdeviceview.h @@ -30,30 +30,29 @@ ***************************************************************************/ -#ifndef BCDEVICEPANEL_H -#define BCDEVICEPANEL_H +#ifndef BCDEVICEVIEW_H +#define BCDEVICEVIEW_H + +#include #include -#include -class BCItemDelegate; -class BCDevicePanel : public QWidget, private Ui::BCDevicePanel +class BCAnimatedDelegate; + +class BCDeviceView : public QTableView { Q_OBJECT - Q_PROPERTY(QString headerText READ getHeaderText WRITE setHeaderText DESIGNABLE true) public: - explicit BCDevicePanel(QWidget *parent = nullptr); + explicit BCDeviceView(QWidget *parent = nullptr); - void setHeaderText( const QString& headerText); - QString getHeaderText() const; + void setHeaderLabel( const QString& headerText); void setDeviceID( BCDevice::ID deviceID ); BCDevice::ID getDeviceID() const; - QTableView* getValueView(); const BCValueList& getValueListX(); //BCValueModel &getValueModel(); @@ -66,8 +65,8 @@ protected: BCDevice::ID _devideID{BCDevice::ID::Invalid}; BCValueModel _valueModel; - BCItemDelegate* _itemDelegate{}; + BCAnimatedDelegate* _itemDelegate{}; }; -#endif // BCDEVICEPANEL_H +#endif // BCDEVICEVIEW_H diff --git a/bcmainwindow.cpp b/bcmainwindow.cpp index dc13d79..c7a0c94 100644 --- a/bcmainwindow.cpp +++ b/bcmainwindow.cpp @@ -34,7 +34,7 @@ #include "qassert.h" #include -#include +#include #include @@ -91,15 +91,15 @@ void BCMainWindow::initMainWindow() if( _devicePanels.contains(deviceID) ) { - BCDevicePanel* currentPanel = _devicePanels[deviceID]; + BCDeviceView* currentPanel = _devicePanels[deviceID]; // den Panels ihren title geben - currentPanel->setHeaderText( panelTitle ); + currentPanel->setHeaderLabel( panelTitle ); // ... und ihre device ID currentPanel->setDeviceID( deviceID ); // Wenn ein Device (entspricht einem Datenmodel) fertig eingelesen wurde, // wird es weitergereicht. // Problem: alle Panels bekommen alle Datenmodelle angeboten. - connect( &_dataManager, &BCDataManager::valueListReady, currentPanel, &BCDevicePanel::onValueListReady ); + connect( &_dataManager, &BCDataManager::valueListReady, currentPanel, &BCDeviceView::onValueListReady ); } }; @@ -118,7 +118,7 @@ void BCMainWindow::initMainWindow() // Verwendung: - connect(_delegate, &BCItemDelegate::viewUpdateNeeded, _valueView->viewport(), QOverload<>::of(&QWidget::update)); + connect(_delegate, &BCAnimatedDelegate::viewUpdateNeeded, _valueView->viewport(), QOverload<>::of(&QWidget::update)); //_valueView->setItemDelegate(_delegate); @@ -134,7 +134,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, &BCAnimatedDelegate::onHighlightRow ); connect( _connectButton, &QToolButton::clicked, &_transmitter, &BCTransmitter::onToggleConnectionState ); connect( _syncButton, &QToolButton::clicked, this, &BCMainWindow::onSyncFromDevice ); @@ -166,7 +166,7 @@ void BCMainWindow::onValueListReady( BCDevice::ID deviceID ) qDebug() << " --- onValueListReady!" << deviceID; if( _devicePanels.contains( deviceID ) ) { - BCDevicePanel& panel = *_devicePanels[deviceID]; + BCDeviceView& panel = *_devicePanels[deviceID]; BCValueList& victim = panel.exposeValueList(); BCValueList& newValueList = _dataManager.getCurrentValueList(); qDebug() << " --- Before: " << victim.size() << " orig:" << newValueList.size(); @@ -183,7 +183,7 @@ void BCMainWindow::onShowDevicePanel( BCDevice::ID deviceID ) qDebug() << " --- onShowDevicePanel:" << deviceID; if( _devicePanels.contains( deviceID ) ) { - BCDevicePanel* nxtPanel = _devicePanels[deviceID]; + BCDeviceView* nxtPanel = _devicePanels[deviceID]; if( nxtPanel != _currentPanel ) { _stackedWidget->setCurrentWidget( nxtPanel ); @@ -215,7 +215,7 @@ void BCMainWindow::onValueUpdated(BCDevice::ID deviceID, int index, BC::State st qDebug() << "Reply: from: " << deviceID << " at: " << index << "finished. Success:" << state << " on:" << newValue; if( _devicePanels.contains( deviceID ) ) { - BCDevicePanel& panel = *_devicePanels[deviceID]; + BCDeviceView& panel = *_devicePanels[deviceID]; panel.onValueUpdated( index, state, newValue ); } } @@ -248,7 +248,7 @@ void BCMainWindow::onSyncFromDevice() //_transmitter.enqueueValueCommand( value ); emit sendValueCommand( BC::OpID::ReadValue, &value); - emit valueTouched( value.indexRow ); + //emit valueTouched( value.indexRow ); bc::processEventsFor(50); diff --git a/bcmainwindow.h b/bcmainwindow.h index d347a24..9c2381c 100644 --- a/bcmainwindow.h +++ b/bcmainwindow.h @@ -38,7 +38,7 @@ #include #include -class BCDevicePanel; +class BCDeviceView; class BCMainWindow : public QMainWindow, public Ui_BCMainWindow { @@ -78,9 +78,9 @@ protected: // Wir brauchen eine Verbindung zwischen den Views // und dem Device, das sie darstellen. - using BCDevicePanels = QHash; - BCDevicePanels _devicePanels; - BCDevicePanel* _currentPanel{}; + using BCDeviceViews = QHash; + BCDeviceViews _devicePanels; + BCDeviceView* _currentPanel{}; QThread _worker; BCTransmitter _transmitter; diff --git a/bcmainwindow.ui b/bcmainwindow.ui index 6852c6a..bbf33ac 100644 --- a/bcmainwindow.ui +++ b/bcmainwindow.ui @@ -10,8 +10,14 @@ 600 + + + 0 + 0 + + - BCMainWindow + @@ -154,12 +160,12 @@ 0 - 0 + 3 - - - - + + + + @@ -248,10 +254,9 @@ - BCDevicePanel - QWidget -
bcdevicepanel.h
- 1 + BCDeviceView + QTableView +
bcdeviceview.h
diff --git a/bcvaluemodel.cpp b/bcvaluemodel.cpp index befd979..1d16511 100644 --- a/bcvaluemodel.cpp +++ b/bcvaluemodel.cpp @@ -44,6 +44,14 @@ BCValueModel::BCValueModel(QObject *parent) } +/** + * @brief Setzt den Headerlabel ( == die Devicebezeichnung ) + * @param headerLabel + */ +void BCValueModel::setHeaderLabel( const QString& headerLabel ) +{ + _headerLabel = headerLabel; +} /** * @brief Einen Einzelwert hinzufügen @@ -145,18 +153,10 @@ int BCValueModel::columnCount(const QModelIndex& parent) const QVariant BCValueModel::headerData(int section, Qt::Orientation orientation, int role) const { - if (role != Qt::DisplayRole || orientation != Qt::Horizontal) + if (role != Qt::DisplayRole || orientation != Qt::Horizontal || section != 0) return QVariant(); - switch (section) - { - case 0: - return BCTags::LabelTag; - case 1: - return BCTags::ValueTag; - default: - return QVariant(); - } + return _headerLabel; } diff --git a/bcvaluemodel.h b/bcvaluemodel.h index 9d56723..2401e0a 100644 --- a/bcvaluemodel.h +++ b/bcvaluemodel.h @@ -52,8 +52,9 @@ public: explicit BCValueModel(QObject *parent = nullptr); - void addValue(const BCValue& val); + void setHeaderLabel( const QString& headerLabel ); + void addValue(const BCValue& val); void takeValueList(BCValueList& valueList); const BCValueList& getValueList() const; @@ -74,6 +75,7 @@ public slots: protected: + QString _headerLabel; // Die eigentlichen Werte wohnen im tatsächlich hier, im Model. BCValueList _valueList;