diff options
Diffstat (limited to 'examples/dummyresource/dummystore.cpp')
-rw-r--r-- | examples/dummyresource/dummystore.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/examples/dummyresource/dummystore.cpp b/examples/dummyresource/dummystore.cpp index 5a3f74b..41b48ed 100644 --- a/examples/dummyresource/dummystore.cpp +++ b/examples/dummyresource/dummystore.cpp | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <QString> | 21 | #include <QString> |
22 | 22 | ||
23 | #include "dummycalendar_generated.h" | 23 | #include "dummycalendar_generated.h" |
24 | #include "mail_generated.h" | ||
24 | 25 | ||
25 | static std::string createEvent(int i) | 26 | static std::string createEvent(int i) |
26 | { | 27 | { |
@@ -43,6 +44,20 @@ static std::string createEvent(int i) | |||
43 | return std::string(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); | 44 | return std::string(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); |
44 | } | 45 | } |
45 | 46 | ||
47 | static std::string createMail(int i) | ||
48 | { | ||
49 | static flatbuffers::FlatBufferBuilder fbb; | ||
50 | fbb.Clear(); | ||
51 | { | ||
52 | auto subject = fbb.CreateString("summary" + std::to_string(i)); | ||
53 | Akonadi2::ApplicationDomain::Buffer::MailBuilder mailBuilder(fbb); | ||
54 | mailBuilder.add_subject(subject); | ||
55 | Akonadi2::ApplicationDomain::Buffer::FinishMailBuffer(fbb, mailBuilder.Finish()); | ||
56 | } | ||
57 | |||
58 | return std::string(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); | ||
59 | } | ||
60 | |||
46 | QMap<QString, QString> populate() | 61 | QMap<QString, QString> populate() |
47 | { | 62 | { |
48 | QMap<QString, QString> content; | 63 | QMap<QString, QString> content; |
@@ -53,10 +68,24 @@ QMap<QString, QString> populate() | |||
53 | return content; | 68 | return content; |
54 | } | 69 | } |
55 | 70 | ||
56 | static QMap<QString, QString> s_dataSource = populate(); | 71 | QMap<QString, QString> populateMails() |
72 | { | ||
73 | QMap<QString, QString> content; | ||
74 | for (int i = 0; i < 2; i++) { | ||
75 | content.insert(QString("key%1").arg(i), QString::fromStdString(createMail(i))); | ||
76 | } | ||
77 | return content; | ||
78 | } | ||
57 | 79 | ||
80 | static QMap<QString, QString> s_dataSource = populate(); | ||
81 | static QMap<QString, QString> s_mailSource = populateMails(); | ||
58 | 82 | ||
59 | QMap<QString, QString> DummyStore::data() const | 83 | QMap<QString, QString> DummyStore::events() const |
60 | { | 84 | { |
61 | return s_dataSource; | 85 | return s_dataSource; |
62 | } | 86 | } |
87 | |||
88 | QMap<QString, QString> DummyStore::mails() const | ||
89 | { | ||
90 | return s_mailSource; | ||
91 | } | ||