phonebookui/phonebookservices/src/cntserviceeditview.cpp
changeset 24 0ba2181d7c28
child 27 de1630741fbe
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 "cntserviceeditview.h"
       
    19 
       
    20 #include "cntservicehandler.h"
       
    21 
       
    22 CntServiceEditView::CntServiceEditView(CntServiceHandler *aServiceHandler, CntViewManager *aViewManager, QGraphicsItem *aParent) : 
       
    23     CntEditView(aViewManager, aParent),
       
    24     mServiceHandler(aServiceHandler)
       
    25 {   
       
    26 
       
    27 }
       
    28 
       
    29 CntServiceEditView::~CntServiceEditView()
       
    30 {
       
    31 
       
    32 }
       
    33 
       
    34 /*!
       
    35 Saves the contact
       
    36 */
       
    37 void CntServiceEditView::aboutToCloseView()
       
    38 {
       
    39     int result = 0;
       
    40     // save contact if there is one
       
    41     if (contact())
       
    42     {
       
    43         bool isSaved = contactManager()->saveContact(contact());
       
    44         if (isSaved)
       
    45         {
       
    46             result = 1;
       
    47         }
       
    48     }
       
    49     
       
    50     connect(mServiceHandler, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
       
    51     mServiceHandler->completeEdit(result);
       
    52 }
       
    53 
       
    54 /*!
       
    55 Cancel all changes made and return to the application editor was opened from
       
    56 */
       
    57 void CntServiceEditView::discardAllChanges()
       
    58 {
       
    59     connect(mServiceHandler, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
       
    60     mServiceHandler->completeEdit(0);
       
    61 }
       
    62 
       
    63 /*
       
    64 Handle signals emitted from CntCommands, only used for delete command for now.
       
    65 */
       
    66 int CntServiceEditView::handleExecutedCommand(QString aCommand, const QContact &aContact)
       
    67 {
       
    68     Q_UNUSED(aContact);
       
    69     int result=-1;
       
    70     if (aCommand == "delete")
       
    71     {
       
    72         connect(mServiceHandler, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
       
    73         mServiceHandler->completeEdit(result);
       
    74         result = 0;
       
    75     }
       
    76     return result;
       
    77 }
       
    78 
       
    79 // EOF