ui/LabelDelegate.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <QStyledItemDelegate> | ||
| 4 | |||
| 5 | // LabelDelegate renders the Subject column with colored label chips. | ||
| 6 | // Labels (IMAP keywords) are drawn as small colored badges after the subject | ||
| 7 | // text. Mails without labels render normally. | ||
| 8 | class LabelDelegate : public QStyledItemDelegate { | ||
| 9 | 577 | Q_OBJECT | |
| 10 | |||
| 11 | public: | ||
| 12 | explicit LabelDelegate(QObject *parent = nullptr); | ||
| 13 | |||
| 14 | void paint(QPainter *painter, const QStyleOptionViewItem &option, | ||
| 15 | const QModelIndex &index) const override; | ||
| 16 | |||
| 17 | QSize sizeHint(const QStyleOptionViewItem &option, | ||
| 18 | const QModelIndex &index) const override; | ||
| 19 | |||
| 20 | // Label color and display name (also used by MailView) | ||
| 21 | static QColor colorForLabel(const QString &label); | ||
| 22 | static QString displayName(const QString &label); | ||
| 23 | }; | ||
| 24 |