Hightlight lines when touched.

This commit is contained in:
2025-12-19 17:37:24 +01:00
parent 3e5f616461
commit 552fcdf8f8
11 changed files with 140 additions and 40 deletions

View File

@@ -2,18 +2,18 @@
#ifndef BCITEMDELEGATE_H
#define BCITEMDELEGATE_H
#include <QStyledItemDelegate>
class QListView;
class BCItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
explicit BCItemDelegate(QObject *parent = nullptr);
explicit BCItemDelegate(QListView *view );
// WICHTIG: Zuständig für die normale Anzeige (ohne Editor)
QString displayText(const QVariant& dataValue, const QLocale& locale) const override;
// Zuständig für den Edit-Modus (Doppelklick)
@@ -23,9 +23,19 @@ public:
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
QSize sizeHint(const QStyleOptionViewItem &option,const QModelIndex &index) const override;
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
public slots:
void onHighlightRow(int row);
private:
QString formatDisplayString(const QModelIndex &index) const;
int _highlightedRow{-1};
QListView* _view{nullptr};
};