diff options
Diffstat (limited to 'examples/client/main.cpp')
-rw-r--r-- | examples/client/main.cpp | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/examples/client/main.cpp b/examples/client/main.cpp index 6660f86..f437c19 100644 --- a/examples/client/main.cpp +++ b/examples/client/main.cpp | |||
@@ -34,64 +34,64 @@ | |||
34 | #include <iostream> | 34 | #include <iostream> |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * A small abstraction layer to use the akonadi store with the type available as string. | 37 | * A small abstraction layer to use the sink store with the type available as string. |
38 | */ | 38 | */ |
39 | class StoreBase { | 39 | class StoreBase { |
40 | public: | 40 | public: |
41 | virtual Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr getObject() = 0; | 41 | virtual Sink::ApplicationDomain::ApplicationDomainType::Ptr getObject() = 0; |
42 | virtual Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr getObject(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier = QByteArray()) = 0; | 42 | virtual Sink::ApplicationDomain::ApplicationDomainType::Ptr getObject(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier = QByteArray()) = 0; |
43 | virtual KAsync::Job<void> create(const Akonadi2::ApplicationDomain::ApplicationDomainType &type) = 0; | 43 | virtual KAsync::Job<void> create(const Sink::ApplicationDomain::ApplicationDomainType &type) = 0; |
44 | virtual KAsync::Job<void> modify(const Akonadi2::ApplicationDomain::ApplicationDomainType &type) = 0; | 44 | virtual KAsync::Job<void> modify(const Sink::ApplicationDomain::ApplicationDomainType &type) = 0; |
45 | virtual KAsync::Job<void> remove(const Akonadi2::ApplicationDomain::ApplicationDomainType &type) = 0; | 45 | virtual KAsync::Job<void> remove(const Sink::ApplicationDomain::ApplicationDomainType &type) = 0; |
46 | virtual QSharedPointer<QAbstractItemModel> loadModel(const Akonadi2::Query &query) = 0; | 46 | virtual QSharedPointer<QAbstractItemModel> loadModel(const Sink::Query &query) = 0; |
47 | }; | 47 | }; |
48 | 48 | ||
49 | template <typename T> | 49 | template <typename T> |
50 | class Store : public StoreBase { | 50 | class Store : public StoreBase { |
51 | public: | 51 | public: |
52 | Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr getObject() Q_DECL_OVERRIDE { | 52 | Sink::ApplicationDomain::ApplicationDomainType::Ptr getObject() Q_DECL_OVERRIDE { |
53 | return T::Ptr::create(); | 53 | return T::Ptr::create(); |
54 | } | 54 | } |
55 | 55 | ||
56 | Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr getObject(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier = QByteArray()) Q_DECL_OVERRIDE { | 56 | Sink::ApplicationDomain::ApplicationDomainType::Ptr getObject(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier = QByteArray()) Q_DECL_OVERRIDE { |
57 | return T::Ptr::create(resourceInstanceIdentifier, identifier, 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); | 57 | return T::Ptr::create(resourceInstanceIdentifier, identifier, 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
58 | } | 58 | } |
59 | 59 | ||
60 | KAsync::Job<void> create(const Akonadi2::ApplicationDomain::ApplicationDomainType &type) Q_DECL_OVERRIDE { | 60 | KAsync::Job<void> create(const Sink::ApplicationDomain::ApplicationDomainType &type) Q_DECL_OVERRIDE { |
61 | return Akonadi2::Store::create<T>(*static_cast<const T*>(&type)); | 61 | return Sink::Store::create<T>(*static_cast<const T*>(&type)); |
62 | } | 62 | } |
63 | 63 | ||
64 | KAsync::Job<void> modify(const Akonadi2::ApplicationDomain::ApplicationDomainType &type) Q_DECL_OVERRIDE { | 64 | KAsync::Job<void> modify(const Sink::ApplicationDomain::ApplicationDomainType &type) Q_DECL_OVERRIDE { |
65 | return Akonadi2::Store::modify<T>(*static_cast<const T*>(&type)); | 65 | return Sink::Store::modify<T>(*static_cast<const T*>(&type)); |
66 | } | 66 | } |
67 | 67 | ||
68 | KAsync::Job<void> remove(const Akonadi2::ApplicationDomain::ApplicationDomainType &type) Q_DECL_OVERRIDE { | 68 | KAsync::Job<void> remove(const Sink::ApplicationDomain::ApplicationDomainType &type) Q_DECL_OVERRIDE { |
69 | return Akonadi2::Store::remove<T>(*static_cast<const T*>(&type)); | 69 | return Sink::Store::remove<T>(*static_cast<const T*>(&type)); |
70 | } | 70 | } |
71 | 71 | ||
72 | QSharedPointer<QAbstractItemModel> loadModel(const Akonadi2::Query &query) Q_DECL_OVERRIDE { | 72 | QSharedPointer<QAbstractItemModel> loadModel(const Sink::Query &query) Q_DECL_OVERRIDE { |
73 | return Akonadi2::Store::loadModel<T>(query); | 73 | return Sink::Store::loadModel<T>(query); |
74 | } | 74 | } |
75 | }; | 75 | }; |
76 | 76 | ||
77 | StoreBase& getStore(const QString &type) | 77 | StoreBase& getStore(const QString &type) |
78 | { | 78 | { |
79 | if (type == "folder") { | 79 | if (type == "folder") { |
80 | static Store<Akonadi2::ApplicationDomain::Folder> store; | 80 | static Store<Sink::ApplicationDomain::Folder> store; |
81 | return store; | 81 | return store; |
82 | } else if (type == "mail") { | 82 | } else if (type == "mail") { |
83 | static Store<Akonadi2::ApplicationDomain::Mail> store; | 83 | static Store<Sink::ApplicationDomain::Mail> store; |
84 | return store; | 84 | return store; |
85 | } else if (type == "event") { | 85 | } else if (type == "event") { |
86 | static Store<Akonadi2::ApplicationDomain::Event> store; | 86 | static Store<Sink::ApplicationDomain::Event> store; |
87 | return store; | 87 | return store; |
88 | } else if (type == "resource") { | 88 | } else if (type == "resource") { |
89 | static Store<Akonadi2::ApplicationDomain::AkonadiResource> store; | 89 | static Store<Sink::ApplicationDomain::SinkResource> store; |
90 | return store; | 90 | return store; |
91 | } | 91 | } |
92 | Q_ASSERT(false); | 92 | Q_ASSERT(false); |
93 | qWarning() << "Trying to get a store that doesn't exist, falling back to event"; | 93 | qWarning() << "Trying to get a store that doesn't exist, falling back to event"; |
94 | static Store<Akonadi2::ApplicationDomain::Event> store; | 94 | static Store<Sink::ApplicationDomain::Event> store; |
95 | return store; | 95 | return store; |
96 | } | 96 | } |
97 | 97 | ||
@@ -118,17 +118,17 @@ public: | |||
118 | auto syncButton = new QPushButton(this); | 118 | auto syncButton = new QPushButton(this); |
119 | syncButton->setText("Synchronize!"); | 119 | syncButton->setText("Synchronize!"); |
120 | QObject::connect(syncButton, &QPushButton::pressed, []() { | 120 | QObject::connect(syncButton, &QPushButton::pressed, []() { |
121 | Akonadi2::Query query; | 121 | Sink::Query query; |
122 | query.resources << "org.kde.dummy.instance1"; | 122 | query.resources << "org.kde.dummy.instance1"; |
123 | Akonadi2::Store::synchronize(query).exec(); | 123 | Sink::Store::synchronize(query).exec(); |
124 | }); | 124 | }); |
125 | 125 | ||
126 | auto removeButton = new QPushButton(this); | 126 | auto removeButton = new QPushButton(this); |
127 | removeButton->setText("Remove"); | 127 | removeButton->setText("Remove"); |
128 | QObject::connect(removeButton, &QPushButton::pressed, [modelView]() { | 128 | QObject::connect(removeButton, &QPushButton::pressed, [modelView]() { |
129 | for (auto index : modelView->selectionModel()->selectedIndexes()) { | 129 | for (auto index : modelView->selectionModel()->selectedIndexes()) { |
130 | auto object = index.data(Akonadi2::Store::DomainObjectRole).value<typename T::Ptr>(); | 130 | auto object = index.data(Sink::Store::DomainObjectRole).value<typename T::Ptr>(); |
131 | Akonadi2::Store::remove(*object).exec(); | 131 | Sink::Store::remove(*object).exec(); |
132 | } | 132 | } |
133 | }); | 133 | }); |
134 | 134 | ||
@@ -142,7 +142,7 @@ public: | |||
142 | 142 | ||
143 | }; | 143 | }; |
144 | 144 | ||
145 | static QSharedPointer<QAbstractItemModel> loadModel(const QString &type, Akonadi2::Query query) | 145 | static QSharedPointer<QAbstractItemModel> loadModel(const QString &type, Sink::Query query) |
146 | { | 146 | { |
147 | QTime time; | 147 | QTime time; |
148 | time.start(); | 148 | time.start(); |
@@ -187,13 +187,13 @@ int main(int argc, char *argv[]) | |||
187 | QStringList args = cliOptions.positionalArguments(); | 187 | QStringList args = cliOptions.positionalArguments(); |
188 | 188 | ||
189 | if (cliOptions.isSet("debuglevel")) { | 189 | if (cliOptions.isSet("debuglevel")) { |
190 | Akonadi2::Log::setDebugOutputLevel(static_cast<Akonadi2::Log::DebugLevel>(cliOptions.value("debuglevel").toInt())); | 190 | Sink::Log::setDebugOutputLevel(static_cast<Sink::Log::DebugLevel>(cliOptions.value("debuglevel").toInt())); |
191 | } | 191 | } |
192 | 192 | ||
193 | auto type = !args.isEmpty() ? args.takeFirst() : QByteArray(); | 193 | auto type = !args.isEmpty() ? args.takeFirst() : QByteArray(); |
194 | auto resources = args; | 194 | auto resources = args; |
195 | 195 | ||
196 | Akonadi2::Query query; | 196 | Sink::Query query; |
197 | for (const auto &res : resources) { | 197 | for (const auto &res : resources) { |
198 | query.resources << res.toLatin1(); | 198 | query.resources << res.toLatin1(); |
199 | } | 199 | } |
@@ -208,13 +208,13 @@ int main(int argc, char *argv[]) | |||
208 | model->fetchMore(model->index(i, 0, index)); | 208 | model->fetchMore(model->index(i, 0, index)); |
209 | } | 209 | } |
210 | }); | 210 | }); |
211 | auto view = QSharedPointer<View<Akonadi2::ApplicationDomain::Folder> >::create(model.data()); | 211 | auto view = QSharedPointer<View<Sink::ApplicationDomain::Folder> >::create(model.data()); |
212 | app.exec(); | 212 | app.exec(); |
213 | } else if (type == "mail") { | 213 | } else if (type == "mail") { |
214 | auto view = QSharedPointer<View<Akonadi2::ApplicationDomain::Mail> >::create(model.data()); | 214 | auto view = QSharedPointer<View<Sink::ApplicationDomain::Mail> >::create(model.data()); |
215 | app.exec(); | 215 | app.exec(); |
216 | } else if (type == "event") { | 216 | } else if (type == "event") { |
217 | auto view = QSharedPointer<View<Akonadi2::ApplicationDomain::Event> >::create(model.data()); | 217 | auto view = QSharedPointer<View<Sink::ApplicationDomain::Event> >::create(model.data()); |
218 | app.exec(); | 218 | app.exec(); |
219 | } | 219 | } |
220 | return 0; | 220 | return 0; |