summaryrefslogtreecommitdiff
path: root/libsowatch/watchserver.cpp
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2013-05-05 01:44:40 +0200
committerJavier S. Pedro <maemo@javispedro.com>2013-05-05 01:44:40 +0200
commit24c7c2f6f1429103d922ef940c0e17a3d4778059 (patch)
tree76ab9ac2c9fade7db77f64424a17c478979d8a8b /libsowatch/watchserver.cpp
parentea5123cb6b30d5ab083ee3821269537b1d31b9f0 (diff)
downloadsowatch-24c7c2f6f1429103d922ef940c0e17a3d4778059.tar.gz
sowatch-24c7c2f6f1429103d922ef940c0e17a3d4778059.zip
ABI change: Watchlet now depends on Watch, not WatchServer
Diffstat (limited to 'libsowatch/watchserver.cpp')
-rw-r--r--libsowatch/watchserver.cpp24
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);