/* Роли модели и отрисовка 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 */ 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; };