From 641a883bfdc65c7c9a86e799912e1aaf4dd63f05 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Thu, 30 Apr 2020 23:59:17 +0200 Subject: Optimize RoomList sorting Keep the almost sorted list around and sort by the raw timestamp value instead of doing the expensive toMSecSinceEpoch conversion. --- src/RoomInfoListItem.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/RoomInfoListItem.cpp') diff --git a/src/RoomInfoListItem.cpp b/src/RoomInfoListItem.cpp index 13c7b54d..ee8d532d 100644 --- a/src/RoomInfoListItem.cpp +++ b/src/RoomInfoListItem.cpp @@ -187,10 +187,11 @@ RoomInfoListItem::paintEvent(QPaintEvent *event) QFont tsFont; tsFont.setPointSizeF(tsFont.pointSizeF() * 0.9); #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) - const int msgStampWidth = QFontMetrics(tsFont).width(lastMsgInfo_.timestamp) + 4; + const int msgStampWidth = + QFontMetrics(tsFont).width(lastMsgInfo_.descriptiveTime) + 4; #else const int msgStampWidth = - QFontMetrics(tsFont).horizontalAdvance(lastMsgInfo_.timestamp) + 4; + QFontMetrics(tsFont).horizontalAdvance(lastMsgInfo_.descriptiveTime) + 4; #endif // We use the full width of the widget if there is no unread msg bubble. const int bottomLineWidthLimit = (unreadMsgCount_ > 0) ? msgStampWidth : 0; @@ -227,7 +228,7 @@ RoomInfoListItem::paintEvent(QPaintEvent *event) p.setFont(tsFont); p.drawText(QPoint(width() - wm.padding - msgStampWidth, top_y), - lastMsgInfo_.timestamp); + lastMsgInfo_.descriptiveTime); p.restore(); } else { int btnWidth = (width() - wm.iconSize - 6 * wm.padding) / 2; -- cgit 1.5.1