phonebookui/pbkcommonui/src/cntdetailpopup.cpp
changeset 59 a642906a277a
parent 47 7cbcb2896f0e
equal deleted inserted replaced
47:7cbcb2896f0e 59:a642906a277a
    16 */
    16 */
    17 
    17 
    18 #include "cntdetailpopup.h"
    18 #include "cntdetailpopup.h"
    19 
    19 
    20 #include <hblabel.h>
    20 #include <hblabel.h>
    21 #include <hbgroupbox.h>
       
    22 #include <hbaction.h>
       
    23 #include <qtcontacts.h>
       
    24 #include <hblistview.h>
       
    25 #include <hblistviewitem.h>
       
    26 #include <QStandardItemModel>
    21 #include <QStandardItemModel>
    27 
    22 
    28 QTM_USE_NAMESPACE
       
    29 
       
    30 CntDetailPopup::CntDetailPopup(QGraphicsItem *parent,  CntViewIdList aList ):
    23 CntDetailPopup::CntDetailPopup(QGraphicsItem *parent,  CntViewIdList aList ):
    31     HbDialog(parent),
    24     HbSelectionDialog(parent),
    32     mListModel(NULL),
    25     mListModel(NULL),
    33     mListView(NULL),
       
    34     mSelectedDetail(0),
       
    35     mViewIdList( aList )
    26     mViewIdList( aList )
    36 {
    27 {
    37     mListView = new HbListView(this);
       
    38     mListModel = new QStandardItemModel(this);
    28     mListModel = new QStandardItemModel(this);
    39 
    29 
    40     addListItem("qtg_small_mobile", hbTrId("txt_phob_list_number"), phoneNumberEditorView );
    30     addListItem("qtg_small_mobile", hbTrId("txt_phob_list_number"), phoneNumberEditorView );
    41     addListItem("qtg_small_email", hbTrId("txt_phob_list_email"), emailEditorView );
    31     addListItem("qtg_small_email", hbTrId("txt_phob_list_email"), emailEditorView );
    42     addListItem("qtg_small_url_address", hbTrId("txt_phob_list_url"), urlEditorView);
    32     addListItem("qtg_small_url_address", hbTrId("txt_phob_list_url"), urlEditorView);
    45     addListItem("qtg_small_sound", hbTrId("txt_phob_list_personal_ringing_tone"), ringToneFetcherView );
    35     addListItem("qtg_small_sound", hbTrId("txt_phob_list_personal_ringing_tone"), ringToneFetcherView );
    46     addListItem("qtg_small_calendar", hbTrId("txt_phob_list_date"), dateEditorView);
    36     addListItem("qtg_small_calendar", hbTrId("txt_phob_list_date"), dateEditorView);
    47     addListItem("qtg_small_company_details", hbTrId("txt_phob_list_company_details"), companyEditorView);
    37     addListItem("qtg_small_company_details", hbTrId("txt_phob_list_company_details"), companyEditorView);
    48     addListItem("qtg_small_family", hbTrId("txt_phob_list_family"), familyDetailEditorView);
    38     addListItem("qtg_small_family", hbTrId("txt_phob_list_family"), familyDetailEditorView);
    49     
    39     
    50     mListView->setModel(mListModel);
       
    51     mListView->setSelectionMode(HbAbstractItemView::NoSelection);
       
    52     // ownership of prototype is not transferred
       
    53     HbListViewItem* prototype = mListView->listItemPrototype();
       
    54     prototype->setGraphicsSize( HbListViewItem::SmallIcon );
       
    55     
       
    56     HbLabel *label = new HbLabel(this);    
    40     HbLabel *label = new HbLabel(this);    
    57     label->setPlainText(hbTrId("txt_phob_title_add_field"));
    41     label->setPlainText(hbTrId("txt_phob_title_add_field"));
    58 
    42 
    59     setHeadingWidget(label);
    43     setHeadingWidget(label);
    60     setContentWidget(mListView);
       
    61 
       
    62     HbAction *cancelAction = new HbAction(hbTrId("txt_common_button_cancel"), this);
       
    63     addAction(cancelAction);
       
    64     setTimeout(HbDialog::NoTimeout);
    44     setTimeout(HbDialog::NoTimeout);
    65     setDismissPolicy(HbDialog::NoDismiss);
    45     setDismissPolicy(HbDialog::NoDismiss);
    66     setAttribute(Qt::WA_DeleteOnClose, true);
    46     setAttribute(Qt::WA_DeleteOnClose, true);
    67     setModal(true);
    47     setModal(true);
    68 
    48     setSelectionMode(HbAbstractItemView::SingleSelection);
    69     connect(mListView, SIGNAL(activated(const QModelIndex&)), this, SLOT(listItemSelected(QModelIndex)));
    49     setModel(mListModel);
    70 }
    50 }
    71 
    51 
    72 CntDetailPopup::~CntDetailPopup()
    52 CntDetailPopup::~CntDetailPopup()
    73 {
    53 {
    74 }
    54     
    75 
       
    76 void CntDetailPopup::listItemSelected(QModelIndex index)
       
    77 {
       
    78     mSelectedDetail = mListModel->item(index.row())->data(Qt::UserRole).toInt();
       
    79     close();
       
    80 }
       
    81 
       
    82 int CntDetailPopup::selectedDetail()
       
    83 {
       
    84     return mSelectedDetail;
       
    85 }
    55 }
    86 
    56 
    87 void CntDetailPopup::selectDetail( CntViewIdList aList, QObject *receiver, const char *member  )
    57 void CntDetailPopup::selectDetail( CntViewIdList aList, QObject *receiver, const char *member  )
    88 {
    58 {
    89     CntDetailPopup *popup = new CntDetailPopup( NULL, aList );
    59     CntDetailPopup *popup = new CntDetailPopup( NULL, aList );