~ubuntu-branches/ubuntu/quantal/qtmobility/quantal

« back to all changes in this revision

Viewing changes to plugins/organizer/skeleton/qorganizerskeleton.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-11-16 16:18:07 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20101116161807-k2dzt2nyse975r3l
Tags: 1.1.0-0ubuntu1
* New upstream release
* Syncronise with Debian, no remaining changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
**
9
9
** $QT_BEGIN_LICENSE:LGPL$
10
10
** Commercial Usage
11
 
** Licensees holding valid Qt Commercial licenses may use this file in
12
 
** accordance with the Qt Solutions Commercial License Agreement provided
13
 
** with the Software or, alternatively, in accordance with the terms
 
11
** Licensees holding valid Qt Commercial licenses may use this file in 
 
12
** accordance with the Qt Commercial License Agreement provided with
 
13
** the Software or, alternatively, in accordance with the terms
14
14
** contained in a written agreement between you and Nokia.
15
15
**
16
16
** GNU Lesser General Public License Usage
33
33
** ensure the GNU General Public License version 3.0 requirements will be
34
34
** met: http://www.gnu.org/copyleft/gpl.html.
35
35
**
36
 
** Please note Third Party Software included with Qt Solutions may impose
37
 
** additional restrictions and it is the user's responsibility to ensure
38
 
** that they have met the licensing requirements of the GPL, LGPL, or Qt
39
 
** Solutions Commercial license and the relevant license of the Third
40
 
** Party Software they are using.
41
 
**
42
36
** If you are unsure which license is appropriate for your use, please
43
37
** contact the sales department at qt-sales@nokia.com.
44
38
** $QT_END_LICENSE$
50
44
 
51
45
//QTM_USE_NAMESPACE
52
46
 
53
 
QOrganizerItemManagerEngine* QOrganizerItemSkeletonFactory::engine(const QMap<QString, QString>& parameters, QOrganizerItemManager::Error* error)
 
47
QOrganizerManagerEngine* QOrganizerItemSkeletonFactory::engine(const QMap<QString, QString>& parameters, QOrganizerManager::Error* error)
54
48
{
55
49
    Q_UNUSED(parameters);
56
50
    Q_UNUSED(error);
61
55
    return ret;
62
56
}
63
57
 
 
58
QOrganizerItemEngineId* QOrganizerItemSkeletonFactory::createItemEngineId(const QMap<QString, QString>& parameters, const QString& idString) const
 
59
{
 
60
    /*
 
61
      TODO
 
62
 
 
63
      Instantiate your engine-specific item id in this function.
 
64
 
 
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.
 
69
 
 
70
      This function allows clients to deserialize serialized ids from
 
71
      your engine.
 
72
     */
 
73
    Q_UNUSED(parameters);
 
74
    QOrganizerItemSkeletonEngineId* retn = new QOrganizerItemSkeletonEngineId;
 
75
    if (!idString.isEmpty())
 
76
        retn->m_itemId = idString.toUInt();
 
77
    return retn;
 
78
}
 
79
 
 
80
QOrganizerCollectionEngineId* QOrganizerItemSkeletonFactory::createCollectionEngineId(const QMap<QString, QString>& parameters, const QString& idString) const
 
81
{
 
82
    /*
 
83
      TODO
 
84
 
 
85
      Instantiate your engine-specific collection id in this function.
 
86
 
 
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.
 
91
 
 
92
      This function allows clients to deserialize serialized ids from
 
93
      your engine.
 
94
     */
 
95
    Q_UNUSED(parameters);
 
96
    QOrganizerCollectionSkeletonEngineId* retn = new QOrganizerCollectionSkeletonEngineId;
 
97
    if (!idString.isEmpty())
 
98
        retn->m_collectionId = idString.toUInt();
 
99
    return retn;
 
100
}
 
101
 
64
102
QString QOrganizerItemSkeletonFactory::managerName() const
65
103
{
66
104
    /* TODO - put your engine name here */
67
 
    return QString("skeleton");
 
105
    return QLatin1String("skeleton");
68
106
}
69
107
Q_EXPORT_PLUGIN2(qtorganizer_skeleton, QOrganizerItemSkeletonFactory);
70
108
 
 
109
QOrganizerItemSkeletonEngineId::QOrganizerItemSkeletonEngineId()
 
110
    : QOrganizerItemEngineId(), m_itemId(0)
 
111
{
 
112
    /*
 
113
      TODO
 
114
 
 
115
      Initialize any data members of your engine-specific item id in the constructor.
 
116
 
 
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.
 
120
 
 
121
      When returning a null id, the backend should simply return a default
 
122
      constructed QOrganizerItemId.
 
123
 
 
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).
 
129
     */
 
130
}
 
131
 
 
132
QOrganizerItemSkeletonEngineId::QOrganizerItemSkeletonEngineId(quint32 itemId)
 
133
    : QOrganizerItemEngineId(), m_itemId(itemId)
 
134
{
 
135
    /*
 
136
      TODO
 
137
 
 
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
 
140
      engine code.
 
141
 
 
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).
 
147
     */
 
148
}
 
149
 
 
150
QOrganizerItemSkeletonEngineId::QOrganizerItemSkeletonEngineId(const QOrganizerItemSkeletonEngineId& other)
 
151
    : QOrganizerItemEngineId(), m_itemId(other.m_itemId)
 
152
{
 
153
    /* TODO - implement a copy constructor for your engine-specific id class */
 
154
}
 
155
 
 
156
QOrganizerItemSkeletonEngineId::~QOrganizerItemSkeletonEngineId()
 
157
{
 
158
    /* TODO - Clean up any memory in use by your engine-specific id. */
 
159
}
 
160
 
 
161
bool QOrganizerItemSkeletonEngineId::isEqualTo(const QOrganizerItemEngineId* other) const
 
162
{
 
163
    /*
 
164
      TODO
 
165
 
 
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.
 
168
 
 
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.
 
171
     */
 
172
 
 
173
    quint32 otherItemId = static_cast<const QOrganizerItemSkeletonEngineId*>(other)->m_itemId;
 
174
    if (m_itemId != otherItemId)
 
175
        return false;
 
176
    return true;
 
177
}
 
178
 
 
179
bool QOrganizerItemSkeletonEngineId::isLessThan(const QOrganizerItemEngineId* other) const
 
180
{
 
181
    /*
 
182
      TODO
 
183
 
 
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.
 
186
 
 
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.
 
189
     */
 
190
 
 
191
    quint32 otherItemId = static_cast<const QOrganizerItemSkeletonEngineId*>(other)->m_itemId;
 
192
    return (m_itemId < otherItemId);
 
193
}
 
194
 
 
195
QString QOrganizerItemSkeletonEngineId::managerUri() const
 
196
{
 
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:"));
 
200
    return uri;
 
201
}
 
202
 
 
203
QOrganizerItemEngineId* QOrganizerItemSkeletonEngineId::clone() const
 
204
{
 
205
    /*
 
206
      TODO
 
207
 
 
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.
 
210
 
 
211
      Implement this function so that the data members of your engine-specific id
 
212
      are deep-copied.
 
213
 
 
214
      An example implementation for the case where an item can be uniquely identified
 
215
      with just a single quint32 is given below.
 
216
     */
 
217
 
 
218
    QOrganizerItemSkeletonEngineId *myClone = new QOrganizerItemSkeletonEngineId;
 
219
    myClone->m_itemId = m_itemId;
 
220
    return myClone;
 
221
}
 
222
 
 
223
#ifndef QT_NO_DEBUG_STREAM
 
224
QDebug& QOrganizerItemSkeletonEngineId::debugStreamOut(QDebug& dbg) const
 
225
{
 
226
    /*
 
227
      TODO
 
228
 
 
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
 
232
      parentheses.
 
233
 
 
234
      An example implementation for the case where an item can be uniquely identified
 
235
      with just a single quint32 is given below.
 
236
 
 
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.
 
240
     */
 
241
 
 
242
    dbg.nospace() << "QOrganizerItemSkeletonEngineId(" << m_itemId << ")";
 
243
    return dbg.maybeSpace();
 
244
}
 
245
#endif
 
246
 
 
247
QString QOrganizerItemSkeletonEngineId::toString() const
 
248
{
 
249
    /*
 
250
      TODO
 
251
 
 
252
      In order to allow clients to serialize QOrganizerItemId's, you must implement
 
253
      this function.
 
254
 
 
255
      An example implementation for the case where an item can be uniquely identified
 
256
      with just a single quint32 is given below.
 
257
     */
 
258
 
 
259
    return QString::number(m_itemId);
 
260
}
 
261
 
 
262
uint QOrganizerItemSkeletonEngineId::hash() const
 
263
{
 
264
    /*
 
265
      TODO
 
266
 
 
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.
 
272
 
 
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.
 
276
     */
 
277
 
 
278
    return QT_PREPEND_NAMESPACE(qHash)(m_itemId);
 
279
}
 
280
 
 
281
 
 
282
QOrganizerCollectionSkeletonEngineId::QOrganizerCollectionSkeletonEngineId()
 
283
    : QOrganizerCollectionEngineId(), m_collectionId(0)
 
284
{
 
285
    /*
 
286
      TODO
 
287
 
 
288
      Initialize any data members of your engine-specific collection id in the constructor.
 
289
 
 
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.
 
293
 
 
294
      When returning a null id, the backend should simply return a default
 
295
      constructed QOrganizerCollectionId.
 
296
 
 
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).
 
301
     */
 
302
}
 
303
 
 
304
QOrganizerCollectionSkeletonEngineId::QOrganizerCollectionSkeletonEngineId(quint32 collectionId)
 
305
    : QOrganizerCollectionEngineId(), m_collectionId(collectionId)
 
306
{
 
307
    /*
 
308
      TODO
 
309
 
 
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
 
312
      engine code.
 
313
 
 
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).
 
319
     */
 
320
}
 
321
 
 
322
QOrganizerCollectionSkeletonEngineId::QOrganizerCollectionSkeletonEngineId(const QOrganizerCollectionSkeletonEngineId& other)
 
323
    : QOrganizerCollectionEngineId(), m_collectionId(other.m_collectionId)
 
324
{
 
325
    /* TODO - implement a copy constructor for your engine-specific id class */
 
326
}
 
327
 
 
328
QOrganizerCollectionSkeletonEngineId::~QOrganizerCollectionSkeletonEngineId()
 
329
{
 
330
    /* TODO - Clean up any memory in use by your engine-specific id. */
 
331
}
 
332
 
 
333
bool QOrganizerCollectionSkeletonEngineId::isEqualTo(const QOrganizerCollectionEngineId* other) const
 
334
{
 
335
    /*
 
336
      TODO
 
337
 
 
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.
 
340
 
 
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.
 
343
     */
 
344
 
 
345
    quint32 otherCollectionId = static_cast<const QOrganizerCollectionSkeletonEngineId*>(other)->m_collectionId;
 
346
    if (m_collectionId != otherCollectionId)
 
347
        return false;
 
348
    return true;
 
349
}
 
350
 
 
351
bool QOrganizerCollectionSkeletonEngineId::isLessThan(const QOrganizerCollectionEngineId* other) const
 
352
{
 
353
    /*
 
354
      TODO
 
355
 
 
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.
 
358
 
 
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.
 
361
     */
 
362
 
 
363
    quint32 otherCollectionId = static_cast<const QOrganizerCollectionSkeletonEngineId*>(other)->m_collectionId;
 
364
    if (m_collectionId < otherCollectionId)
 
365
        return true;
 
366
    return false;
 
367
}
 
368
 
 
369
QString QOrganizerCollectionSkeletonEngineId::managerUri() const
 
370
{
 
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:"));
 
374
    return uri;
 
375
}
 
376
 
 
377
QOrganizerCollectionEngineId* QOrganizerCollectionSkeletonEngineId::clone() const
 
378
{
 
379
    /*
 
380
      TODO
 
381
 
 
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.
 
384
 
 
385
      Implement this function so that the data members of your engine-specific id
 
386
      are deep-copied.
 
387
 
 
388
      An example implementation for the case where a collection can be uniquely identified
 
389
      with just a single quint32 is given below.
 
390
     */
 
391
 
 
392
    QOrganizerCollectionSkeletonEngineId *myClone = new QOrganizerCollectionSkeletonEngineId;
 
393
    myClone->m_collectionId = m_collectionId;
 
394
    return myClone;
 
395
}
 
396
 
 
397
#ifndef QT_NO_DEBUG_STREAM
 
398
QDebug& QOrganizerCollectionSkeletonEngineId::debugStreamOut(QDebug& dbg) const
 
399
{
 
400
    /*
 
401
      TODO
 
402
 
 
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
 
406
      parentheses.
 
407
 
 
408
      An example implementation for the case where a collection can be uniquely identified
 
409
      with just a single quint32 is given below.
 
410
 
 
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.
 
414
     */
 
415
 
 
416
    dbg.nospace() << "QOrganizerCollectionSkeletonEngineId(" << m_collectionId << ")";
 
417
    return dbg.maybeSpace();
 
418
}
 
419
#endif
 
420
 
 
421
QString QOrganizerCollectionSkeletonEngineId::toString() const
 
422
{
 
423
    /*
 
424
      TODO
 
425
 
 
426
      In order to allow clients to serialize QOrganizerCollectionId's, you must implement
 
427
      this function.
 
428
 
 
429
      An example implementation for the case where a collection can be uniquely identified
 
430
      with just a single quint32 is given below.
 
431
     */
 
432
 
 
433
    return QString::number(m_collectionId);
 
434
}
 
435
 
 
436
uint QOrganizerCollectionSkeletonEngineId::hash() const
 
437
{
 
438
    /*
 
439
      TODO
 
440
 
 
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.
 
446
 
 
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.
 
450
     */
 
451
 
 
452
    return QT_PREPEND_NAMESPACE(qHash)(m_collectionId);
 
453
}
 
454
 
 
455
 
71
456
 
72
457
QOrganizerItemSkeletonEngine::~QOrganizerItemSkeletonEngine()
73
458
{
77
462
QString QOrganizerItemSkeletonEngine::managerName() const
78
463
{
79
464
    /* TODO - put your engine name here */
80
 
    return QLatin1String("Skeleton");
 
465
    return QLatin1String("skeleton");
81
466
}
82
467
 
83
468
QMap<QString, QString> QOrganizerItemSkeletonEngine::managerParameters() const
92
477
    return 1;
93
478
}
94
479
 
95
 
QList<QOrganizerItem> QOrganizerItemSkeletonEngine::itemInstances(const QOrganizerItem& generator, const QDateTime& periodStart, const QDateTime& periodEnd, int maxCount, QOrganizerItemManager::Error* error) const
 
480
QList<QOrganizerItem> QOrganizerItemSkeletonEngine::itemOccurrences(const QOrganizerItem& parentItem, const QDateTime& periodStart, const QDateTime& periodEnd, int maxCount, const QOrganizerItemFetchHint& fetchHint, QOrganizerManager::Error* error) const
96
481
{
97
482
    /*
98
483
        TODO
99
484
 
100
 
        This function should create a list of instances that occur in the time period from the supplied item.
 
485
        This function should create a list of occurrences that occur in the time period from the supplied item,
 
486
        generated from the parent item.
 
487
 
101
488
        The periodStart should always be valid, and either the periodEnd or the maxCount will be valid (if periodEnd is
102
489
        valid, use that.  Otherwise use the count).  It's permissible to limit the number of items returned...
103
490
 
104
 
        Basically, if the generator item is an Event, a list of EventOccurrences should be returned.  Similarly for
 
491
        Basically, if the parent item is an Event, a list of EventOccurrences should be returned.  Similarly for
105
492
        Todo/TodoOccurrence.
106
493
 
107
494
        If there are no instances, return an empty list.
108
495
 
109
 
        The returned items should have a QOrganizerItemInstanceOrigin detail that points to the generator and the
 
496
        The returned items should have a QOrganizerItemParent detail that points to the parentItem and the
110
497
        original instance that the event would have occurred on (e.g. with an exception).
111
498
 
112
499
        They should not have recurrence information details in them.
114
501
        We might change the signature to split up the periodStart + periodEnd / periodStart + maxCount cases.
115
502
    */
116
503
 
117
 
    return QOrganizerItemManagerEngine::itemInstances(generator, periodStart, periodEnd, maxCount, error);
 
504
    return QOrganizerManagerEngine::itemOccurrences(parentItem, periodStart, periodEnd, maxCount, fetchHint, error);
118
505
}
119
506
 
120
 
QList<QOrganizerItemLocalId> QOrganizerItemSkeletonEngine::itemIds(const QOrganizerItemFilter& filter, const QList<QOrganizerItemSortOrder>& sortOrders, QOrganizerItemManager::Error* error) const
 
507
QList<QOrganizerItemId> QOrganizerItemSkeletonEngine::itemIds(const QDateTime& startDate, const QDateTime& endDate, const QOrganizerItemFilter& filter, const QList<QOrganizerItemSortOrder>& sortOrders, QOrganizerManager::Error* error) const
121
508
{
122
509
    /*
123
510
        TODO
130
517
        If you do have to fetch, consider setting a fetch hint that restricts the information to that needed for filtering/sorting.
131
518
    */
132
519
 
133
 
    *error = QOrganizerItemManager::NotSupportedError; // TODO <- remove this
 
520
    *error = QOrganizerManager::NotSupportedError; // TODO <- remove this
134
521
 
135
522
    QList<QOrganizerItem> partiallyFilteredItems; // = ..., your code here.. [TODO]
136
523
    QList<QOrganizerItem> ret;
137
524
 
138
525
    foreach(const QOrganizerItem& item, partiallyFilteredItems) {
139
 
        if (QOrganizerItemManagerEngine::testFilter(filter, item)) {
140
 
            ret.append(item);
 
526
        if (QOrganizerManagerEngine::isItemBetweenDates(item, startDate, endDate) && QOrganizerManagerEngine::testFilter(filter, item)) {
 
527
            QOrganizerManagerEngine::addSorted(&ret, item, sortOrders);
141
528
        }
142
529
    }
143
530
 
144
 
    return QOrganizerItemManagerEngine::sortItems(ret, sortOrders);
 
531
    return QOrganizerManager::extractIds(ret);
145
532
}
146
533
 
147
 
QList<QOrganizerItem> QOrganizerItemSkeletonEngine::items(const QOrganizerItemFilter& filter, const QList<QOrganizerItemSortOrder>& sortOrders, const QOrganizerItemFetchHint& fetchHint, QOrganizerItemManager::Error* error) const
 
534
QList<QOrganizerItem> QOrganizerItemSkeletonEngine::items(const QDateTime& startDate, const QDateTime& endDate, const QOrganizerItemFilter& filter, const QList<QOrganizerItemSortOrder>& sortOrders, const QOrganizerItemFetchHint& fetchHint, QOrganizerManager::Error* error) const
148
535
{
149
536
    /*
150
537
        TODO
159
546
    */
160
547
 
161
548
    Q_UNUSED(fetchHint);
162
 
    *error = QOrganizerItemManager::NotSupportedError; // TODO <- remove this
 
549
    *error = QOrganizerManager::NotSupportedError; // TODO <- remove this
163
550
 
164
551
    QList<QOrganizerItem> partiallyFilteredItems; // = ..., your code here.. [TODO]
165
552
    QList<QOrganizerItem> ret;
166
553
 
167
554
    foreach(const QOrganizerItem& item, partiallyFilteredItems) {
168
 
        if (QOrganizerItemManagerEngine::testFilter(filter, item)) {
169
 
            QOrganizerItemManagerEngine::addSorted(&ret, item, sortOrders);
 
555
        if (QOrganizerManagerEngine::isItemBetweenDates(item, startDate, endDate) && QOrganizerManagerEngine::testFilter(filter, item)) {
 
556
            QOrganizerManagerEngine::addSorted(&ret, item, sortOrders);
170
557
        }
171
558
    }
172
559
 
173
560
    /* An alternative formulation, depending on how your engine is implemented is just:
174
561
 
175
 
        foreach(const QOrganizerItemLocalId& id, itemIds(filter, sortOrders, error)) {
 
562
        foreach(const QOrganizerItemId& id, itemIds(filter, sortOrders, error)) {
176
563
            ret.append(item(id, fetchHint, error);
177
564
        }
178
565
     */
180
567
    return ret;
181
568
}
182
569
 
183
 
QOrganizerItem QOrganizerItemSkeletonEngine::item(const QOrganizerItemLocalId& itemId, const QOrganizerItemFetchHint& fetchHint, QOrganizerItemManager::Error* error) const
 
570
QOrganizerItem QOrganizerItemSkeletonEngine::item(const QOrganizerItemId& itemId, const QOrganizerItemFetchHint& fetchHint, QOrganizerManager::Error* error) const
184
571
{
185
572
    /*
186
573
        TODO
191
578
        fetch at least what is mentioned in the fetch hint).
192
579
 
193
580
    */
194
 
    return QOrganizerItemManagerEngine::item(itemId, fetchHint, error);
 
581
    return QOrganizerManagerEngine::item(itemId, fetchHint, error);
195
582
}
196
583
 
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)
198
585
{
199
586
    /*
200
587
        TODO
201
588
 
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).
205
592
 
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.
208
596
 
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).
212
600
 
213
601
        The item passed in should be validated according to the schema.
214
602
    */
215
 
    return QOrganizerItemManagerEngine::saveItems(items, collectionId, errorMap, error);
 
603
    return QOrganizerManagerEngine::saveItems(items, errorMap, error);
216
604
 
217
605
}
218
606
 
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)
220
608
{
221
609
    /*
222
610
        TODO
228
616
 
229
617
        DoesNotExistError should be used if the id refers to a non existent item.
230
618
    */
231
 
    return QOrganizerItemManagerEngine::removeItems(itemIds, errorMap, error);
 
619
    return QOrganizerManagerEngine::removeItems(itemIds, errorMap, error);
232
620
}
233
621
 
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
235
623
{
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);
238
626
}
239
627
 
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
241
629
{
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);
244
632
}
245
633
 
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)
247
635
{
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);
250
638
}
251
639
 
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)
253
641
{
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);
256
644
}
257
645
 
258
646
 
259
 
QOrganizerCollectionLocalId QOrganizerItemSkeletonEngine::defaultCollectionId(QOrganizerItemManager::Error* error) const
 
647
QOrganizerCollection QOrganizerItemSkeletonEngine::defaultCollection(QOrganizerManager::Error* error) const
260
648
{
261
649
    /*
262
650
        TODO
263
651
 
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.
267
 
 
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().
270
655
 
271
656
        There is always at least one collection in a manager, and all items are
272
657
        saved in exactly one collection.
273
658
     */
274
 
    return QOrganizerItemManagerEngine::defaultCollectionId(error);
275
 
}
276
 
 
277
 
QList<QOrganizerCollectionLocalId> QOrganizerItemSkeletonEngine::collectionIds(QOrganizerItemManager::Error* error) const
278
 
{
279
 
    /*
280
 
        TODO
281
 
 
282
 
        This allows clients to retrieve the ids of all collections currently
 
659
    return QOrganizerManagerEngine::defaultCollection(error);
 
660
}
 
661
 
 
662
QOrganizerCollection QOrganizerItemSkeletonEngine::collection(const QOrganizerCollectionId& collectionId, QOrganizerManager::Error* error) const
 
663
{
 
664
    /*
 
665
        TODO
 
666
 
 
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().
 
670
     */
 
671
    return QOrganizerManagerEngine::collection(collectionId, error);
 
672
}
 
673
 
 
674
QList<QOrganizerCollection> QOrganizerItemSkeletonEngine::collections(QOrganizerManager::Error* error) const
 
675
{
 
676
    /*
 
677
        TODO
 
678
 
 
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.
285
 
     */
286
 
    return QOrganizerItemManagerEngine::collectionIds(error);
287
 
}
288
 
 
289
 
QList<QOrganizerCollection> QOrganizerItemSkeletonEngine::collections(const QList<QOrganizerCollectionLocalId>& collectionIds, QOrganizerItemManager::Error* error) const
290
 
{
291
 
    /*
292
 
        TODO
293
 
 
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.
297
683
     */
298
 
    return QOrganizerItemManagerEngine::collections(collectionIds, error);
 
684
    return QOrganizerManagerEngine::collections(error);
299
685
}
300
686
 
301
 
bool QOrganizerItemSkeletonEngine::saveCollection(QOrganizerCollection* collection, QOrganizerItemManager::Error* error)
 
687
bool QOrganizerItemSkeletonEngine::saveCollection(QOrganizerCollection* collection, QOrganizerManager::Error* error)
302
688
{
303
689
    /*
304
690
        TODO
307
693
        mutable collections.  If the backend does support mutable collections, it
308
694
        should report that it supports the MutableCollections manager feature.
309
695
     */
310
 
    return QOrganizerItemManagerEngine::saveCollection(collection, error);
 
696
    return QOrganizerManagerEngine::saveCollection(collection, error);
311
697
}
312
698
 
313
 
bool QOrganizerItemSkeletonEngine::removeCollection(const QOrganizerCollectionLocalId& collectionId, QOrganizerItemManager::Error* error)
 
699
bool QOrganizerItemSkeletonEngine::removeCollection(const QOrganizerCollectionId& collectionId, QOrganizerManager::Error* error)
314
700
{
315
701
    /*
316
702
        TODO
326
712
        the backend may decide whether to fail (with a permissions error) or to
327
713
        succeed and arbitrarily choose another collection to be the default collection.
328
714
     */
329
 
    return QOrganizerItemManagerEngine::removeCollection(collectionId, error);
 
715
    return QOrganizerManagerEngine::removeCollection(collectionId, error);
330
716
}
331
717
 
332
 
bool QOrganizerItemSkeletonEngine::startRequest(QOrganizerItemAbstractRequest* req)
 
718
bool QOrganizerItemSkeletonEngine::startRequest(QOrganizerAbstractRequest* req)
333
719
{
334
720
    /*
335
721
        TODO
368
754
        Return true if the request can be started, false otherwise.  You can set an error
369
755
        in the request if you like.
370
756
    */
371
 
    return QOrganizerItemManagerEngine::startRequest(req);
 
757
    return QOrganizerManagerEngine::startRequest(req);
372
758
}
373
759
 
374
 
bool QOrganizerItemSkeletonEngine::cancelRequest(QOrganizerItemAbstractRequest* req)
 
760
bool QOrganizerItemSkeletonEngine::cancelRequest(QOrganizerAbstractRequest* req)
375
761
{
376
762
    /*
377
763
        TODO
378
764
 
379
765
        Cancel an in progress async request.  If not possible, return false from here.
380
766
    */
381
 
    return QOrganizerItemManagerEngine::cancelRequest(req);
 
767
    return QOrganizerManagerEngine::cancelRequest(req);
382
768
}
383
769
 
384
 
bool QOrganizerItemSkeletonEngine::waitForRequestFinished(QOrganizerItemAbstractRequest* req, int msecs)
 
770
bool QOrganizerItemSkeletonEngine::waitForRequestFinished(QOrganizerAbstractRequest* req, int msecs)
385
771
{
386
772
    /*
387
773
        TODO
395
781
 
396
782
        It's best to avoid processing events, if you can, or at least only process non-UI events.
397
783
    */
398
 
    return QOrganizerItemManagerEngine::waitForRequestFinished(req, msecs);
 
784
    return QOrganizerManagerEngine::waitForRequestFinished(req, msecs);
399
785
}
400
786
 
401
 
void QOrganizerItemSkeletonEngine::requestDestroyed(QOrganizerItemAbstractRequest* req)
 
787
void QOrganizerItemSkeletonEngine::requestDestroyed(QOrganizerAbstractRequest* req)
402
788
{
403
789
    /*
404
790
        TODO
419
805
        ordering problems :D
420
806
 
421
807
    */
422
 
    return QOrganizerItemManagerEngine::requestDestroyed(req);
 
808
    return QOrganizerManagerEngine::requestDestroyed(req);
423
809
}
424
810
 
425
 
bool QOrganizerItemSkeletonEngine::hasFeature(QOrganizerItemManager::ManagerFeature feature, const QString& itemType) const
 
811
bool QOrganizerItemSkeletonEngine::hasFeature(QOrganizerManager::ManagerFeature feature, const QString& itemType) const
426
812
{
427
813
    // TODO - the answer to the question may depend on the type
428
814
    Q_UNUSED(itemType);
429
815
    switch(feature) {
430
 
        case QOrganizerItemManager::MutableDefinitions:
 
816
        case QOrganizerManager::MutableDefinitions:
431
817
            // TODO If you support save/remove detail definition, return true
432
818
            return false;
433
819
 
434
 
        case QOrganizerItemManager::Anonymous:
 
820
        case QOrganizerManager::Anonymous:
435
821
            // TODO if this engine is anonymous (e.g. no other engine can share the data) return true
436
822
            // (mostly for an in memory engine)
437
823
            return false;
438
 
        case QOrganizerItemManager::ChangeLogs:
 
824
        case QOrganizerManager::ChangeLogs:
439
825
            // TODO if this engine supports filtering by last modified/created/removed timestamps, return true
440
826
            return false;
441
827
    }
449
835
    return false;
450
836
}
451
837
 
452
 
QList<QVariant::Type> QOrganizerItemSkeletonEngine::supportedDataTypes() const
 
838
QList<int> QOrganizerItemSkeletonEngine::supportedDataTypes() const
453
839
{
454
 
    QList<QVariant::Type> ret;
 
840
    QList<int> ret;
455
841
    // TODO - tweak which data types this engine understands
456
842
    ret << QVariant::String;
457
843
    ret << QVariant::Date;