68
|
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: Public declaration of Contact History Model API
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#ifndef NMCONTACTHISTORYMODEL_H
|
|
18 |
#define NMCONTACTHISTORYMODEL_H
|
|
19 |
|
74
|
20 |
#include <QMetaType>
|
68
|
21 |
#include <QAbstractListModel>
|
|
22 |
#include <QSharedDataPointer>
|
|
23 |
|
|
24 |
#include "nmcontacthistorymodelcommon.h"
|
|
25 |
|
|
26 |
// NmContactHistoryModelSubItem - display name is one item, email address/phone number another
|
|
27 |
class NmContactHistoryModelSubItem
|
|
28 |
{
|
|
29 |
public:
|
|
30 |
|
|
31 |
inline NmContactHistoryModelSubItem()
|
|
32 |
{
|
|
33 |
}
|
|
34 |
|
|
35 |
inline ~NmContactHistoryModelSubItem()
|
|
36 |
{
|
|
37 |
}
|
|
38 |
// email address, or concatenated firstName+' '+lastName.
|
|
39 |
QString mItemText;
|
|
40 |
// amount of items in mMatchingRanges is 2*mItemTexts.length() because for each text there is begin/end index
|
|
41 |
// TODO: Fix above^ always two indeces
|
|
42 |
// for example "Ville Virtanen" with query "vi" returns indeces 0,1,6,7
|
|
43 |
QList<int> mMatchingRanges;
|
|
44 |
};
|
|
45 |
|
|
46 |
class NmContactHistoryModelPrivate;
|
|
47 |
class NmContactHistoryModelItemData;
|
|
48 |
|
|
49 |
class NMCHMAPI_EXPORT NmContactHistoryModelItem
|
|
50 |
{
|
|
51 |
public:
|
|
52 |
NmContactHistoryModelItem();
|
|
53 |
NmContactHistoryModelItem(const NmContactHistoryModelItem &other);
|
74
|
54 |
virtual ~NmContactHistoryModelItem();
|
68
|
55 |
|
|
56 |
public:
|
|
57 |
// contact id is 0xDEAD if not associated with a contact item
|
|
58 |
unsigned int contactId() const;
|
|
59 |
|
|
60 |
void setContactId(unsigned int contactId);
|
|
61 |
|
|
62 |
int subItemCount() const;
|
|
63 |
|
|
64 |
NmContactHistoryModelSubItem subItemAt(int index) const;
|
|
65 |
|
|
66 |
// First entry is display name, second email address.
|
|
67 |
QList<NmContactHistoryModelSubItem> subEntries() const;
|
|
68 |
|
|
69 |
void appendSubItem(NmContactHistoryModelSubItem entry);
|
|
70 |
|
|
71 |
private:
|
|
72 |
//
|
|
73 |
QSharedDataPointer<NmContactHistoryModelItemData> d;
|
|
74 |
};
|
|
75 |
Q_DECLARE_METATYPE(NmContactHistoryModelItem)
|
|
76 |
|
|
77 |
/**
|
|
78 |
* Model for contact history queries.
|
|
79 |
*
|
|
80 |
*/
|
|
81 |
class NMCHMAPI_EXPORT NmContactHistoryModel : public QAbstractListModel
|
|
82 |
{
|
|
83 |
Q_OBJECT
|
|
84 |
|
|
85 |
public: // The exported API
|
|
86 |
|
|
87 |
/**
|
|
88 |
* Constructor
|
|
89 |
* @param modelType
|
|
90 |
*/
|
|
91 |
explicit NmContactHistoryModel(
|
|
92 |
const NmContactHistoryModelType modelType);
|
|
93 |
|
|
94 |
/**
|
|
95 |
* Destructor
|
|
96 |
*/
|
74
|
97 |
virtual ~NmContactHistoryModel();
|
68
|
98 |
|
|
99 |
public: // From QAbstractItemModel
|
|
100 |
|
|
101 |
/**
|
|
102 |
* Get number of rows currently in the model.
|
|
103 |
* @return number of rows
|
|
104 |
*/
|
74
|
105 |
int rowCount(const QModelIndex &parent) const;
|
68
|
106 |
|
|
107 |
/**
|
|
108 |
* Get various data from the model. Fetched data type is defined
|
|
109 |
* by role input parameter. Only Qt::DisplayRole is supported.
|
|
110 |
*/
|
74
|
111 |
QVariant data(const QModelIndex &index, int role) const;
|
68
|
112 |
|
|
113 |
signals:
|
|
114 |
|
|
115 |
/**
|
|
116 |
* Signaled once model is ready.
|
|
117 |
* @param err, 0 if building model was success
|
|
118 |
*/
|
|
119 |
void modelCompleted(int err);
|
|
120 |
|
|
121 |
public slots:
|
|
122 |
|
|
123 |
// TODO: query could keep previous query in order to check if results will only get narrowed (a char is appended)
|
|
124 |
void query(const QString &query);
|
|
125 |
|
|
126 |
private slots:
|
|
127 |
|
|
128 |
/**
|
|
129 |
* Signaled once query is completed, emits modelCompleted.
|
|
130 |
* @param err, 0 if building model was success
|
|
131 |
*/
|
|
132 |
void handleQueryCompleted(int err);
|
|
133 |
|
|
134 |
private:
|
|
135 |
/*
|
|
136 |
* Private Implementation
|
|
137 |
* Own
|
|
138 |
*/
|
|
139 |
NmContactHistoryModelPrivate *d_ptr;
|
|
140 |
|
74
|
141 |
private:
|
|
142 |
|
|
143 |
friend class TestNmContactHistoryModel;
|
68
|
144 |
};
|
|
145 |
|
|
146 |
#endif //NMCONTACTHISTORYMODEL_H
|