Cleanups in ui.
This commit is contained in:
@@ -26,9 +26,9 @@ windows
|
|||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
bc.cpp \
|
bc.cpp \
|
||||||
|
bcanimateddelegate.cpp \
|
||||||
bcdatamanager.cpp \
|
bcdatamanager.cpp \
|
||||||
bcdevicepanel.cpp \
|
bcdeviceview.cpp \
|
||||||
bcitemdelegate.cpp \
|
|
||||||
bclegacy.cpp \
|
bclegacy.cpp \
|
||||||
bctransmitter.cpp \
|
bctransmitter.cpp \
|
||||||
bcvalue.cpp \
|
bcvalue.cpp \
|
||||||
@@ -42,11 +42,11 @@ SOURCES += \
|
|||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
bc.h \
|
bc.h \
|
||||||
|
bcanimateddelegate.h \
|
||||||
bccandriver.h \
|
bccandriver.h \
|
||||||
bccandrivertinycan.h \
|
bccandrivertinycan.h \
|
||||||
bcdatamanager.h \
|
bcdatamanager.h \
|
||||||
bcdevicepanel.h \
|
bcdeviceview.h \
|
||||||
bcitemdelegate.h \
|
|
||||||
bcmainwindow.h \
|
bcmainwindow.h \
|
||||||
bctransmitter.h \
|
bctransmitter.h \
|
||||||
bcvalue.h \
|
bcvalue.h \
|
||||||
@@ -54,7 +54,6 @@ HEADERS += \
|
|||||||
bcvaluetype.h
|
bcvaluetype.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
bcdevicepanel.ui \
|
|
||||||
bcmainwindow.ui
|
bcmainwindow.ui
|
||||||
|
|
||||||
# Default rules for deployment.
|
# Default rules for deployment.
|
||||||
|
|||||||
51
bc.h
51
bc.h
@@ -723,45 +723,45 @@ public:
|
|||||||
Reg_Sensor_Config_Ramp_Up_Steps_Hi = 0x12,
|
Reg_Sensor_Config_Ramp_Up_Steps_Hi = 0x12,
|
||||||
Reg_Sensor_Config_Ramp_Up_Steps_Lo = 0x13,
|
Reg_Sensor_Config_Ramp_Up_Steps_Lo = 0x13,
|
||||||
|
|
||||||
Reg_Sensor_Config_Decay_Delay_Hi = 0x14,
|
Reg_Sensor_Config_Decay_Delay_Hi = 0x14,
|
||||||
Reg_Sensor_Config_Decay_Delay_Lo = 0x15,
|
Reg_Sensor_Config_Decay_Delay_Lo = 0x15,
|
||||||
|
|
||||||
Reg_Sensor_Config_Decay_Steps_Hi = 0x16,
|
Reg_Sensor_Config_Decay_Steps_Hi = 0x16,
|
||||||
Reg_Sensor_Config_Decay_Steps_Lo = 0x17,
|
Reg_Sensor_Config_Decay_Steps_Lo = 0x17,
|
||||||
|
|
||||||
Reg_Sensor_Config_Speed_Threshold_Hi = 0x18,
|
Reg_Sensor_Config_Speed_Threshold_Hi = 0x18,
|
||||||
Reg_Sensor_Config_Speed_Threshold_Lo = 0x19,
|
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_Year = 0x72, // Mfd. Year
|
||||||
Reg_Sensor_Sn_Month = 0x73, // Mfd. Month
|
Reg_Sensor_Sn_Month = 0x73, // Mfd. Month
|
||||||
Reg_Sensor_Sn_Day = 0x74, // Mfd. Day
|
Reg_Sensor_Sn_Day = 0x74, // Mfd. Day
|
||||||
|
|
||||||
Reg_Sensor_Sn_Pn_Hi = 0x75, // Partnumber
|
Reg_Sensor_Sn_Pn_Hi = 0x75, // Partnumber
|
||||||
Reg_Sensor_Sn_Pn_Lo = 0x76,
|
Reg_Sensor_Sn_Pn_Lo = 0x76,
|
||||||
|
|
||||||
Reg_Sensor_Sn_Item_Hi = 0x77, // Serial Number
|
Reg_Sensor_Sn_Item_Hi = 0x77, // Serial Number
|
||||||
Reg_Sensor_Sn_Item_Lo = 0x78,
|
Reg_Sensor_Sn_Item_Lo = 0x78,
|
||||||
|
|
||||||
Reg_Sensor_Rev_Hw = 0x80, // Hardware Version
|
Reg_Sensor_Rev_Hw = 0x80, // Hardware Version
|
||||||
Reg_Sensor_Rev_Sw = 0x81, // Software 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)
|
Q_ENUM(ID)
|
||||||
@@ -803,9 +803,6 @@ namespace BCTags
|
|||||||
inline constexpr auto Max = "Max"_L1;
|
inline constexpr auto Max = "Max"_L1;
|
||||||
inline constexpr auto Factor = "Factor"_L1;
|
inline constexpr auto Factor = "Factor"_L1;
|
||||||
|
|
||||||
inline constexpr auto ValueTag = "Wert"_L1;
|
|
||||||
inline constexpr auto LabelTag = "Bezeichnung"_L1;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // BC_H
|
#endif // BC_H
|
||||||
|
|||||||
@@ -43,20 +43,20 @@
|
|||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
#include "bcitemdelegate.h"
|
#include "bcanimateddelegate.h"
|
||||||
#include "bcvalue.h"
|
#include "bcvalue.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BCItemDelegate::BCItemDelegate(const BCValueList& valueList, QTableView* view)
|
BCAnimatedDelegate::BCAnimatedDelegate(const BCValueList& valueList, QTableView* view)
|
||||||
: QStyledItemDelegate{view}, _valueList{valueList}, _view{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
|
// Wir prüfen, ob im Variant unser Struct steckt
|
||||||
if (dataValue.canConvert<const BCValue*>())
|
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);
|
QVariant rawData = index.data(Qt::EditRole);
|
||||||
//if (!rawData.canConvert<BCValue*>())
|
//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
|
// Daten vom Model in den Editor laden
|
||||||
const BCValue& bc = *index.data(Qt::EditRole).value<BCValue*>();
|
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)
|
// Daten vom Editor zurück ins Model speichern (Beim Schließen)
|
||||||
QSlider *slider = editor->findChild<QSlider*>("slider");
|
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!
|
// __fix!
|
||||||
editor->setGeometry(option.rect);
|
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);
|
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
|
// 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->save();
|
||||||
painter->setRenderHint(QPainter::Antialiasing);
|
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;
|
qDebug() << " --- should highlight: " << row;
|
||||||
|
|
||||||
@@ -323,7 +323,7 @@ void BCItemDelegate::onHighlightRow(int row)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Optional: alle Highlights sofort clearen
|
// Optional: alle Highlights sofort clearen
|
||||||
void BCItemDelegate::clearAllHighlights()
|
void BCAnimatedDelegate::clearAllHighlights()
|
||||||
{
|
{
|
||||||
for(auto* anim : std::as_const(m_rowAnimations))
|
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)
|
if (_view && _view->model() && row >= 0)
|
||||||
{
|
{
|
||||||
@@ -30,8 +30,8 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef BCITEMDELEGATE_H
|
#ifndef BCANIMATEDDELEGATE_H
|
||||||
#define BCITEMDELEGATE_H
|
#define BCANIMATEDDELEGATE_H
|
||||||
|
|
||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
|
|
||||||
@@ -40,13 +40,13 @@ class QVariantAnimation;
|
|||||||
class QTableView;
|
class QTableView;
|
||||||
class BCValueList;
|
class BCValueList;
|
||||||
|
|
||||||
class BCItemDelegate : public QStyledItemDelegate
|
class BCAnimatedDelegate : public QStyledItemDelegate
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
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;
|
// QString displayText(const QVariant& dataValue, const QLocale& locale) const override;
|
||||||
|
|
||||||
@@ -106,4 +106,4 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // BCITEMDELEGATE_H
|
#endif // BCANIMATEDDELEGATE_H
|
||||||
@@ -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>
|
|
||||||
@@ -30,72 +30,64 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include <bcdevicepanel.h>
|
#include <bcdeviceview.h>
|
||||||
#include <bcitemdelegate.h>
|
#include <bcanimateddelegate.h>
|
||||||
|
|
||||||
BCDevicePanel::BCDevicePanel(QWidget *parent)
|
BCDeviceView::BCDeviceView(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QTableView(parent)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
|
||||||
_valueView->setModel( &_valueModel );
|
setModel( &_valueModel );
|
||||||
//_valueView->resizeColumnsToContents();
|
//resizeColumnsToContents();
|
||||||
//_valueView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
//horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||||
|
|
||||||
// __fix! ziemlich wildes ge-pointere, hier
|
// __fix! ziemlich wildes ge-pointere, hier
|
||||||
_itemDelegate = new BCItemDelegate( _valueModel.getValueList(), _valueView);
|
_itemDelegate = new BCAnimatedDelegate( _valueModel.getValueList(), this);
|
||||||
_valueView->setItemDelegate( _itemDelegate );
|
setItemDelegate( _itemDelegate );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BCDeviceView::setHeaderLabel( const QString& headerText)
|
||||||
void BCDevicePanel::setHeaderText( 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;
|
_devideID = deviceID;
|
||||||
}
|
}
|
||||||
|
|
||||||
BCDevice::ID BCDevicePanel::getDeviceID() const
|
BCDevice::ID BCDeviceView::getDeviceID() const
|
||||||
{
|
{
|
||||||
return _devideID;
|
return _devideID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QTableView* BCDevicePanel::getValueView()
|
|
||||||
{
|
|
||||||
return _valueView;
|
|
||||||
}
|
|
||||||
|
|
||||||
const BCValueList& BCDevicePanel::getValueListX()
|
|
||||||
|
const BCValueList& BCDeviceView::getValueListX()
|
||||||
{
|
{
|
||||||
return _valueModel.getValueList();
|
return _valueModel.getValueList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
BCValueModel& BCDevicePanel::getValueModel()
|
BCValueModel& BCDeviceView::getValueModel()
|
||||||
{
|
{
|
||||||
return _valueModel;
|
return _valueModel;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// __FIX ist das ok so?
|
// __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)
|
if(_devideID == deviceID)
|
||||||
_valueModel.takeValueList( valueList );
|
_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);
|
_valueModel.onValueUpdated( index,state,newVisibleValue);
|
||||||
_itemDelegate->onHighlightRow( index );
|
_itemDelegate->onHighlightRow( index );
|
||||||
@@ -30,30 +30,29 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef BCDEVICEPANEL_H
|
#ifndef BCDEVICEVIEW_H
|
||||||
#define BCDEVICEPANEL_H
|
#define BCDEVICEVIEW_H
|
||||||
|
|
||||||
|
#include <QTableView>
|
||||||
|
|
||||||
#include <bcvaluemodel.h>
|
#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_OBJECT
|
||||||
Q_PROPERTY(QString headerText READ getHeaderText WRITE setHeaderText DESIGNABLE true)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit BCDevicePanel(QWidget *parent = nullptr);
|
explicit BCDeviceView(QWidget *parent = nullptr);
|
||||||
|
|
||||||
void setHeaderText( const QString& headerText);
|
void setHeaderLabel( const QString& headerText);
|
||||||
QString getHeaderText() const;
|
|
||||||
|
|
||||||
void setDeviceID( BCDevice::ID deviceID );
|
void setDeviceID( BCDevice::ID deviceID );
|
||||||
BCDevice::ID getDeviceID() const;
|
BCDevice::ID getDeviceID() const;
|
||||||
|
|
||||||
QTableView* getValueView();
|
|
||||||
const BCValueList& getValueListX();
|
const BCValueList& getValueListX();
|
||||||
//BCValueModel &getValueModel();
|
//BCValueModel &getValueModel();
|
||||||
|
|
||||||
@@ -66,8 +65,8 @@ protected:
|
|||||||
|
|
||||||
BCDevice::ID _devideID{BCDevice::ID::Invalid};
|
BCDevice::ID _devideID{BCDevice::ID::Invalid};
|
||||||
BCValueModel _valueModel;
|
BCValueModel _valueModel;
|
||||||
BCItemDelegate* _itemDelegate{};
|
BCAnimatedDelegate* _itemDelegate{};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BCDEVICEPANEL_H
|
#endif // BCDEVICEVIEW_H
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
#include "qassert.h"
|
#include "qassert.h"
|
||||||
#include <bcmainwindow.h>
|
#include <bcmainwindow.h>
|
||||||
#include <bcitemdelegate.h>
|
#include <bcanimateddelegate.h>
|
||||||
#include <ui_bcmainwindow.h>
|
#include <ui_bcmainwindow.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -91,15 +91,15 @@ void BCMainWindow::initMainWindow()
|
|||||||
|
|
||||||
if( _devicePanels.contains(deviceID) )
|
if( _devicePanels.contains(deviceID) )
|
||||||
{
|
{
|
||||||
BCDevicePanel* currentPanel = _devicePanels[deviceID];
|
BCDeviceView* currentPanel = _devicePanels[deviceID];
|
||||||
// den Panels ihren title geben
|
// den Panels ihren title geben
|
||||||
currentPanel->setHeaderText( panelTitle );
|
currentPanel->setHeaderLabel( panelTitle );
|
||||||
// ... und ihre device ID
|
// ... und ihre device ID
|
||||||
currentPanel->setDeviceID( deviceID );
|
currentPanel->setDeviceID( deviceID );
|
||||||
// Wenn ein Device (entspricht einem Datenmodel) fertig eingelesen wurde,
|
// Wenn ein Device (entspricht einem Datenmodel) fertig eingelesen wurde,
|
||||||
// wird es weitergereicht.
|
// wird es weitergereicht.
|
||||||
// Problem: alle Panels bekommen alle Datenmodelle angeboten.
|
// 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:
|
// Verwendung:
|
||||||
|
|
||||||
connect(_delegate, &BCItemDelegate::viewUpdateNeeded, _valueView->viewport(), QOverload<>::of(&QWidget::update));
|
connect(_delegate, &BCAnimatedDelegate::viewUpdateNeeded, _valueView->viewport(), QOverload<>::of(&QWidget::update));
|
||||||
|
|
||||||
|
|
||||||
//_valueView->setItemDelegate(_delegate);
|
//_valueView->setItemDelegate(_delegate);
|
||||||
@@ -134,7 +134,7 @@ void BCMainWindow::initMainWindow()
|
|||||||
|
|
||||||
// besser: model::emit dataChanged
|
// besser: model::emit dataChanged
|
||||||
// also: emit dataChanged(index, index, {Qt::DisplayRole, Qt::EditRole, ValueRole});
|
// 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( _connectButton, &QToolButton::clicked, &_transmitter, &BCTransmitter::onToggleConnectionState );
|
||||||
connect( _syncButton, &QToolButton::clicked, this, &BCMainWindow::onSyncFromDevice );
|
connect( _syncButton, &QToolButton::clicked, this, &BCMainWindow::onSyncFromDevice );
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ void BCMainWindow::onValueListReady( BCDevice::ID deviceID )
|
|||||||
qDebug() << " --- onValueListReady!" << deviceID;
|
qDebug() << " --- onValueListReady!" << deviceID;
|
||||||
if( _devicePanels.contains( deviceID ) )
|
if( _devicePanels.contains( deviceID ) )
|
||||||
{
|
{
|
||||||
BCDevicePanel& panel = *_devicePanels[deviceID];
|
BCDeviceView& panel = *_devicePanels[deviceID];
|
||||||
BCValueList& victim = panel.exposeValueList();
|
BCValueList& victim = panel.exposeValueList();
|
||||||
BCValueList& newValueList = _dataManager.getCurrentValueList();
|
BCValueList& newValueList = _dataManager.getCurrentValueList();
|
||||||
qDebug() << " --- Before: " << victim.size() << " orig:" << newValueList.size();
|
qDebug() << " --- Before: " << victim.size() << " orig:" << newValueList.size();
|
||||||
@@ -183,7 +183,7 @@ void BCMainWindow::onShowDevicePanel( BCDevice::ID deviceID )
|
|||||||
qDebug() << " --- onShowDevicePanel:" << deviceID;
|
qDebug() << " --- onShowDevicePanel:" << deviceID;
|
||||||
if( _devicePanels.contains( deviceID ) )
|
if( _devicePanels.contains( deviceID ) )
|
||||||
{
|
{
|
||||||
BCDevicePanel* nxtPanel = _devicePanels[deviceID];
|
BCDeviceView* nxtPanel = _devicePanels[deviceID];
|
||||||
if( nxtPanel != _currentPanel )
|
if( nxtPanel != _currentPanel )
|
||||||
{
|
{
|
||||||
_stackedWidget->setCurrentWidget( nxtPanel );
|
_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;
|
qDebug() << "Reply: from: " << deviceID << " at: " << index << "finished. Success:" << state << " on:" << newValue;
|
||||||
if( _devicePanels.contains( deviceID ) )
|
if( _devicePanels.contains( deviceID ) )
|
||||||
{
|
{
|
||||||
BCDevicePanel& panel = *_devicePanels[deviceID];
|
BCDeviceView& panel = *_devicePanels[deviceID];
|
||||||
panel.onValueUpdated( index, state, newValue );
|
panel.onValueUpdated( index, state, newValue );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -248,7 +248,7 @@ void BCMainWindow::onSyncFromDevice()
|
|||||||
|
|
||||||
//_transmitter.enqueueValueCommand( value );
|
//_transmitter.enqueueValueCommand( value );
|
||||||
emit sendValueCommand( BC::OpID::ReadValue, &value);
|
emit sendValueCommand( BC::OpID::ReadValue, &value);
|
||||||
emit valueTouched( value.indexRow );
|
//emit valueTouched( value.indexRow );
|
||||||
|
|
||||||
bc::processEventsFor(50);
|
bc::processEventsFor(50);
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
#include <ui_bcmainwindow.h>
|
#include <ui_bcmainwindow.h>
|
||||||
#include <bcdatamanager.h>
|
#include <bcdatamanager.h>
|
||||||
|
|
||||||
class BCDevicePanel;
|
class BCDeviceView;
|
||||||
|
|
||||||
class BCMainWindow : public QMainWindow, public Ui_BCMainWindow
|
class BCMainWindow : public QMainWindow, public Ui_BCMainWindow
|
||||||
{
|
{
|
||||||
@@ -78,9 +78,9 @@ protected:
|
|||||||
// Wir brauchen eine Verbindung zwischen den Views
|
// Wir brauchen eine Verbindung zwischen den Views
|
||||||
// und dem Device, das sie darstellen.
|
// und dem Device, das sie darstellen.
|
||||||
|
|
||||||
using BCDevicePanels = QHash<BCDevice::ID, BCDevicePanel*>;
|
using BCDeviceViews = QHash<BCDevice::ID, BCDeviceView*>;
|
||||||
BCDevicePanels _devicePanels;
|
BCDeviceViews _devicePanels;
|
||||||
BCDevicePanel* _currentPanel{};
|
BCDeviceView* _currentPanel{};
|
||||||
|
|
||||||
QThread _worker;
|
QThread _worker;
|
||||||
BCTransmitter _transmitter;
|
BCTransmitter _transmitter;
|
||||||
|
|||||||
@@ -10,8 +10,14 @@
|
|||||||
<height>600</height>
|
<height>600</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>BCMainWindow</string>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="_centralwidget">
|
<widget class="QWidget" name="_centralwidget">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
@@ -154,12 +160,12 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="BCDevicePanel" name="_consolePanel"/>
|
<widget class="BCDeviceView" name="_consolePanel"/>
|
||||||
<widget class="BCDevicePanel" name="_motorPanel"/>
|
<widget class="BCDeviceView" name="_motorPanel"/>
|
||||||
<widget class="BCDevicePanel" name="_batteryPanel"/>
|
<widget class="BCDeviceView" name="_batteryPanel"/>
|
||||||
<widget class="BCDevicePanel" name="_pimpPanel"/>
|
<widget class="BCDeviceView" name="_pimpPanel"/>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@@ -248,10 +254,9 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>BCDevicePanel</class>
|
<class>BCDeviceView</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QTableView</extends>
|
||||||
<header location="global">bcdevicepanel.h</header>
|
<header location="global">bcdeviceview.h</header>
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
|
|||||||
@@ -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
|
* @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
|
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();
|
return QVariant();
|
||||||
|
|
||||||
switch (section)
|
return _headerLabel;
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
return BCTags::LabelTag;
|
|
||||||
case 1:
|
|
||||||
return BCTags::ValueTag;
|
|
||||||
default:
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,9 @@ public:
|
|||||||
|
|
||||||
explicit BCValueModel(QObject *parent = nullptr);
|
explicit BCValueModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
void addValue(const BCValue& val);
|
void setHeaderLabel( const QString& headerLabel );
|
||||||
|
|
||||||
|
void addValue(const BCValue& val);
|
||||||
void takeValueList(BCValueList& valueList);
|
void takeValueList(BCValueList& valueList);
|
||||||
const BCValueList& getValueList() const;
|
const BCValueList& getValueList() const;
|
||||||
|
|
||||||
@@ -74,6 +75,7 @@ public slots:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
QString _headerLabel;
|
||||||
// Die eigentlichen Werte wohnen im tatsächlich hier, im Model.
|
// Die eigentlichen Werte wohnen im tatsächlich hier, im Model.
|
||||||
BCValueList _valueList;
|
BCValueList _valueList;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user