phonebookui/cntcommonui/contacteditors/cntdetaileditor.cpp
changeset 81 640d30f4fb64
parent 72 6abfb1094884
equal deleted inserted replaced
77:c18f9fa7f42e 81:640d30f4fb64
    50     mView(NULL),
    50     mView(NULL),
    51     mLoader(NULL),   
    51     mLoader(NULL),   
    52     mViewManager(NULL),
    52     mViewManager(NULL),
    53     mEditorFactory(NULL),
    53     mEditorFactory(NULL),
    54     mCancel(NULL),
    54     mCancel(NULL),
    55     mSaveManager(NULL),
       
    56     mVirtualKeyboard(NULL)
    55     mVirtualKeyboard(NULL)
    57 {
    56 {
    58     bool ok;
    57     bool ok;
    59     document()->load(CNT_DETAILEDITOR_XML, &ok);
    58     document()->load(CNT_DETAILEDITOR_XML, &ok);
    60     if (!ok) {
    59     if (!ok) {
    86     mHeader = NULL;
    85     mHeader = NULL;
    87     delete mLoader;
    86     delete mLoader;
    88     mLoader = NULL;
    87     mLoader = NULL;
    89     delete mEditorFactory;
    88     delete mEditorFactory;
    90     mEditorFactory = NULL;
    89     mEditorFactory = NULL;
    91     delete mSaveManager;
       
    92     mSaveManager = NULL;
       
    93     delete mVirtualKeyboard;
    90     delete mVirtualKeyboard;
    94     mVirtualKeyboard = NULL;
    91     mVirtualKeyboard = NULL;
    95 }
    92 }
    96 
    93 
    97 void CntDetailEditor::setViewId( int aId )
    94 void CntDetailEditor::setViewId( int aId )
   119     
   116     
   120     if ( mView->navigationAction() != mSoftkey) {
   117     if ( mView->navigationAction() != mSoftkey) {
   121         mView->setNavigationAction(mSoftkey);
   118         mView->setNavigationAction(mSoftkey);
   122     }
   119     }
   123     
   120     
   124     QContact selectedContact;
       
   125     if ( mId == groupEditorView )
   121     if ( mId == groupEditorView )
   126     {
   122     {
   127         selectedContact = aArgs.value(ESelectedGroupContact).value<QContact>();
   123         mContact = aArgs.value(ESelectedGroupContact).value<QContact>();
   128         connect( mDataForm, SIGNAL(itemShown(const QModelIndex&)), this, SLOT(handleItemShown(const QModelIndex&)) );
   124         connect( mDataForm, SIGNAL(itemShown(const QModelIndex&)), this, SLOT(handleItemShown(const QModelIndex&)) );
   129     }
   125     }
   130     else
   126     else
   131     {
   127     {
   132         selectedContact = aArgs.value(ESelectedContact).value<QContact>();
   128         mContact = aArgs.value(ESelectedContact).value<QContact>();
   133         connect( mDataForm, SIGNAL(itemShown(const QModelIndex&)), this, SLOT(handleItemShown(const QModelIndex&)) );
   129         connect( mDataForm, SIGNAL(itemShown(const QModelIndex&)), this, SLOT(handleItemShown(const QModelIndex&)) );
   134     }
   130     }
   135     
   131     
   136     QContactManager& cm = mEngine->contactManager(SYMBIAN_BACKEND);
   132     QContactManager& cm = mEngine->contactManager(SYMBIAN_BACKEND);
   137     connect(&cm, SIGNAL(contactsRemoved(const QList<QContactLocalId>&)), 
   133     connect(&cm, SIGNAL(contactsRemoved(const QList<QContactLocalId>&)), 
   138         this, SLOT(contactDeletedFromOtherSource(const QList<QContactLocalId>&)));
   134         this, SLOT(contactDeletedFromOtherSource(const QList<QContactLocalId>&)));
   139     
   135     
   140     mEditorFactory->setupEditorView(*this, selectedContact);
   136     mEditorFactory->setupEditorView(*this, mContact);
   141     
       
   142     QString myCard = mArgs.value( EMyCard ).toString();
       
   143     QContactLocalId localId = selectedContact.localId();
       
   144     QContactLocalId selfContactId = cm.selfContactId();
       
   145     bool isMyCard = ( localId == selfContactId && localId != 0 ) || !myCard.isEmpty();
       
   146     
       
   147     if (isMyCard)
       
   148     {
       
   149         mSaveManager = new CntSaveManager(CntSaveManager::EMyCard);
       
   150     }
       
   151     else if ( mId == groupEditorView )
       
   152     {
       
   153         mSaveManager = new CntSaveManager(CntSaveManager::EGroup);
       
   154     }
       
   155     else
       
   156     {
       
   157         mSaveManager = new CntSaveManager();
       
   158     }
       
   159     
       
   160     mDataForm->setItemRecycling(true);
   137     mDataForm->setItemRecycling(true);
   161 
   138 
   162     // add new field if required
   139     // add new field if required
   163     if ( aArgs.value(ESelectedAction).toString() == CNT_ADD_ACTION )
   140     if ( aArgs.value(ESelectedAction).toString() == CNT_ADD_ACTION )
   164     {
   141     {
   171     mDataForm->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded); 
   148     mDataForm->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded); 
   172     mDataForm->setScrollingStyle(HbScrollArea::PanWithFollowOn);
   149     mDataForm->setScrollingStyle(HbScrollArea::PanWithFollowOn);
   173     mDataForm->verticalScrollBar()->setInteractive(true);
   150     mDataForm->verticalScrollBar()->setInteractive(true);
   174     
   151     
   175     mVirtualKeyboard = new HbShrinkingVkbHost(mView);
   152     mVirtualKeyboard = new HbShrinkingVkbHost(mView);
   176         
       
   177     connect(mVirtualKeyboard, SIGNAL(keypadOpened()), this, SLOT(handleKeypadOpen()));
       
   178     connect(mVirtualKeyboard, SIGNAL(keypadClosed()), this, SLOT(handleKeypadClosed()));
       
   179 }
   153 }
   180 
   154 
   181 void CntDetailEditor::deactivate()
   155 void CntDetailEditor::deactivate()
   182 {
   156 {
   183     QContactManager& mgr = mEngine->contactManager(SYMBIAN_BACKEND);
   157     QContactManager& mgr = mEngine->contactManager(SYMBIAN_BACKEND);
   184     if( mId == groupEditorView) {
       
   185         mgr.saveContact( mDataFormModel->contact() );
       
   186     }
       
   187     
   158     
   188     disconnect(&mgr, SIGNAL(contactsRemoved(const QList<QContactLocalId>&)),
   159     disconnect(&mgr, SIGNAL(contactsRemoved(const QList<QContactLocalId>&)),
   189             this, SLOT(contactDeletedFromOtherSource(const QList<QContactLocalId>&)));
   160             this, SLOT(contactDeletedFromOtherSource(const QList<QContactLocalId>&)));
       
   161     
       
   162     delete mVirtualKeyboard;
       
   163     mVirtualKeyboard = NULL;
   190 }
   164 }
   191     
   165     
   192 bool CntDetailEditor::isDefault() const
   166 bool CntDetailEditor::isDefault() const
   193 {
   167 {
   194     return false;
   168     return false;
   307     if (name.isEmpty())
   281     if (name.isEmpty())
   308     {
   282     {
   309         name = hbTrId("txt_phob_list_unnamed");
   283         name = hbTrId("txt_phob_list_unnamed");
   310     }
   284     }
   311     
   285     
   312     CntSaveManager::CntSaveResult result = mSaveManager->saveContact(mDataFormModel->contact(), &mgr);
   286     QString myCard = mArgs.value( EMyCard ).toString();
   313     
   287     QContactLocalId localId = mContact.localId();
   314     if (mId != groupEditorView)
   288     QContactLocalId selfContactId = mgr.selfContactId();
   315     {
   289     bool isMyCard = ( localId == selfContactId && localId != 0 ) || !myCard.isEmpty();
       
   290         
       
   291     CntSaveManager::CntSaveResult result;
       
   292     CntSaveManager& saveMgr = mEngine->saveManager();
       
   293     if (isMyCard) {
       
   294         result = saveMgr.saveMyCard( mDataFormModel->contact(), &mgr );
       
   295     }
       
   296     else if ( mId == groupEditorView ) {
       
   297         result = saveMgr.saveGroup( mDataFormModel->contact(), &mgr );
       
   298     }
       
   299     else {
       
   300         result = saveMgr.saveContact( mDataFormModel->contact(), &mgr );
       
   301     }
       
   302         
       
   303     if (mId != groupEditorView) {
   316         switch (result)
   304         switch (result)
   317         {
   305         {
   318         case CntSaveManager::ESaved:
   306         case CntSaveManager::ESaved:
   319             HbDeviceNotificationDialog::notification(QString(),HbParameterLengthLimiter(hbTrId("txt_phob_dpophead_contact_1_saved")).arg(name));
   307             HbDeviceNotificationDialog::notification(QString(),HbParameterLengthLimiter("txt_phob_dpophead_contact_1_saved").arg(name));
   320             break;
   308             break;
   321         case CntSaveManager::EUpdated:
   309         case CntSaveManager::EUpdated:
   322             HbDeviceNotificationDialog::notification(QString(),HbParameterLengthLimiter(hbTrId("txt_phob_dpophead_contacts_1_updated")).arg(name));
   310             HbDeviceNotificationDialog::notification(QString(),HbParameterLengthLimiter("txt_phob_dpophead_contacts_1_updated").arg(name));
   323             break;
   311             break;
   324         case CntSaveManager::EFailed:
   312         case CntSaveManager::EFailed:
   325             HbDeviceNotificationDialog::notification(QString(),hbTrId("SAVING FAILED!"));
   313             HbDeviceNotificationDialog::notification(QString(),hbTrId("SAVING FAILED!"));
   326             break;
   314             break;
   327         case CntSaveManager::EDeleted:
   315         case CntSaveManager::EDeleted:
   387 void CntDetailEditor::enableDiscardChanges()
   375 void CntDetailEditor::enableDiscardChanges()
   388 {
   376 {
   389     mCancel->setDisabled(false);
   377     mCancel->setDisabled(false);
   390 }
   378 }
   391 
   379 
   392 
       
   393 void CntDetailEditor::handleKeypadOpen()
       
   394 {
       
   395     CNT_ENTRY
       
   396     
       
   397   // enable full screen
       
   398     mView->setContentFullScreen(true);
       
   399     CNT_EXIT
       
   400 }
       
   401 
       
   402 void CntDetailEditor::handleKeypadClosed()
       
   403 {
       
   404     CNT_ENTRY
       
   405     // disable full screen
       
   406     mView->setContentFullScreen(false);
       
   407     CNT_EXIT
       
   408 }
       
   409 
       
   410 // End of File
   380 // End of File