|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Private declaration of Contact History Model API |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef NMCONTACTHISTORYMODELPRIVATE_H |
|
19 #define NMCONTACTHISTORYMODELPRIVATE_H |
|
20 |
|
21 #include <QObject> |
|
22 #include <QSharedData> |
|
23 #include <qtcontacts.h> |
|
24 |
|
25 #include "nmcontacthistorymodel.h" |
|
26 |
|
27 QTM_USE_NAMESPACE |
|
28 |
|
29 class NmContactHistoryModelItemData : public QSharedData |
|
30 { |
|
31 public: |
|
32 |
|
33 NmContactHistoryModelItemData() : |
|
34 mContactId(0xDEAD) |
|
35 { |
|
36 |
|
37 } |
|
38 |
|
39 ~NmContactHistoryModelItemData() |
|
40 { |
|
41 mItems.clear(); |
|
42 } |
|
43 |
|
44 unsigned int mContactId; |
|
45 QList<NmContactHistoryModelSubItem> mItems; |
|
46 }; |
|
47 |
|
48 class NmContactHistoryModelPrivate : public QObject |
|
49 { |
|
50 |
|
51 enum nameOrder |
|
52 { |
|
53 LastNameFirstName = 0x0, |
|
54 LastNameCommaFirstName = 0x1, |
|
55 FirstNameLastName = 0x2 |
|
56 }; |
|
57 |
|
58 Q_OBJECT |
|
59 |
|
60 public: |
|
61 |
|
62 NmContactHistoryModelPrivate(const NmContactHistoryModelType modelType); |
|
63 ~NmContactHistoryModelPrivate(); |
|
64 |
|
65 signals: |
|
66 |
|
67 void queryCompleted(int err); |
|
68 |
|
69 private: |
|
70 |
|
71 void queryDatabases(const QString &query); |
|
72 |
|
73 // Helper functions that are used by queryDatabases(); |
|
74 bool queryMruDatabase(const QString &query); |
|
75 QList<QContactLocalId> queryContactDatabase(const QString &query); |
|
76 |
|
77 void populateListWithMruItems(const QString &query); |
|
78 |
|
79 void populateListWithContactItems(const QList<QContactLocalId> cnt_ids, |
|
80 const QString &query); |
|
81 |
|
82 |
|
83 int rowCount(const QModelIndex &parent) const; |
|
84 QVariant data(const QModelIndex &index, int role) const; |
|
85 void refreshDataModel(); |
|
86 |
|
87 bool fillMruMatchList(); |
|
88 QString obeyContactOrder(const QString &firstName, const QString &lastName); |
|
89 |
|
90 private: |
|
91 |
|
92 // Member variables |
|
93 NmContactHistoryModelType mType; |
|
94 QList<NmContactHistoryModelItem> mModelItemList; |
|
95 QList< QSharedPointer<NmContactHistoryModelItemData> > mPrivateItemList; |
|
96 QContactManager *mContactManager; |
|
97 QHash<QString, QString> mMruList; |
|
98 QMap<QString, QString> mMruMatches; |
|
99 bool mModelReady; |
|
100 TUint32 mNameOrder; |
|
101 |
|
102 private: // Friend definitions |
|
103 |
|
104 friend class NmContactHistoryModel; |
|
105 friend class TestNmContactHistoryModelPrivate; |
|
106 }; |
|
107 |
|
108 #endif //NMCONTACTHISTORYMODELPRIVATE_H |