phonebookui/cntcommonui/widgets/cntactionpopup_p.cpp
changeset 81 640d30f4fb64
parent 72 6abfb1094884
equal deleted inserted replaced
77:c18f9fa7f42e 81:640d30f4fb64
    22 #include <QDebug>
    22 #include <QDebug>
    23 #include "cntstringmapper.h"
    23 #include "cntstringmapper.h"
    24 #include <hblistview.h>
    24 #include <hblistview.h>
    25 #include <hblistviewitem.h>
    25 #include <hblistviewitem.h>
    26 #include <QStandardItemModel>
    26 #include <QStandardItemModel>
    27 #include <hblabel.h>
       
    28 //#include <QtAlgorithms.h>
       
    29 
       
    30 
       
    31 
    27 
    32 CntActionPopupPrivate::CntActionPopupPrivate( QContact* aContact, QGraphicsItem *parent ) :
    28 CntActionPopupPrivate::CntActionPopupPrivate( QContact* aContact, QGraphicsItem *parent ) :
    33 HbSelectionDialog(parent),
    29 HbSelectionDialog(parent),
    34 mContact( NULL ),
    30 mContact( NULL ),
    35 mListModel(NULL),
    31 mListModel(NULL),
   192     clearActions(); 
   188     clearActions(); 
   193     mListView->setModel(mListModel);
   189     mListView->setModel(mListModel);
   194     mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn);
   190     mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn);
   195     mListView->setFrictionEnabled(true);
   191     mListView->setFrictionEnabled(true);
   196     mListView->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Maximum );
   192     mListView->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Maximum );
       
   193     mListView->setLongPressEnabled(false);//This is to make longpress act like shortpress when no tap menu
   197     
   194     
   198     QString contactName = mContact->displayLabel();
   195     QString contactName = mContact->displayLabel();
   199     if (contactName.isEmpty())
   196     if (contactName.isEmpty())
   200     {
   197     {
   201         contactName = hbTrId("txt_phob_list_unnamed");
   198         contactName = hbTrId("txt_phob_list_unnamed");
   202     }
   199     }
   203     HbLabel *label = new HbLabel();
   200     
   204     label->setPlainText(contactName);
   201     setHeadingText(contactName);
   205     
       
   206     setHeadingWidget(label);
       
   207     setContentWidget(mListView);
   202     setContentWidget(mListView);
   208     
   203     
   209     mCancelAction = new HbAction(hbTrId("txt_common_button_cancel"), this);
   204     mCancelAction = new HbAction(hbTrId("txt_common_button_cancel"), this);
   210     addAction(mCancelAction);
   205     addAction(mCancelAction);
   211     setTimeout(HbDialog::NoTimeout);
   206     setTimeout(HbDialog::NoTimeout);
   212     setDismissPolicy(HbDialog::NoDismiss);
   207     setDismissPolicy(HbDialog::NoDismiss);
   213     setModal(true);
   208     setModal(true);
   214     
   209     
   215     connect(mListView, SIGNAL(activated(const QModelIndex&)), this, SLOT(listItemSelected(QModelIndex)));
   210     connect(mListView, SIGNAL(activated (const QModelIndex &)), 
   216     connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,const QPointF&)), 
   211             this, SLOT(listItemSelected(QModelIndex)) );
   217             this, SLOT(onLongPressed(HbAbstractViewItem*,const QPointF&)) );
       
   218       
       
   219     
   212     
   220     //launch dialog asyncronously
   213     //launch dialog asyncronously
   221     open(this, SLOT(handleUserResponse(HbAction*)));
   214     open(this, SLOT(handleUserResponse(HbAction*)));
   222 
   215 
   223 }
   216 }
   228     {
   221     {
   229     emit actionPopupCancelPressed();
   222     emit actionPopupCancelPressed();
   230     }
   223     }
   231     mCancelAction = 0;
   224     mCancelAction = 0;
   232     
   225     
   233 }
       
   234 
       
   235 void CntActionPopupPrivate::onLongPressed(HbAbstractViewItem *item, const QPointF &coords)
       
   236 {
       
   237     Q_UNUSED(coords);
       
   238     QModelIndex index = item->modelIndex();
       
   239     listItemSelected(index);
       
   240 }
   226 }
   241 
   227 
   242 void CntActionPopupPrivate::listItemSelected( QModelIndex index )
   228 void CntActionPopupPrivate::listItemSelected( QModelIndex index )
   243 {   
   229 {   
   244     if (index.isValid())
   230     if (index.isValid())