phonebookui/phonebookservices/src/cntserviceassigncontactcardview.cpp
changeset 24 0ba2181d7c28
child 25 76a2435edfd4
equal deleted inserted replaced
0:e686773b3f54 24:0ba2181d7c28
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include "cntserviceassigncontactcardview.h"
       
    19 #include "cntservicehandler.h"
       
    20 
       
    21 #include <hbdialog.h>
       
    22 #include <hbpushbutton.h>
       
    23 #include <hblabel.h>
       
    24 #include <hbwidget.h>
       
    25 #include <QGraphicsLinearLayout>
       
    26 
       
    27 /*!
       
    28 Constructor, initialize member variables.
       
    29 \a viewManager is the parent that creates this view. \a parent is a pointer to parent QGraphicsItem (by default this is 0)
       
    30 */
       
    31 CntServiceAssignContactCardView::CntServiceAssignContactCardView(CntServiceHandler *aServiceHandler, CntViewManager *viewManager, QGraphicsItem *parent) : 
       
    32     CntContactCardView(viewManager, parent),
       
    33     mServiceHandler(aServiceHandler)
       
    34 {
       
    35 
       
    36 }
       
    37 
       
    38 /*!
       
    39 Destructor
       
    40 */
       
    41 CntServiceAssignContactCardView::~CntServiceAssignContactCardView()
       
    42 {
       
    43 
       
    44 }
       
    45 
       
    46 /*!
       
    47 Add actions to the toolbar
       
    48 */
       
    49 void CntServiceAssignContactCardView::addActionsToToolBar()
       
    50 {
       
    51     //Add Action to the toolbar
       
    52     actions()->clearActionList();
       
    53     actions()->actionList() << actions()->baseAction("cnt:addtocontacts"); 
       
    54     actions()->addActionsToToolBar(toolBar());
       
    55 
       
    56     connect(actions()->baseAction("cnt:addtocontacts"), SIGNAL(triggered()),
       
    57             this, SLOT(addToContacts()));
       
    58 }
       
    59 
       
    60 /*!
       
    61 Opens the Add to Contacts popup
       
    62 */
       
    63 void CntServiceAssignContactCardView::addToContacts()
       
    64 {
       
    65     HbDialog *popup = new HbDialog();
       
    66     popup->setDismissPolicy(HbDialog::NoDismiss);
       
    67     popup->setHeadingWidget(new HbLabel(hbTrId("txt_phob_title_add_to_contacts"), popup));
       
    68     popup->setAttribute(Qt::WA_DeleteOnClose);
       
    69 
       
    70     HbWidget *buttonWidget = new HbWidget(popup);
       
    71     QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
       
    72     HbPushButton *addButton = new HbPushButton(hbTrId("txt_missing_list_save_as_a_new_contact"), buttonWidget);
       
    73     connect(addButton, SIGNAL(clicked()), this, SLOT(saveNew()));
       
    74     HbPushButton *updateButton = new HbPushButton(hbTrId("txt_missing_list_update_existing_contact"), buttonWidget);
       
    75     connect(updateButton, SIGNAL(clicked()), this, SLOT(updateExisting()));
       
    76     layout->addItem(addButton);
       
    77     layout->addItem(updateButton);
       
    78     buttonWidget->setLayout(layout);
       
    79     popup->setContentWidget(buttonWidget);
       
    80     
       
    81     popup->setSecondaryAction(new HbAction(hbTrId("txt_common_button_cancel"), popup));
       
    82 }
       
    83 
       
    84 /*!
       
    85 Create a new contact with the detail
       
    86 */
       
    87 void CntServiceAssignContactCardView::saveNew()
       
    88 {
       
    89     CntViewParameters viewParameters(CntViewParameters::serviceEditView);
       
    90     viewParameters.setSelectedContact(*mContact);
       
    91     viewManager()->onActivateView(viewParameters);
       
    92 }
       
    93 
       
    94 /*!
       
    95 Update an existing contact with the detail
       
    96 */
       
    97 void CntServiceAssignContactCardView::updateExisting()
       
    98 {
       
    99     CntViewParameters viewParameters(CntViewParameters::serviceContactSelectionView);
       
   100     viewParameters.setSelectedDetail(mDetail);
       
   101     viewManager()->onActivateView(viewParameters);
       
   102 }
       
   103 
       
   104 void CntServiceAssignContactCardView::activateView(const CntViewParameters &viewParameters)
       
   105 {
       
   106     CntContactCardView::activateView(viewParameters);
       
   107     mDetail = viewParameters.selectedDetail();
       
   108 }
       
   109 
       
   110 /*!
       
   111 Close the view (quits the service as well)
       
   112 */
       
   113 void CntServiceAssignContactCardView::aboutToCloseView()
       
   114 {
       
   115     qApp->quit();
       
   116 }
       
   117 
       
   118 // end of file