summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/modelresult.cpp10
-rw-r--r--common/notifier.cpp6
-rw-r--r--common/store.cpp2
3 files changed, 11 insertions, 7 deletions
diff --git a/common/modelresult.cpp b/common/modelresult.cpp
index 3edbec7..26d4f82 100644
--- a/common/modelresult.cpp
+++ b/common/modelresult.cpp
@@ -53,7 +53,9 @@ ModelResult<T, Ptr>::ModelResult(const Sink::Query &query, const QList<QByteArra
53 : QAbstractItemModel(), mLogCtx(ctx.subContext("modelresult")), mPropertyColumns(propertyColumns), mQuery(query) 53 : QAbstractItemModel(), mLogCtx(ctx.subContext("modelresult")), mPropertyColumns(propertyColumns), mQuery(query)
54{ 54{
55 if (query.flags().testFlag(Sink::Query::UpdateStatus)) { 55 if (query.flags().testFlag(Sink::Query::UpdateStatus)) {
56 mNotifier.reset(new Sink::Notifier{query}); 56 Sink::Query resourceQuery;
57 resourceQuery.setFilter(query.getResourceFilter());
58 mNotifier.reset(new Sink::Notifier{resourceQuery});
57 mNotifier->registerHandler([this](const Notification &notification) { 59 mNotifier->registerHandler([this](const Notification &notification) {
58 switch (notification.type) { 60 switch (notification.type) {
59 case Notification::Status: 61 case Notification::Status:
@@ -120,8 +122,10 @@ ModelResult<T, Ptr>::ModelResult(const Sink::Query &query, const QList<QByteArra
120 changedRoles << WarningRole; 122 changedRoles << WarningRole;
121 } 123 }
122 124
123 const auto idx = createIndexFromId(id); 125 if (!changedRoles.isEmpty()) {
124 emit dataChanged(idx, idx, changedRoles); 126 const auto idx = createIndexFromId(id);
127 emit dataChanged(idx, idx, changedRoles);
128 }
125 } 129 }
126 }); 130 });
127 } 131 }
diff --git a/common/notifier.cpp b/common/notifier.cpp
index 7dbc85e..f52e28b 100644
--- a/common/notifier.cpp
+++ b/common/notifier.cpp
@@ -39,7 +39,7 @@ public:
39 39
40 void listenForNotifications(const QSharedPointer<ResourceAccess> &access) 40 void listenForNotifications(const QSharedPointer<ResourceAccess> &access)
41 { 41 {
42 QObject::connect(access.data(), &ResourceAccess::notification, context.data(), [this](const Notification &notification) { 42 QObject::connect(access.data(), &ResourceAccess::notification, &context, [this](const Notification &notification) {
43 for (const auto &handler : handler) { 43 for (const auto &handler : handler) {
44 handler(notification); 44 handler(notification);
45 } 45 }
@@ -49,7 +49,7 @@ public:
49 49
50 QList<QSharedPointer<ResourceAccess>> resourceAccess; 50 QList<QSharedPointer<ResourceAccess>> resourceAccess;
51 QList<std::function<void(const Notification &)>> handler; 51 QList<std::function<void(const Notification &)>> handler;
52 QSharedPointer<QObject> context; 52 QObject context;
53}; 53};
54 54
55Notifier::Notifier(const QSharedPointer<ResourceAccess> &resourceAccess) : d(new Sink::Notifier::Private) 55Notifier::Notifier(const QSharedPointer<ResourceAccess> &resourceAccess) : d(new Sink::Notifier::Private)
@@ -77,7 +77,7 @@ Notifier::Notifier(const Sink::Query &resourceQuery) : d(new Sink::Notifier::Pri
77 auto result = facade->load(resourceQuery, resourceCtx); 77 auto result = facade->load(resourceQuery, resourceCtx);
78 auto emitter = result.second; 78 auto emitter = result.second;
79 emitter->onAdded([=](const ApplicationDomain::SinkResource::Ptr &resource) { 79 emitter->onAdded([=](const ApplicationDomain::SinkResource::Ptr &resource) {
80 auto resourceAccess = Sink::ResourceAccess::Ptr::create(resource->identifier(), ResourceConfig::getResourceType(resource->identifier())); 80 auto resourceAccess = Sink::ResourceAccessFactory::instance().getAccess(resource->identifier(), ResourceConfig::getResourceType(resource->identifier()));
81 resourceAccess->open(); 81 resourceAccess->open();
82 d->listenForNotifications(resourceAccess); 82 d->listenForNotifications(resourceAccess);
83 }); 83 });
diff --git a/common/store.cpp b/common/store.cpp
index 264f2e3..8c0a985 100644
--- a/common/store.cpp
+++ b/common/store.cpp
@@ -279,7 +279,7 @@ KAsync::Job<void> Store::removeDataFromDisk(const QByteArray &identifier)
279 279
280static KAsync::Job<void> synchronize(const QByteArray &resource, const Sink::SyncScope &scope) 280static KAsync::Job<void> synchronize(const QByteArray &resource, const Sink::SyncScope &scope)
281{ 281{
282 SinkLog() << "Synchronizing " << resource; 282 SinkLog() << "Synchronizing " << resource << scope;
283 auto resourceAccess = ResourceAccessFactory::instance().getAccess(resource, ResourceConfig::getResourceType(resource)); 283 auto resourceAccess = ResourceAccessFactory::instance().getAccess(resource, ResourceConfig::getResourceType(resource));
284 return resourceAccess->synchronizeResource(scope) 284 return resourceAccess->synchronizeResource(scope)
285 .addToContext(resourceAccess) 285 .addToContext(resourceAccess)