phonebookui/phonebookservices/src/cntservicesubeditview.cpp
changeset 24 0ba2181d7c28
child 25 76a2435edfd4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/phonebookui/phonebookservices/src/cntservicesubeditview.cpp	Fri Mar 19 09:27:18 2010 +0200
@@ -0,0 +1,77 @@
+/*
+* 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