|
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 /** |
|
33 * @class MsgContactCardWidget |
|
34 * @brief This class is a custom layout widget for Contact Card layout. |
|
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 |
|
87 signals: |
|
88 |
|
89 /** |
|
90 * |
|
91 */ |
|
92 void conversationIdChanged(qint64 convId); |
|
93 |
|
94 protected: |
|
95 |
|
96 /** |
|
97 * Event handler for gesture events. |
|
98 * Reimplemented from HbWidgetBase. |
|
99 * @see HbWidgetBase |
|
100 */ |
|
101 virtual void gestureEvent(QGestureEvent *event); |
|
102 |
|
103 private: |
|
104 |
|
105 /** |
|
106 * Initialization function. |
|
107 */ |
|
108 void init(); |
|
109 |
|
110 /** Helper method to get contact id against phone number. |
|
111 * @param value phone number. |
|
112 */ |
|
113 int resolveContactId(const QString& value); |
|
114 |
|
115 /** |
|
116 * Handles pressed state. |
|
117 */ |
|
118 void setPressed(bool pressed); |
|
119 |
|
120 private slots: |
|
121 |
|
122 /** |
|
123 * show longp tap. |
|
124 */ |
|
125 void handleLongTap(const QPointF &position); |
|
126 |
|
127 /** |
|
128 * handles short tap. |
|
129 */ |
|
130 void handleShortTap(const QPointF &position); |
|
131 |
|
132 /** |
|
133 * Slot for handling valid returns from the framework. |
|
134 * Updates the display name in the contact card widget. |
|
135 * @param result const QVariant& |
|
136 */ |
|
137 void handleOk(const QVariant& result); |
|
138 |
|
139 /** |
|
140 * Slot for handling errors. Error ids are provided as |
|
141 * 32-bit integers. |
|
142 * @param errorCode qint32 |
|
143 */ |
|
144 void handleError(int errorCode, const QString& errorMessage); |
|
145 |
|
146 /** |
|
147 * Called when clicked() signal is emitted |
|
148 * Launches phonebook to view an existing contact |
|
149 * or to add a new contact |
|
150 */ |
|
151 void openContactInfo(); |
|
152 |
|
153 /** |
|
154 * Launches Dialer Service |
|
155 */ |
|
156 void call(); |
|
157 |
|
158 /** |
|
159 * Adds unknown number to phonebook |
|
160 */ |
|
161 void addToContacts(); |
|
162 |
|
163 /** |
|
164 * Called after service request is completed. |
|
165 */ |
|
166 void onServiceRequestCompleted(); |
|
167 |
|
168 /** |
|
169 * Slot hit when the thumbnail is ready. |
|
170 */ |
|
171 void thumbnailReady(const QPixmap& pixmap, void *data, int id, int error); |
|
172 |
|
173 /** |
|
174 * Slot to regrab gesture after some delay (300 ms) to avoid multiple gesture |
|
175 * events back to back. |
|
176 */ |
|
177 void regrabGesture(); |
|
178 |
|
179 private: |
|
180 |
|
181 /** |
|
182 * Contact Number for the conversation |
|
183 */ |
|
184 QString mContactNumber; |
|
185 |
|
186 /** |
|
187 * Address string. |
|
188 */ |
|
189 QString mAddress; |
|
190 |
|
191 /** |
|
192 * Avatar icon item. |
|
193 * Own. |
|
194 */ |
|
195 HbIconItem *mAvatarIconItem; |
|
196 |
|
197 /** |
|
198 * Presence icon item. |
|
199 * Own. |
|
200 */ |
|
201 HbIconItem *mPresenceIconItem; |
|
202 |
|
203 /** |
|
204 * Address text item. |
|
205 * Own. |
|
206 */ |
|
207 HbTextItem *mAddressTextItem; |
|
208 |
|
209 /** |
|
210 * ThumbnailManager |
|
211 * Own. |
|
212 */ |
|
213 ThumbnailManager *mThumbnailManager; |
|
214 }; |
|
215 |
|
216 #endif // MSGCONTACTCARDWIDGET_H |
|
217 // EOF |