messagingapp/msgui/conversationview/src/msgcontactcardwidget.cpp
author hgs
Tue, 07 Sep 2010 13:28:39 +0530
changeset 62 fdbe8253b596
parent 56 f42d9a78f435
child 67 fc91263aee62
permissions -rw-r--r--
201035_03
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
 * All rights reserved.
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
 *
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
 * Initial Contributors:
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
 *
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
 * Contributors:
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
 *
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
 * Description:
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
 *
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
 */
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
#include "msgcontactcardwidget.h"
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
// SYSTEM INCLUDES
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <HbStyle>
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include <HbIconItem>
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <HbTextItem>
37
hgs
parents: 25
diff changeset
    24
#include <HbTapGesture>
hgs
parents: 25
diff changeset
    25
#include <HbInstantFeedback>
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    26
#include <HbFrameItem>
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    27
#include <qcontactphonenumber.h>
37
hgs
parents: 25
diff changeset
    28
#include <qcontactavatar.h>
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    29
#include <xqaiwrequest.h>
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    30
#include <xqappmgr.h>
37
hgs
parents: 25
diff changeset
    31
#include <xqservicerequest.h>
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    32
#include <cntservicescontact.h>
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    33
#include <QGraphicsSceneMouseEvent>
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    34
#include <HbMenu>
37
hgs
parents: 25
diff changeset
    35
#include <thumbnailmanager_qt.h>
hgs
parents: 25
diff changeset
    36
#include <QTimer>
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    37
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    38
#include <ccsdefs.h>
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
// USER INCLUDES
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
#include "conversationsenginedefines.h"
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
#include "conversationsengine.h"
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    43
#include "convergedmessage.h"
37
hgs
parents: 25
diff changeset
    44
#include "msgcontacthandler.h"
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
// LOCAL CONSTANTS
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    47
const QString DEFAULT_AVATAR_ICON("qtg_large_avatar");
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    48
const QString BT_ICON("qtg_large_bluetooth");
37
hgs
parents: 25
diff changeset
    49
const QString BG_FRAME_NORMAL("qtg_fr_groupbox_normal");
hgs
parents: 25
diff changeset
    50
const QString BG_FRAME_PRESSED("qtg_fr_groupbox_pressed");
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    52
// LOCALIZATION CONSTANTS
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    53
#define LOC_RECEIVED_FILES hbTrId("txt_messaging_title_received_files")
37
hgs
parents: 25
diff changeset
    54
#define LOC_MENU_CONTACT_INFO hbTrId("txt_messaging_menu_contact_info")
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    55
#define LOC_COMMON_MENU_CALL hbTrId("txt_common_menu_call_verb")
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    56
#define LOC_SAVETO_CONTACTS hbTrId("txt_messaging_menu_save_to_contacts")
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    57
37
hgs
parents: 25
diff changeset
    58
// LOCAL FUNCTIONS
hgs
parents: 25
diff changeset
    59
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
// MsgContactCardWidget::MsgContactCardWidget
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
// @see header
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
MsgContactCardWidget::MsgContactCardWidget(QGraphicsItem *parent) :
51
3507212d340e 201031_02
hgs
parents: 41
diff changeset
    65
    HbWidget(parent), mAvatarIconItem(NULL), mPresenceIconItem(NULL),
37
hgs
parents: 25
diff changeset
    66
        mAddressTextItem(NULL), mThumbnailManager(NULL)
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
{
37
hgs
parents: 25
diff changeset
    68
    init();
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
// MsgContactCardWidget::~MsgContactCardWidget
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
// @see header
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
MsgContactCardWidget::~MsgContactCardWidget()
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
// MsgContactCardWidget::init
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
// @see header
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
void MsgContactCardWidget::init()
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
{
37
hgs
parents: 25
diff changeset
    85
    this->setProperty("state", "normal");
hgs
parents: 25
diff changeset
    86
    this->grabGesture(Qt::TapGesture);
hgs
parents: 25
diff changeset
    87
hgs
parents: 25
diff changeset
    88
    HbFrameItem *frameItem = new HbFrameItem(BG_FRAME_NORMAL, HbFrameDrawer::NinePieces, this);
hgs
parents: 25
diff changeset
    89
    this->setBackgroundItem(frameItem);
hgs
parents: 25
diff changeset
    90
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
    mAvatarIconItem = new HbIconItem(this);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
    HbStyle::setItemName(mAvatarIconItem, "avatar");
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
    mPresenceIconItem = new HbIconItem(this);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
    HbStyle::setItemName(mPresenceIconItem, "presence");
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
    mAddressTextItem = new HbTextItem(this);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
    HbStyle::setItemName(mAddressTextItem, "addressText");
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
37
hgs
parents: 25
diff changeset
   100
    mThumbnailManager = new ThumbnailManager(this);
hgs
parents: 25
diff changeset
   101
    mThumbnailManager->setMode(ThumbnailManager::Default);
hgs
parents: 25
diff changeset
   102
    mThumbnailManager->setQualityPreference(ThumbnailManager::OptimizeForQuality);
hgs
parents: 25
diff changeset
   103
    mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailLarge);
hgs
parents: 25
diff changeset
   104
hgs
parents: 25
diff changeset
   105
    connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void*, int, int)), this,
hgs
parents: 25
diff changeset
   106
        SLOT(thumbnailReady(QPixmap, void*, int, int)));
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
// MsgContactCardWidget::setAvatar
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
// @see header
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
void MsgContactCardWidget::setAvatar(const HbIcon &avatar)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
    mAvatarIconItem->setIcon(avatar);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
// MsgContactCardWidget::setPresenceIcon
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
// @see header
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
void MsgContactCardWidget::setPresenceIcon(const HbIcon &presenceIcon)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
    mPresenceIconItem->setIcon(presenceIcon);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
// MsgContactCardWidget::setAddress
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
// @see header
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
void MsgContactCardWidget::setAddress(const QString &address)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
    mAddress = address;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
    mAddressTextItem->setText(address);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
// MsgContactCardWidget::address
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
// @see header
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
ConvergedMessageAddressList MsgContactCardWidget::address()
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
    ConvergedMessageAddressList addresses;
37
hgs
parents: 25
diff changeset
   144
    QStandardItemModel* msgModel = ConversationsEngine::instance()->getConversationsModel();
hgs
parents: 25
diff changeset
   145
    const int rowCnt = msgModel->rowCount();
hgs
parents: 25
diff changeset
   146
    QModelIndex index = msgModel->index(rowCnt-1, 0);
41
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   147
    QString addr = index.data(ConversationAddress).toString();
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   148
    ConvergedMessageAddress* address = new ConvergedMessageAddress(addr);
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   149
    // resolve contact
37
hgs
parents: 25
diff changeset
   150
    QString displayname;
41
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   151
    int count;
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   152
    int retval = MsgContactHandler::resolveContactDisplayName(
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   153
            addr, displayname, count);
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   154
    if(retval != -1)
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   155
    {
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   156
        address->setAlias(displayname);
25fe1fe642e3 201027_02
hgs
parents: 37
diff changeset
   157
    }
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
    addresses.append(address);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
    return addresses;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
// MsgContactCardWidget::updateContents
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
// @see header file
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
void MsgContactCardWidget::updateContents()
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
    // Get the Model Index
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   169
    QModelIndex index = ConversationsEngine::instance()->getConversationsModel()->index(0, 0);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   170
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   171
    // Index is not valid, return.
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   172
    if (!index.isValid()) {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   173
        return;
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
    }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   175
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   176
    qint64 convId = ConversationsEngine::instance()->getCurrentConversationId();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   177
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   178
    if (KBluetoothMsgsConversationId == convId) {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   179
        setAddress(LOC_RECEIVED_FILES);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   180
        setAvatar(HbIcon(BT_ICON));
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
    }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   182
    else {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   183
        //Set the Contact Name/Number
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   184
        qint64 convId;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   185
        QString displayName;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   186
        QString contactAddress;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   187
        convId = ConversationsEngine::instance()->getCurrentConversationId();
37
hgs
parents: 25
diff changeset
   188
        ConversationsEngine::instance()->getContactDetails(convId, displayName, contactAddress);
hgs
parents: 25
diff changeset
   189
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   190
        mContactNumber = contactAddress;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   191
        QString contactName;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   192
        if (displayName.isEmpty()) {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   193
            contactName.append(contactAddress);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   194
        }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   195
        else {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   196
            contactName.append(displayName);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   197
        }
37
hgs
parents: 25
diff changeset
   198
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   199
        setAddress(contactName);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   201
        // Set Avatar
37
hgs
parents: 25
diff changeset
   202
        QList<QContact> contactList = MsgContactHandler::findContactList(mContactNumber);
hgs
parents: 25
diff changeset
   203
hgs
parents: 25
diff changeset
   204
        if (!contactList.isEmpty()) {
hgs
parents: 25
diff changeset
   205
            QList<QContactAvatar> avatarDetails = contactList.at(0).details<QContactAvatar> ();
hgs
parents: 25
diff changeset
   206
hgs
parents: 25
diff changeset
   207
            if (!avatarDetails.isEmpty()) {
hgs
parents: 25
diff changeset
   208
                mThumbnailManager->getThumbnail(avatarDetails.at(0).imageUrl().toString());
hgs
parents: 25
diff changeset
   209
            }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   210
        }
37
hgs
parents: 25
diff changeset
   211
hgs
parents: 25
diff changeset
   212
        // Set default avatar till actual is set.
hgs
parents: 25
diff changeset
   213
        setAvatar(HbIcon(DEFAULT_AVATAR_ICON));
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
    }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
// MsgContactCardWidget::clearContent
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
// @see header file
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
void MsgContactCardWidget::clearContent()
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
{
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   223
    setAddress("");
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   224
    setAvatar(HbIcon());
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   225
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   226
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   227
//---------------------------------------------------------------
37
hgs
parents: 25
diff changeset
   228
// MsgContactCardWidget::gestureEvent
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   229
// @see header file
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   230
//---------------------------------------------------------------
37
hgs
parents: 25
diff changeset
   231
void MsgContactCardWidget::gestureEvent(QGestureEvent *event)
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   232
{
37
hgs
parents: 25
diff changeset
   233
    HbTapGesture *tapGesture = qobject_cast<HbTapGesture*> (event->gesture(Qt::TapGesture));
hgs
parents: 25
diff changeset
   234
    if (tapGesture) {
hgs
parents: 25
diff changeset
   235
        switch (tapGesture->state()) {
hgs
parents: 25
diff changeset
   236
        case Qt::GestureStarted:
hgs
parents: 25
diff changeset
   237
        {
hgs
parents: 25
diff changeset
   238
            // Trigger haptic feedback.
hgs
parents: 25
diff changeset
   239
            HbInstantFeedback::play(HbFeedback::Basic);
hgs
parents: 25
diff changeset
   240
            setPressed(true);
hgs
parents: 25
diff changeset
   241
            break;
hgs
parents: 25
diff changeset
   242
        }
hgs
parents: 25
diff changeset
   243
        case Qt::GestureUpdated:
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   244
        {
37
hgs
parents: 25
diff changeset
   245
            if (HbTapGesture::TapAndHold == tapGesture->tapStyleHint()) {
hgs
parents: 25
diff changeset
   246
                // Handle longtap.
hgs
parents: 25
diff changeset
   247
                setPressed(false);
hgs
parents: 25
diff changeset
   248
                handleLongTap(tapGesture->scenePosition());
hgs
parents: 25
diff changeset
   249
            }
hgs
parents: 25
diff changeset
   250
            break;
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   251
        }
37
hgs
parents: 25
diff changeset
   252
        case Qt::GestureFinished:
hgs
parents: 25
diff changeset
   253
        {
hgs
parents: 25
diff changeset
   254
            HbInstantFeedback::play(HbFeedback::Basic);
hgs
parents: 25
diff changeset
   255
            if (HbTapGesture::Tap == tapGesture->tapStyleHint()) {
hgs
parents: 25
diff changeset
   256
                // Handle short tap.
hgs
parents: 25
diff changeset
   257
                setPressed(false);
hgs
parents: 25
diff changeset
   258
                handleShortTap(tapGesture->scenePosition());
hgs
parents: 25
diff changeset
   259
            }
hgs
parents: 25
diff changeset
   260
            break;
hgs
parents: 25
diff changeset
   261
        }
hgs
parents: 25
diff changeset
   262
        case Qt::GestureCanceled:
hgs
parents: 25
diff changeset
   263
        {
hgs
parents: 25
diff changeset
   264
            HbInstantFeedback::play(HbFeedback::Basic);
hgs
parents: 25
diff changeset
   265
            setPressed(false);
hgs
parents: 25
diff changeset
   266
            break;
hgs
parents: 25
diff changeset
   267
        }
hgs
parents: 25
diff changeset
   268
        }
hgs
parents: 25
diff changeset
   269
    }
hgs
parents: 25
diff changeset
   270
    else {
hgs
parents: 25
diff changeset
   271
        HbWidget::gestureEvent(event);
hgs
parents: 25
diff changeset
   272
    }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   273
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   274
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   275
//---------------------------------------------------------------
37
hgs
parents: 25
diff changeset
   276
// MsgContactCardWidget::setPressed
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   277
// @see header file
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   278
//---------------------------------------------------------------
37
hgs
parents: 25
diff changeset
   279
void MsgContactCardWidget::setPressed(bool pressed)
hgs
parents: 25
diff changeset
   280
{
hgs
parents: 25
diff changeset
   281
    HbFrameItem *frameItem = static_cast<HbFrameItem *> (this->backgroundItem());
hgs
parents: 25
diff changeset
   282
    if (pressed) {
hgs
parents: 25
diff changeset
   283
        this->setProperty("state", "pressed");
hgs
parents: 25
diff changeset
   284
        frameItem->frameDrawer().setFrameGraphicsName(BG_FRAME_PRESSED);
hgs
parents: 25
diff changeset
   285
    }
hgs
parents: 25
diff changeset
   286
    else {
hgs
parents: 25
diff changeset
   287
        this->setProperty("state", "normal");
hgs
parents: 25
diff changeset
   288
        frameItem->frameDrawer().setFrameGraphicsName(BG_FRAME_NORMAL);
hgs
parents: 25
diff changeset
   289
    }
hgs
parents: 25
diff changeset
   290
}
hgs
parents: 25
diff changeset
   291
hgs
parents: 25
diff changeset
   292
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
   293
// MsgContactCardWidget::handleLongTap
hgs
parents: 25
diff changeset
   294
// @see header file
hgs
parents: 25
diff changeset
   295
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
   296
void MsgContactCardWidget::handleLongTap(const QPointF &position)
hgs
parents: 25
diff changeset
   297
{
hgs
parents: 25
diff changeset
   298
    if (KBluetoothMsgsConversationId != ConversationsEngine::instance()->getCurrentConversationId()) {
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   299
        HbMenu* contextMenu = new HbMenu();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   300
        contextMenu->setDismissPolicy(HbPopup::TapAnywhere);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   301
        contextMenu->setAttribute(Qt::WA_DeleteOnClose, true);
37
hgs
parents: 25
diff changeset
   302
        contextMenu->setPreferredPos(position);   
hgs
parents: 25
diff changeset
   303
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   304
        //If contact doesn't exist in phonebook then add another menu item "Save to Contacts"
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   305
        int contactId = resolveContactId(mContactNumber);
37
hgs
parents: 25
diff changeset
   306
        if (contactId < 0) {
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   307
            contextMenu->addAction(LOC_SAVETO_CONTACTS, this, SLOT(addToContacts()));
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   308
        }
37
hgs
parents: 25
diff changeset
   309
        else{
hgs
parents: 25
diff changeset
   310
            contextMenu->addAction(LOC_MENU_CONTACT_INFO, this, SLOT(openContactInfo()));
hgs
parents: 25
diff changeset
   311
        }
hgs
parents: 25
diff changeset
   312
        contextMenu->addAction(LOC_COMMON_MENU_CALL, this, SLOT(call()));
hgs
parents: 25
diff changeset
   313
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   314
        contextMenu->show();
37
hgs
parents: 25
diff changeset
   315
    }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   316
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   317
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   318
//---------------------------------------------------------------
37
hgs
parents: 25
diff changeset
   319
// MsgContactCardWidget::handleShortTap
hgs
parents: 25
diff changeset
   320
// @see header
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   321
//---------------------------------------------------------------
37
hgs
parents: 25
diff changeset
   322
void MsgContactCardWidget::handleShortTap(const QPointF &position)
hgs
parents: 25
diff changeset
   323
{
hgs
parents: 25
diff changeset
   324
    this->ungrabGesture(Qt::TapGesture);
hgs
parents: 25
diff changeset
   325
    
hgs
parents: 25
diff changeset
   326
    int contactId = resolveContactId(mContactNumber);
hgs
parents: 25
diff changeset
   327
    if(contactId > 0)
hgs
parents: 25
diff changeset
   328
    {
hgs
parents: 25
diff changeset
   329
        //resolved contact open contact card.
hgs
parents: 25
diff changeset
   330
        openContactInfo();
hgs
parents: 25
diff changeset
   331
    }
hgs
parents: 25
diff changeset
   332
    else
hgs
parents: 25
diff changeset
   333
    {
hgs
parents: 25
diff changeset
   334
        //unresolved contact show longpress options menu.
hgs
parents: 25
diff changeset
   335
        handleLongTap(position);
hgs
parents: 25
diff changeset
   336
    }
hgs
parents: 25
diff changeset
   337
    
hgs
parents: 25
diff changeset
   338
    //fire timer to regrab gesture after some delay.
hgs
parents: 25
diff changeset
   339
    QTimer::singleShot(300,this,SLOT(regrabGesture()));    
hgs
parents: 25
diff changeset
   340
}
hgs
parents: 25
diff changeset
   341
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   342
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   343
// MsgContactCardWidget::openContactInfo
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   344
// @see header
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   345
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   346
void MsgContactCardWidget::openContactInfo()
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   347
{
62
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
   348
    //service stuff.
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
   349
    QString service("phonebookservices");
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
   350
    QString interface;
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   351
    QString operation;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   352
    QList<QVariant> args;
37
hgs
parents: 25
diff changeset
   353
    if (KBluetoothMsgsConversationId != ConversationsEngine::instance()->getCurrentConversationId()) {
hgs
parents: 25
diff changeset
   354
        int contactId = resolveContactId(mContactNumber);
hgs
parents: 25
diff changeset
   355
        if (contactId > 0) {
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   356
            //open existing contact card
62
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
   357
            interface = QString("com.nokia.symbian.IContactsView");
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
   358
            operation = QString("openContactCard(int)");
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   359
            args << contactId;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   360
        }
37
hgs
parents: 25
diff changeset
   361
        else {
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   362
            //populate data and open unknown contact template
62
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
   363
            interface = QString("com.nokia.symbian.IContactsEdit");
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   364
            operation = QString("editCreateNew(QString,QString)");
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   365
            QString type = QContactPhoneNumber::DefinitionName;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   366
            args << type;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   367
            args << mAddress;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   368
        }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   369
        XQAiwRequest* request;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   370
        XQApplicationManager appManager;
62
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
   371
        request = appManager.create(service, interface, operation, true); // embedded
37
hgs
parents: 25
diff changeset
   372
        if (request == NULL) {
hgs
parents: 25
diff changeset
   373
            return;
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   374
        }
37
hgs
parents: 25
diff changeset
   375
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   376
        // Result handlers
37
hgs
parents: 25
diff changeset
   377
        connect(request, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleOk(const QVariant&)));
hgs
parents: 25
diff changeset
   378
        connect(request, SIGNAL(requestError(const QVariant&)), this,
hgs
parents: 25
diff changeset
   379
            SLOT(handleError(const QVariant&)));
hgs
parents: 25
diff changeset
   380
hgs
parents: 25
diff changeset
   381
        //disbale subscritption for the CV events
hgs
parents: 25
diff changeset
   382
        ConversationsEngine::instance()->disableRegisterationForCVEvents();
62
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
   383
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   384
        request->setArguments(args);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   385
        request->send();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   386
        delete request;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   387
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   388
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   389
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   390
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   391
// MsgContactCardWidget::resolveContactId
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   392
// @see header
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   393
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   394
int MsgContactCardWidget::resolveContactId(const QString& value)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   395
{
37
hgs
parents: 25
diff changeset
   396
    QString displayLabel;
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   397
37
hgs
parents: 25
diff changeset
   398
    int count;
hgs
parents: 25
diff changeset
   399
    return MsgContactHandler::resolveContactDisplayName(value, displayLabel, count);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   400
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   401
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   402
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   403
// MsgContactCardWidget::call
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   404
// @see header
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   405
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   406
void MsgContactCardWidget::call()
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   407
{
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   408
    //Launch dialer service     
37
hgs
parents: 25
diff changeset
   409
    QString serviceName("com.nokia.symbian.ICallDial");
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   410
    QString operation("dial(QString)");
37
hgs
parents: 25
diff changeset
   411
hgs
parents: 25
diff changeset
   412
    XQServiceRequest* serviceRequest = new XQServiceRequest(serviceName, operation, false);
hgs
parents: 25
diff changeset
   413
hgs
parents: 25
diff changeset
   414
    connect(serviceRequest, SIGNAL(requestCompleted(QVariant)), this,
hgs
parents: 25
diff changeset
   415
        SLOT(onServiceRequestCompleted()));
hgs
parents: 25
diff changeset
   416
hgs
parents: 25
diff changeset
   417
    connect(serviceRequest, SIGNAL(requestError(int)), this, SLOT(onServiceRequestCompleted()));
hgs
parents: 25
diff changeset
   418
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   419
    *serviceRequest << mContactNumber;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   420
    serviceRequest->send();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   421
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   422
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   423
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   424
// MsgContactCardWidget::addToContacts
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   425
// @see header
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   426
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   427
void MsgContactCardWidget::addToContacts()
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   428
{
37
hgs
parents: 25
diff changeset
   429
    openContactInfo();
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   430
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   431
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   432
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   433
// MsgContactCardWidget::handleOk
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   434
// @see header
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   435
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   436
void MsgContactCardWidget::handleOk(const QVariant& result)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   437
{
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   438
    Q_UNUSED(result)
37
hgs
parents: 25
diff changeset
   439
hgs
parents: 25
diff changeset
   440
    QList<QContact> matchingContacts = MsgContactHandler::findContactList(mContactNumber);
hgs
parents: 25
diff changeset
   441
hgs
parents: 25
diff changeset
   442
    if (!matchingContacts.isEmpty()) {
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   443
        QString displayLabel = matchingContacts.at(0).displayLabel();
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   444
        if(!displayLabel.isEmpty())
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   445
        {
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   446
            setAddress(displayLabel);
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   447
        }
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   448
        else
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   449
        {
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   450
            setAddress(mContactNumber);
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   451
        }
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   452
        
37
hgs
parents: 25
diff changeset
   453
        QList<QContactAvatar> avatarDetails = matchingContacts.at(0).details<QContactAvatar> ();
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   454
37
hgs
parents: 25
diff changeset
   455
        if (!avatarDetails.isEmpty()) {
hgs
parents: 25
diff changeset
   456
            mThumbnailManager->getThumbnail(avatarDetails.at(0).imageUrl().toString());
hgs
parents: 25
diff changeset
   457
        }
51
3507212d340e 201031_02
hgs
parents: 41
diff changeset
   458
        else {
3507212d340e 201031_02
hgs
parents: 41
diff changeset
   459
            //Set default avatar since avtar is deleted        
3507212d340e 201031_02
hgs
parents: 41
diff changeset
   460
            setAvatar(HbIcon(DEFAULT_AVATAR_ICON));
3507212d340e 201031_02
hgs
parents: 41
diff changeset
   461
        }        
37
hgs
parents: 25
diff changeset
   462
	}
51
3507212d340e 201031_02
hgs
parents: 41
diff changeset
   463
    else  {
3507212d340e 201031_02
hgs
parents: 41
diff changeset
   464
        //case for deletion from contact card widget
3507212d340e 201031_02
hgs
parents: 41
diff changeset
   465
        //set the default number as address
3507212d340e 201031_02
hgs
parents: 41
diff changeset
   466
        setAddress(mContactNumber);
3507212d340e 201031_02
hgs
parents: 41
diff changeset
   467
        //Set default avatar since contact is deleted
3507212d340e 201031_02
hgs
parents: 41
diff changeset
   468
        setAvatar(HbIcon(DEFAULT_AVATAR_ICON));
3507212d340e 201031_02
hgs
parents: 41
diff changeset
   469
    }
37
hgs
parents: 25
diff changeset
   470
	
hgs
parents: 25
diff changeset
   471
	// Get the new conversation id.
hgs
parents: 25
diff changeset
   472
    qint64 convId = ConversationsEngine::instance()->getConversationIdFromAddress(
hgs
parents: 25
diff changeset
   473
                mContactNumber);
hgs
parents: 25
diff changeset
   474
    emit conversationIdChanged(convId);
hgs
parents: 25
diff changeset
   475
            
hgs
parents: 25
diff changeset
   476
    ConversationsEngine::instance(
hgs
parents: 25
diff changeset
   477
                    )->emitOpenConversationViewIdUpdate(convId);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   478
    
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   479
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   480
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   481
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   482
// MsgContactCardWidget::handleError
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   483
// @see header
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   484
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   485
void MsgContactCardWidget::handleError(int errorCode, const QString& errorMessage)
37
hgs
parents: 25
diff changeset
   486
{
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   487
    Q_UNUSED(errorMessage)
37
hgs
parents: 25
diff changeset
   488
    Q_UNUSED(errorCode)    
hgs
parents: 25
diff changeset
   489
    
hgs
parents: 25
diff changeset
   490
    //unblock the cv events in case of contacts save error
hgs
parents: 25
diff changeset
   491
    ConversationsEngine::instance(
hgs
parents: 25
diff changeset
   492
                        )->emitOpenConversationViewIdUpdate(
hgs
parents: 25
diff changeset
   493
                                ConversationsEngine::instance(
hgs
parents: 25
diff changeset
   494
                                        )->getCurrentConversationId(
hgs
parents: 25
diff changeset
   495
                                                ));
hgs
parents: 25
diff changeset
   496
}
hgs
parents: 25
diff changeset
   497
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   498
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   499
// MsgContactCardWidget::onServiceRequestCompleted
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   500
// @see header
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   501
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   502
void MsgContactCardWidget::onServiceRequestCompleted()
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   503
{
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   504
    //service request is now complete. delete it.
37
hgs
parents: 25
diff changeset
   505
    XQServiceRequest* request = qobject_cast<XQServiceRequest*> (sender());
hgs
parents: 25
diff changeset
   506
    if (request) {
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   507
        delete request;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   508
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   509
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   510
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   511
//---------------------------------------------------------------
37
hgs
parents: 25
diff changeset
   512
// MsgContactCardWidget::thumbnailReady
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   513
// @see header
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   514
//---------------------------------------------------------------
37
hgs
parents: 25
diff changeset
   515
void MsgContactCardWidget::thumbnailReady(const QPixmap& pixmap, void *data, int id, int error)
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   516
{
37
hgs
parents: 25
diff changeset
   517
    Q_UNUSED(data)
hgs
parents: 25
diff changeset
   518
    Q_UNUSED(id)
hgs
parents: 25
diff changeset
   519
hgs
parents: 25
diff changeset
   520
    if (!error) {
hgs
parents: 25
diff changeset
   521
        QIcon icon(pixmap);
hgs
parents: 25
diff changeset
   522
        setAvatar(HbIcon(icon));
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   523
    }
37
hgs
parents: 25
diff changeset
   524
    else {
hgs
parents: 25
diff changeset
   525
        setAvatar(HbIcon(DEFAULT_AVATAR_ICON));
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   526
    }
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   527
}
37
hgs
parents: 25
diff changeset
   528
hgs
parents: 25
diff changeset
   529
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
   530
// MsgContactCardWidget::regrabGesture
hgs
parents: 25
diff changeset
   531
// @see header file
hgs
parents: 25
diff changeset
   532
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
   533
void MsgContactCardWidget::regrabGesture()
hgs
parents: 25
diff changeset
   534
{
hgs
parents: 25
diff changeset
   535
    this->grabGesture(Qt::TapGesture);
hgs
parents: 25
diff changeset
   536
}
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   537
// EOF