|
1 #ifndef QTCONTACTS_H |
|
2 #define QTCONTACTS_H |
|
3 |
|
4 #include <QSharedPointer> |
|
5 #include <QVariant> |
|
6 |
|
7 extern bool setDetailDefinitionNameCalled; |
|
8 extern bool setMatchFlagsCalled; |
|
9 extern bool setValueCalled; |
|
10 extern bool ContactIdsCalled; |
|
11 extern bool returnZeroEmails; |
|
12 |
|
13 typedef quint32 QContactLocalId; |
|
14 /* |
|
15 class UnitTestReporter |
|
16 { |
|
17 public: |
|
18 inline static void resetFlags() |
|
19 { |
|
20 //mFlagA = false; |
|
21 UnitTestReporter::mFlagB = false; |
|
22 //mFlagC = false; |
|
23 UnitTestReporter::mFlagD = false; |
|
24 //mVariant1.clear(); |
|
25 //mVariant2.clear(); |
|
26 } |
|
27 |
|
28 inline static void setFlagA() |
|
29 { |
|
30 mFlagA = true; |
|
31 } |
|
32 inline static void setFlagB() |
|
33 { |
|
34 mFlagB = true; |
|
35 } |
|
36 |
|
37 inline static void setFlagC() |
|
38 { |
|
39 mFlagC = true; |
|
40 } |
|
41 |
|
42 inline static void setFlagD() |
|
43 { |
|
44 mFlagD = true; |
|
45 } |
|
46 |
|
47 inline static void setVariant1(QVariant &variant) |
|
48 { |
|
49 mVariant1 = variant; |
|
50 } |
|
51 |
|
52 inline static void setVariant2(QVariant &variant) |
|
53 { |
|
54 mVariant2 = variant; |
|
55 } |
|
56 |
|
57 static bool mFlagA; |
|
58 static bool mFlagB; |
|
59 static bool mFlagC; |
|
60 static bool mFlagD; |
|
61 static QVariant mVariant1; |
|
62 static QVariant mVariant2; |
|
63 }; |
|
64 */ |
|
65 |
|
66 template <int N> struct QLatin1Constant |
|
67 { |
|
68 char chars[N]; |
|
69 |
|
70 bool operator ==(const QLatin1Constant& other) const {return (chars == other.chars) || (qstrcmp(chars, other.chars) == 0);} |
|
71 bool operator !=(const QLatin1Constant& other) const {return !operator==(other);} |
|
72 |
|
73 inline const char * latin1() const {return chars;} |
|
74 |
|
75 operator QLatin1String() const {return QLatin1String(chars);} |
|
76 operator QString() const {return QString::fromLatin1(chars, N-1);} |
|
77 operator QVariant() const {return QVariant(operator QString());} |
|
78 }; |
|
79 |
|
80 #define QTM_USE_NAMESPACE |
|
81 #endif |
|
82 |
|
83 // Stub for ContactManager |
|
84 #ifndef QCONTACTMANAGER_H |
|
85 #define QCONTACTMANAGER_H |
|
86 |
|
87 #include <QObject> |
|
88 #include <QMap> |
|
89 #include <QString> |
|
90 #include <QStringList> |
|
91 #include <QList> |
|
92 #include <QDateTime> |
|
93 #include <QGlobal.h> |
|
94 |
|
95 class QContactSortOrder |
|
96 { |
|
97 public: |
|
98 inline QContactSortOrder() |
|
99 { |
|
100 } |
|
101 |
|
102 inline ~QContactSortOrder() |
|
103 { |
|
104 } |
|
105 |
|
106 inline QContactSortOrder(const QContactSortOrder& other) |
|
107 { |
|
108 Q_UNUSED(other); |
|
109 } |
|
110 |
|
111 inline QContactSortOrder& operator=(const QContactSortOrder& other) |
|
112 { |
|
113 Q_UNUSED(other); |
|
114 return (const_cast<QContactSortOrder &>(other)); |
|
115 } |
|
116 |
|
117 enum BlankPolicy { |
|
118 BlanksFirst, |
|
119 BlanksLast, |
|
120 }; |
|
121 |
|
122 /* Mutators */ |
|
123 // void setDetailDefinitionName(const QString& definitionName, const QString& fieldName); |
|
124 // void setBlankPolicy(BlankPolicy blankPolicy); |
|
125 // void setDirection(Qt::SortOrder direction); |
|
126 // void setCaseSensitivity(Qt::CaseSensitivity sensitivity); |
|
127 |
|
128 /* Accessors */ |
|
129 // QString detailDefinitionName() const; |
|
130 // QString detailFieldName() const; |
|
131 // BlankPolicy blankPolicy() const; |
|
132 // Qt::SortOrder direction() const; |
|
133 // Qt::CaseSensitivity caseSensitivity() const; |
|
134 |
|
135 // bool isValid() const; |
|
136 |
|
137 inline bool operator==(const QContactSortOrder& other) const |
|
138 { |
|
139 Q_UNUSED(other); |
|
140 return true; |
|
141 } |
|
142 |
|
143 inline bool operator!=(const QContactSortOrder& other) const {Q_UNUSED(other); return !operator==(other);} |
|
144 }; |
|
145 |
|
146 #define Q_DECLARE_LATIN1_CONSTANT(varname, str) static const QLatin1Constant<sizeof(str)> varname |
|
147 #define Q_DEFINE_LATIN1_CONSTANT(varname, str) const QLatin1Constant<sizeof(str)> varname = {str} |
|
148 |
|
149 #define Q_DECLARE_CUSTOM_CONTACT_DETAIL(className, definitionNameString) \ |
|
150 className() : QContactDetail(DefinitionName.latin1()) {} \ |
|
151 className(const QContactDetail& field) : QContactDetail(field, DefinitionName.latin1()) {} \ |
|
152 className& operator=(const QContactDetail& other) {assign(other, DefinitionName.latin1()); return *this;} \ |
|
153 \ |
|
154 Q_DECLARE_LATIN1_CONSTANT(DefinitionName, definitionNameString); |
|
155 |
|
156 class QContactDetail |
|
157 { |
|
158 public: |
|
159 |
|
160 inline QContactDetail() |
|
161 { |
|
162 } |
|
163 |
|
164 inline explicit QContactDetail(const char* definitionName) |
|
165 { |
|
166 Q_UNUSED(definitionName); |
|
167 } |
|
168 |
|
169 inline explicit QContactDetail(const QString& definitionName) |
|
170 { |
|
171 Q_UNUSED(definitionName); |
|
172 } |
|
173 |
|
174 inline ~QContactDetail() |
|
175 { |
|
176 } |
|
177 |
|
178 inline QContactDetail(const QContactDetail& other) |
|
179 { |
|
180 Q_UNUSED(other); |
|
181 } |
|
182 |
|
183 inline QContactDetail& operator=(const QContactDetail& other) |
|
184 { |
|
185 Q_UNUSED(other); |
|
186 return (const_cast<QContactDetail &>(other)); |
|
187 } |
|
188 |
|
189 enum AccessConstraint { |
|
190 NoConstraint = 0, |
|
191 ReadOnly = 0x01, |
|
192 Irremovable = 0x02 |
|
193 }; |
|
194 |
|
195 Q_DECLARE_FLAGS(AccessConstraints, AccessConstraint) |
|
196 |
|
197 inline AccessConstraints accessConstraints() const |
|
198 { |
|
199 return AccessConstraints(); |
|
200 } |
|
201 |
|
202 // Predefined attribute names and values |
|
203 #ifdef Q_QDOC |
|
204 static const QLatin1Constant FieldContext; |
|
205 static const QLatin1Constant ContextHome; |
|
206 static const QLatin1Constant ContextWork; |
|
207 static const QLatin1Constant ContextOther; |
|
208 static const QLatin1Constant FieldDetailUri; |
|
209 static const QLatin1Constant FieldLinkedDetailUris; |
|
210 #else |
|
211 Q_DECLARE_LATIN1_CONSTANT(FieldContext, "Context"); |
|
212 Q_DECLARE_LATIN1_CONSTANT(ContextHome, "Home"); |
|
213 Q_DECLARE_LATIN1_CONSTANT(ContextWork, "Work"); |
|
214 Q_DECLARE_LATIN1_CONSTANT(ContextOther, "Other"); |
|
215 Q_DECLARE_LATIN1_CONSTANT(FieldDetailUri, "DetailUri"); |
|
216 Q_DECLARE_LATIN1_CONSTANT(FieldLinkedDetailUris, "LinkedDetailUris"); |
|
217 #endif |
|
218 |
|
219 bool operator==(const QContactDetail& other) const; |
|
220 bool operator!=(const QContactDetail& other) const {return !(other == *this);} |
|
221 |
|
222 inline QString definitionName() const |
|
223 { |
|
224 return QString(); |
|
225 } |
|
226 |
|
227 inline bool isEmpty() const |
|
228 { |
|
229 return false; |
|
230 } |
|
231 |
|
232 int key() const; |
|
233 void resetKey(); |
|
234 |
|
235 inline QString value(const QString& key) const |
|
236 { |
|
237 Q_UNUSED(key); |
|
238 return QString(); |
|
239 } |
|
240 |
|
241 inline bool setValue(const QString& key, const QVariant& value) |
|
242 { |
|
243 Q_UNUSED(key); |
|
244 Q_UNUSED(value); |
|
245 return true; |
|
246 } |
|
247 |
|
248 bool removeValue(const QString& key); |
|
249 bool hasValue(const QString& key) const; |
|
250 |
|
251 QVariantMap variantValues() const; |
|
252 QVariant variantValue(const QString& key) const; |
|
253 template <typename T> T value(const QString& key) const |
|
254 { |
|
255 return variantValue(key).value<T>(); |
|
256 } |
|
257 |
|
258 /* These are probably internal */ |
|
259 inline QString value(const char* key) const |
|
260 { |
|
261 return key; |
|
262 } |
|
263 |
|
264 inline bool setValue(const char* key, const QVariant& value) |
|
265 { |
|
266 Q_UNUSED(key); |
|
267 Q_UNUSED(value); |
|
268 return true; |
|
269 } |
|
270 |
|
271 inline bool removeValue(const char* key) |
|
272 { |
|
273 Q_UNUSED(key); |
|
274 return true; |
|
275 } |
|
276 |
|
277 inline bool hasValue(const char* key) const |
|
278 { |
|
279 Q_UNUSED(key); |
|
280 return true; |
|
281 } |
|
282 |
|
283 QVariant variantValue(const char *key) const; |
|
284 |
|
285 template<typename T> T value(const char *key) const |
|
286 { |
|
287 return variantValue(key).value<T>(); |
|
288 } |
|
289 |
|
290 #ifdef Q_QDOC |
|
291 QString value(const QLatin1Constant& key) const; |
|
292 bool setValue(const QLatin1Constant& key, const QVariant& value); |
|
293 bool removeValue(const QLatin1Constant& key); |
|
294 bool hasValue(const QLatin1Constant& key) const; |
|
295 QVariant variantValue(const QLatin1Constant& key) const; |
|
296 T value(const QLatin1Constant& key) const; |
|
297 #else |
|
298 |
|
299 template<int N> QString value(const QLatin1Constant<N>& key) const |
|
300 { |
|
301 return value(key.latin1()); |
|
302 } |
|
303 template<int N> bool setValue(const QLatin1Constant<N>& key, const QVariant& value) |
|
304 { |
|
305 return setValue(key.latin1(), value); |
|
306 } |
|
307 template<int N> bool removeValue(const QLatin1Constant<N>& key) |
|
308 { |
|
309 return removeValue(key.latin1()); |
|
310 } |
|
311 template<int N> bool hasValue(const QLatin1Constant<N>& key) const |
|
312 { |
|
313 return hasValue(key.latin1()); |
|
314 } |
|
315 template<int N> QVariant variantValue(const QLatin1Constant<N>& key) const |
|
316 { |
|
317 return variantValue(key.latin1()); |
|
318 } |
|
319 template<typename T, int N> T value(const QLatin1Constant<N>& key) const |
|
320 { |
|
321 return value<T>(key.latin1()); |
|
322 } |
|
323 #endif |
|
324 |
|
325 inline void setContexts(const QStringList& contexts) |
|
326 { |
|
327 setValue(FieldContext, contexts); |
|
328 } |
|
329 |
|
330 inline void setContexts(const QString& context) |
|
331 { |
|
332 setValue(FieldContext, QStringList(context)); |
|
333 } |
|
334 |
|
335 inline QStringList contexts() const |
|
336 { |
|
337 return value<QStringList>(FieldContext); |
|
338 } |
|
339 |
|
340 inline void setDetailUri(const QString& detailUri) |
|
341 { |
|
342 setValue(FieldDetailUri, detailUri); |
|
343 } |
|
344 |
|
345 inline QString detailUri() const |
|
346 { |
|
347 return value(FieldDetailUri); |
|
348 } |
|
349 |
|
350 inline void setLinkedDetailUris(const QStringList& linkedDetailUris) |
|
351 { |
|
352 setValue(FieldLinkedDetailUris, linkedDetailUris); |
|
353 } |
|
354 |
|
355 inline void setLinkedDetailUris(const QString& linkedDetailUri) |
|
356 { |
|
357 setValue(FieldLinkedDetailUris, QStringList(linkedDetailUri)); |
|
358 } |
|
359 |
|
360 inline QStringList linkedDetailUris() const |
|
361 { |
|
362 return value<QStringList>(FieldLinkedDetailUris); |
|
363 } |
|
364 |
|
365 // Protected.. |
|
366 |
|
367 inline QContactDetail(const QContactDetail &other, const QString& expectedDefinitionId) |
|
368 { |
|
369 Q_UNUSED(other); |
|
370 Q_UNUSED(expectedDefinitionId); |
|
371 } |
|
372 |
|
373 inline QContactDetail& assign(const QContactDetail &other, const QString& expectedDefinitionId) |
|
374 { |
|
375 Q_UNUSED(other); |
|
376 Q_UNUSED(expectedDefinitionId); |
|
377 return (const_cast<QContactDetail &>(other)); |
|
378 } |
|
379 |
|
380 inline QContactDetail(const QContactDetail &other, const char* expectedDefinitionId) |
|
381 { |
|
382 Q_UNUSED(other); |
|
383 Q_UNUSED(expectedDefinitionId); |
|
384 } |
|
385 |
|
386 inline QContactDetail& assign(const QContactDetail &other, const char* expectedDefinitionId) |
|
387 { |
|
388 Q_UNUSED(other); |
|
389 Q_UNUSED(expectedDefinitionId); |
|
390 return (const_cast<QContactDetail &>(other)); |
|
391 } |
|
392 }; |
|
393 |
|
394 // Stub for QContactFilter |
|
395 class QContactFilter |
|
396 { |
|
397 public: |
|
398 inline QContactFilter() |
|
399 { |
|
400 } |
|
401 |
|
402 inline ~QContactFilter() |
|
403 { |
|
404 } |
|
405 |
|
406 inline QContactFilter(const QContactFilter& other) |
|
407 { |
|
408 Q_UNUSED(other); |
|
409 } |
|
410 |
|
411 inline QContactFilter& operator=(const QContactFilter& other) |
|
412 { |
|
413 Q_UNUSED(other); |
|
414 return (const_cast<QContactFilter &>(other)); |
|
415 } |
|
416 |
|
417 enum FilterType { |
|
418 InvalidFilter, |
|
419 ContactDetailFilter, |
|
420 ContactDetailRangeFilter, |
|
421 ChangeLogFilter, |
|
422 ActionFilter, |
|
423 RelationshipFilter, |
|
424 IntersectionFilter, |
|
425 UnionFilter, |
|
426 LocalIdFilter, |
|
427 DefaultFilter |
|
428 }; |
|
429 |
|
430 inline FilterType type() const |
|
431 { |
|
432 return FilterType(); |
|
433 } |
|
434 |
|
435 // Qt::MatchFlags don't quite match here |
|
436 enum MatchFlag { |
|
437 MatchExactly = Qt::MatchExactly, // 0 |
|
438 MatchContains = Qt::MatchContains, // 1 |
|
439 MatchStartsWith = Qt::MatchStartsWith, // 2 |
|
440 MatchEndsWith = Qt::MatchEndsWith, // 3 |
|
441 MatchFixedString = Qt::MatchFixedString, // 8 |
|
442 MatchCaseSensitive = Qt::MatchCaseSensitive, // 16 |
|
443 MatchPhoneNumber = 1024, |
|
444 MatchKeypadCollation = 2048 |
|
445 }; |
|
446 Q_DECLARE_FLAGS(MatchFlags, MatchFlag) |
|
447 }; |
|
448 |
|
449 class QContactEmailAddress : public QContactDetail |
|
450 { |
|
451 public: |
|
452 |
|
453 #ifdef Q_QDOC |
|
454 static const QLatin1Constant DefinitionName; |
|
455 static const QLatin1Constant FieldEmailAddress; |
|
456 #else |
|
457 Q_DECLARE_CUSTOM_CONTACT_DETAIL(QContactEmailAddress, "EmailAddress") |
|
458 Q_DECLARE_LATIN1_CONSTANT(FieldEmailAddress, "EmailAddress"); |
|
459 #endif |
|
460 |
|
461 void setEmailAddress(const QString& emailAddress) {Q_UNUSED(emailAddress);} |
|
462 QString emailAddress() const {return value(FieldEmailAddress);} |
|
463 |
|
464 static QContactFilter match(const QString& emailAddress) |
|
465 { |
|
466 Q_UNUSED(emailAddress); |
|
467 return QContactFilter(); |
|
468 } |
|
469 }; |
|
470 |
|
471 class QContactName : public QContactDetail |
|
472 { |
|
473 public: |
|
474 |
|
475 #ifdef Q_QDOC |
|
476 //static const QLatin1Constant DefinitionName; |
|
477 static const QLatin1Constant FieldPrefix; |
|
478 static const QLatin1Constant FieldFirstName; |
|
479 static const QLatin1Constant FieldMiddleName; |
|
480 static const QLatin1Constant FieldLastName; |
|
481 static const QLatin1Constant FieldSuffix; |
|
482 static const QLatin1Constant FieldCustomLabel; |
|
483 #else |
|
484 Q_DECLARE_CUSTOM_CONTACT_DETAIL(QContactName, "Name") |
|
485 Q_DECLARE_LATIN1_CONSTANT(FieldPrefix, "Prefix"); |
|
486 Q_DECLARE_LATIN1_CONSTANT(FieldFirstName, "FirstName"); |
|
487 Q_DECLARE_LATIN1_CONSTANT(FieldMiddleName, "MiddleName"); |
|
488 Q_DECLARE_LATIN1_CONSTANT(FieldLastName, "LastName"); |
|
489 Q_DECLARE_LATIN1_CONSTANT(FieldSuffix, "Suffix"); |
|
490 Q_DECLARE_LATIN1_CONSTANT(FieldCustomLabel, "CustomLabel"); |
|
491 #endif |
|
492 //static const QString DefinitionName; |
|
493 |
|
494 QString prefix() const {return value(FieldPrefix);} |
|
495 QString firstName() const {return value(FieldFirstName);} |
|
496 QString middleName() const {return value(FieldMiddleName);} |
|
497 QString lastName() const {return value(FieldLastName);} |
|
498 QString suffix() const {return value(FieldSuffix);} |
|
499 QString customLabel() const{return value(FieldCustomLabel);} |
|
500 |
|
501 void setPrefix(const QString& prefix) {setValue(FieldPrefix, prefix);} |
|
502 void setFirstName(const QString& firstName) {setValue(FieldFirstName, firstName);} |
|
503 void setMiddleName(const QString& middleName) {setValue(FieldMiddleName, middleName);} |
|
504 void setLastName(const QString& lastName) {setValue(FieldLastName, lastName);} |
|
505 void setSuffix(const QString& suffix) {setValue(FieldSuffix, suffix);} |
|
506 void setCustomLabel(const QString& customLabel) {setValue(FieldCustomLabel, customLabel);} |
|
507 |
|
508 // Convenience filter |
|
509 static QContactFilter match(const QString& name); |
|
510 static QContactFilter match(const QString& firstName, const QString& lastName); |
|
511 }; |
|
512 |
|
513 // Stub for QContactDetailFilter |
|
514 class QContactDetailFilter : public QContactFilter |
|
515 { |
|
516 public: |
|
517 inline QContactDetailFilter() |
|
518 { |
|
519 } |
|
520 |
|
521 inline QContactDetailFilter(const QContactFilter& other) |
|
522 { |
|
523 Q_UNUSED(other); |
|
524 } |
|
525 |
|
526 inline void setDetailDefinitionName(const QString& definition, const QString& fieldName = QString()) |
|
527 { |
|
528 Q_UNUSED(definition); |
|
529 Q_UNUSED(fieldName); |
|
530 setDetailDefinitionNameCalled = true; |
|
531 } |
|
532 |
|
533 inline void setMatchFlags(QContactFilter::MatchFlags flags) |
|
534 { |
|
535 Q_UNUSED(flags); |
|
536 setMatchFlagsCalled = true; |
|
537 } |
|
538 |
|
539 inline void setValue(const QVariant& value) |
|
540 { |
|
541 Q_UNUSED(value); |
|
542 setValueCalled = true; |
|
543 } |
|
544 }; |
|
545 |
|
546 // Stub for QContactFetchHint |
|
547 class QContactFetchHint { |
|
548 public: |
|
549 |
|
550 inline QContactFetchHint() |
|
551 { |
|
552 } |
|
553 |
|
554 inline QContactFetchHint(const QContactFetchHint& other) |
|
555 { |
|
556 Q_UNUSED(other); |
|
557 } |
|
558 |
|
559 inline ~QContactFetchHint() |
|
560 { |
|
561 } |
|
562 |
|
563 }; |
|
564 |
|
565 class QContact |
|
566 { |
|
567 public: |
|
568 inline QContact() |
|
569 { |
|
570 } |
|
571 |
|
572 inline ~QContact() |
|
573 { |
|
574 } |
|
575 |
|
576 QContact(const QContact& other); |
|
577 QContact& operator=(const QContact& other); |
|
578 |
|
579 bool operator==(const QContact &other) const; |
|
580 bool operator!=(const QContact &other) const {return !(other == *this);} |
|
581 |
|
582 /* Access details of particular type or which support a particular action */ |
|
583 QContactDetail detail(const QString& definitionId) const; |
|
584 QList<QContactDetail> details(const QString& definitionId = QString()) const; |
|
585 |
|
586 QList<QContactDetail> details(const QString& definitionName, const QString& fieldName, const QString& value) const; |
|
587 |
|
588 inline QContactDetail detail(const char* definitionId) const |
|
589 { |
|
590 Q_UNUSED(definitionId); |
|
591 QContactDetail detail; |
|
592 |
|
593 detail.setValue(definitionId, definitionId); |
|
594 |
|
595 return detail; |
|
596 } |
|
597 |
|
598 inline QList<QContactDetail> details(const char* definitionId) const |
|
599 { |
|
600 QList<QContactDetail> tmpList; |
|
601 QContactDetail detail; |
|
602 |
|
603 if(!returnZeroEmails) |
|
604 { |
|
605 detail.setValue(definitionId, definitionId); |
|
606 tmpList.append(detail); |
|
607 } |
|
608 |
|
609 return tmpList; |
|
610 } |
|
611 |
|
612 QList<QContactDetail> details(const char* definitionId, const char* fieldName, const QString& value) const; |
|
613 |
|
614 /* Templated retrieval for definition names */ |
|
615 #ifdef Q_QDOC |
|
616 QContactDetail detail(const QLatin1Constant& definitionName) const; |
|
617 QList<QContactDetail> details(const QLatin1Constant& definitionName) const; |
|
618 QList<QContactDetail> details(const QLatin1Constant& definitionName, const QLatin1Constant& fieldName, const QString& value); |
|
619 #else |
|
620 template <int N> QContactDetail detail(const QLatin1Constant<N>& definitionName) const |
|
621 { |
|
622 return detail(definitionName.latin1()); |
|
623 } |
|
624 template <int N> QList<QContactDetail> details(const QLatin1Constant<N>& definitionName) const |
|
625 { |
|
626 return details(definitionName.latin1()); |
|
627 } |
|
628 template <int N, int M> QList<QContactDetail> details(const QLatin1Constant<N>& definitionName, const QLatin1Constant<M>& fieldName, const QString& value) |
|
629 { |
|
630 return details(definitionName.latin1(), fieldName.latin1(), value); |
|
631 } |
|
632 #endif |
|
633 |
|
634 /* Templated (type-specific) detail retrieval */ |
|
635 template<typename T> QList<T> details() const |
|
636 { |
|
637 QList<QContactDetail> props = details(T::DefinitionName.latin1()); |
|
638 QList<T> ret; |
|
639 foreach(QContactDetail prop, props) |
|
640 ret.append(T(prop)); |
|
641 return ret; |
|
642 } |
|
643 |
|
644 /* Templated (type-specific) detail retrieval base on given detail field name and field value */ |
|
645 template<typename T> QList<T> details(const QString& fieldName, const QString& value) const |
|
646 { |
|
647 QList<QContactDetail> props = details(T::DefinitionName, fieldName, value); |
|
648 QList<T> ret; |
|
649 foreach(QContactDetail prop, props) |
|
650 ret.append(T(prop)); |
|
651 return ret; |
|
652 } |
|
653 |
|
654 template<typename T> QList<T> details(const char* fieldName, const QString& value) const |
|
655 { |
|
656 QList<QContactDetail> props = details(T::DefinitionName.latin1(), fieldName, value); |
|
657 QList<T> ret; |
|
658 foreach(QContactDetail prop, props) |
|
659 ret.append(T(prop)); |
|
660 return ret; |
|
661 } |
|
662 |
|
663 template<typename T> T detail() const |
|
664 { |
|
665 return T(detail(T::DefinitionName.latin1())); |
|
666 } |
|
667 |
|
668 }; |
|
669 |
|
670 // Stub for QContactManager |
|
671 //class QContactManager : public QObject |
|
672 class QContactManager |
|
673 { |
|
674 // Q_OBJECT |
|
675 |
|
676 public: |
|
677 |
|
678 #if Q_QDOC // qdoc's parser fails to recognise the default map argument |
|
679 |
|
680 inline explicit QContactManager(const QString& managerName = QString(), const QMap<QString, QString>& parameters = 0, QObject* parent = 0) |
|
681 { |
|
682 Q_UNUSED(managerName); |
|
683 Q_UNUSED(parameters; |
|
684 Q_UNUSED(parent); |
|
685 } |
|
686 |
|
687 inline QContactManager(const QString& managerName, int implementationVersion, const QMap<QString, QString>& parameters = 0, QObject* parent = 0) |
|
688 { |
|
689 Q_UNUSED(managerName); |
|
690 Q_UNUSED(implementationVersion); |
|
691 Q_UNUSED(parameters); |
|
692 Q_UNUSED(parent); |
|
693 } |
|
694 |
|
695 #else |
|
696 |
|
697 inline explicit QContactManager(const QString& managerName = QString(), const QMap<QString, QString>& parameters = (QMap<QString, QString>()), QObject* parent = 0) |
|
698 { |
|
699 Q_UNUSED(managerName); |
|
700 Q_UNUSED(parameters); |
|
701 Q_UNUSED(parent); |
|
702 } |
|
703 |
|
704 inline QContactManager(const QString& managerName, int implementationVersion, const QMap<QString, QString>& parameters = (QMap<QString, QString>()), QObject* parent = 0) |
|
705 { |
|
706 Q_UNUSED(managerName); |
|
707 Q_UNUSED(implementationVersion); |
|
708 Q_UNUSED(parameters); |
|
709 Q_UNUSED(parent); |
|
710 } |
|
711 |
|
712 #endif |
|
713 // explicit QContactManager(QObject* parent); |
|
714 |
|
715 // static QContactManager* fromUri(const QString& uri, QObject* parent = 0); |
|
716 inline ~QContactManager() |
|
717 { |
|
718 |
|
719 } |
|
720 |
|
721 /* Contacts - Accessors and Mutators */ |
|
722 // QList<QContactLocalId> contactIds(const QList<QContactSortOrder>& sortOrders = QList<QContactSortOrder>()) const; |
|
723 |
|
724 // QContactLocalId - Check |
|
725 // QContactFilter - Check |
|
726 // QContactSortOrder - Check |
|
727 // QContactFetchHint - Check |
|
728 |
|
729 |
|
730 inline QList<QContactLocalId> contactIds(const QContactFilter& filter, const QList<QContactSortOrder>& sortOrders = QList<QContactSortOrder>()) const |
|
731 { |
|
732 Q_UNUSED(filter); |
|
733 Q_UNUSED(sortOrders); |
|
734 |
|
735 QList<QContactLocalId> list; |
|
736 list.append(12); |
|
737 list.append(24); |
|
738 list.append(48); |
|
739 |
|
740 ContactIdsCalled = true; |
|
741 |
|
742 return list; |
|
743 } |
|
744 |
|
745 // QList<QContact> contacts(const QList<QContactSortOrder>& sortOrders = QList<QContactSortOrder>(), const QContactFetchHint& fetchHint = QContactFetchHint()) const; |
|
746 // QList<QContact> contacts(const QContactFilter& filter, const QList<QContactSortOrder>& sortOrders = QList<QContactSortOrder>(), const QContactFetchHint& fetchHint = QContactFetchHint()) const; |
|
747 inline QContact contact(const QContactLocalId& contactId, const QContactFetchHint& fetchHint = QContactFetchHint()) const // retrieve a contact |
|
748 { |
|
749 Q_UNUSED(fetchHint); |
|
750 |
|
751 QContact cnt; |
|
752 |
|
753 int keu = contactId; |
|
754 |
|
755 switch (keu) |
|
756 { |
|
757 case 12: |
|
758 |
|
759 break; |
|
760 |
|
761 case 24: |
|
762 |
|
763 break; |
|
764 |
|
765 case 48: |
|
766 |
|
767 break; |
|
768 |
|
769 default: |
|
770 break; |
|
771 } |
|
772 |
|
773 |
|
774 |
|
775 return cnt; |
|
776 } |
|
777 |
|
778 |
|
779 |
|
780 }; |
|
781 |
|
782 //QTM_END_NAMESPACE |
|
783 |
|
784 #endif |