58
QOrganizerItemEngineId* QOrganizerItemSkeletonFactory::createItemEngineId(const QMap<QString, QString>& parameters, const QString& idString) const
63
Instantiate your engine-specific item id in this function.
65
If idString is not empty, then you should deserialize the idString
66
(the opposite of your QOrganizerItemEngineId derived-class'
67
toString() function), otherwise you should instantiate an empty
68
engine-specific collection id.
70
This function allows clients to deserialize serialized ids from
74
QOrganizerItemSkeletonEngineId* retn = new QOrganizerItemSkeletonEngineId;
75
if (!idString.isEmpty())
76
retn->m_itemId = idString.toUInt();
80
QOrganizerCollectionEngineId* QOrganizerItemSkeletonFactory::createCollectionEngineId(const QMap<QString, QString>& parameters, const QString& idString) const
85
Instantiate your engine-specific collection id in this function.
87
If idString is not empty, then you should deserialize the idString
88
(the opposite of your QOrganizerCollectionEngineId derived-class'
89
toString() function), otherwise you should instantiate an empty
90
engine-specific collection id.
92
This function allows clients to deserialize serialized ids from
96
QOrganizerCollectionSkeletonEngineId* retn = new QOrganizerCollectionSkeletonEngineId;
97
if (!idString.isEmpty())
98
retn->m_collectionId = idString.toUInt();
64
102
QString QOrganizerItemSkeletonFactory::managerName() const
66
104
/* TODO - put your engine name here */
67
return QString("skeleton");
105
return QLatin1String("skeleton");
69
107
Q_EXPORT_PLUGIN2(qtorganizer_skeleton, QOrganizerItemSkeletonFactory);
109
QOrganizerItemSkeletonEngineId::QOrganizerItemSkeletonEngineId()
110
: QOrganizerItemEngineId(), m_itemId(0)
115
Initialize any data members of your engine-specific item id in the constructor.
117
This default constructor should not be used when returning a null id,
118
but is provided in order to allow use of the ids in a list, and as an
119
enabler for the implementation of QOrganizerItemId.
121
When returning a null id, the backend should simply return a default
122
constructed QOrganizerItemId.
124
In this example, we use just a single quint32 to identify the item,
125
however your engine may require more information in order to uniquely
126
identify an item within it (e.g., a collection identifier plus an item
127
identifier, and perhaps a datastore identifier which identifies the
128
datastore in which the collection can be found).
132
QOrganizerItemSkeletonEngineId::QOrganizerItemSkeletonEngineId(quint32 itemId)
133
: QOrganizerItemEngineId(), m_itemId(itemId)
138
Whatever data members your particular class has, should be passed as arguments
139
to a ctor of this type. This is the constructor which will be used by your
142
In particular, you will most likely be returning to clients an id by calling:
143
QOrganizerItemId id(new QOrganizerItemSkeletonEngineId(3));
144
or something similar. Note that the QOrganizerItemId constructor which
145
takes a QOrganizerItemEngineId pointer as a parameter takes ownership
146
of that pointer (and so controls its lifetime).
150
QOrganizerItemSkeletonEngineId::QOrganizerItemSkeletonEngineId(const QOrganizerItemSkeletonEngineId& other)
151
: QOrganizerItemEngineId(), m_itemId(other.m_itemId)
153
/* TODO - implement a copy constructor for your engine-specific id class */
156
QOrganizerItemSkeletonEngineId::~QOrganizerItemSkeletonEngineId()
158
/* TODO - Clean up any memory in use by your engine-specific id. */
161
bool QOrganizerItemSkeletonEngineId::isEqualTo(const QOrganizerItemEngineId* other) const
166
The isEqualTo(other) function is called by the QOrganizerItemId::operator==(other) function.
167
You must implement this in terms of the data members which your class contains.
169
An example implementation is provided below, for the case where only a single quint32
170
is required to uniquely identify an item in a manager.
173
quint32 otherItemId = static_cast<const QOrganizerItemSkeletonEngineId*>(other)->m_itemId;
174
if (m_itemId != otherItemId)
179
bool QOrganizerItemSkeletonEngineId::isLessThan(const QOrganizerItemEngineId* other) const
184
The isLessThan(other) function is called by the QOrganizerItemId::operator<(other) function.
185
You must implement this in terms of the data members which your class contains.
187
An example implementation is provided below, for the case where only a single quint32
188
is required to uniquely identify an item in a manager.
191
quint32 otherItemId = static_cast<const QOrganizerItemSkeletonEngineId*>(other)->m_itemId;
192
return (m_itemId < otherItemId);
195
QString QOrganizerItemSkeletonEngineId::managerUri() const
197
// TODO: make this return the actual managerUri (including params) of the
198
// engine it is associated with
199
static const QString uri(QLatin1String("qtorganizer:skeleton:"));
203
QOrganizerItemEngineId* QOrganizerItemSkeletonEngineId::clone() const
208
When a QOrganizerItemId is copied or assigned, it performs a clone of
209
the engine-specific id. This function is called in that case.
211
Implement this function so that the data members of your engine-specific id
214
An example implementation for the case where an item can be uniquely identified
215
with just a single quint32 is given below.
218
QOrganizerItemSkeletonEngineId *myClone = new QOrganizerItemSkeletonEngineId;
219
myClone->m_itemId = m_itemId;
223
#ifndef QT_NO_DEBUG_STREAM
224
QDebug& QOrganizerItemSkeletonEngineId::debugStreamOut(QDebug& dbg) const
229
In order to allow clients to debug applications, you must implement this
230
function. We recommend streaming the name of your class followed by the
231
values of the data members in your engine-specific id class in
234
An example implementation for the case where an item can be uniquely identified
235
with just a single quint32 is given below.
237
Note that you must include the #ifndef QT_NO_DEBUG_STREAM preprocessor
238
directive block in order to ensure compilation in environments where that
239
directive is defined.
242
dbg.nospace() << "QOrganizerItemSkeletonEngineId(" << m_itemId << ")";
243
return dbg.maybeSpace();
247
QString QOrganizerItemSkeletonEngineId::toString() const
252
In order to allow clients to serialize QOrganizerItemId's, you must implement
255
An example implementation for the case where an item can be uniquely identified
256
with just a single quint32 is given below.
259
return QString::number(m_itemId);
262
uint QOrganizerItemSkeletonEngineId::hash() const
267
Provide a hash function for your engine-specific id.
268
Note that the hash doesn't strictly need to be unique, since isEqualTo()
269
ensures that individual id's in a single hash-bucket can be uniquely
270
determined; however a better hash function will result in better performance
271
because the ids will be distributed more randomly in a hash table.
273
In the example implementation below, we could simply return the id, since the
274
id is a quint32. In more complex id classes, however, you may need to
275
qHash() individual data members and combine the results somehow.
278
return QT_PREPEND_NAMESPACE(qHash)(m_itemId);
282
QOrganizerCollectionSkeletonEngineId::QOrganizerCollectionSkeletonEngineId()
283
: QOrganizerCollectionEngineId(), m_collectionId(0)
288
Initialize any data members of your engine-specific collection id in the constructor.
290
This default constructor should not be used when returning a null id,
291
but is provided in order to allow use of the ids in a list, and as an
292
enabler for the implementation of QOrganizerCollectionId.
294
When returning a null id, the backend should simply return a default
295
constructed QOrganizerCollectionId.
297
In this example, we use just a single quint32 to identify the collection,
298
however your engine may require more information in order to uniquely
299
identify a collection within it (e.g., a collection identifier plus a datastore
300
identifier which identifies the datastore in which the collection can be found).
304
QOrganizerCollectionSkeletonEngineId::QOrganizerCollectionSkeletonEngineId(quint32 collectionId)
305
: QOrganizerCollectionEngineId(), m_collectionId(collectionId)
310
Whatever data members your particular class has, should be passed as arguments
311
to a ctor of this type. This is the constructor which will be used by your
314
In particular, you will most likely be returning to clients an id by calling:
315
QOrganizerCollectionId id(new QOrganizerCollectionSkeletonEngineId(3));
316
or something similar. Note that the QOrganizerCollectionId constructor which
317
takes a QOrganizerCollectionEngineId pointer as a parameter takes ownership
318
of that pointer (and so controls its lifetime).
322
QOrganizerCollectionSkeletonEngineId::QOrganizerCollectionSkeletonEngineId(const QOrganizerCollectionSkeletonEngineId& other)
323
: QOrganizerCollectionEngineId(), m_collectionId(other.m_collectionId)
325
/* TODO - implement a copy constructor for your engine-specific id class */
328
QOrganizerCollectionSkeletonEngineId::~QOrganizerCollectionSkeletonEngineId()
330
/* TODO - Clean up any memory in use by your engine-specific id. */
333
bool QOrganizerCollectionSkeletonEngineId::isEqualTo(const QOrganizerCollectionEngineId* other) const
338
The isEqualTo(other) function is called by the QOrganizerCollectionId::operator==(other) function.
339
You must implement this in terms of the data members which your class contains.
341
An example implementation is provided below, for the case where only a single quint32
342
is required to uniquely identify a collection in a manager.
345
quint32 otherCollectionId = static_cast<const QOrganizerCollectionSkeletonEngineId*>(other)->m_collectionId;
346
if (m_collectionId != otherCollectionId)
351
bool QOrganizerCollectionSkeletonEngineId::isLessThan(const QOrganizerCollectionEngineId* other) const
356
The isLessThan(other) function is called by the QOrganizerCollectionId::operator<(other) function.
357
You must implement this in terms of the data members which your class contains.
359
An example implementation is provided below, for the case where only a single quint32
360
is required to uniquely identify a collection in a manager.
363
quint32 otherCollectionId = static_cast<const QOrganizerCollectionSkeletonEngineId*>(other)->m_collectionId;
364
if (m_collectionId < otherCollectionId)
369
QString QOrganizerCollectionSkeletonEngineId::managerUri() const
371
// TODO: make this return the actual managerUri (including params) of the
372
// engine it is associated with
373
static const QString uri(QLatin1String("qtorganizer:skeleton:"));
377
QOrganizerCollectionEngineId* QOrganizerCollectionSkeletonEngineId::clone() const
382
When a QOrganizerCollectionId is copied or assigned, it performs a clone of
383
the engine-specific id. This function is called in that case.
385
Implement this function so that the data members of your engine-specific id
388
An example implementation for the case where a collection can be uniquely identified
389
with just a single quint32 is given below.
392
QOrganizerCollectionSkeletonEngineId *myClone = new QOrganizerCollectionSkeletonEngineId;
393
myClone->m_collectionId = m_collectionId;
397
#ifndef QT_NO_DEBUG_STREAM
398
QDebug& QOrganizerCollectionSkeletonEngineId::debugStreamOut(QDebug& dbg) const
403
In order to allow clients to debug applications, you must implement this
404
function. We recommend streaming the name of your class followed by the
405
values of the data members in your engine-specific id class in
408
An example implementation for the case where a collection can be uniquely identified
409
with just a single quint32 is given below.
411
Note that you must include the #ifndef QT_NO_DEBUG_STREAM preprocessor
412
directive block in order to ensure compilation in environments where that
413
directive is defined.
416
dbg.nospace() << "QOrganizerCollectionSkeletonEngineId(" << m_collectionId << ")";
417
return dbg.maybeSpace();
421
QString QOrganizerCollectionSkeletonEngineId::toString() const
426
In order to allow clients to serialize QOrganizerCollectionId's, you must implement
429
An example implementation for the case where a collection can be uniquely identified
430
with just a single quint32 is given below.
433
return QString::number(m_collectionId);
436
uint QOrganizerCollectionSkeletonEngineId::hash() const
441
Provide a hash function for your engine-specific id.
442
Note that the hash doesn't strictly need to be unique, since isEqualTo()
443
ensures that individual id's in a single hash-bucket can be uniquely
444
determined; however a better hash function will result in better performance
445
because the ids will be distributed more randomly in a hash table.
447
In the example implementation below, we could simply return the id, since the
448
id is a quint32. In more complex id classes, however, you may need to
449
qHash() individual data members and combine the results somehow.
452
return QT_PREPEND_NAMESPACE(qHash)(m_collectionId);
72
457
QOrganizerItemSkeletonEngine::~QOrganizerItemSkeletonEngine()
191
578
fetch at least what is mentioned in the fetch hint).
194
return QOrganizerItemManagerEngine::item(itemId, fetchHint, error);
581
return QOrganizerManagerEngine::item(itemId, fetchHint, error);
197
bool QOrganizerItemSkeletonEngine::saveItems(QList<QOrganizerItem>* items, const QOrganizerCollectionLocalId& collectionId, QMap<int, QOrganizerItemManager::Error>* errorMap, QOrganizerItemManager::Error* error)
584
bool QOrganizerItemSkeletonEngine::saveItems(QList<QOrganizerItem>* items, QMap<int, QOrganizerManager::Error>* errorMap, QOrganizerManager::Error* error)
202
Save a list of items into the collection specified (or their current collection
589
Save a list of items into the collection specified in each (or their current collection
203
590
if no collection is specified and they already exist, or the default collection
204
591
if no collection is specified and they do not exist).
206
For each item, convert it to your local type, assign an item id, and update the
593
For each item, convert it to your type, assign an item id, and update the
207
594
QOrganizerItem's ID (in the list above - e.g. *items[idx] = updated item).
595
Then, examine the collection id specified in each item and save the item in that collection.
209
If you encounter an error (e.g. converting to local type, or saving), insert an entry into
597
If you encounter an error (e.g. converting to type, or saving), insert an entry into
210
598
the map above at the corresponding index (e.g. errorMap->insert(idx, QOIM::InvalidDetailError).
211
599
You should set the "error" variable as well (first, last, most serious error etc).
213
601
The item passed in should be validated according to the schema.
215
return QOrganizerItemManagerEngine::saveItems(items, collectionId, errorMap, error);
603
return QOrganizerManagerEngine::saveItems(items, errorMap, error);
219
bool QOrganizerItemSkeletonEngine::removeItems(const QList<QOrganizerItemLocalId>& itemIds, QMap<int, QOrganizerItemManager::Error>* errorMap, QOrganizerItemManager::Error* error)
607
bool QOrganizerItemSkeletonEngine::removeItems(const QList<QOrganizerItemId>& itemIds, QMap<int, QOrganizerManager::Error>* errorMap, QOrganizerManager::Error* error)
229
617
DoesNotExistError should be used if the id refers to a non existent item.
231
return QOrganizerItemManagerEngine::removeItems(itemIds, errorMap, error);
619
return QOrganizerManagerEngine::removeItems(itemIds, errorMap, error);
234
QMap<QString, QOrganizerItemDetailDefinition> QOrganizerItemSkeletonEngine::detailDefinitions(const QString& itemType, QOrganizerItemManager::Error* error) const
622
QMap<QString, QOrganizerItemDetailDefinition> QOrganizerItemSkeletonEngine::detailDefinitions(const QString& itemType, QOrganizerManager::Error* error) const
236
624
/* TODO - once you know what your engine will support, implement this properly. One way is to call the base version, and add/remove things as needed */
237
return QOrganizerItemManagerEngine::detailDefinitions(itemType, error);
625
return QOrganizerManagerEngine::detailDefinitions(itemType, error);
240
QOrganizerItemDetailDefinition QOrganizerItemSkeletonEngine::detailDefinition(const QString& definitionId, const QString& itemType, QOrganizerItemManager::Error* error) const
628
QOrganizerItemDetailDefinition QOrganizerItemSkeletonEngine::detailDefinition(const QString& definitionId, const QString& itemType, QOrganizerManager::Error* error) const
242
630
/* TODO - the default implementation just calls the base detailDefinitions function. If that's inefficent, implement this */
243
return QOrganizerItemManagerEngine::detailDefinition(definitionId, itemType, error);
631
return QOrganizerManagerEngine::detailDefinition(definitionId, itemType, error);
246
bool QOrganizerItemSkeletonEngine::saveDetailDefinition(const QOrganizerItemDetailDefinition& def, const QString& itemType, QOrganizerItemManager::Error* error)
634
bool QOrganizerItemSkeletonEngine::saveDetailDefinition(const QOrganizerItemDetailDefinition& def, const QString& itemType, QOrganizerManager::Error* error)
248
636
/* TODO - if you support adding custom fields, do that here. Otherwise call the base functionality. */
249
return QOrganizerItemManagerEngine::saveDetailDefinition(def, itemType, error);
637
return QOrganizerManagerEngine::saveDetailDefinition(def, itemType, error);
252
bool QOrganizerItemSkeletonEngine::removeDetailDefinition(const QString& definitionId, const QString& itemType, QOrganizerItemManager::Error* error)
640
bool QOrganizerItemSkeletonEngine::removeDetailDefinition(const QString& definitionId, const QString& itemType, QOrganizerManager::Error* error)
254
642
/* TODO - if you support removing custom fields, do that here. Otherwise call the base functionality. */
255
return QOrganizerItemManagerEngine::removeDetailDefinition(definitionId, itemType, error);
643
return QOrganizerManagerEngine::removeDetailDefinition(definitionId, itemType, error);
259
QOrganizerCollectionLocalId QOrganizerItemSkeletonEngine::defaultCollectionId(QOrganizerItemManager::Error* error) const
647
QOrganizerCollection QOrganizerItemSkeletonEngine::defaultCollection(QOrganizerManager::Error* error) const
264
652
This allows clients to determine which collection an item will be saved,
265
653
if the item is saved via saveItems() without specifying a collection id
266
of a collection in which to save the item.
268
If the backend does not support multiple collections (calendars) it may
269
return the default constructed collection id.
654
of a collection in which to save the item, via item->setCollectionId().
271
656
There is always at least one collection in a manager, and all items are
272
657
saved in exactly one collection.
274
return QOrganizerItemManagerEngine::defaultCollectionId(error);
277
QList<QOrganizerCollectionLocalId> QOrganizerItemSkeletonEngine::collectionIds(QOrganizerItemManager::Error* error) const
282
This allows clients to retrieve the ids of all collections currently
659
return QOrganizerManagerEngine::defaultCollection(error);
662
QOrganizerCollection QOrganizerItemSkeletonEngine::collection(const QOrganizerCollectionId& collectionId, QOrganizerManager::Error* error) const
667
This allows clients to retrieve a collection by (manager) id.
668
Prior to saving items, clients will set which collection the item will/should
669
be saved by calling item->setCollectionId().
671
return QOrganizerManagerEngine::collection(collectionId, error);
674
QList<QOrganizerCollection> QOrganizerItemSkeletonEngine::collections(QOrganizerManager::Error* error) const
679
This allows clients to retrieve a list of all of the collections currently
283
680
in this manager. Some backends will have a prepopulated list of valid
284
collections, others will not.
286
return QOrganizerItemManagerEngine::collectionIds(error);
289
QList<QOrganizerCollection> QOrganizerItemSkeletonEngine::collections(const QList<QOrganizerCollectionLocalId>& collectionIds, QOrganizerItemManager::Error* error) const
294
This allows clients to retrieve the collections which correspond
295
to the given collection ids. A collection can have properties
681
collections, others will not. A collection can have properties
296
682
like colour, description, perhaps a priority, etc etc.
298
return QOrganizerItemManagerEngine::collections(collectionIds, error);
684
return QOrganizerManagerEngine::collections(error);
301
bool QOrganizerItemSkeletonEngine::saveCollection(QOrganizerCollection* collection, QOrganizerItemManager::Error* error)
687
bool QOrganizerItemSkeletonEngine::saveCollection(QOrganizerCollection* collection, QOrganizerManager::Error* error)