phonebookui/pbkcommonui/src/cntgroupdeletepopup.cpp
changeset 31 2a11b5b00470
parent 27 de1630741fbe
child 37 fd64c38c277d
equal deleted inserted replaced
27:de1630741fbe 31:2a11b5b00470
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include "cntgroupdeletepopup.h"
    18 #include "cntgroupdeletepopup.h"
    19 
    19 
    20 #include <hblabel.h>
       
    21 #include <hbgroupbox.h>
    20 #include <hbgroupbox.h>
    22 #include <hbaction.h>
    21 #include <hbaction.h>
    23 #include <hbsearchpanel.h>
    22 #include <hblistview.h>
    24 #include <hbtextitem.h>
       
    25 #include <qtcontacts.h>
    23 #include <qtcontacts.h>
    26 #include <QStringListModel>
       
    27 #include <QGraphicsWidget>
       
    28 #include <mobcntmodel.h>
       
    29 
       
    30 
    24 
    31 CntGroupDeletePopup::CntGroupDeletePopup(QContactManager *manager, QGraphicsItem *parent):
    25 CntGroupDeletePopup::CntGroupDeletePopup(QContactManager *manager, QGraphicsItem *parent):
    32     HbDialog(parent),
    26     HbDialog(parent),
    33     mListView(0),
    27     mListView(0),
    34     mContactManager(manager),
    28     mContactManager(manager),
    43     mModel = 0;
    37     mModel = 0;
    44 }
    38 }
    45 
    39 
    46 void CntGroupDeletePopup::populateListOfGroup()
    40 void CntGroupDeletePopup::populateListOfGroup()
    47 {
    41 {
    48     HbGroupBox *headingLabel = new HbGroupBox();
    42     HbGroupBox *headingLabel = new HbGroupBox(this);   
    49     HbLabel *label = new HbLabel(hbTrId("txt_phob_opt_delete_groups"));    
    43     headingLabel->setHeading(hbTrId("txt_phob_opt_delete_groups"));
    50     headingLabel->setContentWidget(label);
       
    51     
    44     
    52     setHeadingWidget(headingLabel);
    45     setHeadingWidget(headingLabel);
    53     
    46     
    54     mListView = new HbListView(this);
    47     mListView = new HbListView(this);
    55     
       
    56     
    48     
    57     mModel->initializeGroupsList();
    49     mModel->initializeGroupsList();
    58 
    50 
    59     //Get the index of the contacts
    51     //Get the index of the contacts
    60     // Set the select option for those contacts in the selectionModel
    52     // Set the select option for those contacts in the selectionModel
    64     mListView->setFrictionEnabled(true);
    56     mListView->setFrictionEnabled(true);
    65     mListView->setScrollingStyle(HbScrollArea::PanOrFlick);
    57     mListView->setScrollingStyle(HbScrollArea::PanOrFlick);
    66     
    58     
    67     setContentWidget(mListView);
    59     setContentWidget(mListView);
    68     
    60     
    69     setTimeout(0);
    61     setTimeout(HbDialog::NoTimeout);
       
    62     setDismissPolicy(HbDialog::NoDismiss);
    70     setModal(true);
    63     setModal(true);
       
    64     setAttribute(Qt::WA_DeleteOnClose, true);
    71     
    65     
    72     HbAction *mPrimaryAction = new HbAction(hbTrId("Delete selected"));
    66     HbAction *mPrimaryAction = new HbAction(hbTrId("Delete selected"), this);
    73     setPrimaryAction(mPrimaryAction);
    67     addAction(mPrimaryAction);
    74     
    68     
    75     HbAction *mSecondaryAction = new HbAction(hbTrId("txt_common_button_cancel"));
    69     HbAction *mSecondaryAction = new HbAction(hbTrId("txt_common_button_cancel"), this);
    76     setSecondaryAction(mSecondaryAction);
    70     addAction(mSecondaryAction);
    77 }
    71 }
    78 
    72 
    79 void CntGroupDeletePopup::deleteGroup()
    73 QList<QContactLocalId> CntGroupDeletePopup::deleteGroup() const
    80 {
    74 {
    81     QModelIndexList indexes = mListView->selectionModel()->selection().indexes();
    75     QModelIndexList indexes = mListView->selectionModel()->selection().indexes();
    82     QList<QContactLocalId>   selectionList;
    76     QList<QContactLocalId> selectionList;
    83     for (int i = 0; i < indexes.count(); i++)
    77     for (int i = 0; i < indexes.count(); i++)
    84     {
    78     {
    85         QContact contact = mModel->contact(indexes[i]);
    79         QContact contact = mModel->contact(indexes[i]);
    86         QContactLocalId locId = contact.localId();
    80         QContactLocalId locId = contact.localId();
    87         selectionList.append(locId); 
    81         selectionList.append(locId); 
    88     }
    82     }
    89     
    83     
    90     QMap<int, QContactManager::Error> errors;
    84     QMap<int, QContactManager::Error> errors;
    91     bool result = mContactManager->removeContacts(selectionList, &errors);
    85     mContactManager->removeContacts(selectionList, &errors);
       
    86     
       
    87     return selectionList;
    92 }
    88 }