Changeset View
Changeset View
Standalone View
Standalone View
tests/testlib/gentodo.cpp
Show All 19 Lines | 1 | /* This file is part of Zanshin | |||
---|---|---|---|---|---|
20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | 20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
21 | USA. | 21 | USA. | ||
22 | */ | 22 | */ | ||
23 | 23 | | |||
24 | #include "gentodo.h" | 24 | #include "gentodo.h" | ||
25 | 25 | | |||
26 | #include <KCalCore/Todo> | 26 | #include <KCalCore/Todo> | ||
27 | #include <QDateTime> | 27 | #include <QDateTime> | ||
28 | #include <akonadi/akonadiserializer.h> | ||||
28 | 29 | | |||
29 | using namespace Testlib; | 30 | using namespace Testlib; | ||
30 | 31 | using Akonadi::Serializer; | |||
31 | static const char s_contextListProperty[] = "ContextList"; | | |||
32 | static const char s_appName[] = "Zanshin"; | | |||
33 | 32 | | |||
34 | GenTodo::GenTodo(const Akonadi::Item &item) | 33 | GenTodo::GenTodo(const Akonadi::Item &item) | ||
35 | : m_item(item) | 34 | : m_item(item) | ||
36 | { | 35 | { | ||
37 | m_item.setMimeType(KCalCore::Todo::todoMimeType()); | 36 | m_item.setMimeType(KCalCore::Todo::todoMimeType()); | ||
38 | if (!m_item.hasPayload<KCalCore::Todo::Ptr>()) | 37 | if (!m_item.hasPayload<KCalCore::Todo::Ptr>()) | ||
39 | m_item.setPayload(KCalCore::Todo::Ptr::create()); | 38 | m_item.setPayload(KCalCore::Todo::Ptr::create()); | ||
40 | } | 39 | } | ||
Show All 14 Lines | 53 | { | |||
55 | m_item.setParentCollection(Akonadi::Collection(id)); | 54 | m_item.setParentCollection(Akonadi::Collection(id)); | ||
56 | return *this; | 55 | return *this; | ||
57 | } | 56 | } | ||
58 | 57 | | |||
59 | GenTodo &GenTodo::withContexts(const QStringList &contextUids) | 58 | GenTodo &GenTodo::withContexts(const QStringList &contextUids) | ||
60 | { | 59 | { | ||
61 | auto todo = m_item.payload<KCalCore::Todo::Ptr>(); | 60 | auto todo = m_item.payload<KCalCore::Todo::Ptr>(); | ||
62 | if (contextUids.isEmpty()) | 61 | if (contextUids.isEmpty()) | ||
63 | todo->removeCustomProperty(s_appName, s_contextListProperty); | 62 | todo->removeCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList()); | ||
64 | else | 63 | else | ||
65 | todo->setCustomProperty(s_appName, s_contextListProperty, contextUids.join(',')); | 64 | todo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList(), contextUids.join(',')); | ||
66 | m_item.setPayload<KCalCore::Todo::Ptr>(todo); | 65 | m_item.setPayload<KCalCore::Todo::Ptr>(todo); | ||
67 | return *this; | 66 | return *this; | ||
68 | } | 67 | } | ||
69 | 68 | | |||
70 | GenTodo &GenTodo::asProject(bool value) | 69 | GenTodo &GenTodo::asProject(bool value) | ||
71 | { | 70 | { | ||
72 | auto todo = m_item.payload<KCalCore::Todo::Ptr>(); | 71 | auto todo = m_item.payload<KCalCore::Todo::Ptr>(); | ||
73 | if (value) | 72 | if (value) | ||
74 | todo->setCustomProperty("Zanshin", "Project", QStringLiteral("1")); | 73 | todo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject(), QStringLiteral("1")); | ||
75 | else | 74 | else | ||
76 | todo->removeCustomProperty("Zanshin", "Project"); | 75 | todo->removeCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject()); | ||
77 | return *this; | 76 | return *this; | ||
78 | } | 77 | } | ||
79 | 78 | | |||
80 | GenTodo &GenTodo::asContext(bool value) | 79 | GenTodo &GenTodo::asContext(bool value) | ||
81 | { | 80 | { | ||
82 | auto todo = m_item.payload<KCalCore::Todo::Ptr>(); | 81 | auto todo = m_item.payload<KCalCore::Todo::Ptr>(); | ||
83 | if (value) | 82 | if (value) | ||
84 | todo->setCustomProperty("Zanshin", "Context", QStringLiteral("1")); | 83 | todo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsContext(), QStringLiteral("1")); | ||
85 | else | 84 | else | ||
86 | todo->removeCustomProperty("Zanshin", "Context"); | 85 | todo->removeCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsContext()); | ||
87 | return *this; | 86 | return *this; | ||
88 | } | 87 | } | ||
89 | 88 | | |||
90 | GenTodo &GenTodo::withUid(const QString &uid) | 89 | GenTodo &GenTodo::withUid(const QString &uid) | ||
91 | { | 90 | { | ||
92 | m_item.payload<KCalCore::Todo::Ptr>()->setUid(uid); | 91 | m_item.payload<KCalCore::Todo::Ptr>()->setUid(uid); | ||
93 | return *this; | 92 | return *this; | ||
94 | } | 93 | } | ||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |