author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 00:13:15 +0300 | |
changeset 72 | 6f657153cbc5 |
parent 70 | a15d9966050f |
permissions | -rw-r--r-- |
31 | 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: Custom layout widget for Contact Card layout. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#ifndef MSGCONTACTCARDWIDGET_H |
|
19 |
#define MSGCONTACTCARDWIDGET_H |
|
20 |
||
21 |
// SYSTEM INCLUDES |
|
22 |
#include <HbWidget> |
|
23 |
||
24 |
// FORWORD DECLARATIONS |
|
25 |
class HbIconItem; |
|
26 |
class HbTextItem; |
|
27 |
class HbIcon; |
|
28 |
class ThumbnailManager; |
|
29 |
||
30 |
#include "convergedmessageaddress.h" |
|
31 |
||
32 |
/** |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
33 |
* @class MsgContactCardWidget |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
34 |
* @brief This class is a custom layout widget for Contact Card layout. |
31 | 35 |
*/ |
36 |
class MsgContactCardWidget: public HbWidget |
|
37 |
{ |
|
38 |
Q_OBJECT |
|
39 |
||
40 |
public: |
|
41 |
||
42 |
/** |
|
43 |
* Constructor |
|
44 |
*/ |
|
45 |
explicit MsgContactCardWidget(QGraphicsItem *parent = 0); |
|
46 |
||
47 |
/** |
|
48 |
* Destructor |
|
49 |
*/ |
|
50 |
virtual ~MsgContactCardWidget(); |
|
51 |
||
52 |
public: |
|
53 |
||
54 |
/** |
|
55 |
* Sets the avatar |
|
56 |
* @param avatar Avatar to be set. |
|
57 |
*/ |
|
58 |
void setAvatar(const HbIcon &avatar); |
|
59 |
||
60 |
/** |
|
61 |
* Sets the presence icon |
|
62 |
* @param presenceIcon Presence icon to set. |
|
63 |
*/ |
|
64 |
void setPresenceIcon(const HbIcon &presenceIcon); |
|
65 |
||
66 |
/** |
|
67 |
* Sets the address to be displayed. |
|
68 |
* @param address Address string to be set. |
|
69 |
*/ |
|
70 |
void setAddress(const QString &address); |
|
71 |
||
72 |
/** |
|
73 |
* Returns the address displayed in the Contact card. |
|
74 |
*/ |
|
75 |
ConvergedMessageAddressList address(); |
|
76 |
||
77 |
/** |
|
78 |
* Refreshes all the Contact card fields. |
|
79 |
*/ |
|
80 |
void updateContents(); |
|
81 |
||
82 |
/** |
|
83 |
* Clears all the Contact card fields. |
|
84 |
*/ |
|
85 |
void clearContent(); |
|
86 |
||
72
6f657153cbc5
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
87 |
/** |
6f657153cbc5
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
88 |
* Checks if the address displayed in valid |
6f657153cbc5
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
89 |
* phone number or email id. |
6f657153cbc5
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
90 |
* @return true if valid else false |
6f657153cbc5
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
91 |
*/ |
6f657153cbc5
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
92 |
bool isValidAddress(); |
6f657153cbc5
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
93 |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
94 |
signals: |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
95 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
96 |
/** |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
97 |
* |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
98 |
*/ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
99 |
void conversationIdChanged(qint64 convId); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
100 |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
101 |
protected: |
31 | 102 |
|
103 |
/** |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
104 |
* Event handler for gesture events. |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
105 |
* Reimplemented from HbWidgetBase. |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
106 |
* @see HbWidgetBase |
31 | 107 |
*/ |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
108 |
virtual void gestureEvent(QGestureEvent *event); |
31 | 109 |
|
110 |
private: |
|
111 |
||
112 |
/** |
|
113 |
* Initialization function. |
|
114 |
*/ |
|
115 |
void init(); |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
116 |
|
31 | 117 |
/** Helper method to get contact id against phone number. |
118 |
* @param value phone number. |
|
119 |
*/ |
|
120 |
int resolveContactId(const QString& value); |
|
121 |
||
122 |
/** |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
123 |
* Handles pressed state. |
31 | 124 |
*/ |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
125 |
void setPressed(bool pressed); |
31 | 126 |
|
127 |
private slots: |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
128 |
|
31 | 129 |
/** |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
130 |
* show longp tap. |
31 | 131 |
*/ |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
132 |
void handleLongTap(const QPointF &position); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
133 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
134 |
/** |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
135 |
* handles short tap. |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
136 |
*/ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
137 |
void handleShortTap(const QPointF &position); |
31 | 138 |
|
139 |
/** |
|
140 |
* Slot for handling valid returns from the framework. |
|
141 |
* Updates the display name in the contact card widget. |
|
142 |
* @param result const QVariant& |
|
143 |
*/ |
|
144 |
void handleOk(const QVariant& result); |
|
145 |
||
146 |
/** |
|
147 |
* Slot for handling errors. Error ids are provided as |
|
148 |
* 32-bit integers. |
|
149 |
* @param errorCode qint32 |
|
150 |
*/ |
|
151 |
void handleError(int errorCode, const QString& errorMessage); |
|
152 |
||
153 |
/** |
|
154 |
* Called when clicked() signal is emitted |
|
155 |
* Launches phonebook to view an existing contact |
|
156 |
* or to add a new contact |
|
157 |
*/ |
|
158 |
void openContactInfo(); |
|
159 |
||
160 |
/** |
|
161 |
* Launches Dialer Service |
|
162 |
*/ |
|
163 |
void call(); |
|
164 |
||
165 |
/** |
|
166 |
* Adds unknown number to phonebook |
|
167 |
*/ |
|
168 |
void addToContacts(); |
|
169 |
||
170 |
/** |
|
171 |
* Called after service request is completed. |
|
172 |
*/ |
|
173 |
void onServiceRequestCompleted(); |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
174 |
|
31 | 175 |
/** |
176 |
* Slot hit when the thumbnail is ready. |
|
177 |
*/ |
|
178 |
void thumbnailReady(const QPixmap& pixmap, void *data, int id, int error); |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
179 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
180 |
/** |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
181 |
* Slot to regrab gesture after some delay (300 ms) to avoid multiple gesture |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
182 |
* events back to back. |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
183 |
*/ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
184 |
void regrabGesture(); |
31 | 185 |
|
186 |
private: |
|
187 |
||
188 |
/** |
|
189 |
* Contact Number for the conversation |
|
190 |
*/ |
|
191 |
QString mContactNumber; |
|
192 |
||
193 |
/** |
|
194 |
* Address string. |
|
195 |
*/ |
|
196 |
QString mAddress; |
|
197 |
||
198 |
/** |
|
199 |
* Avatar icon item. |
|
200 |
* Own. |
|
201 |
*/ |
|
202 |
HbIconItem *mAvatarIconItem; |
|
203 |
||
204 |
/** |
|
205 |
* Presence icon item. |
|
206 |
* Own. |
|
207 |
*/ |
|
208 |
HbIconItem *mPresenceIconItem; |
|
209 |
||
210 |
/** |
|
211 |
* Address text item. |
|
212 |
* Own. |
|
213 |
*/ |
|
214 |
HbTextItem *mAddressTextItem; |
|
215 |
||
216 |
/** |
|
217 |
* ThumbnailManager |
|
218 |
* Own. |
|
219 |
*/ |
|
220 |
ThumbnailManager *mThumbnailManager; |
|
70
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
221 |
|
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
222 |
#ifdef MSGUI_UNIT_TEST |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
223 |
/** |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
224 |
* Unit Testing |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
225 |
*/ |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
226 |
friend class TestMsgContactCardWidget; |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
227 |
#endif |
31 | 228 |
}; |
229 |
||
230 |
#endif // MSGCONTACTCARDWIDGET_H |
|
231 |
// EOF |