mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
Show topic and name changes in timeline
This commit is contained in:
parent
dee49508de
commit
e98a61fea6
4 changed files with 48 additions and 1 deletions
|
@ -49,6 +49,18 @@ DelegateChooser {
|
||||||
text: qsTr("Encryption enabled")
|
text: qsTr("Encryption enabled")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
DelegateChoice {
|
||||||
|
roleValue: MtxEvent.Name
|
||||||
|
NoticeMessage {
|
||||||
|
notice: model.roomName ? qsTr("room name changed to: %1").arg(model.roomName) : qsTr("removed room name")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DelegateChoice {
|
||||||
|
roleValue: MtxEvent.Topic
|
||||||
|
NoticeMessage {
|
||||||
|
notice: model.roomTopic ? qsTr("topic changed to: %1").arg(model.roomTopic) : qsTr("removed topic")
|
||||||
|
}
|
||||||
|
}
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
Placeholder {}
|
Placeholder {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import ".."
|
import ".."
|
||||||
|
|
||||||
MatrixText {
|
MatrixText {
|
||||||
text: model.formattedBody
|
property string notice: model.formattedBody.replace("<pre>", "<pre style='white-space: pre-wrap'>")
|
||||||
|
text: notice
|
||||||
width: parent ? parent.width : undefined
|
width: parent ? parent.width : undefined
|
||||||
font.italic: true
|
font.italic: true
|
||||||
color: inactiveColors.text
|
color: inactiveColors.text
|
||||||
|
|
|
@ -59,6 +59,30 @@ eventMsgType(const mtx::events::RoomEvent<T> &e) -> decltype(e.content.msgtype)
|
||||||
return e.content.msgtype;
|
return e.content.msgtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
QString
|
||||||
|
eventRoomName(const T &)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
QString
|
||||||
|
eventRoomName(const mtx::events::StateEvent<mtx::events::state::Name> &e)
|
||||||
|
{
|
||||||
|
return QString::fromStdString(e.content.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
QString
|
||||||
|
eventRoomTopic(const T &)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
QString
|
||||||
|
eventRoomTopic(const mtx::events::StateEvent<mtx::events::state::Topic> &e)
|
||||||
|
{
|
||||||
|
return QString::fromStdString(e.content.topic);
|
||||||
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
QString
|
QString
|
||||||
eventBody(const mtx::events::Event<T> &)
|
eventBody(const mtx::events::Event<T> &)
|
||||||
|
@ -437,6 +461,8 @@ TimelineModel::roleNames() const
|
||||||
{State, "state"},
|
{State, "state"},
|
||||||
{IsEncrypted, "isEncrypted"},
|
{IsEncrypted, "isEncrypted"},
|
||||||
{ReplyTo, "replyTo"},
|
{ReplyTo, "replyTo"},
|
||||||
|
{RoomName, "roomName"},
|
||||||
|
{RoomTopic, "roomTopic"},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
int
|
int
|
||||||
|
@ -563,6 +589,12 @@ TimelineModel::data(const QModelIndex &index, int role) const
|
||||||
[](const auto &e) -> QString { return eventRelatesTo(e); }, event);
|
[](const auto &e) -> QString { return eventRelatesTo(e); }, event);
|
||||||
return QVariant(evId);
|
return QVariant(evId);
|
||||||
}
|
}
|
||||||
|
case RoomName:
|
||||||
|
return QVariant(boost::apply_visitor(
|
||||||
|
[](const auto &e) -> QString { return eventRoomName(e); }, event));
|
||||||
|
case RoomTopic:
|
||||||
|
return QVariant(boost::apply_visitor(
|
||||||
|
[](const auto &e) -> QString { return eventRoomTopic(e); }, event));
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,6 +141,8 @@ public:
|
||||||
State,
|
State,
|
||||||
IsEncrypted,
|
IsEncrypted,
|
||||||
ReplyTo,
|
ReplyTo,
|
||||||
|
RoomName,
|
||||||
|
RoomTopic,
|
||||||
};
|
};
|
||||||
|
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
Loading…
Reference in a new issue