From 24c7c2f6f1429103d922ef940c0e17a3d4778059 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Sun, 5 May 2013 01:44:40 +0200 Subject: ABI change: Watchlet now depends on Watch, not WatchServer --- libsowatch/declarativewatchlet.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'libsowatch/declarativewatchlet.cpp') diff --git a/libsowatch/declarativewatchlet.cpp b/libsowatch/declarativewatchlet.cpp index 7e3ac53..ed6ec26 100644 --- a/libsowatch/declarativewatchlet.cpp +++ b/libsowatch/declarativewatchlet.cpp @@ -10,8 +10,8 @@ using namespace sowatch; bool DeclarativeWatchlet::_registered = false; -DeclarativeWatchlet::DeclarativeWatchlet(WatchServer* server, const QString& id) : - GraphicsWatchlet(server, id), +DeclarativeWatchlet::DeclarativeWatchlet(Watch* watch, const QString& id) : + GraphicsWatchlet(watch, id), _engine(0), _component(0), _item(0), @@ -31,27 +31,26 @@ DeclarativeWatchlet::DeclarativeWatchlet(WatchServer* server, const QString& id) _registered = true; } - // A dynamic property on the WatchServer object is used to share a single + // A dynamic property on the Watch object is used to share a single // DeclarativeEngine amongst all DeclarativeWatchlet instances. - QVariant serverEngine = server->property("declarativeEngine"); - if (!serverEngine.isValid()) { + QVariant watchEngine = watch->property("declarativeEngine"); + if (!watchEngine.isValid()) { // Create the shared engine qDebug() << "Starting QDeclarativeEngine"; - _engine = new QDeclarativeEngine(server); + _engine = new QDeclarativeEngine(watch); _engine->addImportPath(SOWATCH_QML_DIR); // Set context properties that are shared by all watchlets here - _engine->rootContext()->setContextProperty("notifications", - const_cast(server->notifications())); + _engine->rootContext()->setContextProperty("notifications", 0); - server->setProperty("declarativeEngine", QVariant::fromValue(_engine)); + watch->setProperty("declarativeEngine", QVariant::fromValue(_engine)); } else { - _engine = serverEngine.value(); + _engine = watchEngine.value(); } _context = new QDeclarativeContext(_engine, this); - _wrapper = new DeclarativeWatchWrapper(server, server->watch(), this); + _wrapper = new DeclarativeWatchWrapper(watch, this); _context->setContextProperty("watch", _wrapper); } @@ -125,6 +124,12 @@ void DeclarativeWatchlet::deactivate() GraphicsWatchlet::deactivate(); } +void DeclarativeWatchlet::setNotificationsModel(NotificationsModel *model) +{ + qDebug() << Q_FUNC_INFO; + _context->setContextProperty("notifications", model); +} + void DeclarativeWatchlet::setRootObject(QDeclarativeItem *item) { Q_ASSERT(_item == 0); /* This function should not be called with a current object. */ -- cgit v1.2.3