Improve time handling in NeoChat

This introduces a new NeoChatDateTime object that wraps a QDateTime. The intent is that it can be passed to QML and has a series of functions that format the QDateTime into the various string representations we need.

This means we only have to send the single object to QML and then the correct string can be grabbed from there, simplifying the backend. It is also easy to add a new representation if needed as a function with a QString output and Q_PROPERTY can be added and then it will be available.
This commit is contained in:
James Graham
2026-01-25 13:01:31 +00:00
parent 72416884d4
commit 275d221f75
23 changed files with 222 additions and 186 deletions

View File

@@ -13,6 +13,11 @@ import org.kde.neochat
TimelineDelegate {
id: root
/**
* @brief The timestamp of the event as a NeoChatDateTime.
*/
required property NeoChatDateTime dateTime
property bool isTemporaryHighlighted: false
onIsTemporaryHighlightedChanged: if (isTemporaryHighlighted) {
temporaryHighlightTimer.start();
@@ -39,7 +44,7 @@ TimelineDelegate {
}
contentItem: QQC2.Label {
text: i18nc("Relative time since the room was last read", "Last read: %1", time)
text: i18nc("Relative time since the room was last read", "Last read: %1", root.dateTime.relativeDateTime)
}
background: Kirigami.ShadowedRectangle {