author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 23 Jun 2010 18:09:17 +0300 | |
changeset 43 | 35b64624a9e7 |
parent 34 | 84197e66a4bd |
child 44 | 36f374c67aa8 |
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; |
|
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
144 |
QStandardItemModel* msgModel = ConversationsEngine::instance()->getConversationsModel(); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
145 |
const int rowCnt = msgModel->rowCount(); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
146 |
QModelIndex index = msgModel->index(rowCnt-1, 0); |
31 | 147 |
ConvergedMessageAddress* address = new ConvergedMessageAddress( |
148 |
index.data(ConversationAddress).toString()); |
|
149 |
address->setAlias(mAddress); |
|
150 |
addresses.append(address); |
|
151 |
return addresses; |
|
152 |
} |
|
153 |
||
154 |
//--------------------------------------------------------------- |
|
155 |
// MsgContactCardWidget::updateContents |
|
156 |
// @see header file |
|
157 |
//--------------------------------------------------------------- |
|
158 |
void MsgContactCardWidget::updateContents() |
|
159 |
{ |
|
160 |
// Get the Model Index |
|
161 |
QModelIndex index = ConversationsEngine::instance()->getConversationsModel()->index(0, 0); |
|
162 |
||
163 |
// Index is not valid, return. |
|
164 |
if (!index.isValid()) { |
|
165 |
return; |
|
166 |
} |
|
167 |
||
168 |
qint64 convId = ConversationsEngine::instance()->getCurrentConversationId(); |
|
169 |
||
170 |
if (KBluetoothMsgsConversationId == convId) { |
|
171 |
setAddress(LOC_RECEIVED_FILES); |
|
172 |
setAvatar(HbIcon(BT_ICON)); |
|
173 |
} |
|
174 |
else { |
|
175 |
//Set the Contact Name/Number |
|
176 |
qint64 convId; |
|
177 |
QString displayName; |
|
178 |
QString contactAddress; |
|
179 |
convId = ConversationsEngine::instance()->getCurrentConversationId(); |
|
180 |
ConversationsEngine::instance()->getContactDetails(convId, displayName, contactAddress); |
|
181 |
||
182 |
mContactNumber = contactAddress; |
|
183 |
QString contactName; |
|
184 |
if (displayName.isEmpty()) { |
|
185 |
contactName.append(contactAddress); |
|
186 |
} |
|
187 |
else { |
|
188 |
contactName.append(displayName); |
|
189 |
} |
|
190 |
||
191 |
setAddress(contactName); |
|
192 |
||
193 |
// Set Avatar |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
194 |
QList<QContact> contactList = MsgContactHandler::findContactList(mContactNumber); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
195 |
|
31 | 196 |
if (!contactList.isEmpty()) { |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
197 |
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
|
198 |
|
31 | 199 |
if (!avatarDetails.isEmpty()) { |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
200 |
mThumbnailManager->getThumbnail(avatarDetails.at(0).imageUrl().toString()); |
31 | 201 |
} |
202 |
} |
|
203 |
||
204 |
// Set default avatar till actual is set. |
|
205 |
setAvatar(HbIcon(DEFAULT_AVATAR_ICON)); |
|
206 |
} |
|
207 |
} |
|
208 |
||
209 |
//--------------------------------------------------------------- |
|
210 |
// MsgContactCardWidget::clearContent |
|
211 |
// @see header file |
|
212 |
//--------------------------------------------------------------- |
|
213 |
void MsgContactCardWidget::clearContent() |
|
214 |
{ |
|
215 |
setAddress(""); |
|
216 |
setAvatar(HbIcon()); |
|
217 |
} |
|
218 |
||
219 |
//--------------------------------------------------------------- |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
220 |
// MsgContactCardWidget::gestureEvent |
31 | 221 |
// @see header file |
222 |
//--------------------------------------------------------------- |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
223 |
void MsgContactCardWidget::gestureEvent(QGestureEvent *event) |
31 | 224 |
{ |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
225 |
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
|
226 |
if (tapGesture) { |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
227 |
switch (tapGesture->state()) { |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
228 |
case Qt::GestureStarted: |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
229 |
{ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
230 |
// Trigger haptic feedback. |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
231 |
HbInstantFeedback::play(HbFeedback::Basic); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
232 |
setPressed(true); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
233 |
break; |
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 |
case Qt::GestureUpdated: |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
236 |
{ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
237 |
if (HbTapGesture::TapAndHold == tapGesture->tapStyleHint()) { |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
238 |
// Handle longtap. |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
239 |
setPressed(false); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
240 |
handleLongPress(tapGesture->scenePosition()); |
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 |
break; |
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 |
case Qt::GestureFinished: |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
245 |
{ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
246 |
HbInstantFeedback::play(HbFeedback::Basic); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
247 |
if (HbTapGesture::Tap == tapGesture->tapStyleHint()) { |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
248 |
// Handle short tap. |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
249 |
setPressed(false); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
250 |
openContactInfo(); |
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 |
break; |
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 |
case Qt::GestureCanceled: |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
255 |
{ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
256 |
HbInstantFeedback::play(HbFeedback::Basic); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
257 |
setPressed(false); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
258 |
break; |
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 |
} |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
261 |
} |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
262 |
else { |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
263 |
HbWidget::gestureEvent(event); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
264 |
} |
31 | 265 |
} |
266 |
||
267 |
//--------------------------------------------------------------- |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
268 |
// MsgContactCardWidget::setPressed |
31 | 269 |
// @see header file |
270 |
//--------------------------------------------------------------- |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
271 |
void MsgContactCardWidget::setPressed(bool pressed) |
31 | 272 |
{ |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
273 |
HbFrameItem *frameItem = static_cast<HbFrameItem *> (this->backgroundItem()); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
274 |
if (pressed) { |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
275 |
this->setProperty("state", "pressed"); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
276 |
frameItem->frameDrawer().setFrameGraphicsName(BG_FRAME_PRESSED); |
31 | 277 |
} |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
278 |
else { |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
279 |
this->setProperty("state", "normal"); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
280 |
frameItem->frameDrawer().setFrameGraphicsName(BG_FRAME_NORMAL); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
281 |
} |
31 | 282 |
} |
283 |
||
284 |
//--------------------------------------------------------------- |
|
285 |
// MsgContactCardWidget::handleLongPress |
|
286 |
// @see header file |
|
287 |
//--------------------------------------------------------------- |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
288 |
void MsgContactCardWidget::handleLongPress(const QPointF &position) |
31 | 289 |
{ |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
290 |
// 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
|
291 |
if (mIgnoreEvents) { |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
292 |
return; |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
293 |
} |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
294 |
|
31 | 295 |
if (KBluetoothMsgsConversationId != ConversationsEngine::instance()->getCurrentConversationId()) { |
296 |
HbMenu* contextMenu = new HbMenu(); |
|
297 |
contextMenu->setDismissPolicy(HbPopup::TapAnywhere); |
|
298 |
contextMenu->setAttribute(Qt::WA_DeleteOnClose, true); |
|
299 |
contextMenu->setPreferredPos(position); |
|
300 |
||
301 |
contextMenu->addAction(LOC_MENU_CONTACT_INFO, this, SLOT(openContactInfo())); |
|
302 |
contextMenu->addAction(LOC_COMMON_MENU_CALL, this, SLOT(call())); |
|
303 |
||
304 |
//If contact doesn't exist in phonebook then add another menu item "Save to Contacts" |
|
305 |
int contactId = resolveContactId(mContactNumber); |
|
306 |
if (contactId < 0) { |
|
307 |
contextMenu->addAction(LOC_SAVETO_CONTACTS, this, SLOT(addToContacts())); |
|
308 |
} |
|
309 |
||
310 |
contextMenu->show(); |
|
311 |
} |
|
312 |
} |
|
313 |
||
314 |
//--------------------------------------------------------------- |
|
315 |
// MsgContactCardWidget::openContactInfo |
|
316 |
// @see header |
|
317 |
//--------------------------------------------------------------- |
|
318 |
void MsgContactCardWidget::openContactInfo() |
|
319 |
{ |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
320 |
this->ungrabGesture(Qt::TapGesture); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
321 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
322 |
// 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
|
323 |
if (mIgnoreEvents) { |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
324 |
return; |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
325 |
} |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
326 |
|
31 | 327 |
QString operation; |
328 |
QList<QVariant> args; |
|
329 |
if (KBluetoothMsgsConversationId != ConversationsEngine::instance()->getCurrentConversationId()) { |
|
330 |
int contactId = resolveContactId(mContactNumber); |
|
331 |
if (contactId > 0) { |
|
332 |
//open existing contact card |
|
333 |
operation = QString("open(int)"); |
|
334 |
args << contactId; |
|
335 |
} |
|
336 |
else { |
|
337 |
//populate data and open unknown contact template |
|
338 |
operation = QString("editCreateNew(QString,QString)"); |
|
339 |
QString type = QContactPhoneNumber::DefinitionName; |
|
340 |
||
341 |
args << type; |
|
342 |
args << mAddress; |
|
343 |
} |
|
344 |
//service stuff. |
|
345 |
QString serviceName("com.nokia.services.phonebookservices"); |
|
346 |
||
347 |
XQAiwRequest* request; |
|
348 |
XQApplicationManager appManager; |
|
349 |
request = appManager.create(serviceName, "Fetch", operation, true); // embedded |
|
350 |
if (request == NULL) { |
|
351 |
return; |
|
352 |
} |
|
353 |
||
354 |
// Result handlers |
|
355 |
connect(request, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleOk(const QVariant&))); |
|
356 |
connect(request, SIGNAL(requestError(const QVariant&)), this, |
|
357 |
SLOT(handleError(const QVariant&))); |
|
358 |
||
359 |
request->setArguments(args); |
|
360 |
request->send(); |
|
361 |
delete request; |
|
362 |
} |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
363 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
364 |
//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
|
365 |
QTimer::singleShot(300,this,SLOT(regrabGesture())); |
31 | 366 |
} |
367 |
||
368 |
//--------------------------------------------------------------- |
|
369 |
// MsgContactCardWidget::resolveContactId |
|
370 |
// @see header |
|
371 |
//--------------------------------------------------------------- |
|
372 |
int MsgContactCardWidget::resolveContactId(const QString& value) |
|
373 |
{ |
|
374 |
QString displayLabel; |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
375 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
376 |
int count; |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
377 |
return MsgContactHandler::resolveContactDisplayName(value, displayLabel, count); |
31 | 378 |
} |
379 |
||
380 |
//--------------------------------------------------------------- |
|
381 |
// MsgContactCardWidget::call |
|
382 |
// @see header |
|
383 |
//--------------------------------------------------------------- |
|
384 |
void MsgContactCardWidget::call() |
|
385 |
{ |
|
386 |
//Launch dialer service |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
387 |
QString serviceName("com.nokia.symbian.ICallDial"); |
31 | 388 |
QString operation("dial(QString)"); |
389 |
||
390 |
XQServiceRequest* serviceRequest = new XQServiceRequest(serviceName, operation, false); |
|
391 |
||
392 |
connect(serviceRequest, SIGNAL(requestCompleted(QVariant)), this, |
|
393 |
SLOT(onServiceRequestCompleted())); |
|
394 |
||
395 |
connect(serviceRequest, SIGNAL(requestError(int)), this, SLOT(onServiceRequestCompleted())); |
|
396 |
||
397 |
*serviceRequest << mContactNumber; |
|
398 |
serviceRequest->send(); |
|
399 |
} |
|
400 |
||
401 |
//--------------------------------------------------------------- |
|
402 |
// MsgContactCardWidget::addToContacts |
|
403 |
// @see header |
|
404 |
//--------------------------------------------------------------- |
|
405 |
void MsgContactCardWidget::addToContacts() |
|
406 |
{ |
|
407 |
} |
|
408 |
||
409 |
//--------------------------------------------------------------- |
|
410 |
// MsgContactCardWidget::handleOk |
|
411 |
// @see header |
|
412 |
//--------------------------------------------------------------- |
|
413 |
void MsgContactCardWidget::handleOk(const QVariant& result) |
|
414 |
{ |
|
415 |
Q_UNUSED(result) |
|
416 |
||
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
417 |
QList<QContact> matchingContacts = MsgContactHandler::findContactList(mContactNumber); |
31 | 418 |
|
419 |
if (!matchingContacts.isEmpty()) { |
|
420 |
setAddress(matchingContacts.at(0).displayLabel()); |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
421 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
422 |
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
|
423 |
|
31 | 424 |
if (!avatarDetails.isEmpty()) { |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
425 |
mThumbnailManager->getThumbnail(avatarDetails.at(0).imageUrl().toString()); |
31 | 426 |
} |
427 |
} |
|
428 |
} |
|
429 |
||
430 |
//--------------------------------------------------------------- |
|
431 |
// MsgContactCardWidget::handleError |
|
432 |
// @see header |
|
433 |
//--------------------------------------------------------------- |
|
434 |
void MsgContactCardWidget::handleError(int errorCode, const QString& errorMessage) |
|
435 |
{ |
|
436 |
Q_UNUSED(errorMessage) |
|
437 |
Q_UNUSED(errorCode) |
|
438 |
} |
|
439 |
||
440 |
//--------------------------------------------------------------- |
|
441 |
// MsgContactCardWidget::onServiceRequestCompleted |
|
442 |
// @see header |
|
443 |
//--------------------------------------------------------------- |
|
444 |
void MsgContactCardWidget::onServiceRequestCompleted() |
|
445 |
{ |
|
446 |
//service request is now complete. delete it. |
|
447 |
XQServiceRequest* request = qobject_cast<XQServiceRequest*> (sender()); |
|
448 |
if (request) { |
|
449 |
delete request; |
|
450 |
} |
|
451 |
} |
|
452 |
||
453 |
//--------------------------------------------------------------- |
|
454 |
// MsgContactCardWidget::thumbnailReady |
|
455 |
// @see header |
|
456 |
//--------------------------------------------------------------- |
|
457 |
void MsgContactCardWidget::thumbnailReady(const QPixmap& pixmap, void *data, int id, int error) |
|
458 |
{ |
|
459 |
Q_UNUSED(data) |
|
460 |
Q_UNUSED(id) |
|
461 |
||
462 |
if (!error) { |
|
463 |
QIcon icon(pixmap); |
|
464 |
setAvatar(HbIcon(icon)); |
|
465 |
} |
|
466 |
else { |
|
467 |
setAvatar(HbIcon(DEFAULT_AVATAR_ICON)); |
|
468 |
} |
|
469 |
} |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
470 |
|
31 | 471 |
//--------------------------------------------------------------- |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
472 |
// MsgContactCardWidget::ignoreSignals |
31 | 473 |
// @see header |
474 |
//--------------------------------------------------------------- |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
475 |
void MsgContactCardWidget::ignoreSignals(bool yes) |
31 | 476 |
{ |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
477 |
mIgnoreEvents = yes; |
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 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
480 |
//--------------------------------------------------------------- |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
481 |
// MsgContactCardWidget::regrabGesture |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
482 |
// @see header file |
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 |
void MsgContactCardWidget::regrabGesture() |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
485 |
{ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
486 |
this->grabGesture(Qt::TapGesture); |
31 | 487 |
} |
488 |
// EOF |