Fix a case that sender avatar is not displayed.
This commit is contained in:
parent
588c23ebdc
commit
29597faae9
|
@ -262,17 +262,15 @@ ColumnLayout {
|
||||||
Layout.rightMargin: sentByMe ? 12 : undefined
|
Layout.rightMargin: sentByMe ? 12 : undefined
|
||||||
Layout.bottomMargin: 4
|
Layout.bottomMargin: 4
|
||||||
|
|
||||||
visible: showTimestamp || (showAuthor && !sentByMe)
|
visible: showAuthor
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
visible: showTimestamp
|
|
||||||
|
|
||||||
text: Qt.formatDateTime(time, "hh:mm")
|
text: Qt.formatDateTime(time, "hh:mm")
|
||||||
color: MPalette.lighter
|
color: MPalette.lighter
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
visible: showAuthor && !sentByMe
|
visible: !sentByMe
|
||||||
|
|
||||||
text: author.displayName
|
text: author.displayName
|
||||||
color: MPalette.lighter
|
color: MPalette.lighter
|
||||||
|
|
|
@ -192,6 +192,15 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DelegateChoice {
|
||||||
|
roleValue: "sticker"
|
||||||
|
delegate: ImageDelegate {
|
||||||
|
anchors.right: sentByMe ? parent.right : undefined
|
||||||
|
|
||||||
|
Layout.maximumWidth: parent.width
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: "file"
|
roleValue: "file"
|
||||||
delegate: FileDelegate {
|
delegate: FileDelegate {
|
||||||
|
|
|
@ -34,7 +34,6 @@ QHash<int, QByteArray> MessageEventModel::roleNames() const {
|
||||||
roles[ReplyAuthorRole] = "replyAuthor";
|
roles[ReplyAuthorRole] = "replyAuthor";
|
||||||
roles[ReplyDisplayRole] = "replyDisplay";
|
roles[ReplyDisplayRole] = "replyDisplay";
|
||||||
roles[UserMarkerRole] = "userMarker";
|
roles[UserMarkerRole] = "userMarker";
|
||||||
roles[ShowTimestampRole] = "showTimestamp";
|
|
||||||
roles[ShowAuthorRole] = "showAuthor";
|
roles[ShowAuthorRole] = "showAuthor";
|
||||||
roles[BubbleShapeRole] = "bubbleShape";
|
roles[BubbleShapeRole] = "bubbleShape";
|
||||||
return roles;
|
return roles;
|
||||||
|
@ -83,9 +82,8 @@ void MessageEventModel::setRoom(SpectralRoom* room) {
|
||||||
if (biggest < m_currentRoom->maxTimelineIndex()) {
|
if (biggest < m_currentRoom->maxTimelineIndex()) {
|
||||||
auto rowBelowInserted = m_currentRoom->maxTimelineIndex() -
|
auto rowBelowInserted = m_currentRoom->maxTimelineIndex() -
|
||||||
biggest + timelineBaseIndex() - 1;
|
biggest + timelineBaseIndex() - 1;
|
||||||
refreshEventRoles(
|
refreshEventRoles(rowBelowInserted,
|
||||||
rowBelowInserted,
|
{ShowAuthorRole, BubbleShapeRole});
|
||||||
{ShowTimestampRole, ShowAuthorRole, BubbleShapeRole});
|
|
||||||
}
|
}
|
||||||
for (auto i = m_currentRoom->maxTimelineIndex() - biggest;
|
for (auto i = m_currentRoom->maxTimelineIndex() - biggest;
|
||||||
i <= m_currentRoom->maxTimelineIndex() - lowest; ++i)
|
i <= m_currentRoom->maxTimelineIndex() - lowest; ++i)
|
||||||
|
@ -116,7 +114,7 @@ void MessageEventModel::setRoom(SpectralRoom* room) {
|
||||||
refreshEventRoles(timelineBaseIndex() + 1, {ReadMarkerRole});
|
refreshEventRoles(timelineBaseIndex() + 1, {ReadMarkerRole});
|
||||||
if (timelineBaseIndex() > 0) // Refresh below, see #312
|
if (timelineBaseIndex() > 0) // Refresh below, see #312
|
||||||
refreshEventRoles(timelineBaseIndex() - 1,
|
refreshEventRoles(timelineBaseIndex() - 1,
|
||||||
{ShowTimestampRole, ShowAuthorRole, BubbleShapeRole});
|
{ShowAuthorRole, BubbleShapeRole});
|
||||||
});
|
});
|
||||||
connect(m_currentRoom, &Room::pendingEventChanged, this,
|
connect(m_currentRoom, &Room::pendingEventChanged, this,
|
||||||
&MessageEventModel::refreshRow);
|
&MessageEventModel::refreshRow);
|
||||||
|
@ -290,9 +288,10 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
|
||||||
return "image";
|
return "image";
|
||||||
case MessageEventType::Audio:
|
case MessageEventType::Audio:
|
||||||
return "audio";
|
return "audio";
|
||||||
default:
|
|
||||||
return e->hasFileContent() ? "file" : "message";
|
|
||||||
}
|
}
|
||||||
|
if (e->hasFileContent()) return "file";
|
||||||
|
|
||||||
|
return "message";
|
||||||
}
|
}
|
||||||
if (evt.isStateEvent())
|
if (evt.isStateEvent())
|
||||||
return "state";
|
return "state";
|
||||||
|
@ -415,25 +414,15 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role == ShowTimestampRole) {
|
|
||||||
for (auto r = row - 1; r >= 0; --r) {
|
|
||||||
auto i = index(r);
|
|
||||||
if (data(i, SpecialMarksRole) != EventStatus::Hidden) {
|
|
||||||
return data(idx, TimeRole)
|
|
||||||
.toDateTime()
|
|
||||||
.msecsTo(data(i, TimeRole).toDateTime()) > 600000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (role == ShowAuthorRole) {
|
if (role == ShowAuthorRole) {
|
||||||
for (auto r = row - 1; r >= 0; --r) {
|
for (auto r = row - 1; r >= 0; --r) {
|
||||||
auto i = index(r);
|
auto i = index(r);
|
||||||
if (data(i, SpecialMarksRole) != EventStatus::Hidden) {
|
if (data(i, SpecialMarksRole) != EventStatus::Hidden) {
|
||||||
return data(i, AuthorRole) != data(idx, AuthorRole) ||
|
return data(i, AuthorRole) != data(idx, AuthorRole) ||
|
||||||
data(i, EventTypeRole) != data(idx, EventTypeRole);
|
data(i, EventTypeRole) != data(idx, EventTypeRole) ||
|
||||||
|
data(idx, TimeRole)
|
||||||
|
.toDateTime()
|
||||||
|
.msecsTo(data(i, TimeRole).toDateTime()) > 600000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,11 +444,9 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
|
||||||
if (aboveRow == -1) {
|
if (aboveRow == -1) {
|
||||||
aboveShow = true;
|
aboveShow = true;
|
||||||
} else {
|
} else {
|
||||||
aboveShow = data(index(aboveRow), ShowAuthorRole).toBool() ||
|
aboveShow = data(index(aboveRow), ShowAuthorRole).toBool();
|
||||||
data(index(aboveRow), ShowTimestampRole).toBool();
|
|
||||||
}
|
}
|
||||||
belowShow = data(idx, ShowAuthorRole).toBool() ||
|
belowShow = data(idx, ShowAuthorRole).toBool();
|
||||||
data(idx, ShowTimestampRole).toBool();
|
|
||||||
|
|
||||||
if (aboveShow && belowShow)
|
if (aboveShow && belowShow)
|
||||||
return BubbleShapes::NoShape;
|
return BubbleShapes::NoShape;
|
||||||
|
|
|
@ -31,7 +31,6 @@ class MessageEventModel : public QAbstractListModel {
|
||||||
ReplyAuthorRole,
|
ReplyAuthorRole,
|
||||||
ReplyDisplayRole,
|
ReplyDisplayRole,
|
||||||
|
|
||||||
ShowTimestampRole,
|
|
||||||
ShowAuthorRole,
|
ShowAuthorRole,
|
||||||
BubbleShapeRole,
|
BubbleShapeRole,
|
||||||
// For debugging
|
// For debugging
|
||||||
|
|
Loading…
Reference in New Issue