messagingapp/msgsettings/settingsview/src/msgsettingsview.cpp
branchRCL_3
changeset 57 ebe688cedc25
equal deleted inserted replaced
54:fa1df4b99609 57:ebe688cedc25
       
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:This is the first view for msgsettings plugin 
       
    15  *
       
    16  */
       
    17 #include <hbmainwindow.h>
       
    18 #include <hbgroupbox.h>
       
    19 #include <QGraphicsLinearLayout>
       
    20 #include <HbAction>
       
    21 
       
    22 #include "msgsettingsview.h"
       
    23 #include "msgsettingsform.h"
       
    24 #include "msgsmscenterview.h"
       
    25 #include "debugtraces.h"
       
    26 
       
    27 //LOCALAIZED CONSTANTS 
       
    28 #define LOC_MESSAGE_SETTINGS_HEADING hbTrId("txt_messaging_title_messaging_settings")
       
    29 
       
    30 MsgSettingsView::MsgSettingsView(SettingsView settingsView,QGraphicsItem *parent):
       
    31 MsgBaseView(parent),
       
    32 mSMSCenterView(0),
       
    33 mSettingsForm(0),
       
    34 mCurrentView(settingsView)
       
    35 {
       
    36     mMainWindow = this->mainWindow();
       
    37 
       
    38     // Create parent layout.
       
    39     QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(Qt::Vertical);
       
    40     mainLayout->setContentsMargins(0, 0, 0, 0);
       
    41     mainLayout->setSpacing(0);
       
    42 
       
    43     // Create view heading.
       
    44     HbGroupBox *viewHeading = new HbGroupBox();
       
    45     viewHeading->setHeading(LOC_MESSAGE_SETTINGS_HEADING);
       
    46 
       
    47     mSettingsForm = new MsgSettingsForm(settingsView);
       
    48 
       
    49     connect(mSettingsForm,
       
    50             SIGNAL(newSMSCCenterClicked(int)),
       
    51             this,
       
    52             SLOT(onNewSMSCCenterClicked(int)));
       
    53     
       
    54 
       
    55     mainLayout->addItem(viewHeading);
       
    56     mainLayout->addItem(mSettingsForm);
       
    57 
       
    58     this->setLayout(mainLayout);
       
    59     
       
    60     //sms settings need to be created so launch MsgSMSCenterView in edit mode.
       
    61     if(settingsView == SMSView)
       
    62     {
       
    63         onNewSMSCCenterClicked(-1);
       
    64     }
       
    65 }
       
    66 
       
    67 MsgSettingsView::~MsgSettingsView()
       
    68 {
       
    69     delete mSMSCenterView;
       
    70 }
       
    71 
       
    72 void MsgSettingsView::onNewSMSCCenterClicked(int index)
       
    73 {
       
    74     //open the sms center views
       
    75     if (mSMSCenterView)
       
    76     {
       
    77         delete mSMSCenterView;
       
    78         mSMSCenterView = NULL;
       
    79     }
       
    80 
       
    81     mSMSCenterView = new MsgSMSCenterView(index);
       
    82 
       
    83     connect(mSMSCenterView,
       
    84             SIGNAL(smsCenterEditViewClosed()),
       
    85             this,
       
    86             SLOT(onSmsCenterEditViewClosed()));
       
    87 
       
    88     mMainWindow->addView(mSMSCenterView);
       
    89     mMainWindow->setCurrentView(mSMSCenterView);
       
    90 }
       
    91 
       
    92 void MsgSettingsView::onSmsCenterEditViewClosed()
       
    93 {
       
    94 
       
    95     //sms center view was directly launched, no need to go back to settings view.
       
    96     if(mCurrentView == SMSView)
       
    97     {
       
    98         this->navigationAction()->trigger();
       
    99         return;
       
   100     }
       
   101     //remove the view 
       
   102     mMainWindow->removeView(mSMSCenterView);
       
   103     
       
   104     // This check is needed in case when smsc center view is 
       
   105     // launched directly 
       
   106     if(mMainWindow->views().count() > 0)
       
   107     {
       
   108         QCRITICAL_WRITE("MsgViewManager::onSmsCenterEditViewClosed count>0");
       
   109         
       
   110         //refresh the form
       
   111         mSettingsForm->refreshViewForm();
       
   112         
       
   113         //add the current view on top
       
   114         mMainWindow->setCurrentView(this);
       
   115     }
       
   116 }
       
   117 
       
   118 //eof
       
   119