add translations and actually add changes to TimelineModel

This commit is contained in:
Malte E 2022-02-07 21:53:37 +01:00
parent 384c9c91e3
commit 12d600db97
4 changed files with 21 additions and 9 deletions

View file

@ -252,7 +252,7 @@ ScrollView {
topPadding: 4
bottomPadding: 4
spacing: 8
visible: (previousMessageUserId !== userId || previousMessageDay !== day || previousMessageIsStateEvent) && !isStateEvent
visible: (previousMessageUserId !== userId || previousMessageDay !== day || isStateEvent !== previousMessageIsStateEvent)
width: parentWidth
height: ((previousMessageDay !== day) ? dateBubble.height : 0) + (isStateEvent? 0 : userName.height +8 )
@ -278,6 +278,7 @@ ScrollView {
Row {
height: userName_.height
spacing: 8
visible: !isStateEvent
Avatar {
id: messageUserAvatar
@ -289,7 +290,7 @@ ScrollView {
userid: userId
onClicked: room.openUserProfile(userId)
ToolTip.visible: avatarHover.hovered
ToolTip.delay: Nheko.tooltipDelay
ToolTip.delay: Nheko.tooltipDelay
ToolTip.text: userid
HoverHandler {

View file

@ -186,7 +186,7 @@ Item {
roleValue: MtxEvent.Redaction
Pill {
text: qsTr("removed")
text: qsTr("%1 removed a message").arg(d.userName)
isStateEvent: d.isStateEvent
}
@ -196,7 +196,7 @@ Item {
roleValue: MtxEvent.Encryption
Pill {
text: qsTr("Encryption enabled")
text: qsTr("%1 enabled encryption").arg(d.userName)
isStateEvent: d.isStateEvent
}
@ -220,7 +220,7 @@ Item {
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
formatted: d.roomName ? qsTr("room name changed to: %1").arg(d.roomName) : qsTr("removed room name")
formatted: d.roomName ? qsTr("%2 changed the room name to: %1").arg(d.roomName).arg(d.userName) : qsTr("%1 removed the room name").arg(d.userName)
}
}
@ -233,7 +233,7 @@ Item {
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
formatted: d.roomTopic ? qsTr("topic changed to: %1").arg(d.roomTopic) : qsTr("removed topic")
formatted: d.roomTopic ? qsTr("%2 changed the topic to: %1").arg(d.roomTopic).arg(d.userName): qsTr("%1 removed the topic").arg(d.userName)
}
}
@ -372,7 +372,7 @@ Item {
isOnlyEmoji: false
isReply: d.isReply
isStateEvent: d.isStateEvent
formatted: qsTr("Negotiating call...")
formatted: qsTr("% is negotiating the call...").arg(d.userName)
}
}

View file

@ -453,6 +453,7 @@ TimelineModel::roleNames() const
{UserId, "userId"},
{UserName, "userName"},
{PreviousMessageDay, "previousMessageDay"},
{PreviousMessageIsStateEvent, "previousMessageIsStateEvent"},
{Day, "day"},
{Timestamp, "timestamp"},
{Url, "url"},
@ -469,6 +470,7 @@ TimelineModel::roleNames() const
{IsEdited, "isEdited"},
{IsEditable, "isEditable"},
{IsEncrypted, "isEncrypted"},
{IsStateEvent, "isStateEvent"},
{Trustlevel, "trustlevel"},
{EncryptionError, "encryptionError"},
{ReplyTo, "replyTo"},
@ -666,6 +668,9 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
std::holds_alternative<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
*encrypted_event);
}
case IsStateEvent: {
return is_state_event(event);
}
case Trustlevel: {
auto encrypted_event = events.get(event_id(event), "", false);
@ -730,6 +735,7 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
m.insert(names[IsEdited], data(event, static_cast<int>(IsEdited)));
m.insert(names[IsEditable], data(event, static_cast<int>(IsEditable)));
m.insert(names[IsEncrypted], data(event, static_cast<int>(IsEncrypted)));
m.insert(names[IsStateEvent], data(event, static_cast<int>(IsStateEvent)));
m.insert(names[ReplyTo], data(event, static_cast<int>(ReplyTo)));
m.insert(names[RoomName], data(event, static_cast<int>(RoomName)));
m.insert(names[RoomTopic], data(event, static_cast<int>(RoomTopic)));
@ -762,7 +768,8 @@ TimelineModel::data(const QModelIndex &index, int role) const
if (!event)
return "";
if (role == PreviousMessageDay || role == PreviousMessageUserId) {
if (role == PreviousMessageDay || role == PreviousMessageUserId ||
role == PreviousMessageIsStateEvent) {
int prevIdx = rowCount() - index.row() - 2;
if (prevIdx < 0)
return {};
@ -771,8 +778,10 @@ TimelineModel::data(const QModelIndex &index, int role) const
return {};
if (role == PreviousMessageUserId)
return data(*tempEv, UserId);
else
else if (role == PreviousMessageDay)
return data(*tempEv, Day);
else
return data(*tempEv, IsStateEvent);
}
return data(*event, role);

View file

@ -205,6 +205,7 @@ public:
UserId,
UserName,
PreviousMessageDay,
PreviousMessageIsStateEvent,
Day,
Timestamp,
Url,
@ -221,6 +222,7 @@ public:
IsEdited,
IsEditable,
IsEncrypted,
IsStateEvent,
Trustlevel,
EncryptionError,
ReplyTo,