Indicate messages that are not sent yet
This commit is contained in:
@@ -68,6 +68,7 @@ QHash<int, QByteArray> MessageEventModel::roleNames() const
|
|||||||
roles[IsAvatarChangeRole] = "isAvatarChange";
|
roles[IsAvatarChangeRole] = "isAvatarChange";
|
||||||
roles[IsRedactedRole] = "isRedacted";
|
roles[IsRedactedRole] = "isRedacted";
|
||||||
roles[GenericDisplayRole] = "genericDisplay";
|
roles[GenericDisplayRole] = "genericDisplay";
|
||||||
|
roles[IsPendingRole] = "isPending";
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,6 +177,7 @@ void MessageEventModel::setRoom(NeoChatRoom *room)
|
|||||||
});
|
});
|
||||||
connect(m_currentRoom, &Room::pendingEventAdded, this, &MessageEventModel::endInsertRows);
|
connect(m_currentRoom, &Room::pendingEventAdded, this, &MessageEventModel::endInsertRows);
|
||||||
connect(m_currentRoom, &Room::pendingEventAboutToMerge, this, [this](RoomEvent *, int i) {
|
connect(m_currentRoom, &Room::pendingEventAboutToMerge, this, [this](RoomEvent *, int i) {
|
||||||
|
Q_EMIT dataChanged(index(i, 0), index(i, 0), {IsPendingRole});
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
return; // No need to move anything, just refresh
|
return; // No need to move anything, just refresh
|
||||||
}
|
}
|
||||||
@@ -908,6 +910,10 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
|
|||||||
return evt.isRedacted();
|
return evt.isRedacted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (role == IsPendingRole) {
|
||||||
|
return row < m_currentRoom->pendingEvents().size();
|
||||||
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ public:
|
|||||||
IsNameChangeRole,
|
IsNameChangeRole,
|
||||||
IsAvatarChangeRole,
|
IsAvatarChangeRole,
|
||||||
IsRedactedRole,
|
IsRedactedRole,
|
||||||
|
IsPendingRole,
|
||||||
LastRole, // Keep this last
|
LastRole, // Keep this last
|
||||||
};
|
};
|
||||||
Q_ENUM(EventRoles)
|
Q_ENUM(EventRoles)
|
||||||
|
|||||||
@@ -197,7 +197,15 @@ ColumnLayout {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
contentItem: ColumnLayout {
|
contentItem: RowLayout {
|
||||||
|
Kirigami.Icon {
|
||||||
|
source: "content-loading-symbolic"
|
||||||
|
width: height
|
||||||
|
Layout.preferredWidth: Kirigami.Units.iconSizes.small
|
||||||
|
Layout.preferredHeight: Kirigami.Units.iconSizes.small
|
||||||
|
visible: model.isPending && Config.showLocalMessagesOnRight
|
||||||
|
}
|
||||||
|
ColumnLayout {
|
||||||
id: column
|
id: column
|
||||||
spacing: Kirigami.Units.smallSpacing
|
spacing: Kirigami.Units.smallSpacing
|
||||||
RowLayout {
|
RowLayout {
|
||||||
@@ -266,6 +274,15 @@ ColumnLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Kirigami.Icon {
|
||||||
|
source: "content-loading-symbolic"
|
||||||
|
width: height
|
||||||
|
Layout.preferredWidth: Kirigami.Units.iconSizes.small
|
||||||
|
Layout.preferredHeight: Kirigami.Units.iconSizes.small
|
||||||
|
visible: model.isPending && !Config.showLocalMessagesOnRight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
background: Item {
|
background: Item {
|
||||||
Kirigami.ShadowedRectangle {
|
Kirigami.ShadowedRectangle {
|
||||||
|
|||||||
Reference in New Issue
Block a user