Changeset View
Changeset View
Standalone View
Standalone View
src/akonadi/akonadilivequeryintegrator.cpp
Show All 37 Lines | 35 | { | |||
---|---|---|---|---|---|
38 | 38 | | |||
39 | connect(m_monitor.data(), &MonitorInterface::collectionAdded, this, &LiveQueryIntegrator::onCollectionAdded); | 39 | connect(m_monitor.data(), &MonitorInterface::collectionAdded, this, &LiveQueryIntegrator::onCollectionAdded); | ||
40 | connect(m_monitor.data(), &MonitorInterface::collectionRemoved, this, &LiveQueryIntegrator::onCollectionRemoved); | 40 | connect(m_monitor.data(), &MonitorInterface::collectionRemoved, this, &LiveQueryIntegrator::onCollectionRemoved); | ||
41 | connect(m_monitor.data(), &MonitorInterface::collectionChanged, this, &LiveQueryIntegrator::onCollectionChanged); | 41 | connect(m_monitor.data(), &MonitorInterface::collectionChanged, this, &LiveQueryIntegrator::onCollectionChanged); | ||
42 | 42 | | |||
43 | connect(m_monitor.data(), &MonitorInterface::itemAdded, this, &LiveQueryIntegrator::onItemAdded); | 43 | connect(m_monitor.data(), &MonitorInterface::itemAdded, this, &LiveQueryIntegrator::onItemAdded); | ||
44 | connect(m_monitor.data(), &MonitorInterface::itemRemoved, this, &LiveQueryIntegrator::onItemRemoved); | 44 | connect(m_monitor.data(), &MonitorInterface::itemRemoved, this, &LiveQueryIntegrator::onItemRemoved); | ||
45 | connect(m_monitor.data(), &MonitorInterface::itemChanged, this, &LiveQueryIntegrator::onItemChanged); | 45 | connect(m_monitor.data(), &MonitorInterface::itemChanged, this, &LiveQueryIntegrator::onItemChanged); | ||
46 | | ||||
47 | connect(m_monitor.data(), &MonitorInterface::tagAdded, this, &LiveQueryIntegrator::onTagAdded); | | |||
48 | connect(m_monitor.data(), &MonitorInterface::tagRemoved, this, &LiveQueryIntegrator::onTagRemoved); | | |||
49 | connect(m_monitor.data(), &MonitorInterface::tagChanged, this, &LiveQueryIntegrator::onTagChanged); | | |||
50 | } | 46 | } | ||
51 | 47 | | |||
52 | void LiveQueryIntegrator::addRemoveHandler(const LiveQueryIntegrator::CollectionRemoveHandler &handler) | 48 | void LiveQueryIntegrator::addRemoveHandler(const LiveQueryIntegrator::CollectionRemoveHandler &handler) | ||
53 | { | 49 | { | ||
54 | m_collectionRemoveHandlers << handler; | 50 | m_collectionRemoveHandlers << handler; | ||
55 | } | 51 | } | ||
56 | 52 | | |||
57 | void LiveQueryIntegrator::addRemoveHandler(const LiveQueryIntegrator::ItemRemoveHandler &handler) | 53 | void LiveQueryIntegrator::addRemoveHandler(const LiveQueryIntegrator::ItemRemoveHandler &handler) | ||
58 | { | 54 | { | ||
59 | m_itemRemoveHandlers << handler; | 55 | m_itemRemoveHandlers << handler; | ||
60 | } | 56 | } | ||
61 | 57 | | |||
62 | void LiveQueryIntegrator::addRemoveHandler(const LiveQueryIntegrator::TagRemoveHandler &handler) | | |||
63 | { | | |||
64 | m_tagRemoveHandlers << handler; | | |||
65 | } | | |||
66 | | ||||
67 | void LiveQueryIntegrator::onCollectionSelectionChanged() | 58 | void LiveQueryIntegrator::onCollectionSelectionChanged() | ||
68 | { | 59 | { | ||
69 | foreach (const auto &weak, m_itemInputQueries) { | 60 | foreach (const auto &weak, m_itemInputQueries) { | ||
70 | auto query = weak.toStrongRef(); | 61 | auto query = weak.toStrongRef(); | ||
71 | if (query) | 62 | if (query) | ||
72 | query->reset(); | 63 | query->reset(); | ||
73 | } | 64 | } | ||
74 | } | 65 | } | ||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | |||||
132 | { | 123 | { | ||
133 | foreach (const auto &weak, m_itemInputQueries) { | 124 | foreach (const auto &weak, m_itemInputQueries) { | ||
134 | auto query = weak.toStrongRef(); | 125 | auto query = weak.toStrongRef(); | ||
135 | if (query) | 126 | if (query) | ||
136 | query->onChanged(item); | 127 | query->onChanged(item); | ||
137 | } | 128 | } | ||
138 | } | 129 | } | ||
139 | 130 | | |||
140 | void LiveQueryIntegrator::onTagAdded(const Tag &tag) | | |||
141 | { | | |||
142 | foreach (const auto &weak, m_tagInputQueries) { | | |||
143 | auto query = weak.toStrongRef(); | | |||
144 | if (query) | | |||
145 | query->onAdded(tag); | | |||
146 | } | | |||
147 | } | | |||
148 | | ||||
149 | void LiveQueryIntegrator::onTagRemoved(const Tag &tag) | | |||
150 | { | | |||
151 | foreach (const auto &weak, m_tagInputQueries) { | | |||
152 | auto query = weak.toStrongRef(); | | |||
153 | if (query) | | |||
154 | query->onRemoved(tag); | | |||
155 | } | | |||
156 | | ||||
157 | foreach (const auto &handler, m_tagRemoveHandlers) | | |||
158 | handler(tag); | | |||
159 | | ||||
160 | cleanupQueries(); | | |||
161 | } | | |||
162 | | ||||
163 | void LiveQueryIntegrator::onTagChanged(const Tag &tag) | | |||
164 | { | | |||
165 | foreach (const auto &weak, m_tagInputQueries) { | | |||
166 | auto query = weak.toStrongRef(); | | |||
167 | if (query) | | |||
168 | query->onChanged(tag); | | |||
169 | } | | |||
170 | } | | |||
171 | | ||||
172 | void LiveQueryIntegrator::cleanupQueries() | 131 | void LiveQueryIntegrator::cleanupQueries() | ||
173 | { | 132 | { | ||
174 | m_collectionInputQueries.removeAll(Domain::LiveQueryInput<Collection>::WeakPtr()); | 133 | m_collectionInputQueries.removeAll(Domain::LiveQueryInput<Collection>::WeakPtr()); | ||
175 | m_itemInputQueries.removeAll(Domain::LiveQueryInput<Item>::WeakPtr()); | 134 | m_itemInputQueries.removeAll(Domain::LiveQueryInput<Item>::WeakPtr()); | ||
176 | m_tagInputQueries.removeAll(Domain::LiveQueryInput<Tag>::WeakPtr()); | | |||
177 | } | 135 | } |