phonebookui/cntcommonui/widgets/cntactionpopup_p.cpp
author hgs
Tue, 21 Sep 2010 17:07:25 +0300
changeset 72 6abfb1094884
child 81 640d30f4fb64
permissions -rw-r--r--
201037
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
72
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
#include "cntactionpopup_p.h"
hgs
parents:
diff changeset
    18
#include <qcontact.h>
hgs
parents:
diff changeset
    19
#include <qcontactdetail.h>
hgs
parents:
diff changeset
    20
#include <qcontactphonenumber.h>
hgs
parents:
diff changeset
    21
#include <hbaction.h>
hgs
parents:
diff changeset
    22
#include <QDebug>
hgs
parents:
diff changeset
    23
#include "cntstringmapper.h"
hgs
parents:
diff changeset
    24
#include <hblistview.h>
hgs
parents:
diff changeset
    25
#include <hblistviewitem.h>
hgs
parents:
diff changeset
    26
#include <QStandardItemModel>
hgs
parents:
diff changeset
    27
#include <hblabel.h>
hgs
parents:
diff changeset
    28
//#include <QtAlgorithms.h>
hgs
parents:
diff changeset
    29
hgs
parents:
diff changeset
    30
hgs
parents:
diff changeset
    31
hgs
parents:
diff changeset
    32
CntActionPopupPrivate::CntActionPopupPrivate( QContact* aContact, QGraphicsItem *parent ) :
hgs
parents:
diff changeset
    33
HbSelectionDialog(parent),
hgs
parents:
diff changeset
    34
mContact( NULL ),
hgs
parents:
diff changeset
    35
mListModel(NULL),
hgs
parents:
diff changeset
    36
mListView(NULL),
hgs
parents:
diff changeset
    37
mCancelAction(NULL)
hgs
parents:
diff changeset
    38
{
hgs
parents:
diff changeset
    39
    mContact = new QContact( *aContact );
hgs
parents:
diff changeset
    40
    mListView = new HbListView(this);
hgs
parents:
diff changeset
    41
    mListModel = new QStandardItemModel(this);
hgs
parents:
diff changeset
    42
    setAttribute(Qt::WA_DeleteOnClose, true);
hgs
parents:
diff changeset
    43
    mDataItemList.clear();
hgs
parents:
diff changeset
    44
}
hgs
parents:
diff changeset
    45
hgs
parents:
diff changeset
    46
CntActionPopupPrivate::~CntActionPopupPrivate()
hgs
parents:
diff changeset
    47
{
hgs
parents:
diff changeset
    48
    delete mContact;
hgs
parents:
diff changeset
    49
    mContact = NULL;
hgs
parents:
diff changeset
    50
}
hgs
parents:
diff changeset
    51
    
hgs
parents:
diff changeset
    52
void CntActionPopupPrivate::buildCallActionPopup()
hgs
parents:
diff changeset
    53
{
hgs
parents:
diff changeset
    54
    // Create call action
hgs
parents:
diff changeset
    55
    QList<QContactPhoneNumber> details = mContact->details<QContactPhoneNumber>();
hgs
parents:
diff changeset
    56
    CntStringMapper map;
hgs
parents:
diff changeset
    57
    for (int index = 0; index < details.count(); index++)
hgs
parents:
diff changeset
    58
    {
hgs
parents:
diff changeset
    59
       if(supportsDetail("call", details[index]))
hgs
parents:
diff changeset
    60
       {
hgs
parents:
diff changeset
    61
           QString context = details[index].contexts().isEmpty() ? QString() : details[index].contexts().first();
hgs
parents:
diff changeset
    62
           QString subtype = details[index].subTypes().isEmpty() ? details[index].definitionName() : details[index].subTypes().first();
hgs
parents:
diff changeset
    63
           
hgs
parents:
diff changeset
    64
           int position = getPosition(subtype, context);
hgs
parents:
diff changeset
    65
           
hgs
parents:
diff changeset
    66
           QString titleText = map.getContactCardListLocString(subtype , context);
hgs
parents:
diff changeset
    67
           QString valueText = details[index].number();
hgs
parents:
diff changeset
    68
           
hgs
parents:
diff changeset
    69
           QStandardItem *labelItem = new QStandardItem();
hgs
parents:
diff changeset
    70
           QStringList textList;
hgs
parents:
diff changeset
    71
           textList << titleText << valueText;
hgs
parents:
diff changeset
    72
           labelItem->setData(textList, Qt::DisplayRole);
hgs
parents:
diff changeset
    73
           labelItem->setData(HbIcon(map.getContactCardIconString(subtype, context)), Qt::DecorationRole);
hgs
parents:
diff changeset
    74
           labelItem->setData(index, Qt::UserRole);
hgs
parents:
diff changeset
    75
           labelItem->setData("call", Qt::UserRole+1);
hgs
parents:
diff changeset
    76
           labelItem->setData(position, Qt::UserRole+2);
hgs
parents:
diff changeset
    77
           mDataItemList.append(labelItem);
hgs
parents:
diff changeset
    78
       }
hgs
parents:
diff changeset
    79
    }
hgs
parents:
diff changeset
    80
}
hgs
parents:
diff changeset
    81
hgs
parents:
diff changeset
    82
void CntActionPopupPrivate::buildEmailActionPopup()
hgs
parents:
diff changeset
    83
{
hgs
parents:
diff changeset
    84
    // Create email action
hgs
parents:
diff changeset
    85
    QList<QContactEmailAddress> details = mContact->details<QContactEmailAddress>();
hgs
parents:
diff changeset
    86
    CntStringMapper map;
hgs
parents:
diff changeset
    87
    for (int index = 0; index < details.count(); index++)
hgs
parents:
diff changeset
    88
    {
hgs
parents:
diff changeset
    89
       if(supportsDetail("email", details[index]))
hgs
parents:
diff changeset
    90
       {
hgs
parents:
diff changeset
    91
           QString context = details[index].contexts().isEmpty() ? QString() : details[index].contexts().first();
hgs
parents:
diff changeset
    92
           int position = getPosition(details[index].definitionName(), context);
hgs
parents:
diff changeset
    93
           
hgs
parents:
diff changeset
    94
           QString titleText = map.getContactCardListLocString(details[index].definitionName() , context);
hgs
parents:
diff changeset
    95
           QString valueText = details[index].emailAddress();
hgs
parents:
diff changeset
    96
           
hgs
parents:
diff changeset
    97
           QStandardItem *labelItem = new QStandardItem();
hgs
parents:
diff changeset
    98
           QStringList textList;
hgs
parents:
diff changeset
    99
           textList << titleText << valueText;
hgs
parents:
diff changeset
   100
           labelItem->setData(textList, Qt::DisplayRole);
hgs
parents:
diff changeset
   101
           labelItem->setData(HbIcon(map.getContactEditorIconString(details[index].definitionName(), context)), Qt::DecorationRole);
hgs
parents:
diff changeset
   102
           labelItem->setData(index, Qt::UserRole);
hgs
parents:
diff changeset
   103
           labelItem->setData("email", Qt::UserRole+1);
hgs
parents:
diff changeset
   104
           labelItem->setData(position, Qt::UserRole+2);
hgs
parents:
diff changeset
   105
           mDataItemList.append(labelItem);
hgs
parents:
diff changeset
   106
       }
hgs
parents:
diff changeset
   107
    }
hgs
parents:
diff changeset
   108
}
hgs
parents:
diff changeset
   109
hgs
parents:
diff changeset
   110
void CntActionPopupPrivate::buildMessageActionPopup()
hgs
parents:
diff changeset
   111
{
hgs
parents:
diff changeset
   112
    // Create message action
hgs
parents:
diff changeset
   113
    QList<QContactPhoneNumber> details = mContact->details<QContactPhoneNumber>();
hgs
parents:
diff changeset
   114
    CntStringMapper map;
hgs
parents:
diff changeset
   115
    for (int index = 0; index < details.count(); index++)
hgs
parents:
diff changeset
   116
    {
hgs
parents:
diff changeset
   117
        if(supportsDetail("message", details[index]))
hgs
parents:
diff changeset
   118
        {
hgs
parents:
diff changeset
   119
            // Todo : Use loc string for this dialog
hgs
parents:
diff changeset
   120
            QString context = details[index].contexts().isEmpty() ? QString() : details[index].contexts().first();
hgs
parents:
diff changeset
   121
            QString subtype = details[index].subTypes().isEmpty() ? details[index].definitionName() : details[index].subTypes().first();
hgs
parents:
diff changeset
   122
            
hgs
parents:
diff changeset
   123
            int position = getPosition(subtype, context);
hgs
parents:
diff changeset
   124
        
hgs
parents:
diff changeset
   125
            QString icon;
hgs
parents:
diff changeset
   126
            if (details[index].contexts().isEmpty())
hgs
parents:
diff changeset
   127
            {
hgs
parents:
diff changeset
   128
              icon = "qtg_large_message";
hgs
parents:
diff changeset
   129
            }
hgs
parents:
diff changeset
   130
            else if (details[index].contexts().first() == QContactDetail::ContextHome)
hgs
parents:
diff changeset
   131
            {
hgs
parents:
diff changeset
   132
              icon = "qtg_large_message_home";
hgs
parents:
diff changeset
   133
            }
hgs
parents:
diff changeset
   134
            else if (details[index].contexts().first() == QContactDetail::ContextWork)
hgs
parents:
diff changeset
   135
            {
hgs
parents:
diff changeset
   136
              icon = "qtg_large_message_work";
hgs
parents:
diff changeset
   137
            }
hgs
parents:
diff changeset
   138
            else
hgs
parents:
diff changeset
   139
            {
hgs
parents:
diff changeset
   140
              icon = "qtg_large_message";
hgs
parents:
diff changeset
   141
            }
hgs
parents:
diff changeset
   142
            
hgs
parents:
diff changeset
   143
            QString titleText( hbTrId("txt_phob_dblist_send_message"));
hgs
parents:
diff changeset
   144
            QString valueText = details[index].number();
hgs
parents:
diff changeset
   145
            
hgs
parents:
diff changeset
   146
            QStandardItem *labelItem = new QStandardItem();
hgs
parents:
diff changeset
   147
            QStringList textList;
hgs
parents:
diff changeset
   148
            textList << titleText << valueText;
hgs
parents:
diff changeset
   149
            labelItem->setData(textList, Qt::DisplayRole);
hgs
parents:
diff changeset
   150
            labelItem->setData(HbIcon(icon), Qt::DecorationRole);
hgs
parents:
diff changeset
   151
            labelItem->setData(index, Qt::UserRole);
hgs
parents:
diff changeset
   152
            labelItem->setData("message", Qt::UserRole+1);
hgs
parents:
diff changeset
   153
            labelItem->setData(position, Qt::UserRole+2);
hgs
parents:
diff changeset
   154
            mDataItemList.append(labelItem);
hgs
parents:
diff changeset
   155
        }
hgs
parents:
diff changeset
   156
    }
hgs
parents:
diff changeset
   157
}
hgs
parents:
diff changeset
   158
hgs
parents:
diff changeset
   159
bool CntActionPopupPrivate::showActionPopup(QString action)
hgs
parents:
diff changeset
   160
{
hgs
parents:
diff changeset
   161
    if (action.compare("call", Qt::CaseInsensitive) == 0 )
hgs
parents:
diff changeset
   162
    {
hgs
parents:
diff changeset
   163
        buildCallActionPopup();
hgs
parents:
diff changeset
   164
    }
hgs
parents:
diff changeset
   165
    else if( action.compare("message", Qt::CaseInsensitive) == 0 )
hgs
parents:
diff changeset
   166
    {       
hgs
parents:
diff changeset
   167
        buildMessageActionPopup();
hgs
parents:
diff changeset
   168
    }
hgs
parents:
diff changeset
   169
    else if (action.compare("email", Qt::CaseInsensitive) == 0 )
hgs
parents:
diff changeset
   170
    {
hgs
parents:
diff changeset
   171
        buildEmailActionPopup();
hgs
parents:
diff changeset
   172
    }
hgs
parents:
diff changeset
   173
    
hgs
parents:
diff changeset
   174
    if(mDataItemList.count())
hgs
parents:
diff changeset
   175
    {
hgs
parents:
diff changeset
   176
        showPopup();
hgs
parents:
diff changeset
   177
        return true;
hgs
parents:
diff changeset
   178
    }
hgs
parents:
diff changeset
   179
    return false; 
hgs
parents:
diff changeset
   180
    
hgs
parents:
diff changeset
   181
}
hgs
parents:
diff changeset
   182
hgs
parents:
diff changeset
   183
void CntActionPopupPrivate::showPopup()
hgs
parents:
diff changeset
   184
{
hgs
parents:
diff changeset
   185
    for (int i= 0 ;i< mDataItemList.count() ;i++) 
hgs
parents:
diff changeset
   186
        {
hgs
parents:
diff changeset
   187
        mListModel->appendRow(mDataItemList.at(i));
hgs
parents:
diff changeset
   188
        }
hgs
parents:
diff changeset
   189
    mListModel->setSortRole(Qt::UserRole+2);
hgs
parents:
diff changeset
   190
    mListModel->sort(0, Qt::AscendingOrder);
hgs
parents:
diff changeset
   191
hgs
parents:
diff changeset
   192
    clearActions(); 
hgs
parents:
diff changeset
   193
    mListView->setModel(mListModel);
hgs
parents:
diff changeset
   194
    mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn);
hgs
parents:
diff changeset
   195
    mListView->setFrictionEnabled(true);
hgs
parents:
diff changeset
   196
    mListView->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Maximum );
hgs
parents:
diff changeset
   197
    
hgs
parents:
diff changeset
   198
    QString contactName = mContact->displayLabel();
hgs
parents:
diff changeset
   199
    if (contactName.isEmpty())
hgs
parents:
diff changeset
   200
    {
hgs
parents:
diff changeset
   201
        contactName = hbTrId("txt_phob_list_unnamed");
hgs
parents:
diff changeset
   202
    }
hgs
parents:
diff changeset
   203
    HbLabel *label = new HbLabel();
hgs
parents:
diff changeset
   204
    label->setPlainText(contactName);
hgs
parents:
diff changeset
   205
    
hgs
parents:
diff changeset
   206
    setHeadingWidget(label);
hgs
parents:
diff changeset
   207
    setContentWidget(mListView);
hgs
parents:
diff changeset
   208
    
hgs
parents:
diff changeset
   209
    mCancelAction = new HbAction(hbTrId("txt_common_button_cancel"), this);
hgs
parents:
diff changeset
   210
    addAction(mCancelAction);
hgs
parents:
diff changeset
   211
    setTimeout(HbDialog::NoTimeout);
hgs
parents:
diff changeset
   212
    setDismissPolicy(HbDialog::NoDismiss);
hgs
parents:
diff changeset
   213
    setModal(true);
hgs
parents:
diff changeset
   214
    
hgs
parents:
diff changeset
   215
    connect(mListView, SIGNAL(activated(const QModelIndex&)), this, SLOT(listItemSelected(QModelIndex)));
hgs
parents:
diff changeset
   216
    connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,const QPointF&)), 
hgs
parents:
diff changeset
   217
            this, SLOT(onLongPressed(HbAbstractViewItem*,const QPointF&)) );
hgs
parents:
diff changeset
   218
      
hgs
parents:
diff changeset
   219
    
hgs
parents:
diff changeset
   220
    //launch dialog asyncronously
hgs
parents:
diff changeset
   221
    open(this, SLOT(handleUserResponse(HbAction*)));
hgs
parents:
diff changeset
   222
hgs
parents:
diff changeset
   223
}
hgs
parents:
diff changeset
   224
hgs
parents:
diff changeset
   225
void CntActionPopupPrivate::handleUserResponse(HbAction* action)
hgs
parents:
diff changeset
   226
{
hgs
parents:
diff changeset
   227
    if (action == mCancelAction )
hgs
parents:
diff changeset
   228
    {
hgs
parents:
diff changeset
   229
    emit actionPopupCancelPressed();
hgs
parents:
diff changeset
   230
    }
hgs
parents:
diff changeset
   231
    mCancelAction = 0;
hgs
parents:
diff changeset
   232
    
hgs
parents:
diff changeset
   233
}
hgs
parents:
diff changeset
   234
hgs
parents:
diff changeset
   235
void CntActionPopupPrivate::onLongPressed(HbAbstractViewItem *item, const QPointF &coords)
hgs
parents:
diff changeset
   236
{
hgs
parents:
diff changeset
   237
    Q_UNUSED(coords);
hgs
parents:
diff changeset
   238
    QModelIndex index = item->modelIndex();
hgs
parents:
diff changeset
   239
    listItemSelected(index);
hgs
parents:
diff changeset
   240
}
hgs
parents:
diff changeset
   241
hgs
parents:
diff changeset
   242
void CntActionPopupPrivate::listItemSelected( QModelIndex index )
hgs
parents:
diff changeset
   243
{   
hgs
parents:
diff changeset
   244
    if (index.isValid())
hgs
parents:
diff changeset
   245
    {
hgs
parents:
diff changeset
   246
        int selectedDetail = mListModel->item(index.row())->data(Qt::UserRole).toInt();
hgs
parents:
diff changeset
   247
        QString actionName = mListModel->item(index.row())->data(Qt::UserRole+1).toString();   
hgs
parents:
diff changeset
   248
        if (actionName.compare("call", Qt::CaseInsensitive) == 0 
hgs
parents:
diff changeset
   249
            || actionName.compare("message", Qt::CaseInsensitive) == 0 )
hgs
parents:
diff changeset
   250
        {       
hgs
parents:
diff changeset
   251
            QList<QContactPhoneNumber> details = mContact->details<QContactPhoneNumber>();
hgs
parents:
diff changeset
   252
            emit executeContactAction( *mContact, details[selectedDetail], actionName);
hgs
parents:
diff changeset
   253
        }
hgs
parents:
diff changeset
   254
        else if (actionName.compare("email", Qt::CaseInsensitive) == 0 )
hgs
parents:
diff changeset
   255
        {
hgs
parents:
diff changeset
   256
            QList<QContactEmailAddress> details = mContact->details<QContactEmailAddress>();
hgs
parents:
diff changeset
   257
            emit executeContactAction( *mContact, details[selectedDetail], actionName);
hgs
parents:
diff changeset
   258
        }
hgs
parents:
diff changeset
   259
    }
hgs
parents:
diff changeset
   260
    close();
hgs
parents:
diff changeset
   261
}
hgs
parents:
diff changeset
   262
hgs
parents:
diff changeset
   263
/*!
hgs
parents:
diff changeset
   264
Returns position of specific item
hgs
parents:
diff changeset
   265
*/
hgs
parents:
diff changeset
   266
int CntActionPopupPrivate::getPosition(const QString& aId, const QString& aContext)
hgs
parents:
diff changeset
   267
{
hgs
parents:
diff changeset
   268
    int position = CntActionPopupPrivate::ENotSupported;
hgs
parents:
diff changeset
   269
    if (aId == QContactPhoneNumber::SubTypeAssistant && aContext.isEmpty() )
hgs
parents:
diff changeset
   270
    {
hgs
parents:
diff changeset
   271
        position = CntActionPopupPrivate::ECallAssistant;
hgs
parents:
diff changeset
   272
    }
hgs
parents:
diff changeset
   273
    else if (aId == QContactPhoneNumber::SubTypeCar && aContext.isEmpty() )
hgs
parents:
diff changeset
   274
    {
hgs
parents:
diff changeset
   275
        position = CntActionPopupPrivate::ECallCar;
hgs
parents:
diff changeset
   276
    }
hgs
parents:
diff changeset
   277
    else if (aId == QContactPhoneNumber::SubTypeMobile && aContext.isEmpty() )
hgs
parents:
diff changeset
   278
    {
hgs
parents:
diff changeset
   279
        position = CntActionPopupPrivate::ECallMobile;
hgs
parents:
diff changeset
   280
    }
hgs
parents:
diff changeset
   281
    else if (aId == QContactPhoneNumber::SubTypeMobile && aContext == QContactDetail::ContextHome )
hgs
parents:
diff changeset
   282
    {
hgs
parents:
diff changeset
   283
        position = CntActionPopupPrivate::ECallMobileHome;
hgs
parents:
diff changeset
   284
    }
hgs
parents:
diff changeset
   285
    else if (aId == QContactPhoneNumber::SubTypeMobile && aContext == QContactDetail::ContextWork )
hgs
parents:
diff changeset
   286
    {
hgs
parents:
diff changeset
   287
        position = CntActionPopupPrivate::ECallMobileWork;
hgs
parents:
diff changeset
   288
    }
hgs
parents:
diff changeset
   289
    else if (aId == QContactPhoneNumber::SubTypeLandline && aContext.isEmpty() )
hgs
parents:
diff changeset
   290
    {
hgs
parents:
diff changeset
   291
        position = CntActionPopupPrivate::ECallPhone;
hgs
parents:
diff changeset
   292
    }
hgs
parents:
diff changeset
   293
    else if (aId == QContactPhoneNumber::SubTypeLandline && aContext == QContactDetail::ContextHome )
hgs
parents:
diff changeset
   294
    {
hgs
parents:
diff changeset
   295
        position = CntActionPopupPrivate::ECallPhoneHome;    
hgs
parents:
diff changeset
   296
    }
hgs
parents:
diff changeset
   297
    else if (aId == QContactPhoneNumber::SubTypeLandline && aContext == QContactDetail::ContextWork )
hgs
parents:
diff changeset
   298
    {
hgs
parents:
diff changeset
   299
        position = CntActionPopupPrivate::ECallPhoneWork;
hgs
parents:
diff changeset
   300
    }
hgs
parents:
diff changeset
   301
    else if (aId == QContactPhoneNumber::SubTypeFax && aContext.isEmpty() )
hgs
parents:
diff changeset
   302
    {
hgs
parents:
diff changeset
   303
        position = CntActionPopupPrivate::ECallFax;
hgs
parents:
diff changeset
   304
    }
hgs
parents:
diff changeset
   305
    else if (aId == QContactPhoneNumber::SubTypeFax && aContext == QContactDetail::ContextHome )
hgs
parents:
diff changeset
   306
    {
hgs
parents:
diff changeset
   307
        position = CntActionPopupPrivate::ECallFaxHome;
hgs
parents:
diff changeset
   308
    }
hgs
parents:
diff changeset
   309
    else if (aId == QContactPhoneNumber::SubTypeFax && aContext == QContactDetail::ContextWork )
hgs
parents:
diff changeset
   310
    {
hgs
parents:
diff changeset
   311
        position = CntActionPopupPrivate::ECallFaxWork;
hgs
parents:
diff changeset
   312
    }
hgs
parents:
diff changeset
   313
    else if (aId == QContactPhoneNumber::SubTypePager && aContext.isEmpty() )
hgs
parents:
diff changeset
   314
    {
hgs
parents:
diff changeset
   315
        position = CntActionPopupPrivate::ECallPager;
hgs
parents:
diff changeset
   316
    }
hgs
parents:
diff changeset
   317
    else if (aId == QContactEmailAddress::DefinitionName && aContext.isEmpty())
hgs
parents:
diff changeset
   318
    {
hgs
parents:
diff changeset
   319
            position = CntActionPopupPrivate::EEmail;
hgs
parents:
diff changeset
   320
    }
hgs
parents:
diff changeset
   321
    else if (aId == QContactEmailAddress::DefinitionName && aContext == QContactDetail::ContextHome)
hgs
parents:
diff changeset
   322
    {
hgs
parents:
diff changeset
   323
            position = CntActionPopupPrivate::EEmailHome;
hgs
parents:
diff changeset
   324
    }
hgs
parents:
diff changeset
   325
    else if (aId == QContactEmailAddress::DefinitionName && aContext == QContactDetail::ContextWork)
hgs
parents:
diff changeset
   326
    {
hgs
parents:
diff changeset
   327
            position = CntActionPopupPrivate::EEmailWork;
hgs
parents:
diff changeset
   328
    }
hgs
parents:
diff changeset
   329
    else 
hgs
parents:
diff changeset
   330
    {
hgs
parents:
diff changeset
   331
        position = CntActionPopupPrivate::ENotSupported;
hgs
parents:
diff changeset
   332
    }
hgs
parents:
diff changeset
   333
    
hgs
parents:
diff changeset
   334
    return position;
hgs
parents:
diff changeset
   335
}
hgs
parents:
diff changeset
   336
hgs
parents:
diff changeset
   337
/*!
hgs
parents:
diff changeset
   338
Returns true if contactDetails contains spesific action.
hgs
parents:
diff changeset
   339
*/
hgs
parents:
diff changeset
   340
bool CntActionPopupPrivate::supportsDetail(const QString &actionName, const QContactDetail &contactDetail)
hgs
parents:
diff changeset
   341
{    
hgs
parents:
diff changeset
   342
    QList<QContactActionDescriptor> actionDescriptors = QContactAction::actionDescriptors(actionName, "symbian");
hgs
parents:
diff changeset
   343
    if (actionDescriptors.isEmpty())
hgs
parents:
diff changeset
   344
    {
hgs
parents:
diff changeset
   345
        return false;
hgs
parents:
diff changeset
   346
    }
hgs
parents:
diff changeset
   347
    
hgs
parents:
diff changeset
   348
    QContactAction* contactAction = QContactAction::action(actionDescriptors.first());
hgs
parents:
diff changeset
   349
    bool isSupportDetail = contactAction->isDetailSupported(contactDetail);
hgs
parents:
diff changeset
   350
    
hgs
parents:
diff changeset
   351
    delete contactAction;
hgs
parents:
diff changeset
   352
    
hgs
parents:
diff changeset
   353
    return isSupportDetail;
hgs
parents:
diff changeset
   354
}
hgs
parents:
diff changeset
   355
hgs
parents:
diff changeset
   356
// End of File