diff options
Diffstat (limited to 'src/timeline/TimelineModel.cpp')
-rw-r--r-- | src/timeline/TimelineModel.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 752aedb0..b2a036c5 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -535,6 +535,7 @@ TimelineModel::roleNames() const {IsSender, "isSender"}, {UserId, "userId"}, {UserName, "userName"}, + {UserPowerlevel, "userPowerlevel"}, {Day, "day"}, {Timestamp, "timestamp"}, {Url, "url"}, @@ -597,6 +598,14 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r return QVariant(QString::fromStdString(acc::sender(event))); case UserName: return QVariant(displayName(QString::fromStdString(acc::sender(event)))); + case UserPowerlevel: { + return static_cast<qlonglong>(mtx::events::state::PowerLevels{ + cache::client() + ->getStateEvent<mtx::events::state::PowerLevels>(room_id_.toStdString()) + .value_or(mtx::events::StateEvent<mtx::events::state::PowerLevels>{}) + .content} + .user_level(acc::sender(event))); + } case Day: { QDateTime prevDate = origin_server_ts(event); @@ -1284,13 +1293,20 @@ TimelineModel::updateLastMessage() void TimelineModel::setCurrentIndex(int index) { + setCurrentIndex(index, false); +} + +void +TimelineModel::setCurrentIndex(int index, bool ignoreInactiveState) +{ auto oldIndex = idToIndex(currentId); currentId = indexToId(index); if (index != oldIndex) emit currentIndexChanged(index); - if (!QGuiApplication::focusWindow() || !QGuiApplication::focusWindow()->isActive() || - MainWindow::instance()->windowForRoom(roomId()) != QGuiApplication::focusWindow()) + if (!ignoreInactiveState && + (!QGuiApplication::focusWindow() || !QGuiApplication::focusWindow()->isActive() || + MainWindow::instance()->windowForRoom(roomId()) != QGuiApplication::focusWindow())) return; if (!currentId.startsWith('m')) { @@ -1562,6 +1578,12 @@ TimelineModel::markEventsAsRead(const std::vector<QString> &event_ids) } void +TimelineModel::markRoomAsRead() +{ + setCurrentIndex(0, true); +} + +void TimelineModel::updateLastReadId(const QString ¤tRoomId) { if (currentRoomId == room_id_) { |