/* Роли модели и отрисовка ChannelList: канал/PM, последнее сообщение, unread и кнопки действий. */ #pragma once #include 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 */ ChannelDmOnlineRole = Qt::UserRole + 11, /* bool: живой BGP-путь PM */ 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); };