phonebookui/phonebookservices/src/cntserviceeditview.cpp
changeset 59 a642906a277a
parent 47 7cbcb2896f0e
equal deleted inserted replaced
47:7cbcb2896f0e 59:a642906a277a
    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 #include "cntdebug.h"
    21 
    22 
    22 CntServiceEditView::CntServiceEditView(CntServiceHandler *aServiceHandler ) : CntEditView(),
    23 CntServiceEditView::CntServiceEditView( CntAbstractServiceProvider& aServiceProvider )
    23 mServiceHandler(aServiceHandler)
    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     CNT_ENTRY_ARGS(aSuccess)
    37     mServiceHandler->completeEdit(aSuccess);
    39     
       
    40     int retValue = aSuccess ? KCntServicesReturnValueContactSaved : KCntServicesReturnValueContactNotModified;
       
    41     QVariant variant;
       
    42     variant.setValue(retValue);
       
    43     mProvider.CompleteServiceAndCloseApp(variant);
       
    44     
       
    45     CNT_EXIT
    38 }
    46 }
    39 
    47 
    40 void CntServiceEditView::doContactRemoved(bool aSuccess)
    48 void CntServiceEditView::doContactRemoved(bool aSuccess)
    41 {
    49 {
    42     connect(mServiceHandler, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
    50     CNT_ENTRY_ARGS(aSuccess)
    43     int retValue = aSuccess ? -1 : 0;
    51             
    44     mServiceHandler->completeEdit(retValue);
    52     int retValue = aSuccess ? KCntServicesReturnValueContactDeleted : KCntServicesReturnValueContactNotModified;
       
    53     QVariant variant;
       
    54     variant.setValue(retValue);
       
    55     mProvider.CompleteServiceAndCloseApp(variant);
       
    56     
       
    57     CNT_EXIT
    45 }
    58 }
    46 
    59 
    47 void CntServiceEditView::doChangesDiscarded()
    60 void CntServiceEditView::doChangesDiscarded()
    48 {
    61 {
    49     connect(mServiceHandler, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
    62     CNT_ENTRY
    50     mServiceHandler->completeEdit(0);
    63     
       
    64     QVariant variant;
       
    65     variant.setValue(KCntServicesReturnValueContactNotModified);
       
    66     mProvider.CompleteServiceAndCloseApp(variant);
       
    67     
       
    68     CNT_EXIT
    51 }
    69 }
    52 
    70 
    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
    71 // EOF