Files
BionxControl/bcitemdelegate.h

110 lines
2.8 KiB
C
Raw Normal View History

2025-12-26 14:07:55 +01:00
/***************************************************************************
BionxControl
Copyright © 2025 christoph holzheuer
christoph.holzheuer@gmail.com
Using:
mhs_can_drv.c
© 2011 - 2023 by MHS-Elektronik GmbH & Co. KG, Germany
Klaus Demlehner, klaus@mhs-elektronik.de
@see www.mhs-elektronik.de
Based on Bionx data type descriptions from:
BigXionFlasher USB V 0.2.4 rev. 97
© 2011-2013 by Thomas Koenig <info@bigxionflasher.org>
@see www.bigxionflasher.org
Bionx Bike Info
© 2018 Thorsten Schmidt (tschmidt@ts-soft.de)
@see www.ts-soft.de
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
@see https://github.com/bikemike/bionx-bikeinfo
***************************************************************************/
2025-12-24 14:44:54 +01:00
2025-12-29 20:10:05 +01:00
#ifndef BCITEMDELEGATE_H
#define BCITEMDELEGATE_H
2025-12-17 16:26:22 +01:00
#include <QStyledItemDelegate>
2025-12-19 21:20:14 +01:00
class QPropertyAnimation;
class QVariantAnimation;
2025-12-24 14:44:54 +01:00
class QTableView;
2025-12-29 15:44:06 +01:00
class BCValueList;
2025-12-19 17:37:24 +01:00
2025-12-29 20:10:05 +01:00
class BCItemDelegate : public QStyledItemDelegate
2025-12-17 16:26:22 +01:00
{
Q_OBJECT
public:
2025-12-18 18:39:52 +01:00
2025-12-29 20:10:05 +01:00
explicit BCItemDelegate(const BCValueList& valueList, QTableView* view );
2025-12-17 16:26:22 +01:00
2025-12-29 20:10:05 +01:00
// QString displayText(const QVariant& dataValue, const QLocale& locale) const override;
2025-12-17 16:26:22 +01:00
// Zuständig für den Edit-Modus (Doppelklick)
2025-12-23 11:09:26 +01:00
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const override;
void setEditorData(QWidget *editor, const QModelIndex& index) const override;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex& index) const override;
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex& index) const override;
2025-12-18 18:39:52 +01:00
2025-12-23 11:09:26 +01:00
QSize sizeHint(const QStyleOptionViewItem &option,const QModelIndex& index) const override;
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex& index) const override;
2025-12-19 17:37:24 +01:00
2025-12-29 20:10:05 +01:00
/*
2025-12-19 21:20:14 +01:00
qreal highlightOpacity() const
{
return _opacity;
}
void setHighlightOpacity(qreal opacity)
{
_opacity = opacity;
//qDebug() << " --- opa: " << opacity;
2025-12-29 00:04:15 +01:00
// __fix! unsinn!
2025-12-19 21:20:14 +01:00
emit viewUpdateNeeded();
}
2025-12-29 20:10:05 +01:00
*/
2025-12-19 21:20:14 +01:00
void clearAllHighlights();
2025-12-19 17:37:24 +01:00
public slots:
void onHighlightRow(int row);
2025-12-18 18:39:52 +01:00
2025-12-19 21:20:14 +01:00
signals:
2025-12-29 20:10:05 +01:00
//void viewUpdateNeeded();
2025-12-19 21:20:14 +01:00
2025-12-18 18:39:52 +01:00
private:
2025-12-19 17:37:24 +01:00
2025-12-19 21:20:14 +01:00
void updateRow(int row);
2025-12-21 23:20:22 +01:00
void paintHighlightRow(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
2025-12-19 17:37:24 +01:00
2025-12-29 15:44:06 +01:00
const BCValueList& _valueList;
QTableView* _view{};
2025-12-29 20:10:05 +01:00
//int _highlightedRow{-1};
//qreal _opacity{1.0};
2025-12-29 15:44:06 +01:00
2025-12-29 13:05:35 +01:00
QPropertyAnimation* _animation{};
2025-12-19 21:20:14 +01:00
private:
2025-12-29 13:05:35 +01:00
QHash<int, qreal> m_rowOpacities;
2025-12-19 21:20:14 +01:00
QHash<int, QVariantAnimation*> m_rowAnimations;
2025-12-21 23:20:22 +01:00
2025-12-17 16:26:22 +01:00
};
2025-12-29 20:10:05 +01:00
#endif // BCITEMDELEGATE_H