Fix a bug that avatar does not show after a state event.
This commit is contained in:
parent
e6beb5f6a8
commit
63c7601942
|
@ -7,7 +7,7 @@ import Matrique.Settings 0.1
|
||||||
import "qrc:/js/util.js" as Util
|
import "qrc:/js/util.js" as Util
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
readonly property bool avatarVisible: !(sentByMe || (aboveAuthor === author && section === aboveSection))
|
readonly property bool avatarVisible: !sentByMe && (aboveAuthor !== author || aboveSection !== section || aboveEventType === "state" || aboveEventType === "emote")
|
||||||
readonly property bool highlighted: !(sentByMe || eventType === "notice" )
|
readonly property bool highlighted: !(sentByMe || eventType === "notice" )
|
||||||
readonly property bool sentByMe: author === currentRoom.localUser
|
readonly property bool sentByMe: author === currentRoom.localUser
|
||||||
readonly property bool isText: eventType === "notice" || eventType === "message"
|
readonly property bool isText: eventType === "notice" || eventType === "message"
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
QHash<int, QByteArray> MessageEventModel::roleNames() const {
|
QHash<int, QByteArray> MessageEventModel::roleNames() const {
|
||||||
QHash<int, QByteArray> roles = QAbstractItemModel::roleNames();
|
QHash<int, QByteArray> roles = QAbstractItemModel::roleNames();
|
||||||
roles[EventTypeRole] = "eventType";
|
roles[EventTypeRole] = "eventType";
|
||||||
|
roles[AboveEventTypeRole] = "aboveEventType";
|
||||||
roles[EventIdRole] = "eventId";
|
roles[EventIdRole] = "eventId";
|
||||||
roles[TimeRole] = "time";
|
roles[TimeRole] = "time";
|
||||||
roles[AboveTimeRole] = "aboveTime";
|
roles[AboveTimeRole] = "aboveTime";
|
||||||
|
@ -77,7 +78,8 @@ void MessageEventModel::setRoom(MatriqueRoom* room) {
|
||||||
auto rowBelowInserted = m_currentRoom->maxTimelineIndex() -
|
auto rowBelowInserted = m_currentRoom->maxTimelineIndex() -
|
||||||
biggest + timelineBaseIndex() - 1;
|
biggest + timelineBaseIndex() - 1;
|
||||||
refreshEventRoles(rowBelowInserted,
|
refreshEventRoles(rowBelowInserted,
|
||||||
{AboveAuthorRole, AboveSectionRole});
|
{AboveEventTypeRole, AboveAuthorRole,
|
||||||
|
AboveSectionRole, AboveTimeRole});
|
||||||
}
|
}
|
||||||
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)
|
||||||
|
@ -107,7 +109,8 @@ void MessageEventModel::setRoom(MatriqueRoom* 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,
|
||||||
{AboveAuthorRole, AboveSectionRole});
|
{AboveEventTypeRole, AboveAuthorRole,
|
||||||
|
AboveSectionRole, AboveTimeRole});
|
||||||
});
|
});
|
||||||
connect(m_currentRoom, &Room::pendingEventChanged, this,
|
connect(m_currentRoom, &Room::pendingEventChanged, this,
|
||||||
&MessageEventModel::refreshRow);
|
&MessageEventModel::refreshRow);
|
||||||
|
@ -621,14 +624,20 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
|
||||||
return role == TimeRole ? QVariant(ts) : renderDate(ts);
|
return role == TimeRole ? QVariant(ts) : renderDate(ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role == AboveSectionRole || role == AboveAuthorRole ||
|
if (role == AboveEventTypeRole || role == AboveSectionRole ||
|
||||||
role == AboveTimeRole)
|
role == AboveAuthorRole || role == AboveTimeRole)
|
||||||
for (auto r = row + 1; r < rowCount(); ++r) {
|
for (auto r = row + 1; r < rowCount(); ++r) {
|
||||||
auto i = index(r);
|
auto i = index(r);
|
||||||
if (data(i, SpecialMarksRole) != EventStatus::Hidden)
|
if (data(i, SpecialMarksRole) != EventStatus::Hidden) switch (role) {
|
||||||
return data(i, role == AboveSectionRole
|
case AboveEventTypeRole:
|
||||||
? SectionRole
|
return data(i, EventTypeRole);
|
||||||
: role == AboveAuthorRole ? AuthorRole : TimeRole);
|
case AboveSectionRole:
|
||||||
|
return data(i, SectionRole);
|
||||||
|
case AboveAuthorRole:
|
||||||
|
return data(i, AuthorRole);
|
||||||
|
case AboveTimeRole:
|
||||||
|
return data(i, TimeRole);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
#ifndef MESSAGEEVENTMODEL_H
|
#ifndef MESSAGEEVENTMODEL_H
|
||||||
#define MESSAGEEVENTMODEL_H
|
#define MESSAGEEVENTMODEL_H
|
||||||
|
|
||||||
#include "room.h"
|
|
||||||
#include "matriqueroom.h"
|
#include "matriqueroom.h"
|
||||||
|
#include "room.h"
|
||||||
|
|
||||||
#include <QtCore/QAbstractListModel>
|
#include <QtCore/QAbstractListModel>
|
||||||
|
|
||||||
class MessageEventModel : public QAbstractListModel {
|
class MessageEventModel : public QAbstractListModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(
|
Q_PROPERTY(MatriqueRoom* room READ getRoom WRITE setRoom NOTIFY roomChanged)
|
||||||
MatriqueRoom* room READ getRoom WRITE setRoom NOTIFY roomChanged)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum EventRoles {
|
enum EventRoles {
|
||||||
EventTypeRole = Qt::UserRole + 1,
|
EventTypeRole = Qt::UserRole + 1,
|
||||||
|
AboveEventTypeRole,
|
||||||
EventIdRole,
|
EventIdRole,
|
||||||
TimeRole,
|
TimeRole,
|
||||||
AboveTimeRole,
|
AboveTimeRole,
|
||||||
|
|
Loading…
Reference in New Issue