15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <QList> |
18 #include <QList> |
19 |
19 |
|
20 #include "emailtrace.h" |
20 #include "nmcontacthistorymodel.h" |
21 #include "nmcontacthistorymodel.h" |
21 #include "nmcontacthistorymodel_p.h" |
22 #include "nmcontacthistorymodel_p.h" |
22 |
23 |
23 // -------------------------------------------------------------------------- |
24 // -------------------------------------------------------------------------- |
24 // Start of implementation (NmContactHistoryModel) |
25 // Start of implementation (NmContactHistoryModel) |
29 \param modelType ModelType to be used, Email / Messaging |
30 \param modelType ModelType to be used, Email / Messaging |
30 */ |
31 */ |
31 NmContactHistoryModel::NmContactHistoryModel( |
32 NmContactHistoryModel::NmContactHistoryModel( |
32 const NmContactHistoryModelType modelType) |
33 const NmContactHistoryModelType modelType) |
33 { |
34 { |
|
35 NM_FUNCTION; |
34 d_ptr = new NmContactHistoryModelPrivate(modelType); |
36 d_ptr = new NmContactHistoryModelPrivate(modelType); |
35 Q_CHECK_PTR(d_ptr); |
|
36 |
37 |
37 QObject::connect(d_ptr, SIGNAL(queryCompleted(int)), this, |
38 QObject::connect(d_ptr, SIGNAL(queryCompleted(int)), this, |
38 SLOT(handleQueryCompleted(int))); |
39 SLOT(handleQueryCompleted(int))); |
39 } |
40 } |
40 |
41 |
41 /*! |
42 /*! |
42 Destructor of NmContactHistoryModel |
43 Destructor of NmContactHistoryModel |
43 */ |
44 */ |
44 NmContactHistoryModel::~NmContactHistoryModel() |
45 NmContactHistoryModel::~NmContactHistoryModel() |
45 { |
46 { |
|
47 NM_FUNCTION; |
46 delete d_ptr; |
48 delete d_ptr; |
47 } |
49 } |
48 |
50 |
49 /*! |
51 /*! |
50 Queries contact databases from private implementation |
52 Queries contact databases from private implementation |
51 |
53 |
52 \param query String to be queried. |
54 \param query String to be queried. |
53 */ |
55 */ |
54 void NmContactHistoryModel::query(const QString &query) |
56 void NmContactHistoryModel::query(const QString &query) |
55 { |
57 { |
|
58 NM_FUNCTION; |
56 d_ptr->queryDatabases(query); |
59 d_ptr->queryDatabases(query); |
57 } |
60 } |
58 |
61 |
59 /*! |
62 /*! |
60 Signaled once query is completed, emits modelCompleted. |
63 Signaled once query is completed, emits modelCompleted. |
62 |
65 |
63 \param err, 0 if building model was success |
66 \param err, 0 if building model was success |
64 */ |
67 */ |
65 void NmContactHistoryModel::handleQueryCompleted(int err) |
68 void NmContactHistoryModel::handleQueryCompleted(int err) |
66 { |
69 { |
|
70 NM_FUNCTION; |
67 |
71 |
68 int lastUpdateIndex = (d_ptr->mPrivateItemList.count())-1; |
72 int lastUpdateIndex = (d_ptr->privateDataCount())-1; |
69 |
73 |
70 if (lastUpdateIndex != -1) |
74 if (lastUpdateIndex != -1) |
71 { |
75 { |
72 // Notify views that we are about to change model data. |
76 // Notify views that we are about to change model data. |
73 beginInsertRows(QModelIndex(),0,lastUpdateIndex); |
77 beginInsertRows(QModelIndex(),0,lastUpdateIndex); |
77 // Emit dataChanged(); |
81 // Emit dataChanged(); |
78 bool validIndex = hasIndex ( lastUpdateIndex, 0 ); |
82 bool validIndex = hasIndex ( lastUpdateIndex, 0 ); |
79 |
83 |
80 if (validIndex) |
84 if (validIndex) |
81 { |
85 { |
82 dataChanged(index(0,0), index(lastUpdateIndex,0)); |
86 emit dataChanged(index(0,0), index(lastUpdateIndex,0)); |
83 } |
87 } |
84 } |
88 } |
85 |
89 |
86 emit modelCompleted(err); |
90 emit modelCompleted(err); |
87 } |
91 } |
91 |
95 |
92 From QAbstractItemModel |
96 From QAbstractItemModel |
93 */ |
97 */ |
94 int NmContactHistoryModel::rowCount(const QModelIndex &parent) const |
98 int NmContactHistoryModel::rowCount(const QModelIndex &parent) const |
95 { |
99 { |
96 return d_ptr->rowCount(parent); |
100 NM_FUNCTION; |
|
101 return d_ptr->modelRowCount(parent); |
97 } |
102 } |
98 |
103 |
99 /*! |
104 /*! |
100 Returns the data stored under the given role for the item referred |
105 Returns the data stored under the given role for the item referred |
101 to by the index. |
106 to by the index. |
102 |
107 |
103 From QAbstractItemModel |
108 From QAbstractItemModel |
104 */ |
109 */ |
105 QVariant NmContactHistoryModel::data(const QModelIndex &index, int role) const |
110 QVariant NmContactHistoryModel::data(const QModelIndex &index, int role) const |
106 { |
111 { |
|
112 NM_FUNCTION; |
107 return d_ptr->data(index, role); |
113 return d_ptr->data(index, role); |
108 } |
114 } |
109 |
115 |
110 // -------------------------------------------------------------------------- |
116 // -------------------------------------------------------------------------- |
111 // End of implementation (NmContactHistoryModel) |
117 // End of implementation (NmContactHistoryModel) |