Files
utun2/tools/chatgui/src/memberlistmodel.h
T
evgeny a97e8bcc1f docs: update file inventory and module header contracts
Refresh both AGENTS guides and clarify module purpose, usage, ownership, threading, return values and wire formats in headers. Remove the unused timeout_heap freed_count field and unimplemented getter.
2026-10-04 13:10:01 +02:00

58 lines
1.7 KiB
C++

/* Qt-модель участников канала: ленивый кэш строк, обновления CHAT_EVT_MEMBER_* и RTT.
* События bridge применяются в GUI-потоке; данные строки доступны через Qt roles. */
#ifndef MEMBERLISTMODEL_H
#define MEMBERLISTMODEL_H
#include <QAbstractListModel>
#include <QColor>
#include <QMap>
#include <QString>
#include <QIcon>
#include <QPixmap>
#include <QTimer>
#include <stdint.h>
struct MemberListItem {
quint64 nodeId = 0;
bool online = false;
bool isSelf = false;
QPixmap avatar;
QString name;
int rtt = -1;
int natType = -1;
uint8_t flags = 0;
uint8_t storage = 0;
};
class MemberListModel : public QAbstractListModel {
Q_OBJECT
public:
explicit MemberListModel(QObject* parent = nullptr);
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
void setChannel(const QString& channelId, bool isOwner);
void refresh();
void refreshRtt();
quint64 nodeIdAt(int row) const;
bool isOnlineAt(int row) const;
/* Called from bridge callbacks (GUI thread) */
void onMemberList(const QString& chId, int count, const uint8_t* data, int dataLen);
void onMemberUpdated(const QString& chId, const uint8_t* data);
void onMemberRemoved(const QString& chId, uint64_t nodeId);
private:
void loadBatch(int from, int count);
QPixmap makeAvatar(QColor color, QChar letter) const;
QString m_channelId;
bool m_isOwner = false;
int m_totalCount = 0;
mutable QMap<int, MemberListItem> m_cache;
QTimer* m_rttTimer;
};
#endif