messagingapp/msgsettings/settingsview/src/msgsettingsview.cpp
changeset 25 84d9eb65b26f
parent 23 238255e8b033
child 27 e4592d119491
equal deleted inserted replaced
23:238255e8b033 25:84d9eb65b26f
    12  * Contributors:
    12  * Contributors:
    13  *
    13  *
    14  * Description:This is the first view for msgsettings plugin 
    14  * Description:This is the first view for msgsettings plugin 
    15  *
    15  *
    16  */
    16  */
    17 
       
    18 #include <hbaction.h>
       
    19 #include <hbmainwindow.h>
    17 #include <hbmainwindow.h>
    20 #include <hbinstance.h>
       
    21 
    18 
    22 #include "msgsettingsview.h"
    19 #include "msgsettingsview.h"
    23 #include "msgsettingsform.h"
    20 #include "msgsettingsform.h"
    24 #include "msgsettingsdataformcustomitem.h"
    21 #include "msgsmscenterview.h"
    25 #include "msgsettingsviewmanager.h"
       
    26 #include "debugtraces.h"
    22 #include "debugtraces.h"
    27 
    23 
    28 MsgSettingsView::MsgSettingsView(QGraphicsItem *parent) :
    24 MsgSettingsView::MsgSettingsView(QGraphicsItem *parent) :
    29     MsgBaseView(parent)
    25     MsgBaseView(parent), mSMSCenterView(0)
    30 {
    26 {
    31     mSettingsViewManager = new MsgSettingsViewManager(this);
    27     mSettingsForm = new MsgSettingsForm();
    32     
       
    33     MsgSettingsForm* settingForm = new MsgSettingsForm(
       
    34                                                        mSettingsViewManager,
       
    35                                                        this);
       
    36 
    28 
    37     //custom prototype
    29     setWidget(mSettingsForm);
    38     MsgSettingsDataFormCustomItem* customPrototype =
    30     mMainWindow = this->mainWindow();
    39             new MsgSettingsDataFormCustomItem(settingForm);
       
    40     //settingForm->setItemPrototype(customPrototype);
       
    41     
       
    42     QList<HbAbstractViewItem*> protos = settingForm->itemPrototypes();
       
    43     protos.append(customPrototype);
       
    44     settingForm->setItemPrototypes(protos);
       
    45 
    31 
    46     setWidget(settingForm);
    32     connect(mSettingsForm,
    47 
    33             SIGNAL(newSMSCCenterClicked(int)),
    48     mMainWindow = hbInstance->allMainWindows().at(0);
    34             this,
    49 
    35             SLOT(onNewSMSCCenterClicked(int)));
    50     mBackAction = new HbAction(Hb::BackAction, this);
       
    51     
       
    52     connectCloseAction();    
       
    53     
       
    54     connect (mSettingsViewManager,
       
    55              SIGNAL(advancedSettingsViewClosed()),
       
    56              this,
       
    57              SLOT(connectCloseAction()));
       
    58 }
    36 }
    59 
    37 
    60 MsgSettingsView::~MsgSettingsView()
    38 MsgSettingsView::~MsgSettingsView()
    61 {
    39 {
    62    //do nothing 
    40     delete mSMSCenterView;
    63 }
    41 }
    64 
    42 
    65 void MsgSettingsView::connectCloseAction()
    43 void MsgSettingsView::onNewSMSCCenterClicked(int index)
    66 {
    44 {
    67     this->setNavigationAction(mBackAction);
    45     //open the sms center views
    68     connect(mBackAction, SIGNAL(triggered()), this, SLOT(closeSettings()), Qt::UniqueConnection);
    46     if (mSMSCenterView)
       
    47     {
       
    48         delete mSMSCenterView;
       
    49         mSMSCenterView = NULL;
       
    50     }
       
    51 
       
    52     mSMSCenterView = new MsgSMSCenterView(index);
       
    53     
       
    54     connect(mSMSCenterView,
       
    55             SIGNAL(smsCenterEditViewClosed()),
       
    56             this,
       
    57             SLOT(onSmsCenterEditViewClosed()));
       
    58     
       
    59     mMainWindow->addView(mSMSCenterView);        
       
    60     mMainWindow->setCurrentView(mSMSCenterView);
    69 }
    61 }
    70 
    62 
    71 void MsgSettingsView::closeSettings()
    63 void MsgSettingsView::onSmsCenterEditViewClosed()
    72 {
    64 {
    73     QVariantList param;
    65     //remove the view 
    74     param << MsgBaseView::DEFAULT;
    66     mMainWindow->removeView(mSMSCenterView);
    75     param << MsgBaseView::MSGSETTINGS;
    67 
    76     emit switchView(param);
    68     //refresh the form
       
    69     mSettingsForm->refreshViewForm();
       
    70 
       
    71     //add the current view on top
       
    72     mMainWindow->setCurrentView(this);
    77 }
    73 }
       
    74 
       
    75 //eof
       
    76