diff options
Diffstat (limited to 'libsowatch/watchserver.cpp')
-rw-r--r-- | libsowatch/watchserver.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/libsowatch/watchserver.cpp b/libsowatch/watchserver.cpp index 3d9db24..d3328df 100644 --- a/libsowatch/watchserver.cpp +++ b/libsowatch/watchserver.cpp @@ -65,11 +65,13 @@ void WatchServer::addWatchlet(Watchlet *watchlet) void WatchServer::insertWatchlet(int position, Watchlet *watchlet) { Q_ASSERT(watchlet); - Q_ASSERT(watchlet->_server == this); + Q_ASSERT(watchlet->watch() == _watch); const QString id = watchlet->id(); Q_ASSERT(!_watchletIds.contains(id)); + setWatchletProperties(watchlet); + _watchlets.insert(position, watchlet); _watchletIds[id] = watchlet; } @@ -79,7 +81,7 @@ void WatchServer::moveWatchlet(const Watchlet *watchlet, int to) const QString id = watchlet->id(); int index = _watchlets.indexOf(const_cast<Watchlet*>(watchlet)); - Q_ASSERT(watchlet->_server == this); + Q_ASSERT(watchlet->watch() == _watch); Q_ASSERT(_watchletIds.contains(id)); Q_ASSERT(index >= 0); @@ -90,13 +92,15 @@ void WatchServer::removeWatchlet(const Watchlet *watchlet) { const QString id = watchlet->id(); - Q_ASSERT(watchlet->_server == this); + Q_ASSERT(watchlet->watch() == _watch); Q_ASSERT(_watchletIds.contains(id)); if (_currentWatchlet == watchlet) { closeWatchlet(); } + unsetWatchletProperties(const_cast<Watchlet*>(watchlet)); + _watchlets.removeAll(const_cast<Watchlet*>(watchlet)); _watchletIds.remove(id); } @@ -177,7 +181,7 @@ void WatchServer::nextNotification() void WatchServer::runWatchlet(Watchlet *watchlet) { - Q_ASSERT(watchlet->_server == this); + Q_ASSERT(watchlet->watch() == _watch); if (_currentWatchlet && _currentWatchletActive) { deactivateCurrentWatchlet(); } @@ -278,6 +282,18 @@ void WatchServer::removeNotification(Notification::Type type, Notification *n) disconnect(n, 0, this, 0); } +void WatchServer::setWatchletProperties(Watchlet *watchlet) +{ + Q_ASSERT(watchlet->watch() == _watch); + watchlet->setNotificationsModel(_notifications); +} + +void WatchServer::unsetWatchletProperties(Watchlet *watchlet) +{ + Q_ASSERT(watchlet->watch() == _watch); + watchlet->setNotificationsModel(0); +} + void WatchServer::goToIdle() { Q_ASSERT(!_currentWatchletActive); |