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.
35 lines
1.7 KiB
35 lines
1.7 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 */ |
|
ChannelInviteByLinkBtnHoveredRole = Qt::UserRole + 8, /* bool: hover for invite-by-link button */ |
|
ChannelSettingsBtnHoveredRole = Qt::UserRole + 9, /* bool: hover for per-channel settings gear */ |
|
ChannelUnreadCountRole = Qt::UserRole + 6, /* int: unread message count, 0 if none */ |
|
ChannelLastMsgAtRole = Qt::UserRole + 7, /* qint64: last message timestamp for sorting */ |
|
ChannelIsSectionRole = Qt::UserRole + 10 /* bool: 1 = заголовок секции (не выбирается) */ |
|
}; |
|
|
|
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 constexpr int InviteBtnGap = 2; |
|
static QRect inviteButtonRect(const QRect &itemRect); |
|
static QRect inviteByLinkButtonRect(const QRect &itemRect); |
|
static QRect settingsButtonRect(const QRect &itemRect); |
|
};
|
|
|