|
|
|
@ -229,6 +229,7 @@ void MessageList::loadChannel(const QString& channelId) { |
|
|
|
setMsg(item, author, QString::fromUtf8(m.data), time, avatar, false, |
|
|
|
setMsg(item, author, QString::fromUtf8(m.data), time, avatar, false, |
|
|
|
false, QString(), QString(), reacts); |
|
|
|
false, QString(), QString(), reacts); |
|
|
|
item->setData(m.id, MsgIdRole); |
|
|
|
item->setData(m.id, MsgIdRole); |
|
|
|
|
|
|
|
item->setData(QVariant::fromValue(m.authorNodeId), MsgAuthorNodeIdRole); |
|
|
|
item->setData(m.isOutgoing ? 1 : 0, MsgIsOutgoingRole); |
|
|
|
item->setData(m.isOutgoing ? 1 : 0, MsgIsOutgoingRole); |
|
|
|
m_model->appendRow(item); |
|
|
|
m_model->appendRow(item); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -291,6 +292,7 @@ void MessageList::refresh() { |
|
|
|
setMsg(item, author, QString::fromUtf8(m.data), time, avatar, false, |
|
|
|
setMsg(item, author, QString::fromUtf8(m.data), time, avatar, false, |
|
|
|
false, QString(), QString(), QVariantList{}); |
|
|
|
false, QString(), QString(), QVariantList{}); |
|
|
|
item->setData(m.id, MsgIdRole); |
|
|
|
item->setData(m.id, MsgIdRole); |
|
|
|
|
|
|
|
item->setData(QVariant::fromValue(m.authorNodeId), MsgAuthorNodeIdRole); |
|
|
|
item->setData(m.isOutgoing ? 1 : 0, MsgIsOutgoingRole); |
|
|
|
item->setData(m.isOutgoing ? 1 : 0, MsgIsOutgoingRole); |
|
|
|
m_model->appendRow(item); |
|
|
|
m_model->appendRow(item); |
|
|
|
while (m_model->rowCount() > 100) |
|
|
|
while (m_model->rowCount() > 100) |
|
|
|
@ -323,6 +325,7 @@ void MessageList::addMessage(const QString& channelId, quint64 authorNodeId, |
|
|
|
setMsg(item, author, QString::fromUtf8(content), time, avatar, false, |
|
|
|
setMsg(item, author, QString::fromUtf8(content), time, avatar, false, |
|
|
|
false, QString(), QString(), QVariantList{}); |
|
|
|
false, QString(), QString(), QVariantList{}); |
|
|
|
bool isSelf = m_db && (authorNodeId == m_db->myNodeId()); |
|
|
|
bool isSelf = m_db && (authorNodeId == m_db->myNodeId()); |
|
|
|
|
|
|
|
item->setData(QVariant::fromValue(authorNodeId), MsgAuthorNodeIdRole); |
|
|
|
item->setData(isSelf ? 1 : 0, MsgIsOutgoingRole); |
|
|
|
item->setData(isSelf ? 1 : 0, MsgIsOutgoingRole); |
|
|
|
m_model->appendRow(item); |
|
|
|
m_model->appendRow(item); |
|
|
|
|
|
|
|
|
|
|
|
@ -366,6 +369,20 @@ QString MessageList::authorName(quint64 nodeId) const { |
|
|
|
return m_db->getDisplayName(nodeId); |
|
|
|
return m_db->getDisplayName(nodeId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MessageList::reloadLocalNicks() { |
|
|
|
|
|
|
|
if (m_currentChannelId.isEmpty() || !m_db) return; |
|
|
|
|
|
|
|
m_localNicks = m_db->getLocalNicknames(m_currentChannelId); |
|
|
|
|
|
|
|
for (int r = 0; r < m_model->rowCount(); r++) { |
|
|
|
|
|
|
|
auto* item = m_model->item(r); |
|
|
|
|
|
|
|
if (!item) continue; |
|
|
|
|
|
|
|
QVariant v = item->data(MsgAuthorNodeIdRole); |
|
|
|
|
|
|
|
if (!v.isValid()) continue; |
|
|
|
|
|
|
|
quint64 nid = v.value<quint64>(); |
|
|
|
|
|
|
|
item->setData(authorName(nid), MsgAuthorRole); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
m_view->viewport()->update(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MessageList::restoreScrollPosition(const QString& channelId) { |
|
|
|
void MessageList::restoreScrollPosition(const QString& channelId) { |
|
|
|
if (!m_db || m_model->rowCount() == 0) { |
|
|
|
if (!m_db || m_model->rowCount() == 0) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
|