Fix #117.
This commit is contained in:
parent
3ec1cf71bf
commit
1248b6f334
|
@ -54,13 +54,19 @@ ColumnLayout {
|
||||||
source: author.paintable
|
source: author.paintable
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Label {
|
||||||
Layout.preferredWidth: 32
|
Layout.preferredWidth: 32
|
||||||
Layout.preferredHeight: 32
|
Layout.preferredHeight: 32
|
||||||
Layout.alignment: Qt.AlignTop
|
Layout.alignment: Qt.AlignTop
|
||||||
|
|
||||||
color: "transparent"
|
|
||||||
visible: !(sentByMe || avatarVisible)
|
visible: !(sentByMe || avatarVisible)
|
||||||
|
|
||||||
|
text: Qt.formatDateTime(time, "hh:mm")
|
||||||
|
color: "#5B7480"
|
||||||
|
|
||||||
|
font.pixelSize: 10
|
||||||
|
horizontalAlignment: Label.AlignHCenter
|
||||||
|
verticalAlignment: Label.AlignVCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
Control {
|
Control {
|
||||||
|
@ -78,6 +84,8 @@ ColumnLayout {
|
||||||
AutoMouseArea {
|
AutoMouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
|
id: messageMouseArea
|
||||||
|
|
||||||
onSecondaryClicked: {
|
onSecondaryClicked: {
|
||||||
messageContextMenu.root = root
|
messageContextMenu.root = root
|
||||||
messageContextMenu.model = model
|
messageContextMenu.model = model
|
||||||
|
@ -224,15 +232,4 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Label {
|
|
||||||
// Layout.leftMargin: sentByMe ? 12 : 48
|
|
||||||
|
|
||||||
// text: Qt.formatDateTime(time, "dd/MM/yyyy '-' hh:mm")
|
|
||||||
|
|
||||||
// visible: index === messageListView.currentIndex
|
|
||||||
|
|
||||||
// font.pixelSize: 13
|
|
||||||
// verticalAlignment: Text.AlignVCenter
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ Item {
|
||||||
sourceModel: messageEventModel
|
sourceModel: messageEventModel
|
||||||
|
|
||||||
filters: ExpressionFilter {
|
filters: ExpressionFilter {
|
||||||
expression: marks !== 0x08 && marks !== 0x10 && eventType !== "other"
|
expression: marks !== 0x10 && eventType !== "other"
|
||||||
}
|
}
|
||||||
|
|
||||||
onModelReset: {
|
onModelReset: {
|
||||||
|
|
|
@ -89,6 +89,9 @@ void MessageEventModel::setRoom(SpectralRoom *room) {
|
||||||
{AboveEventTypeRole, AboveAuthorRole,
|
{AboveEventTypeRole, AboveAuthorRole,
|
||||||
AboveSectionRole, AboveTimeRole});
|
AboveSectionRole, AboveTimeRole});
|
||||||
}
|
}
|
||||||
|
for (auto i = m_currentRoom->maxTimelineIndex() - biggest;
|
||||||
|
i <= m_currentRoom->maxTimelineIndex() - lowest; ++i)
|
||||||
|
refreshLastUserEvents(i);
|
||||||
});
|
});
|
||||||
connect(m_currentRoom, &Room::pendingEventAboutToAdd, this,
|
connect(m_currentRoom, &Room::pendingEventAboutToAdd, this,
|
||||||
[this] { beginInsertRows({}, 0, 0); });
|
[this] { beginInsertRows({}, 0, 0); });
|
||||||
|
@ -109,8 +112,9 @@ void MessageEventModel::setRoom(SpectralRoom *room) {
|
||||||
movingEvent = false;
|
movingEvent = false;
|
||||||
}
|
}
|
||||||
refreshRow(timelineBaseIndex()); // Refresh the looks
|
refreshRow(timelineBaseIndex()); // Refresh the looks
|
||||||
|
refreshLastUserEvents(0);
|
||||||
if (m_currentRoom->timelineSize() > 1) // Refresh above
|
if (m_currentRoom->timelineSize() > 1) // Refresh above
|
||||||
refreshEventRoles(timelineBaseIndex() + 1);
|
refreshEventRoles(timelineBaseIndex() + 1, {ReadMarkerRole});
|
||||||
if (timelineBaseIndex() > 0) // Refresh below, see #312
|
if (timelineBaseIndex() > 0) // Refresh below, see #312
|
||||||
refreshEventRoles(timelineBaseIndex() - 1,
|
refreshEventRoles(timelineBaseIndex() - 1,
|
||||||
{AboveEventTypeRole, AboveAuthorRole,
|
{AboveEventTypeRole, AboveAuthorRole,
|
||||||
|
@ -128,9 +132,11 @@ void MessageEventModel::setRoom(SpectralRoom *room) {
|
||||||
{ReadMarkerRole});
|
{ReadMarkerRole});
|
||||||
refreshEventRoles(lastReadEventId, {ReadMarkerRole});
|
refreshEventRoles(lastReadEventId, {ReadMarkerRole});
|
||||||
});
|
});
|
||||||
connect(
|
connect(m_currentRoom, &Room::replacedEvent, this,
|
||||||
m_currentRoom, &Room::replacedEvent, this,
|
[this](const RoomEvent *newEvent) {
|
||||||
[this](const RoomEvent *newEvent) { refreshEvent(newEvent->id()); });
|
refreshLastUserEvents(refreshEvent(newEvent->id()) -
|
||||||
|
timelineBaseIndex());
|
||||||
|
});
|
||||||
connect(m_currentRoom, &Room::fileTransferProgress, this,
|
connect(m_currentRoom, &Room::fileTransferProgress, this,
|
||||||
&MessageEventModel::refreshEvent);
|
&MessageEventModel::refreshEvent);
|
||||||
connect(m_currentRoom, &Room::fileTransferCompleted, this,
|
connect(m_currentRoom, &Room::fileTransferCompleted, this,
|
||||||
|
@ -140,7 +146,7 @@ void MessageEventModel::setRoom(SpectralRoom *room) {
|
||||||
connect(m_currentRoom, &Room::fileTransferCancelled, this,
|
connect(m_currentRoom, &Room::fileTransferCancelled, this,
|
||||||
&MessageEventModel::refreshEvent);
|
&MessageEventModel::refreshEvent);
|
||||||
connect(m_currentRoom, &Room::readMarkerForUserMoved, this,
|
connect(m_currentRoom, &Room::readMarkerForUserMoved, this,
|
||||||
[=](User *user, QString fromEventId, QString toEventId) {
|
[=](User *, QString fromEventId, QString toEventId) {
|
||||||
refreshEventRoles(fromEventId, {UserMarkerRole});
|
refreshEventRoles(fromEventId, {UserMarkerRole});
|
||||||
refreshEventRoles(toEventId, {UserMarkerRole});
|
refreshEventRoles(toEventId, {UserMarkerRole});
|
||||||
});
|
});
|
||||||
|
@ -214,6 +220,23 @@ QString MessageEventModel::renderDate(QDateTime timestamp) const {
|
||||||
return date.toString(Qt::DefaultLocaleShortDate);
|
return date.toString(Qt::DefaultLocaleShortDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessageEventModel::refreshLastUserEvents(int baseTimelineRow) {
|
||||||
|
if (!m_currentRoom || m_currentRoom->timelineSize() <= baseTimelineRow)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const auto &timelineBottom = m_currentRoom->messageEvents().rbegin();
|
||||||
|
const auto &lastSender = (*(timelineBottom + baseTimelineRow))->senderId();
|
||||||
|
const auto limit = timelineBottom + std::min(baseTimelineRow + 10,
|
||||||
|
m_currentRoom->timelineSize());
|
||||||
|
for (auto it = timelineBottom + std::max(baseTimelineRow - 10, 0);
|
||||||
|
it != limit; ++it) {
|
||||||
|
if ((*it)->senderId() == lastSender) {
|
||||||
|
auto idx = index(it - timelineBottom);
|
||||||
|
emit dataChanged(idx, idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int MessageEventModel::rowCount(const QModelIndex &parent) const {
|
int MessageEventModel::rowCount(const QModelIndex &parent) const {
|
||||||
if (!m_currentRoom || parent.isValid()) return 0;
|
if (!m_currentRoom || parent.isValid()) return 0;
|
||||||
return m_currentRoom->timelineSize();
|
return m_currentRoom->timelineSize();
|
||||||
|
@ -306,13 +329,14 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const {
|
||||||
|
|
||||||
if (role == HighlightRole) return m_currentRoom->isEventHighlighted(&evt);
|
if (role == HighlightRole) return m_currentRoom->isEventHighlighted(&evt);
|
||||||
|
|
||||||
if (role == ReadMarkerRole) return evt.id() == lastReadEventId && row > timelineBaseIndex();
|
if (role == ReadMarkerRole)
|
||||||
|
return evt.id() == lastReadEventId && row > timelineBaseIndex();
|
||||||
|
|
||||||
if (role == SpecialMarksRole) {
|
if (role == SpecialMarksRole) {
|
||||||
if (isPending) return pendingIt->deliveryStatus();
|
if (isPending) return pendingIt->deliveryStatus();
|
||||||
|
|
||||||
if (is<RedactionEvent>(evt)) return EventStatus::Hidden;
|
if (is<RedactionEvent>(evt)) return EventStatus::Hidden;
|
||||||
if (evt.isRedacted()) return EventStatus::Redacted;
|
if (evt.isRedacted()) return EventStatus::Hidden;
|
||||||
|
|
||||||
if (evt.isStateEvent() &&
|
if (evt.isStateEvent() &&
|
||||||
static_cast<const StateEventBase &>(evt).repeatsState())
|
static_cast<const StateEventBase &>(evt).repeatsState())
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef MESSAGEEVENTMODEL_H
|
#ifndef MESSAGEEVENTMODEL_H
|
||||||
#define MESSAGEEVENTMODEL_H
|
#define MESSAGEEVENTMODEL_H
|
||||||
|
|
||||||
#include "spectralroom.h"
|
|
||||||
#include "room.h"
|
#include "room.h"
|
||||||
|
#include "spectralroom.h"
|
||||||
|
|
||||||
#include <QtCore/QAbstractListModel>
|
#include <QtCore/QAbstractListModel>
|
||||||
|
|
||||||
|
@ -62,6 +62,7 @@ class MessageEventModel : public QAbstractListModel {
|
||||||
const QMatrixClient::Room::rev_iter_t& baseIt) const;
|
const QMatrixClient::Room::rev_iter_t& baseIt) const;
|
||||||
QString renderDate(QDateTime timestamp) const;
|
QString renderDate(QDateTime timestamp) const;
|
||||||
|
|
||||||
|
void refreshLastUserEvents(int baseRow);
|
||||||
void refreshEventRoles(int row, const QVector<int>& roles = {});
|
void refreshEventRoles(int row, const QVector<int>& roles = {});
|
||||||
int refreshEventRoles(const QString& eventId, const QVector<int>& roles = {});
|
int refreshEventRoles(const QString& eventId, const QVector<int>& roles = {});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue