1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QContactManager.h> |
|
19 #include <QContactDetailFilter.h> |
|
20 #include <QContactPhoneNumber.h> |
|
21 #include <QSharedDataPointer> |
|
22 #include <QContactName.h> |
|
23 #include <QContactDetail.h> |
|
24 |
|
25 #include <QSharedData> |
|
26 #include <QContactAvatar.h> |
|
27 |
|
28 QTM_USE_NAMESPACE |
|
29 |
|
30 class QtMobility::QContactData : public QSharedData |
|
31 { |
|
32 public: |
|
33 QContactData(): QSharedData() |
|
34 { |
|
35 } |
|
36 |
|
37 ~QContactData() {} |
|
38 |
|
39 QContactId m_id; |
|
40 |
|
41 }; |
|
42 |
|
43 class QtMobility::QContactDetailPrivate : public QSharedData |
|
44 { |
|
45 public: |
|
46 QContactDetailPrivate(): QSharedData() |
|
47 { |
|
48 } |
|
49 |
|
50 ~QContactDetailPrivate() {} |
|
51 }; |
|
52 |
|
53 // ---------------------------------------------------------------------------- |
|
54 // QContactManager |
|
55 // ---------------------------------------------------------------------------- |
|
56 // |
|
57 QContactManager::QContactManager( |
|
58 const QString& /*managerName*/, const QMap<QString, QString>& /*parameters*/, |
|
59 QObject* /*parent*/) |
|
60 { |
|
61 |
|
62 } |
|
63 |
|
64 QContactManager::~QContactManager() |
|
65 { |
|
66 |
|
67 } |
|
68 |
|
69 QList<QContactLocalId> QContactManager::contactIds( |
|
70 const QContactFilter& filter, |
|
71 const QList<QContactSortOrder>& /*sortOrders*/) const |
|
72 { |
|
73 const QContactDetailFilter& df = |
|
74 static_cast<const QContactDetailFilter&>( filter ); |
|
75 |
|
76 int digits = df.value().toString().length(); |
|
77 QList<QContactLocalId> list; |
|
78 for( int i=0;i<10-digits;i++) { |
|
79 list.append( 1+i ); |
|
80 } |
|
81 return list; |
|
82 } |
|
83 |
|
84 QContact QContactManager::contact( |
|
85 const QContactLocalId& contactId, |
|
86 const QStringList& definitionRestrictions ) const |
|
87 { |
|
88 QContact contact; |
|
89 QContactId id; |
|
90 id.setLocalId(contactId ); |
|
91 |
|
92 contact.setId( id ); |
|
93 return contact; |
|
94 } |
|
95 |
|
96 // ---------------------------------------------------------------------------- |
|
97 // QContactDetailFilter |
|
98 // ---------------------------------------------------------------------------- |
|
99 // |
|
100 QContactDetailFilter::QContactDetailFilter() |
|
101 { |
|
102 |
|
103 } |
|
104 |
|
105 void QContactDetailFilter::setDetailDefinitionName( |
|
106 const QString& /*definition*/, const QString& /*fieldName*/) |
|
107 { |
|
108 |
|
109 } |
|
110 |
|
111 |
|
112 void QContactDetailFilter::setMatchFlags(QContactFilter::MatchFlags /*flags*/) |
|
113 { |
|
114 |
|
115 } |
|
116 void QContactDetailFilter::setValue(const QVariant& /*value*/) |
|
117 { |
|
118 } |
|
119 |
|
120 QVariant QContactDetailFilter::value() const |
|
121 { |
|
122 return QVariant(); |
|
123 } |
|
124 |
|
125 |
|
126 // ---------------------------------------------------------------------------- |
|
127 // QContact |
|
128 // ---------------------------------------------------------------------------- |
|
129 // |
|
130 QContact::QContact() : d(new QContactData) |
|
131 { |
|
132 |
|
133 } |
|
134 |
|
135 QContact::~QContact() |
|
136 { |
|
137 |
|
138 } |
|
139 |
|
140 |
|
141 QContact& QContact::operator=(const QContact& other) |
|
142 { |
|
143 |
|
144 } |
|
145 |
|
146 QContactDetail QContact::detail(const QString& definitionId) const |
|
147 { |
|
148 if ( definitionId == QContactName::DefinitionName ){ |
|
149 QContactName name; |
|
150 QContactLocalId id = localId(); |
|
151 QString first = QString("first%1").arg( id ); |
|
152 name.setValue(QContactName::FieldFirst, first ); |
|
153 QString last = QString("last%1").arg( id ); |
|
154 name.setValue(QContactName::FieldLast, last ); |
|
155 return name; |
|
156 } |
|
157 if ( definitionId == QContactPhoneNumber::DefinitionName ){ |
|
158 QContactPhoneNumber number; |
|
159 QString n( "555789987" ); |
|
160 number.setValue(QContactPhoneNumber::FieldNumber, n ); |
|
161 return number; |
|
162 } |
|
163 if ( definitionId == QContactAvatar::DefinitionName){ |
|
164 QContactAvatar avatar; |
|
165 avatar.setSubType(QContactAvatar::SubTypeImage); |
|
166 avatar.setAvatar("c:\\data\\images\\logstest1.jpg"); |
|
167 QString a( "Avatar" ); |
|
168 avatar.setValue( QContactAvatar::FieldAvatar, a ); |
|
169 return avatar; |
|
170 } |
|
171 QContactDetail detail; |
|
172 return detail; |
|
173 } |
|
174 |
|
175 |
|
176 // ---------------------------------------------------------------------------- |
|
177 // QContactDetail |
|
178 // ---------------------------------------------------------------------------- |
|
179 // |
|
180 QContactDetail::QContactDetail() |
|
181 { |
|
182 |
|
183 } |
|
184 QContactDetail::QContactDetail(const QString& definitionName) : d(new QContactDetailPrivate) |
|
185 { |
|
186 |
|
187 } |
|
188 QContactDetail::~QContactDetail() |
|
189 { |
|
190 |
|
191 } |
|
192 |
|
193 |
|
194 QContactDetail& QContactDetail::operator=(const QContactDetail& other) |
|
195 { |
|
196 |
|
197 } |
|
198 |
|
199 QString QContactDetail::definitionName() const |
|
200 { |
|
201 return QString(""); |
|
202 } |
|
203 |
|
204 bool QContactDetail::isEmpty() const |
|
205 { |
|
206 return false; |
|
207 } |
|
208 |
|
209 |
|
210 QVariant QContactDetail::variantValue(const QString& key) const |
|
211 { |
|
212 QString val = value(key); |
|
213 return val; |
|
214 } |
|
215 |
|
216 |
|
217 |
|