43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
// BCItemDelegate.h
|
|
#ifndef BCITEMDELEGATE_H
|
|
#define BCITEMDELEGATE_H
|
|
|
|
#include <QStyledItemDelegate>
|
|
|
|
class QListView;
|
|
|
|
class BCItemDelegate : public QStyledItemDelegate
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit BCItemDelegate(QListView *view );
|
|
|
|
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;
|
|
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;
|
|
|
|
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};
|
|
|
|
};
|
|
|
|
|
|
#endif // BCITEMDELEGATE_H
|