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