summary refs log tree commit diff
path: root/src/TimelineViewManager.cc
diff options
context:
space:
mode:
authorMax Sandholm <max@sandholm.org>2017-10-01 19:49:36 +0300
committermujx <mujx@users.noreply.github.com>2017-10-01 19:49:36 +0300
commit7ad45d8d6448c60b4c81c80fa8d6d81afd6e4a02 (patch)
tree821124200c7dac85128790115d527791c1fc4945 /src/TimelineViewManager.cc
parentMore badges (diff)
downloadnheko-7ad45d8d6448c60b4c81c80fa8d6d81afd6e4a02.tar.xz
React to externally left and joined rooms, and add "leave room" button in room menu (#75)
* Initial "join room" feature.
* React correctly to remotely joined rooms.
* Leaving rooms implemented both locally using the room menu
   in nheko, and reacting properly when leaving a room remotely 
   from another client.
Diffstat (limited to 'src/TimelineViewManager.cc')
-rw-r--r--src/TimelineViewManager.cc56
1 files changed, 33 insertions, 23 deletions
diff --git a/src/TimelineViewManager.cc b/src/TimelineViewManager.cc

index a4d616c3..1969ae5b 100644 --- a/src/TimelineViewManager.cc +++ b/src/TimelineViewManager.cc
@@ -101,19 +101,7 @@ void TimelineViewManager::initialize(const Rooms &rooms) { for (auto it = rooms.join().constBegin(); it != rooms.join().constEnd(); it++) { - auto roomid = it.key(); - - // Create a history view with the room events. - TimelineView *view = new TimelineView(it.value().timeline(), client_, it.key()); - views_.insert(it.key(), QSharedPointer<TimelineView>(view)); - - connect(view, - &TimelineView::updateLastTimelineMessage, - this, - &TimelineViewManager::updateRoomsLastMessage); - - // Add the view in the widget stack. - addWidget(view); + addRoom(it.value(), it.key()); } } @@ -121,18 +109,40 @@ void TimelineViewManager::initialize(const QList<QString> &rooms) { for (const auto &roomid : rooms) { - // Create a history view without any events. - TimelineView *view = new TimelineView(client_, roomid); - views_.insert(roomid, QSharedPointer<TimelineView>(view)); + addRoom(roomid); + } +} + +void +TimelineViewManager::addRoom(const JoinedRoom &room, const QString &room_id) +{ + // Create a history view with the room events. + TimelineView *view = new TimelineView(room.timeline(), client_, room_id); + views_.insert(room_id, QSharedPointer<TimelineView>(view)); - connect(view, - &TimelineView::updateLastTimelineMessage, - this, - &TimelineViewManager::updateRoomsLastMessage); + connect(view, + &TimelineView::updateLastTimelineMessage, + this, + &TimelineViewManager::updateRoomsLastMessage); - // Add the view in the widget stack. - addWidget(view); - } + // Add the view in the widget stack. + addWidget(view); +} + +void +TimelineViewManager::addRoom(const QString &room_id) +{ + // Create a history view without any events. + TimelineView *view = new TimelineView(client_, room_id); + views_.insert(room_id, QSharedPointer<TimelineView>(view)); + + connect(view, + &TimelineView::updateLastTimelineMessage, + this, + &TimelineViewManager::updateRoomsLastMessage); + + // Add the view in the widget stack. + addWidget(view); } void