cleanups.

This commit is contained in:
Christoph Holzheuer
2026-02-09 16:03:09 +01:00
parent 5a71884cfb
commit 7993247027
27 changed files with 814 additions and 2253 deletions

View File

@@ -44,8 +44,8 @@
#include <bcdeviceview.h>
#include <bcvaluedelegate.h>
#include <bcvalueeditor.h>
#include <bcvalueslider.h>
#include <bcvaluesliderstyle.h>
BCValueDelegate::BCValueDelegate(const BCValueList& valueList, BCDeviceView* view)
: QStyledItemDelegate{view}, _valueList{valueList}, _view{view}
@@ -69,18 +69,18 @@ QWidget* BCValueDelegate::createEditor(QWidget *parent, const QStyleOptionViewIt
qDebug() << " --- Create Editor: " << bcValue.label() << " value: " << params.value << " min: " << params.min << " max: " << params.max << " ratio:" << bcValue.calcMinMaxRatio()*100.0 << '%';
auto* valueEditor = new BCValueEditor(parent);
auto* valueEditor = new BCValueSlider(parent);
valueEditor->setValueAndRange( params );
// Signal für sofortige Updates
connect(valueEditor, &BCValueEditor::valueChanged, this, [this, valueEditor]()
connect(valueEditor, &BCValueSlider::valueChanged, this, [this, valueEditor]()
{
// Commit data sofort bei Änderung
emit const_cast<BCValueDelegate*>(this)->commitData(valueEditor);
});
// Signal für sofortige Updates
connect(valueEditor, &BCValueEditor::valueCommited, this, [this, valueEditor](int newValue)
connect(valueEditor, &BCValueSlider::valueCommited, this, [this, valueEditor](int newValue)
{
qDebug() << " --- value set:" << newValue;
// Commit data sofort bei Änderung
@@ -104,7 +104,7 @@ void BCValueDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, c
if( index.column() == 1)
{
// Daten vom Editor zurück ins Model speichern (Beim Schließen)
BCValueEditor* slider = qobject_cast<BCValueEditor*>(editor);
BCValueSlider* slider = qobject_cast<BCValueSlider*>(editor);
if (slider)
{
int value = slider->value();
@@ -131,13 +131,11 @@ void BCValueDelegate::paint(QPainter *painter, const QStyleOptionViewItem& optio
const BCValue& bcValue = *(_valueList[ index.row()].get());
if( !bcValue.isReadOnly() )
{
// Wir zeichnen boolean Values an toggle switches
if( bcValue.valueType() == BCValue::ValueType::Bool )
paintButtonIndicator(painter, option, bcValue);
paintToggleSwitch(painter, option, bcValue);
else
{
BCValueEditor::paintSliderIndicator(painter, option.rect, bcValue.calcMinMaxRatio() );
}
paintSlider(painter, option.rect, bcValue.calcMinMaxRatio() );
}
if(_rowOpacities.contains(row))
@@ -145,6 +143,11 @@ void BCValueDelegate::paint(QPainter *painter, const QStyleOptionViewItem& optio
}
void BCValueDelegate::paintSlider(QPainter* painter, const QRect& rect, double ratio )const
{
QRect sliderRect = BCValueSlider::updateEditorRect( rect );
BCValueSliderStyle::paintSliderIndicator2(painter, sliderRect, ratio );
}
void BCValueDelegate::paintHighlightRow(QPainter* painter, const QStyleOptionViewItem& option, int row) const
{
@@ -178,11 +181,11 @@ void BCValueDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionVi
{
Q_UNUSED(index)
QRect sliderRect = BCValueEditor::updateEditorRect( option.rect );
QRect sliderRect = BCValueSlider::updateEditorRect( option.rect );
editor->setGeometry(sliderRect); // Slider nur über Progress Bar
}
void BCValueDelegate::paintButtonIndicator(QPainter* painter, const QStyleOptionViewItem& option, const BCValue& bcValue) const
void BCValueDelegate::paintToggleSwitch(QPainter* painter, const QStyleOptionViewItem& option, const BCValue& bcValue) const
{
}
@@ -219,7 +222,9 @@ void BCValueDelegate::onHighlightRow(int row)
// Schnelles Fade-in (20%), langsames Fade-out (80%)
if (progress < 0.2) {
opacity = progress * 5.0; // 0->1 in 20%
} else {
}
else
{
opacity = 1.0 - ((progress - 0.2) / 0.8); // 1->0 in 80%
}
@@ -229,7 +234,7 @@ void BCValueDelegate::onHighlightRow(int row)
connect(anim, &QVariantAnimation::finished, this, [this, row, anim]()
{
_rowOpacities.remove(row);
_rowOpacities.remove(row);
_rowAnimations.remove(row);
updateRow(row);
anim->deleteLater();
@@ -241,7 +246,7 @@ void BCValueDelegate::onHighlightRow(int row)
/**
* @brief Sopt alle gerade laufenden Animationen
* @brief Stopt alle gerade laufenden Animationen
*/
void BCValueDelegate::clearAllHighlights()
@@ -252,12 +257,11 @@ void BCValueDelegate::clearAllHighlights()
anim->deleteLater();
}
_rowAnimations.clear();
_rowOpacities.clear();
_rowOpacities.clear();
if (_view)
{
_view->viewport()->update();
}
}
@@ -272,9 +276,8 @@ void BCValueDelegate::updateRow(int row)
{
QModelIndex idx = _view->model()->index(row,1);
QRect rect = _view->visualRect(idx);
if (!rect.isEmpty()) {
if (!rect.isEmpty())
_view->viewport()->update(rect);
}
}
}