phonebookui/phonebookservices/src/cntservicesubeditview.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 19 Mar 2010 09:27:18 +0200
changeset 24 0ba2181d7c28
child 25 76a2435edfd4
permissions -rw-r--r--
Revision: 201007 Kit: 201011

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/

#include "cntservicesubeditview.h"

#include "cntservicehandler.h"

CntServiceSubEditView::CntServiceSubEditView(CntServiceHandler *aServiceHandler, CntViewManager *aViewManager, QGraphicsItem *aParent) : 
    CntEditView(aViewManager, aParent),
    mServiceHandler(aServiceHandler)
{   

}

CntServiceSubEditView::~CntServiceSubEditView()
{

}

/*!
Saves the contact
*/
void CntServiceSubEditView::aboutToCloseView()
{
    // save contact if there is one
    if (contact())
    {
        contactManager()->saveContact(contact());
    }
    
    CntViewParameters viewParameters(CntViewParameters::serviceContactCardView);
    viewParameters.setSelectedContact(*contact());   
    viewManager()->onActivateView(viewParameters);
}

/*!
Cancel all changes made and return to comm launcher view
*/
void CntServiceSubEditView::discardAllChanges()
{
    QContact oldContact = contactManager()->contact(contact()->localId());
    CntViewParameters viewParameters(CntViewParameters::serviceContactCardView);
    viewParameters.setSelectedContact(oldContact);   
    viewManager()->onActivateView(viewParameters);
}

/*
Handle signals emitted from CntCommands, only used for delete command for now.
*/
int CntServiceSubEditView::handleExecutedCommand(QString aCommand, const QContact &aContact)
{
    Q_UNUSED(aContact);
    int result = -1;
    if (aCommand == "delete")
    {
        connect(mServiceHandler, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
        mServiceHandler->completeEdit(result);
        result = 0;
    }
    return result;
}

// EOF