You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1.2 KiB
29 lines
1.2 KiB
#pragma once |
|
|
|
#include <QStyledItemDelegate> |
|
|
|
enum ChannelDataRole { |
|
ChannelNameRole = Qt::DisplayRole, |
|
ChannelIconRole = Qt::DecorationRole, |
|
ChannelLastMessageRole = Qt::UserRole + 1, |
|
ChannelChannelIdRole = Qt::UserRole + 2, |
|
ChannelPeersOnlineRole = Qt::UserRole + 3, /* int: count of online peers */ |
|
ChannelAutoConnectActiveRole = Qt::UserRole + 4, /* bool: 1 if auto-connect in progress */ |
|
ChannelInviteBtnHoveredRole = Qt::UserRole + 5, /* bool: 1 when mouse hovers invite button */ |
|
ChannelUnreadCountRole = Qt::UserRole + 6, /* int: unread message count, 0 if none */ |
|
ChannelLastMsgAtRole = Qt::UserRole + 7 /* qint64: last message timestamp for sorting */ |
|
}; |
|
|
|
class ChannelDelegate : public QStyledItemDelegate { |
|
Q_OBJECT |
|
public: |
|
explicit ChannelDelegate(QObject *parent = nullptr); |
|
|
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, |
|
const QModelIndex &index) const override; |
|
QSize sizeHint(const QStyleOptionViewItem &option, |
|
const QModelIndex &index) const override; |
|
|
|
static constexpr int InviteBtnSize = 18; |
|
static QRect inviteButtonRect(const QRect &itemRect); |
|
};
|
|
|