summary refs log tree commit diff
path: root/src/timeline/RoomlistModel.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2024-03-16 03:55:57 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2024-03-16 11:50:39 +0100
commitaef9617d1ec7f73a394ed4bb43b4436e27225176 (patch)
treecd34e86e42c22b8ab3f8c93b0098645fcce9acca /src/timeline/RoomlistModel.cpp
parentInclude moc files for a tiny speedup on incremental builds (diff)
downloadnheko-aef9617d1ec7f73a394ed4bb43b4436e27225176.tar.xz
Make a few headers forward declarations
Diffstat (limited to 'src/timeline/RoomlistModel.cpp')
-rw-r--r--src/timeline/RoomlistModel.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/timeline/RoomlistModel.cpp b/src/timeline/RoomlistModel.cpp

index 898e6e83..4cc50fee 100644 --- a/src/timeline/RoomlistModel.cpp +++ b/src/timeline/RoomlistModel.cpp
@@ -945,6 +945,34 @@ FilteredRoomlistModel::FilteredRoomlistModel(RoomlistModel *model, QObject *pare sort(0); } +FilteredRoomlistModel * +FilteredRoomlistModel::create(QQmlEngine *qmlEngine, QJSEngine *) +{ + // The instance has to exist before it is used. We cannot replace it. + Q_ASSERT(instance_); + + // The engine has to have the same thread affinity as the singleton. + Q_ASSERT(qmlEngine->thread() == instance_->thread()); + + // There can only be one engine accessing the singleton. + static QJSEngine *s_engine = nullptr; + if (s_engine) + Q_ASSERT(qmlEngine == s_engine); + else + s_engine = qmlEngine; + + QJSEngine::setObjectOwnership(instance_, QJSEngine::CppOwnership); + return instance_; +} + +TimelineModel * +FilteredRoomlistModel::getRoomById(const QString &id) const +{ + auto r = roomlistmodel->getRoomById(id).data(); + QQmlEngine::setObjectOwnership(r, QQmlEngine::CppOwnership); + return r; +} + void FilteredRoomlistModel::updateHiddenTagsAndSpaces() {