diff options
Diffstat (limited to 'examples/dummyresource/resourcefactory.cpp')
-rw-r--r-- | examples/dummyresource/resourcefactory.cpp | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/examples/dummyresource/resourcefactory.cpp b/examples/dummyresource/resourcefactory.cpp index 0a2e90b..b742611 100644 --- a/examples/dummyresource/resourcefactory.cpp +++ b/examples/dummyresource/resourcefactory.cpp | |||
@@ -41,13 +41,6 @@ | |||
41 | #define ENTITY_TYPE_EVENT "event" | 41 | #define ENTITY_TYPE_EVENT "event" |
42 | #define ENTITY_TYPE_MAIL "mail" | 42 | #define ENTITY_TYPE_MAIL "mail" |
43 | 43 | ||
44 | static void index(const QByteArray &index, const QVariant &value, const QByteArray &uid, Akonadi2::Storage::Transaction &transaction) | ||
45 | { | ||
46 | if (value.isValid()) { | ||
47 | Index(index, transaction).add(value.toByteArray(), uid); | ||
48 | } | ||
49 | } | ||
50 | |||
51 | /** | 44 | /** |
52 | * Index types: | 45 | * Index types: |
53 | * * uid - property | 46 | * * uid - property |
@@ -74,13 +67,20 @@ public: | |||
74 | add(newEntity.getProperty("remoteId"), uid, transaction); | 67 | add(newEntity.getProperty("remoteId"), uid, transaction); |
75 | } | 68 | } |
76 | 69 | ||
77 | void modifiedEntity(const QByteArray &key, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &oldEntity, const Akonadi2::ApplicationDomain::BufferAdaptor &newEntity, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE | 70 | void modifiedEntity(const QByteArray &uid, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &oldEntity, const Akonadi2::ApplicationDomain::BufferAdaptor &newEntity, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE |
78 | { | 71 | { |
72 | Akonadi2::ApplicationDomain::TypeImplementation<DomainType>::removeIndex(uid, oldEntity, transaction); | ||
73 | Akonadi2::ApplicationDomain::TypeImplementation<DomainType>::index(uid, newEntity, transaction); | ||
74 | remove(oldEntity.getProperty("remoteId"), uid, transaction); | ||
75 | add(newEntity.getProperty("remoteId"), uid, transaction); | ||
79 | } | 76 | } |
80 | 77 | ||
81 | void deletedEntity(const QByteArray &key, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &oldEntity, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE | 78 | void deletedEntity(const QByteArray &uid, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &oldEntity, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE |
82 | { | 79 | { |
80 | Akonadi2::ApplicationDomain::TypeImplementation<DomainType>::removeIndex(uid, oldEntity, transaction); | ||
81 | remove(oldEntity.getProperty("remoteId"), uid, transaction); | ||
83 | } | 82 | } |
83 | |||
84 | private: | 84 | private: |
85 | void add(const QVariant &value, const QByteArray &uid, Akonadi2::Storage::Transaction &transaction) | 85 | void add(const QVariant &value, const QByteArray &uid, Akonadi2::Storage::Transaction &transaction) |
86 | { | 86 | { |
@@ -89,16 +89,9 @@ private: | |||
89 | } | 89 | } |
90 | } | 90 | } |
91 | 91 | ||
92 | void remove(const QByteArray &uid, Akonadi2::Storage::Transaction &transaction) | 92 | void remove(const QVariant &value, const QByteArray &uid, Akonadi2::Storage::Transaction &transaction) |
93 | { | ||
94 | //Knowning the indexed value would probably help removing the uid efficiently. Otherwise we have to execute a full scan. | ||
95 | // Index(mIndexIdentifier, transaction).remove(uid); | ||
96 | } | ||
97 | |||
98 | void modify(Akonadi2::Storage::Transaction &transaction) | ||
99 | { | 93 | { |
100 | //Knowning the indexed value would probably help removing the uid efficiently. Otherwise we have to execute a full scan. | 94 | Index(mIndexIdentifier, transaction).remove(value.toByteArray(), uid); |
101 | // Index(mIndexIdentifier, transaction).remove(uid); | ||
102 | } | 95 | } |
103 | 96 | ||
104 | QByteArray mIndexIdentifier; | 97 | QByteArray mIndexIdentifier; |