chat: deleted-аккаунты — колонка deleted, скрытие/зачёркивание, не подключаемся
This commit is contained in:
1 parent
631a176944
commit
a17a85a383
10 files changed
+91
-46
No files matched your search
@@ -56,9 +56,10 @@ QVariant MemberListModel::data(const QModelIndex& index, int role) const {
|
||||
return {};
|
||||
}
|
||||
|
||||
void MemberListModel::setChannel(const QString& channelId) {
|
||||
void MemberListModel::setChannel(const QString& channelId, bool isOwner) {
|
||||
beginResetModel();
|
||||
m_channelId = channelId;
|
||||
m_isOwner = isOwner;
|
||||
m_totalCount = 0;
|
||||
m_cache.clear();
|
||||
endResetModel();
|
||||
@@ -70,7 +71,7 @@ void MemberListModel::setChannel(const QString& channelId) {
|
||||
}
|
||||
|
||||
void MemberListModel::refresh() {
|
||||
if (!m_channelId.isEmpty()) setChannel(m_channelId);
|
||||
if (!m_channelId.isEmpty()) setChannel(m_channelId, m_isOwner);
|
||||
}
|
||||
|
||||
void MemberListModel::refreshRtt() {
|
||||
@@ -119,14 +120,17 @@ void MemberListModel::onMemberList(const QString& chId, int count, const uint8_t
|
||||
if (chId != m_channelId) return;
|
||||
|
||||
beginResetModel();
|
||||
m_totalCount = count;
|
||||
m_totalCount = 0;
|
||||
m_cache.clear();
|
||||
|
||||
int row = 0;
|
||||
for (int i = 0; i < count; i++) {
|
||||
MemberListItem item;
|
||||
deserialize_member(data + i * CHAT_MEMBER_DISPLAY_SIZE, item);
|
||||
m_cache[i] = item;
|
||||
if ((item.flags & CHAT_MEMBER_FLAG_DELETED) && !m_isOwner) continue;
|
||||
m_cache[row++] = item;
|
||||
}
|
||||
m_totalCount = row;
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
@@ -142,6 +146,17 @@ void MemberListModel::onMemberUpdated(const QString& chId, const uint8_t* data)
|
||||
if (it->nodeId == item.nodeId) { row = it.key(); break; }
|
||||
}
|
||||
|
||||
if ((item.flags & CHAT_MEMBER_FLAG_DELETED) && !m_isOwner) {
|
||||
/* deleted member — remove from non-owner's list */
|
||||
if (row >= 0) {
|
||||
beginRemoveRows(QModelIndex(), row, row);
|
||||
m_cache.remove(row);
|
||||
m_totalCount--;
|
||||
endRemoveRows();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (row >= 0) {
|
||||
m_cache[row] = item;
|
||||
emit dataChanged(index(row), index(row));
|
||||
|
||||
Reference in new issue
Block a user