phonebookui/cntcommonui/collections/cntfavoritesview.cpp
changeset 81 640d30f4fb64
parent 72 6abfb1094884
equal deleted inserted replaced
77:c18f9fa7f42e 81:640d30f4fb64
    69     setOrientation(window->orientation());
    69     setOrientation(window->orientation());
    70     
    70     
    71     mContact = new QContact(aArgs.value(ESelectedGroupContact).value<QContact>());
    71     mContact = new QContact(aArgs.value(ESelectedGroupContact).value<QContact>());
    72     mViewManager = &mEngine->viewManager();
    72     mViewManager = &mEngine->viewManager();
    73 
    73 
    74     HbPushButton *addButton = static_cast<HbPushButton*>(mDocumentLoader.findWidget(QString("cnt_button_add")));
    74     mAddButton = static_cast<HbPushButton*>(mDocumentLoader.findWidget(QString("cnt_button_add")));
    75     connect(addButton, SIGNAL(clicked()), this, SLOT(openSelectionPopup()));
    75     connect(mAddButton, SIGNAL(released()), this, SLOT(openSelectionPopup()));
    76     connect(addButton, SIGNAL(longPress(QPointF)), this, SLOT(openSelectionPopup()));
    76     
    77     
    77     
    78     // If no contacts are present, then disable the button 
    78     // If no contacts are present, then disable the button 
    79     QContactDetailFilter filter;
    79     QContactDetailFilter filter;
    80     filter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType);
    80     filter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType);
    81     filter.setValue(QLatin1String(QContactType::TypeContact));
    81     filter.setValue(QLatin1String(QContactType::TypeContact));
    82    
    82    
    83     QList<QContactLocalId> contactIds = getContactManager()->contactIds(filter);   
    83     QList<QContactLocalId> contactIds = getContactManager()->contactIds(filter);   
    84     if (contactIds.isEmpty())
    84     if (contactIds.isEmpty())
    85     {
    85     {
    86         addButton->setEnabled(false); 
    86         mAddButton->setEnabled(false); 
    87     }
    87     }
    88     
    88     
    89 }
    89 }
    90 
    90 
    91 void CntFavoritesView::deactivate()
    91 void CntFavoritesView::deactivate()
    92 {
    92 {
    93 }
    93 }
    94 
    94 
    95 void CntFavoritesView::openSelectionPopup()
    95 void CntFavoritesView::openSelectionPopup()
    96 {
    96 {
    97     CntFetchContactPopup* popup = CntFetchContactPopup::createMultiSelectionPopup(
    97     if(mAddButton->isUnderMouse())
    98             hbTrId("txt_phob_title_favorite_contacts"), 
    98     {
    99             hbTrId("txt_common_button_save"),
    99         CntFetchContactPopup* popup = CntFetchContactPopup::createMultiSelectionPopup(
   100             *getContactManager());
   100                 hbTrId("txt_phob_title_favorite_contacts"), 
   101     connect(popup, SIGNAL(fetchReady(QSet<QContactLocalId>)), 
   101                 hbTrId("txt_common_button_save"),
   102             this, SLOT(handleMemberSelection(QSet<QContactLocalId>)));
   102                 *getContactManager());
   103     QSet<QContactLocalId> ids;
   103         connect(popup, SIGNAL(fetchReady(QSet<QContactLocalId>)), 
   104     popup->setSelectedContacts(ids);
   104                 this, SLOT(handleMemberSelection(QSet<QContactLocalId>)));
   105     popup->showPopup();
   105         QSet<QContactLocalId> ids;
       
   106         popup->setSelectedContacts(ids);
       
   107         popup->showPopup(); 
       
   108     }
   106 }
   109 }
   107 
   110 
   108 void CntFavoritesView::handleMemberSelection( QSet<QContactLocalId> aIds )
   111 void CntFavoritesView::handleMemberSelection( QSet<QContactLocalId> aIds )
   109 {
   112 {
   110     if ( aIds.isEmpty() )
   113     if ( aIds.isEmpty() )