Mini-Breakthrough: Animantion works.

This commit is contained in:
2025-12-29 20:10:05 +01:00
parent 4491e6fe57
commit 60be19a6ae
11 changed files with 282 additions and 284 deletions

View File

@@ -27,8 +27,8 @@ windows
SOURCES += \
bc.cpp \
bcdatamanager.cpp \
bcdelegate.cpp \
bcdevicepanel.cpp \
bcitemdelegate.cpp \
bclegacy.cpp \
bctransmitter.cpp \
bcvalue.cpp \
@@ -45,8 +45,8 @@ HEADERS += \
bccandriver.h \
bccandrivertinycan.h \
bcdatamanager.h \
bcdelegate.h \
bcdevicepanel.h \
bcitemdelegate.h \
bcmainwindow.h \
bctransmitter.h \
bcvalue.h \

View File

@@ -31,7 +31,7 @@
#include <bcdevicepanel.h>
#include <bcdelegate.h>
#include <bcitemdelegate.h>
BCDevicePanel::BCDevicePanel(QWidget *parent)
: QWidget(parent)
@@ -41,8 +41,10 @@ BCDevicePanel::BCDevicePanel(QWidget *parent)
//_valueView->resizeColumnsToContents();
//_valueView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
BCDelegate* delegate = new BCDelegate( _valueModel.getValueList(), _valueView);
_valueView->setItemDelegate( delegate );
// __fix! ziemlich wildes ge-pointere, hier
_itemDelegate = new BCItemDelegate( _valueModel.getValueList(), _valueView);
_valueView->setItemDelegate( _itemDelegate );
}
@@ -78,10 +80,12 @@ const BCValueList& BCDevicePanel::getValueListX()
return _valueModel.getValueList();
}
/*
BCValueModel& BCDevicePanel::getValueModel()
{
return _valueModel;
}
*/
// __FIX ist das ok so?
void BCDevicePanel::onValueListReady( BCDevice::ID deviceID, BCValueList valueList )
@@ -91,5 +95,11 @@ void BCDevicePanel::onValueListReady( BCDevice::ID deviceID, BCValueList valueLi
_valueModel.takeValueList( valueList );
}
void BCDevicePanel::onValueUpdated(int index, BC::State state, const QString& newVisibleValue )
{
_valueModel.onValueUpdated( index,state,newVisibleValue);
_itemDelegate->onHighlightRow( index );
}

View File

@@ -36,6 +36,8 @@
#include <bcvaluemodel.h>
#include <ui_bcdevicepanel.h>
class BCItemDelegate;
class BCDevicePanel : public QWidget, private Ui::BCDevicePanel
{
Q_OBJECT
@@ -53,17 +55,18 @@ public:
QTableView* getValueView();
const BCValueList& getValueListX();
BCValueModel &getValueModel();
//BCValueModel &getValueModel();
public slots:
void onValueListReady( BCDevice::ID deviceID, BCValueList valueList );
void onValueUpdated( int index, BC::State state, const QString& newVisibleValue="" );
protected:
BCDevice::ID _devideID{BCDevice::ID::Invalid};
BCValueModel _valueModel;
BCDevice::ID _devideID{BCDevice::ID::Invalid};
BCValueModel _valueModel;
BCItemDelegate* _itemDelegate{};
};

View File

@@ -14,12 +14,27 @@
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true">background-color:green;</string>
<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">
@@ -39,7 +54,7 @@
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color:#0000ff</string>
<string notr="true">background-color:#eeeeee</string>
</property>
<property name="frameShape">
<enum>QFrame::Shape::NoFrame</enum>

View File

@@ -43,20 +43,20 @@
#include <QPropertyAnimation>
#include <QPainter>
#include "bcdelegate.h"
#include "bcitemdelegate.h"
#include "bcvalue.h"
#include "qapplication.h"
BCDelegate::BCDelegate(const BCValueList& valueList, QTableView* view)
BCItemDelegate::BCItemDelegate(const BCValueList& valueList, QTableView* view)
: QStyledItemDelegate{view}, _valueList{valueList}, _view{view}
{
}
QString BCDelegate::displayText(const QVariant& dataValue, const QLocale& locale) const
/*
QString BCItemDelegate::displayText(const QVariant& dataValue, const QLocale& locale) const
{
// Wir prüfen, ob im Variant unser Struct steckt
if (dataValue.canConvert<const BCValue*>())
@@ -76,9 +76,10 @@ QString BCDelegate::displayText(const QVariant& dataValue, const QLocale& locale
// Fallback für normale Strings/Zahlen
return QStyledItemDelegate::displayText(dataValue, locale);
}
*/
QWidget *BCDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const
QWidget *BCItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const
{
QVariant rawData = index.data(Qt::EditRole);
//if (!rawData.canConvert<BCValue*>())
@@ -128,7 +129,7 @@ QWidget *BCDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &o
*/
}
void BCDelegate::setEditorData(QWidget *editor, const QModelIndex& index) const
void BCItemDelegate::setEditorData(QWidget *editor, const QModelIndex& index) const
{
// Daten vom Model in den Editor laden
const BCValue& bc = *index.data(Qt::EditRole).value<BCValue*>();
@@ -147,7 +148,7 @@ void BCDelegate::setEditorData(QWidget *editor, const QModelIndex& index) const
}
}
void BCDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex& index) const
void BCItemDelegate::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");
@@ -160,13 +161,13 @@ void BCDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const
}
}
void BCDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex& index) const
void BCItemDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex& index) const
{
// __fix!
editor->setGeometry(option.rect);
}
QSize BCDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex& index) const
QSize BCItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex& index) const
{
return QStyledItemDelegate::sizeHint(option,index);
/*
@@ -180,34 +181,13 @@ QSize BCDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex
}
void BCDelegate::paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
void BCItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
/*
// 1. Standard-Zeichnen (Text, Hintergrund, Selection) durchführen
QStyledItemDelegate::paint(painter, option, index);
// 2. Unser Custom-Overlay: Oranger Rahmen, wenn Zeile passt
if (index.row() == _highlightedRow)
{
painter->save();
qDebug() << " --- is highlight: " << index.row();
// Setup Stift
QPen pen(QColor(255, 165, 0)); // Orange
pen.setWidth(2);
painter->setPen(pen);
// Rechteck zeichnen (leicht eingezogen, damit es nicht abgeschnitten wird)
QRect rect = option.rect.adjusted(1, 1, -1, -1);
painter->drawRect(rect);
painter->restore();
}
*/
QStyledItemDelegate::paint(painter, option, index);
//QPen pen(QColor(255, 165, 0)); // Orange
/*
if (index.row() == _highlightedRow && _opacity > 0.0)
@@ -231,61 +211,70 @@ void BCDelegate::paint(QPainter *painter, const QStyleOptionViewItem& option, co
int row = index.row();
if (m_rowOpacities.contains(row))
if (index.column() == 1 )
{
/*
qreal opacity = m_rowOpacities.value(row);
if (opacity > 0.01)
qDebug() << " --- is highlight: " << row << " : " << index.column();
//if( m_rowOpacities.contains(row))
{
painter->save();
painter->setOpacity(opacity);
painter->fillRect(option.rect, QColor(255, 140, 0, 120));
painter->restore();
qDebug() << " --- PAINT highlight:";
//if ( m_rowOpacities.contains(row))
paintHighlightRow(painter,option,index);
}
*/
paintHighlightRow(painter,option,index);
}
}
void BCDelegate::paintHighlightRow(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
/*
qreal opacity = m_rowOpacities.value(row);
if (opacity > 0.01)
{
painter->save();
painter->setOpacity(opacity);
painter->fillRect(option.rect, QColor(255, 140, 0, 120));
painter->restore();
}
*/
void BCItemDelegate::paintHighlightRow(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
painter->save();
painter->setRenderHint(QPainter::Antialiasing);
int row = index.row();
qreal opacity = m_rowOpacities.value(row);
painter->setOpacity(opacity);
// Margin von 4px
QRect itemRect = option.rect.adjusted(4, 4, -4, -4);
QRect itemRect = option.rect.adjusted(3, 3, -3, -3);
// Border von 2px berücksichtigen (nach innen)
QRect contentRect = itemRect.adjusted(2, 2, -2, -2);
// painter->fillRect(contentRect,Qt::green);
/*
// Hintergrund (weiß)
painter->setBrush(Qt::white);
painter->setPen(Qt::NoPen);
painter->drawRoundedRect(itemRect, 8, 8);
*/
// Border (2px solid #2196F3)
QPen borderPen( Qt::red, 2);
QPen borderPen( Qt::red, 1);
painter->setPen(borderPen);
painter->setBrush(Qt::NoBrush);
painter->drawRoundedRect(itemRect, 8, 8);
painter->drawRoundedRect(itemRect, 2, 2);
// Padding von 8px für den Content
QRect textRect = contentRect.adjusted(8, 8, -8, -8);
//QRect textRect = contentRect.adjusted(8, 8, -8, -8);
/*
// Text zeichnen
painter->setPen(Qt::black); // oder option.palette.color(QPalette::Text)
QString text = index.data(Qt::DisplayRole).toString();
painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, text);
*/
painter->restore();
}
void BCDelegate::onHighlightRow(int row)
void BCItemDelegate::onHighlightRow(int row)
{
qDebug() << " --- should highlight: " << row;
@@ -334,7 +323,7 @@ void BCDelegate::onHighlightRow(int row)
}
// Optional: alle Highlights sofort clearen
void BCDelegate::clearAllHighlights()
void BCItemDelegate::clearAllHighlights()
{
for(auto* anim : std::as_const(m_rowAnimations))
{
@@ -350,11 +339,11 @@ void BCDelegate::clearAllHighlights()
}
}
void BCDelegate::updateRow(int row)
void BCItemDelegate::updateRow(int row)
{
if (_view && _view->model() && row >= 0)
{
QModelIndex idx = _view->model()->index(row, 0);
QModelIndex idx = _view->model()->index(row,1);
QRect rect = _view->visualRect(idx);
if (!rect.isEmpty()) {
_view->viewport()->update(rect);
@@ -362,35 +351,3 @@ void BCDelegate::updateRow(int row)
}
}
QString BCDelegate::formatDisplayString(const QModelIndex& index) const
{
if (!index.isValid())
return QString();
QString displayStr;
/*
QString label = index.data(BCValueListModel::LabelRole).toString();
QVariant value = index.data(BCValueListModel::ValueRole);
QString unit = index.data(BCValueListModel::UnitRole).toString();
QString valueStr = value.toString();
// Formatierung für Zahlen
bool ok;
double numValue = value.toDouble(&ok);
if (ok) {
valueStr = QString::number(numValue, 'f', 2);
}
// Zusammensetzen des Anzeige-Strings
QString displayStr = label;
if (!displayStr.isEmpty() && !valueStr.isEmpty())
displayStr += ": ";
displayStr += valueStr;
if (!unit.isEmpty())
displayStr += " " + unit;
*/
return displayStr;
}

View File

@@ -30,8 +30,8 @@
***************************************************************************/
#ifndef BCDELEGATE_H
#define BCDELEGATE_H
#ifndef BCITEMDELEGATE_H
#define BCITEMDELEGATE_H
#include <QStyledItemDelegate>
@@ -40,16 +40,15 @@ class QVariantAnimation;
class QTableView;
class BCValueList;
class BCDelegate : public QStyledItemDelegate
class BCItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
Q_PROPERTY(qreal highlightOpacity READ highlightOpacity WRITE setHighlightOpacity)
public:
explicit BCDelegate(const BCValueList& valueList, QTableView* view );
explicit BCItemDelegate(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;
// Zuständig für den Edit-Modus (Doppelklick)
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const override;
@@ -60,6 +59,7 @@ public:
QSize sizeHint(const QStyleOptionViewItem &option,const QModelIndex& index) const override;
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex& index) const override;
/*
qreal highlightOpacity() const
{
return _opacity;
@@ -72,6 +72,7 @@ public:
// __fix! unsinn!
emit viewUpdateNeeded();
}
*/
void clearAllHighlights();
@@ -82,19 +83,18 @@ public slots:
signals:
void viewUpdateNeeded();
//void viewUpdateNeeded();
private:
void updateRow(int row);
QString formatDisplayString(const QModelIndex& index) const;
void paintHighlightRow(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
const BCValueList& _valueList;
QTableView* _view{};
int _highlightedRow{-1};
qreal _opacity{1.0};
//int _highlightedRow{-1};
//qreal _opacity{1.0};
QPropertyAnimation* _animation{};
@@ -106,4 +106,4 @@ private:
};
#endif // BCDELEGATE_H
#endif // BCITEMDELEGATE_H

View File

@@ -34,7 +34,7 @@
#include "qassert.h"
#include <bcmainwindow.h>
#include <bcdelegate.h>
#include <bcitemdelegate.h>
#include <ui_bcmainwindow.h>
@@ -114,17 +114,11 @@ void BCMainWindow::initMainWindow()
configureAction(_batteryButton, _batteryAction, BCDevice::ID::Battery, "Battery Settings"_L1 );
configureAction(_pimpButton, _pimpAction, BCDevice::ID::Pimp, "Pimp my Ride"_L1 );
/*
BCDelegate* _delegate = new BCDelegate( _valueView);
//_delegate = new AnimatedDelegate(_valueView );
_valueView->setItemDelegate( _delegate );
// Verwendung:
connect(_delegate, &BCDelegate::viewUpdateNeeded, _valueView->viewport(), QOverload<>::of(&QWidget::update));
connect(_delegate, &BCItemDelegate::viewUpdateNeeded, _valueView->viewport(), QOverload<>::of(&QWidget::update));
//_valueView->setItemDelegate(_delegate);
@@ -140,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, &BCDelegate::onHighlightRow );
//connect( &_dataManager, &BCMainWindow::valueTouched, _delegate, &BCItemDelegate::onHighlightRow );
connect( _connectButton, &QToolButton::clicked, &_transmitter, &BCTransmitter::onToggleConnectionState );
connect( _syncButton, &QToolButton::clicked, this, &BCMainWindow::onSyncFromDevice );
@@ -222,10 +216,8 @@ void BCMainWindow::onValueUpdated(BCDevice::ID deviceID, int index, BC::State st
if( _devicePanels.contains( deviceID ) )
{
BCDevicePanel& panel = *_devicePanels[deviceID];
panel.getValueModel().onValueUpdated( index, state, newValue );
panel.onValueUpdated( index, state, newValue );
}
//_devicePanels;
}
void BCMainWindow::onRunnerMessage(const QString &msg)
@@ -258,7 +250,7 @@ void BCMainWindow::onSyncFromDevice()
emit sendValueCommand( BC::OpID::ReadValue, &value);
emit valueTouched( value.indexRow );
bc::processEventsFor(500);
bc::processEventsFor(50);

View File

@@ -14,144 +14,155 @@
<string>BCMainWindow</string>
</property>
<widget class="QWidget" name="_centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="_buttonWidget" native="true">
<property name="styleSheet">
<string notr="true">background-color: grey;</string>
<widget class="QLabel" name="_headerLabel">
<property name="text">
<string>Bionx Control</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item alignment="Qt::AlignmentFlag::AlignHCenter">
<widget class="QToolButton" name="_motorButton">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
<property name="iconSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
</widget>
</item>
<item alignment="Qt::AlignmentFlag::AlignHCenter">
<widget class="QToolButton" name="_batteryButton">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
<property name="iconSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
</widget>
</item>
<item alignment="Qt::AlignmentFlag::AlignHCenter">
<widget class="QToolButton" name="_consoleButton">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
<property name="iconSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
</widget>
</item>
<item alignment="Qt::AlignmentFlag::AlignHCenter">
<widget class="QToolButton" name="_pimpButton">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
<property name="iconSize">
<size>
<width>48</width>
<height>48</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>239</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignmentFlag::AlignHCenter">
<widget class="QToolButton" name="_syncButton">
<property name="text">
<string>Sync</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="_connectButton">
<property name="text">
<string>Connect</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QStackedWidget" name="_stackedWidget">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: hotpink;</string>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="BCDevicePanel" name="_consolePanel"/>
<widget class="BCDevicePanel" name="_motorPanel"/>
<widget class="BCDevicePanel" name="_batteryPanel"/>
<widget class="BCDevicePanel" name="_pimpPanel"/>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QWidget" name="_buttonWidget" native="true">
<property name="styleSheet">
<string notr="true">background-color: grey;</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item alignment="Qt::AlignmentFlag::AlignHCenter">
<widget class="QToolButton" name="_motorButton">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
<property name="iconSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
</widget>
</item>
<item alignment="Qt::AlignmentFlag::AlignHCenter">
<widget class="QToolButton" name="_batteryButton">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
<property name="iconSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
</widget>
</item>
<item alignment="Qt::AlignmentFlag::AlignHCenter">
<widget class="QToolButton" name="_consoleButton">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
<property name="iconSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
</widget>
</item>
<item alignment="Qt::AlignmentFlag::AlignHCenter">
<widget class="QToolButton" name="_pimpButton">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
<property name="iconSize">
<size>
<width>48</width>
<height>48</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>239</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignmentFlag::AlignHCenter">
<widget class="QToolButton" name="_syncButton">
<property name="text">
<string>Sync</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="_connectButton">
<property name="text">
<string>Connect</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QStackedWidget" name="_stackedWidget">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: hotpink;</string>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="BCDevicePanel" name="_consolePanel"/>
<widget class="BCDevicePanel" name="_motorPanel"/>
<widget class="BCDevicePanel" name="_batteryPanel"/>
<widget class="BCDevicePanel" name="_pimpPanel"/>
</widget>
</item>
</layout>
</item>
</layout>
</widget>

View File

@@ -88,9 +88,6 @@ void BCTransmitter::enqueueValueOp(BC::OpID opID, const BCValue* value)
QMutexLocker locker(&_mutex);
_valueQueue.enqueue( value );
// Logging (Thread-safe via Signal)
//emit messageLogged(QString("Command %1 queued.").arg(cmd.label));
// wir wollen nicht den ganzen Value verschicken, erstrecht
// wollen wir den Value in verschiedenen Threads gleichzeitig
// in die Hand nehmen, also hantieren wir nur mit den Inidizes.
@@ -133,7 +130,7 @@ void BCTransmitter::processValueOp( BC::OpID opID )
// Abkürzung
const BCValue& val = *currentValue;
// Value ist 'under construction'
emit valueUpdated( val.deviceID, val.indexRow, BC::State::Locked );
//emit valueUpdated( val.deviceID, val.indexRow, BC::State::Locked );
if( opID == BC::OpID::ReadValue )
{
QString result = currentValue->readRawValueX( *this );
@@ -151,8 +148,6 @@ void BCTransmitter::processValueOp( BC::OpID opID )
qDebug() << " --- OUCH!";
}
//emit valueStateChanged(cmd.id, true);
//emit valueStateChanged(0, true);
}

View File

@@ -136,6 +136,7 @@ public:
// Copy Assignment Operator
BCValueList& operator=(const BCValueList& other)
{
qDebug() << "BC copy assignment: " << this;
QList<BCValue>::operator=( other );
return *this;
}
@@ -143,6 +144,7 @@ public:
// Move Assignment Operator
BCValueList& operator=(BCValueList&& other) noexcept
{
qDebug() << "BC move assignment: " << this;
QList<BCValue>::operator=( other );
return *this;
}

View File

@@ -31,6 +31,7 @@
#include <bcvaluemodel.h>
#include <bcvaluetype.h>
/**
* @brief Konstruktor, ohne Besonderheiten
@@ -94,7 +95,7 @@ void BCValueModel::takeValueList(BCValueList& newValueList)
void BCValueModel::onValueUpdated( int row, BC::State state, const QString& newVisisbleValue )
{
qDebug() << " Panel update: " << newVisisbleValue;
qDebug() << " BCValueModel::onValueUpdated update: " << newVisisbleValue;
if( row > -1 && row < _valueList.size() )
{
const BCValue& value = _valueList[row];
@@ -160,41 +161,53 @@ QVariant BCValueModel::headerData(int section, Qt::Orientation orientation, int
/**
* @brief Gibt die Model-Daten zurück. Das Model Gibt hier, unabhängig von der DataRole, immer das
* gesamte BCValue Object zurück. Die Umsetzung von Status- und Typeinfromationen in GUI-Elemente
* findet nicht hier, sondern im BCDelagate statt.
* @brief Gibt die Model-Daten zurück.
*/
QVariant BCValueModel::data(const QModelIndex& index, int role) const
{
Q_UNUSED(role)
/*
// Bonus: Rechtsbündig für Zahlen
if (role == Qt::TextAlignmentRole && (index.column() == 0 || index.column() == 2)) {
return Qt::AlignRight | Qt::AlignVCenter;
}
int row = index.row();
int col = index.column();
return QVariant();
*/
int row = index.row();
if (!index.isValid() || row >= _valueList.size())
bool wrongRole = ( role != Qt::DisplayRole && role != Qt::EditRole);
if (wrongRole || !index.isValid() || row >= _valueList.size() )
return QVariant();
const BCValue* entry = &_valueList.at( row );
return QVariant::fromValue( entry );
const BCValue& value = _valueList.at( row );
/*
if (role == Qt::DisplayRole || role == Qt::EditRole)
if( col == 0 )
return value.label;
if( col == 1)
{
if( col == 0 )
return entry.label;
else if( col == 1 )
return entry.visibleValue;
if( role == Qt::DisplayRole )
return QString("%1 %2").arg( value.visibleValue, value.valueType->unitLabel);
return value.visibleValue;
}
*/
return QVariant();
/*
Das Model Gibt hier, unabhängig von der DataRole, immer das
* gesamte BCValue Object zurück. Die Umsetzung von Status- und Typeinfromationen in GUI-Elemente
* findet nicht hier, sondern im BCDelagate statt.
// falsch! wie geben hier doch ordentlich die einzelwerte zurück
// Bonus: Rechtsbündig für Zahlen
if (role == Qt::TextAlignmentRole && (index.column() == 0 || index.column() == 2)) {
return Qt::AlignRight | Qt::AlignVCenter;
}
//return QVariant::fromValue( entry );
return QVariant();
*/
}