author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 11 Jun 2010 13:35:48 +0300 | |
changeset 34 | 84197e66a4bd |
parent 31 | ebfee66fde93 |
child 43 | 35b64624a9e7 |
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: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include "msgcontactcardwidget.h" |
|
19 |
||
20 |
// SYSTEM INCLUDES |
|
21 |
#include <HbStyle> |
|
22 |
#include <HbIconItem> |
|
23 |
#include <HbTextItem> |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
24 |
#include <HbTapGesture> |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
25 |
#include <HbInstantFeedback> |
31 | 26 |
#include <HbFrameItem> |
27 |
#include <qcontactphonenumber.h> |
|
28 |
#include <qcontactavatar.h> |
|
29 |
#include <xqaiwrequest.h> |
|
30 |
#include <xqappmgr.h> |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
31 |
#include <xqservicerequest.h> |
31 | 32 |
#include <cntservicescontact.h> |
33 |
#include <QGraphicsSceneMouseEvent> |
|
34 |
#include <HbMenu> |
|
35 |
#include <thumbnailmanager_qt.h> |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
36 |
#include <QTimer> |
31 | 37 |
|
38 |
#include <ccsdefs.h> |
|
39 |
||
40 |
// USER INCLUDES |
|
41 |
#include "conversationsenginedefines.h" |
|
42 |
#include "conversationsengine.h" |
|
43 |
#include "convergedmessage.h" |
|
44 |
#include "msgcontacthandler.h" |
|
45 |
||
46 |
// LOCAL CONSTANTS |
|
47 |
const QString DEFAULT_AVATAR_ICON("qtg_large_avatar"); |
|
48 |
const QString BT_ICON("qtg_large_bluetooth"); |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
49 |
const QString BG_FRAME_NORMAL("qtg_fr_groupbox_normal"); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
50 |
const QString BG_FRAME_PRESSED("qtg_fr_groupbox_pressed"); |
31 | 51 |
|
52 |
// LOCALIZATION CONSTANTS |
|
53 |
#define LOC_RECEIVED_FILES hbTrId("txt_messaging_title_received_files") |
|
54 |
#define LOC_MENU_CONTACT_INFO hbTrId("txt_messaging_menu_open_contact_info") |
|
55 |
#define LOC_COMMON_MENU_CALL hbTrId("txt_common_menu_call_verb") |
|
56 |
#define LOC_SAVETO_CONTACTS hbTrId("txt_messaging_menu_save_to_contacts") |
|
57 |
||
58 |
// LOCAL FUNCTIONS |
|
59 |
||
60 |
//--------------------------------------------------------------- |
|
61 |
// MsgContactCardWidget::MsgContactCardWidget |
|
62 |
// @see header |
|
63 |
//--------------------------------------------------------------- |
|
64 |
MsgContactCardWidget::MsgContactCardWidget(QGraphicsItem *parent) : |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
65 |
HbWidget(parent), mIgnoreEvents(false), mAvatarIconItem(NULL), mPresenceIconItem(NULL), |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
66 |
mAddressTextItem(NULL), mThumbnailManager(NULL) |
31 | 67 |
{ |
68 |
init(); |
|
69 |
} |
|
70 |
||
71 |
//--------------------------------------------------------------- |
|
72 |
// MsgContactCardWidget::~MsgContactCardWidget |
|
73 |
// @see header |
|
74 |
//--------------------------------------------------------------- |
|
75 |
MsgContactCardWidget::~MsgContactCardWidget() |
|
76 |
{ |
|
77 |
} |
|
78 |
||
79 |
//--------------------------------------------------------------- |
|
80 |
// MsgContactCardWidget::init |
|
81 |
// @see header |
|
82 |
//--------------------------------------------------------------- |
|
83 |
void MsgContactCardWidget::init() |
|
84 |
{ |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
85 |
this->setProperty("state", "normal"); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
86 |
this->grabGesture(Qt::TapGesture); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
87 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
88 |
HbFrameItem *frameItem = new HbFrameItem(BG_FRAME_NORMAL, HbFrameDrawer::NinePieces, this); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
89 |
this->setBackgroundItem(frameItem); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
90 |
|
31 | 91 |
mAvatarIconItem = new HbIconItem(this); |
92 |
HbStyle::setItemName(mAvatarIconItem, "avatar"); |
|
93 |
||
94 |
mPresenceIconItem = new HbIconItem(this); |
|
95 |
HbStyle::setItemName(mPresenceIconItem, "presence"); |
|
96 |
||
97 |
mAddressTextItem = new HbTextItem(this); |
|
98 |
HbStyle::setItemName(mAddressTextItem, "addressText"); |
|
99 |
||
100 |
mThumbnailManager = new ThumbnailManager(this); |
|
101 |
mThumbnailManager->setMode(ThumbnailManager::Default); |
|
102 |
mThumbnailManager->setQualityPreference(ThumbnailManager::OptimizeForQuality); |
|
103 |
mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailLarge); |
|
104 |
||
105 |
connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void*, int, int)), this, |
|
106 |
SLOT(thumbnailReady(QPixmap, void*, int, int))); |
|
107 |
} |
|
108 |
||
109 |
//--------------------------------------------------------------- |
|
110 |
// MsgContactCardWidget::setAvatar |
|
111 |
// @see header |
|
112 |
//--------------------------------------------------------------- |
|
113 |
void MsgContactCardWidget::setAvatar(const HbIcon &avatar) |
|
114 |
{ |
|
115 |
mAvatarIconItem->setIcon(avatar); |
|
116 |
} |
|
117 |
||
118 |
//--------------------------------------------------------------- |
|
119 |
// MsgContactCardWidget::setPresenceIcon |
|
120 |
// @see header |
|
121 |
//--------------------------------------------------------------- |
|
122 |
void MsgContactCardWidget::setPresenceIcon(const HbIcon &presenceIcon) |
|
123 |
{ |
|
124 |
mPresenceIconItem->setIcon(presenceIcon); |
|
125 |
} |
|
126 |
||
127 |
//--------------------------------------------------------------- |
|
128 |
// MsgContactCardWidget::setAddress |
|
129 |
// @see header |
|
130 |
//--------------------------------------------------------------- |
|
131 |
void MsgContactCardWidget::setAddress(const QString &address) |
|
132 |
{ |
|
133 |
mAddress = address; |
|
134 |
mAddressTextItem->setText(address); |
|
135 |
} |
|
136 |
||
137 |
//--------------------------------------------------------------- |
|
138 |
// MsgContactCardWidget::address |
|
139 |
// @see header |
|
140 |
//--------------------------------------------------------------- |
|
141 |
ConvergedMessageAddressList MsgContactCardWidget::address() |
|
142 |
{ |
|
143 |
ConvergedMessageAddressList addresses; |
|
144 |
QModelIndex index = ConversationsEngine::instance()->getConversationsModel()->index(0, 0); |
|
145 |
ConvergedMessageAddress* address = new ConvergedMessageAddress( |
|
146 |
index.data(ConversationAddress).toString()); |
|
147 |
address->setAlias(mAddress); |
|
148 |
addresses.append(address); |
|
149 |
return addresses; |
|
150 |
} |
|
151 |
||
152 |
//--------------------------------------------------------------- |
|
153 |
// MsgContactCardWidget::updateContents |
|
154 |
// @see header file |
|
155 |
//--------------------------------------------------------------- |
|
156 |
void MsgContactCardWidget::updateContents() |
|
157 |
{ |
|
158 |
// Get the Model Index |
|
159 |
QModelIndex index = ConversationsEngine::instance()->getConversationsModel()->index(0, 0); |
|
160 |
||
161 |
// Index is not valid, return. |
|
162 |
if (!index.isValid()) { |
|
163 |
return; |
|
164 |
} |
|
165 |
||
166 |
qint64 convId = ConversationsEngine::instance()->getCurrentConversationId(); |
|
167 |
||
168 |
if (KBluetoothMsgsConversationId == convId) { |
|
169 |
setAddress(LOC_RECEIVED_FILES); |
|
170 |
setAvatar(HbIcon(BT_ICON)); |
|
171 |
} |
|
172 |
else { |
|
173 |
//Set the Contact Name/Number |
|
174 |
qint64 convId; |
|
175 |
QString displayName; |
|
176 |
QString contactAddress; |
|
177 |
convId = ConversationsEngine::instance()->getCurrentConversationId(); |
|
178 |
ConversationsEngine::instance()->getContactDetails(convId, displayName, contactAddress); |
|
179 |
||
180 |
mContactNumber = contactAddress; |
|
181 |
QString contactName; |
|
182 |
if (displayName.isEmpty()) { |
|
183 |
contactName.append(contactAddress); |
|
184 |
} |
|
185 |
else { |
|
186 |
contactName.append(displayName); |
|
187 |
} |
|
188 |
||
189 |
setAddress(contactName); |
|
190 |
||
191 |
// Set Avatar |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
192 |
QList<QContact> contactList = MsgContactHandler::findContactList(mContactNumber); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
193 |
|
31 | 194 |
if (!contactList.isEmpty()) { |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
195 |
QList<QContactAvatar> avatarDetails = contactList.at(0).details<QContactAvatar> (); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
196 |
|
31 | 197 |
if (!avatarDetails.isEmpty()) { |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
198 |
mThumbnailManager->getThumbnail(avatarDetails.at(0).imageUrl().toString()); |
31 | 199 |
} |
200 |
} |
|
201 |
||
202 |
// Set default avatar till actual is set. |
|
203 |
setAvatar(HbIcon(DEFAULT_AVATAR_ICON)); |
|
204 |
} |
|
205 |
} |
|
206 |
||
207 |
//--------------------------------------------------------------- |
|
208 |
// MsgContactCardWidget::clearContent |
|
209 |
// @see header file |
|
210 |
//--------------------------------------------------------------- |
|
211 |
void MsgContactCardWidget::clearContent() |
|
212 |
{ |
|
213 |
setAddress(""); |
|
214 |
setAvatar(HbIcon()); |
|
215 |
} |
|
216 |
||
217 |
//--------------------------------------------------------------- |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
218 |
// MsgContactCardWidget::gestureEvent |
31 | 219 |
// @see header file |
220 |
//--------------------------------------------------------------- |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
221 |
void MsgContactCardWidget::gestureEvent(QGestureEvent *event) |
31 | 222 |
{ |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
223 |
HbTapGesture *tapGesture = qobject_cast<HbTapGesture*> (event->gesture(Qt::TapGesture)); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
224 |
if (tapGesture) { |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
225 |
switch (tapGesture->state()) { |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
226 |
case Qt::GestureStarted: |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
227 |
{ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
228 |
// Trigger haptic feedback. |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
229 |
HbInstantFeedback::play(HbFeedback::Basic); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
230 |
setPressed(true); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
231 |
break; |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
232 |
} |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
233 |
case Qt::GestureUpdated: |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
234 |
{ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
235 |
if (HbTapGesture::TapAndHold == tapGesture->tapStyleHint()) { |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
236 |
// Handle longtap. |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
237 |
setPressed(false); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
238 |
handleLongPress(tapGesture->scenePosition()); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
239 |
} |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
240 |
break; |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
241 |
} |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
242 |
case Qt::GestureFinished: |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
243 |
{ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
244 |
HbInstantFeedback::play(HbFeedback::Basic); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
245 |
if (HbTapGesture::Tap == tapGesture->tapStyleHint()) { |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
246 |
// Handle short tap. |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
247 |
setPressed(false); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
248 |
openContactInfo(); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
249 |
} |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
250 |
break; |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
251 |
} |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
252 |
case Qt::GestureCanceled: |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
253 |
{ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
254 |
HbInstantFeedback::play(HbFeedback::Basic); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
255 |
setPressed(false); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
256 |
break; |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
257 |
} |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
258 |
} |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
259 |
} |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
260 |
else { |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
261 |
HbWidget::gestureEvent(event); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
262 |
} |
31 | 263 |
} |
264 |
||
265 |
//--------------------------------------------------------------- |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
266 |
// MsgContactCardWidget::setPressed |
31 | 267 |
// @see header file |
268 |
//--------------------------------------------------------------- |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
269 |
void MsgContactCardWidget::setPressed(bool pressed) |
31 | 270 |
{ |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
271 |
HbFrameItem *frameItem = static_cast<HbFrameItem *> (this->backgroundItem()); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
272 |
if (pressed) { |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
273 |
this->setProperty("state", "pressed"); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
274 |
frameItem->frameDrawer().setFrameGraphicsName(BG_FRAME_PRESSED); |
31 | 275 |
} |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
276 |
else { |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
277 |
this->setProperty("state", "normal"); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
278 |
frameItem->frameDrawer().setFrameGraphicsName(BG_FRAME_NORMAL); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
279 |
} |
31 | 280 |
} |
281 |
||
282 |
//--------------------------------------------------------------- |
|
283 |
// MsgContactCardWidget::handleLongPress |
|
284 |
// @see header file |
|
285 |
//--------------------------------------------------------------- |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
286 |
void MsgContactCardWidget::handleLongPress(const QPointF &position) |
31 | 287 |
{ |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
288 |
// Check if events need to be ignored/accepted |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
289 |
if (mIgnoreEvents) { |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
290 |
return; |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
291 |
} |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
292 |
|
31 | 293 |
if (KBluetoothMsgsConversationId != ConversationsEngine::instance()->getCurrentConversationId()) { |
294 |
HbMenu* contextMenu = new HbMenu(); |
|
295 |
contextMenu->setDismissPolicy(HbPopup::TapAnywhere); |
|
296 |
contextMenu->setAttribute(Qt::WA_DeleteOnClose, true); |
|
297 |
contextMenu->setPreferredPos(position); |
|
298 |
||
299 |
contextMenu->addAction(LOC_MENU_CONTACT_INFO, this, SLOT(openContactInfo())); |
|
300 |
contextMenu->addAction(LOC_COMMON_MENU_CALL, this, SLOT(call())); |
|
301 |
||
302 |
//If contact doesn't exist in phonebook then add another menu item "Save to Contacts" |
|
303 |
int contactId = resolveContactId(mContactNumber); |
|
304 |
if (contactId < 0) { |
|
305 |
contextMenu->addAction(LOC_SAVETO_CONTACTS, this, SLOT(addToContacts())); |
|
306 |
} |
|
307 |
||
308 |
contextMenu->show(); |
|
309 |
} |
|
310 |
} |
|
311 |
||
312 |
//--------------------------------------------------------------- |
|
313 |
// MsgContactCardWidget::openContactInfo |
|
314 |
// @see header |
|
315 |
//--------------------------------------------------------------- |
|
316 |
void MsgContactCardWidget::openContactInfo() |
|
317 |
{ |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
318 |
this->ungrabGesture(Qt::TapGesture); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
319 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
320 |
// Check if events need to be ignored/accepted |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
321 |
if (mIgnoreEvents) { |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
322 |
return; |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
323 |
} |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
324 |
|
31 | 325 |
QString operation; |
326 |
QList<QVariant> args; |
|
327 |
if (KBluetoothMsgsConversationId != ConversationsEngine::instance()->getCurrentConversationId()) { |
|
328 |
int contactId = resolveContactId(mContactNumber); |
|
329 |
if (contactId > 0) { |
|
330 |
//open existing contact card |
|
331 |
operation = QString("open(int)"); |
|
332 |
args << contactId; |
|
333 |
} |
|
334 |
else { |
|
335 |
//populate data and open unknown contact template |
|
336 |
operation = QString("editCreateNew(QString,QString)"); |
|
337 |
QString type = QContactPhoneNumber::DefinitionName; |
|
338 |
||
339 |
args << type; |
|
340 |
args << mAddress; |
|
341 |
} |
|
342 |
//service stuff. |
|
343 |
QString serviceName("com.nokia.services.phonebookservices"); |
|
344 |
||
345 |
XQAiwRequest* request; |
|
346 |
XQApplicationManager appManager; |
|
347 |
request = appManager.create(serviceName, "Fetch", operation, true); // embedded |
|
348 |
if (request == NULL) { |
|
349 |
return; |
|
350 |
} |
|
351 |
||
352 |
// Result handlers |
|
353 |
connect(request, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleOk(const QVariant&))); |
|
354 |
connect(request, SIGNAL(requestError(const QVariant&)), this, |
|
355 |
SLOT(handleError(const QVariant&))); |
|
356 |
||
357 |
request->setArguments(args); |
|
358 |
request->send(); |
|
359 |
delete request; |
|
360 |
} |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
361 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
362 |
//fire timer to regrab gesture after some delay. |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
363 |
QTimer::singleShot(300,this,SLOT(regrabGesture())); |
31 | 364 |
} |
365 |
||
366 |
//--------------------------------------------------------------- |
|
367 |
// MsgContactCardWidget::resolveContactId |
|
368 |
// @see header |
|
369 |
//--------------------------------------------------------------- |
|
370 |
int MsgContactCardWidget::resolveContactId(const QString& value) |
|
371 |
{ |
|
372 |
QString displayLabel; |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
373 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
374 |
int count; |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
375 |
return MsgContactHandler::resolveContactDisplayName(value, displayLabel, count); |
31 | 376 |
} |
377 |
||
378 |
//--------------------------------------------------------------- |
|
379 |
// MsgContactCardWidget::call |
|
380 |
// @see header |
|
381 |
//--------------------------------------------------------------- |
|
382 |
void MsgContactCardWidget::call() |
|
383 |
{ |
|
384 |
//Launch dialer service |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
385 |
QString serviceName("com.nokia.symbian.ICallDial"); |
31 | 386 |
QString operation("dial(QString)"); |
387 |
||
388 |
XQServiceRequest* serviceRequest = new XQServiceRequest(serviceName, operation, false); |
|
389 |
||
390 |
connect(serviceRequest, SIGNAL(requestCompleted(QVariant)), this, |
|
391 |
SLOT(onServiceRequestCompleted())); |
|
392 |
||
393 |
connect(serviceRequest, SIGNAL(requestError(int)), this, SLOT(onServiceRequestCompleted())); |
|
394 |
||
395 |
*serviceRequest << mContactNumber; |
|
396 |
serviceRequest->send(); |
|
397 |
} |
|
398 |
||
399 |
//--------------------------------------------------------------- |
|
400 |
// MsgContactCardWidget::addToContacts |
|
401 |
// @see header |
|
402 |
//--------------------------------------------------------------- |
|
403 |
void MsgContactCardWidget::addToContacts() |
|
404 |
{ |
|
405 |
} |
|
406 |
||
407 |
//--------------------------------------------------------------- |
|
408 |
// MsgContactCardWidget::handleOk |
|
409 |
// @see header |
|
410 |
//--------------------------------------------------------------- |
|
411 |
void MsgContactCardWidget::handleOk(const QVariant& result) |
|
412 |
{ |
|
413 |
Q_UNUSED(result) |
|
414 |
||
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
415 |
QList<QContact> matchingContacts = MsgContactHandler::findContactList(mContactNumber); |
31 | 416 |
|
417 |
if (!matchingContacts.isEmpty()) { |
|
418 |
setAddress(matchingContacts.at(0).displayLabel()); |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
419 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
420 |
QList<QContactAvatar> avatarDetails = matchingContacts.at(0).details<QContactAvatar> (); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
421 |
|
31 | 422 |
if (!avatarDetails.isEmpty()) { |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
423 |
mThumbnailManager->getThumbnail(avatarDetails.at(0).imageUrl().toString()); |
31 | 424 |
} |
425 |
} |
|
426 |
} |
|
427 |
||
428 |
//--------------------------------------------------------------- |
|
429 |
// MsgContactCardWidget::handleError |
|
430 |
// @see header |
|
431 |
//--------------------------------------------------------------- |
|
432 |
void MsgContactCardWidget::handleError(int errorCode, const QString& errorMessage) |
|
433 |
{ |
|
434 |
Q_UNUSED(errorMessage) |
|
435 |
Q_UNUSED(errorCode) |
|
436 |
} |
|
437 |
||
438 |
//--------------------------------------------------------------- |
|
439 |
// MsgContactCardWidget::onServiceRequestCompleted |
|
440 |
// @see header |
|
441 |
//--------------------------------------------------------------- |
|
442 |
void MsgContactCardWidget::onServiceRequestCompleted() |
|
443 |
{ |
|
444 |
//service request is now complete. delete it. |
|
445 |
XQServiceRequest* request = qobject_cast<XQServiceRequest*> (sender()); |
|
446 |
if (request) { |
|
447 |
delete request; |
|
448 |
} |
|
449 |
} |
|
450 |
||
451 |
//--------------------------------------------------------------- |
|
452 |
// MsgContactCardWidget::thumbnailReady |
|
453 |
// @see header |
|
454 |
//--------------------------------------------------------------- |
|
455 |
void MsgContactCardWidget::thumbnailReady(const QPixmap& pixmap, void *data, int id, int error) |
|
456 |
{ |
|
457 |
Q_UNUSED(data) |
|
458 |
Q_UNUSED(id) |
|
459 |
||
460 |
if (!error) { |
|
461 |
QIcon icon(pixmap); |
|
462 |
setAvatar(HbIcon(icon)); |
|
463 |
} |
|
464 |
else { |
|
465 |
setAvatar(HbIcon(DEFAULT_AVATAR_ICON)); |
|
466 |
} |
|
467 |
} |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
468 |
|
31 | 469 |
//--------------------------------------------------------------- |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
470 |
// MsgContactCardWidget::ignoreSignals |
31 | 471 |
// @see header |
472 |
//--------------------------------------------------------------- |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
473 |
void MsgContactCardWidget::ignoreSignals(bool yes) |
31 | 474 |
{ |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
475 |
mIgnoreEvents = yes; |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
476 |
} |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
477 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
478 |
//--------------------------------------------------------------- |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
479 |
// MsgContactCardWidget::regrabGesture |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
480 |
// @see header file |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
481 |
//--------------------------------------------------------------- |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
482 |
void MsgContactCardWidget::regrabGesture() |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
483 |
{ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
484 |
this->grabGesture(Qt::TapGesture); |
31 | 485 |
} |
486 |
// EOF |