Hightlight lines when touched.
This commit is contained in:
@@ -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};
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user