Cleanups in ui.

This commit is contained in:
2025-12-29 23:29:56 +01:00
parent 60be19a6ae
commit 679bff5e26
12 changed files with 119 additions and 220 deletions

View File

@@ -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.

51
bc.h
View File

@@ -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

View File

@@ -43,20 +43,20 @@
#include <QPropertyAnimation>
#include <QPainter>
#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<const BCValue*>())
@@ -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<BCValue*>())
@@ -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<BCValue*>();
@@ -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<QSlider*>("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)
{

View File

@@ -30,8 +30,8 @@
***************************************************************************/
#ifndef BCITEMDELEGATE_H
#define BCITEMDELEGATE_H
#ifndef BCANIMATEDDELEGATE_H
#define BCANIMATEDDELEGATE_H
#include <QStyledItemDelegate>
@@ -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

View File

@@ -1,95 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BCDevicePanel</class>
<widget class="QWidget" name="BCDevicePanel">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="headerText" stdset="0">
<string>Fitze!</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="_headerLabel">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QTableView" name="_valueView">
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color:#eeeeee</string>
</property>
<property name="frameShape">
<enum>QFrame::Shape::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarPolicy::ScrollBarAsNeeded</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarPolicy::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::SizeAdjustPolicy::AdjustToContents</enum>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
<property name="gridStyle">
<enum>Qt::PenStyle::NoPen</enum>
</property>
<attribute name="horizontalHeaderVisible">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -30,72 +30,64 @@
***************************************************************************/
#include <bcdevicepanel.h>
#include <bcitemdelegate.h>
#include <bcdeviceview.h>
#include <bcanimateddelegate.h>
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 );

View File

@@ -30,30 +30,29 @@
***************************************************************************/
#ifndef BCDEVICEPANEL_H
#define BCDEVICEPANEL_H
#ifndef BCDEVICEVIEW_H
#define BCDEVICEVIEW_H
#include <QTableView>
#include <bcvaluemodel.h>
#include <ui_bcdevicepanel.h>
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

View File

@@ -34,7 +34,7 @@
#include "qassert.h"
#include <bcmainwindow.h>
#include <bcitemdelegate.h>
#include <bcanimateddelegate.h>
#include <ui_bcmainwindow.h>
@@ -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);

View File

@@ -38,7 +38,7 @@
#include <ui_bcmainwindow.h>
#include <bcdatamanager.h>
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<BCDevice::ID, BCDevicePanel*>;
BCDevicePanels _devicePanels;
BCDevicePanel* _currentPanel{};
using BCDeviceViews = QHash<BCDevice::ID, BCDeviceView*>;
BCDeviceViews _devicePanels;
BCDeviceView* _currentPanel{};
QThread _worker;
BCTransmitter _transmitter;

View File

@@ -10,8 +10,14 @@
<height>600</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>BCMainWindow</string>
<string/>
</property>
<widget class="QWidget" name="_centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
@@ -154,12 +160,12 @@
<number>0</number>
</property>
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="BCDevicePanel" name="_consolePanel"/>
<widget class="BCDevicePanel" name="_motorPanel"/>
<widget class="BCDevicePanel" name="_batteryPanel"/>
<widget class="BCDevicePanel" name="_pimpPanel"/>
<widget class="BCDeviceView" name="_consolePanel"/>
<widget class="BCDeviceView" name="_motorPanel"/>
<widget class="BCDeviceView" name="_batteryPanel"/>
<widget class="BCDeviceView" name="_pimpPanel"/>
</widget>
</item>
</layout>
@@ -248,10 +254,9 @@
</widget>
<customwidgets>
<customwidget>
<class>BCDevicePanel</class>
<extends>QWidget</extends>
<header location="global">bcdevicepanel.h</header>
<container>1</container>
<class>BCDeviceView</class>
<extends>QTableView</extends>
<header location="global">bcdeviceview.h</header>
</customwidget>
</customwidgets>
<resources>

View File

@@ -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;
}

View File

@@ -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;