phonebookui/phonebookservices/src/cntserviceeditview.cpp
changeset 50 77bc263e1626
parent 47 7cbcb2896f0e
child 53 e6aff7b69165
equal deleted inserted replaced
49:74b30151afd6 50:77bc263e1626
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include "cntserviceeditview.h"
    18 #include "cntserviceeditview.h"
    19 #include "cntservicehandler.h"
    19 #include <cntservicescontact.h>
    20 #include <QCoreApplication>
    20 #include <QCoreApplication>
    21 
    21 
    22 CntServiceEditView::CntServiceEditView(CntServiceHandler *aServiceHandler ) : CntEditView(),
    22 
    23 mServiceHandler(aServiceHandler)
    23 CntServiceEditView::CntServiceEditView( CntAbstractServiceProvider& aServiceProvider )
       
    24 : CntEditView(),
       
    25 mProvider( aServiceProvider )
    24 {   
    26 {   
    25     connect( this, SIGNAL(contactUpdated(int)), this, SLOT(doContactUpdated(int)) );
    27     connect( this, SIGNAL(contactUpdated(int)), this, SLOT(doContactUpdated(int)) );
    26     connect( this, SIGNAL(contactRemoved(bool)), this, SLOT(doContactRemoved(bool)) );
    28     connect( this, SIGNAL(contactRemoved(bool)), this, SLOT(doContactRemoved(bool)) );
    27     connect( this, SIGNAL(changesDiscarded()), this, SLOT(doChangesDiscarded()) );
    29     connect( this, SIGNAL(changesDiscarded()), this, SLOT(doChangesDiscarded()) );
    28 }
    30 }
    31 {
    33 {
    32 }
    34 }
    33 
    35 
    34 void CntServiceEditView::doContactUpdated(int aSuccess)
    36 void CntServiceEditView::doContactUpdated(int aSuccess)
    35 {
    37 {
    36     connect(mServiceHandler, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
    38     int retValue = aSuccess ? KCntServicesReturnValueContactSaved : KCntServicesReturnValueContactNotModified;
    37     mServiceHandler->completeEdit(aSuccess);
    39     QVariant variant;
       
    40     variant.setValue(retValue);
       
    41     mProvider.CompleteServiceAndCloseApp(variant);
    38 }
    42 }
    39 
    43 
    40 void CntServiceEditView::doContactRemoved(bool aSuccess)
    44 void CntServiceEditView::doContactRemoved(bool aSuccess)
    41 {
    45 {
    42     connect(mServiceHandler, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
    46     int retValue = aSuccess ? KCntServicesReturnValueContactDeleted : KCntServicesReturnValueContactNotModified;
    43     int retValue = aSuccess ? -1 : 0;
    47     QVariant variant;
    44     mServiceHandler->completeEdit(retValue);
    48     variant.setValue(retValue);
       
    49     mProvider.CompleteServiceAndCloseApp(variant);
    45 }
    50 }
    46 
    51 
    47 void CntServiceEditView::doChangesDiscarded()
    52 void CntServiceEditView::doChangesDiscarded()
    48 {
    53 {
    49     connect(mServiceHandler, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
    54     QVariant variant;
    50     mServiceHandler->completeEdit(0);
    55     variant.setValue(KCntServicesReturnValueContactNotModified);
       
    56     mProvider.CompleteServiceAndCloseApp(variant);
    51 }
    57 }
    52 
    58 
    53 //
       
    54 ///*!
       
    55 //Saves the contact
       
    56 //*/
       
    57 //void CntServiceEditView::aboutToCloseView()
       
    58 //{
       
    59 //    int result = 0;
       
    60 //    // save contact if there is one
       
    61 //    if (contact() && !contact()->isEmpty())
       
    62 //    {
       
    63 //        bool isSaved = contactManager()->saveContact(contact());
       
    64 //        if (isSaved)
       
    65 //        {
       
    66 //            result = 1;
       
    67 //        }
       
    68 //    }
       
    69 //    
       
    70 //    connect(mServiceHandler, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
       
    71 //    mServiceHandler->completeEdit(result);
       
    72 //}
       
    73 //
       
    74 ///*!
       
    75 //Cancel all changes made and return to the application editor was opened from
       
    76 //*/
       
    77 //void CntServiceEditView::discardAllChanges()
       
    78 //{
       
    79 //    connect(mServiceHandler, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
       
    80 //    mServiceHandler->completeEdit(0);
       
    81 //}
       
    82 //
       
    83 ///*
       
    84 //Handle signals emitted from CntCommands, only used for delete command for now.
       
    85 //*/
       
    86 //int CntServiceEditView::handleExecutedCommand(QString aCommand, const QContact &aContact)
       
    87 //{
       
    88 //    Q_UNUSED(aContact);
       
    89 //    int result=-1;
       
    90 //    if (aCommand == "delete")
       
    91 //    {
       
    92 //        connect(mServiceHandler, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
       
    93 //        mServiceHandler->completeEdit(result);
       
    94 //        result = 0;
       
    95 //    }
       
    96 //    return result;
       
    97 //}
       
    98 
       
    99 // EOF
    59 // EOF