clock/clockui/clocksettingsview/src/clocksettingsview.cpp
author hgs
Mon, 20 Sep 2010 12:44:39 +0530
changeset 75 7ac58b2aae6f
parent 70 a5ed90760192
permissions -rw-r--r--
201037
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
c198609911f9 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).
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
c198609911f9 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
c198609911f9 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"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
c198609911f9 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".
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
* Implementation file for class ClockSettingsView.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
*/
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
// System includes
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <HbInstance>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <HbDataForm>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include <HbAction>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <HbDataFormModel>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
#include <HbDataFormModelItem>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#include <HbLabel>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include <HbPushButton>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include <HbCheckBox>
45
hgs
parents: 23
diff changeset
    28
#include <HbTranslator>
hgs
parents: 23
diff changeset
    29
#include <xqsettingsmanager.h>
hgs
parents: 23
diff changeset
    30
#include <xqsettingskey.h>
hgs
parents: 23
diff changeset
    31
#include <clockdomaincrkeys.h>
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
// User includes
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
#include "clocksettingsview.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
#include "clocksettingsdefines.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
#include "clocksettingsdocloader.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
#include "settingsutility.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
#include "timezoneclient.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
#include "settingsdatatypes.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
#include "settingscustomitem.h"
57
hgs
parents: 55
diff changeset
    41
#include "OstTraceDefinitions.h"
hgs
parents: 55
diff changeset
    42
#ifdef OST_TRACE_COMPILER_IN_USE
hgs
parents: 55
diff changeset
    43
#include "clocksettingsviewTraces.h"
hgs
parents: 55
diff changeset
    44
#endif
hgs
parents: 55
diff changeset
    45
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
	\class ClockSettingsView
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
	This implements the clock settings which allows user to set the
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
	date, time, location and other related parameters.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
	Constructor.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
	\param parent The parent of type QGraphicsWidget.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
 */
63
hgs
parents: 57
diff changeset
    59
ClockSettingsView::ClockSettingsView(QObject *parent, HbTranslator *translator, bool launchedByClock)
hgs
parents: 57
diff changeset
    60
:QObject(parent), mTranslator(0), mLaunchedByClock(launchedByClock)
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
{
57
hgs
parents: 55
diff changeset
    62
	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_CLOCKSETTINGSVIEW_ENTRY );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
	
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
	// Load the translation file and install the editor specific translator
63
hgs
parents: 57
diff changeset
    65
    if(!translator) {
hgs
parents: 57
diff changeset
    66
        mTranslator = new HbTranslator("clocksettingsview");
hgs
parents: 57
diff changeset
    67
        mTranslator->loadCommon();   
hgs
parents: 57
diff changeset
    68
    }
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
	// Construct the settings utility.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
	mSettingsUtility = new SettingsUtility();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
	// Construct the timezone client.
45
hgs
parents: 23
diff changeset
    74
	mTimezoneClient = TimezoneClient::getInstance();
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
			mTimezoneClient, SIGNAL(timechanged()),
45
hgs
parents: 23
diff changeset
    77
			this, SLOT(updatePlaceItem()));
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
			mTimezoneClient, SIGNAL(timechanged()),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
			this, SLOT(updateDateItem()));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
			mTimezoneClient, SIGNAL(timechanged()),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
			this, SLOT(updateTimeItem()));
45
hgs
parents: 23
diff changeset
    84
	connect(
hgs
parents: 23
diff changeset
    85
			mTimezoneClient, SIGNAL(autoTimeUpdateChanged(int)),
hgs
parents: 23
diff changeset
    86
			this, SLOT(handleAutoTimeUpdateChange(int)));
hgs
parents: 23
diff changeset
    87
	connect(
hgs
parents: 23
diff changeset
    88
			mTimezoneClient, SIGNAL(cityUpdated()),
hgs
parents: 23
diff changeset
    89
			this, SLOT(updatePlaceItem()));
70
hgs
parents: 63
diff changeset
    90
	connect(
hgs
parents: 63
diff changeset
    91
			mTimezoneClient, SIGNAL(timechanged()),
hgs
parents: 63
diff changeset
    92
			this, SLOT(updateClockType()));
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
	// Start a timer. For updating the remaining alarm time.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
	mTickTimer = new QTimer(this);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
			mTickTimer, SIGNAL(timeout()),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
			this, SLOT(updateTimeItem()));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
45
hgs
parents: 23
diff changeset
   100
	// Create the settings manager.
hgs
parents: 23
diff changeset
   101
	mSettingsManager = new XQSettingsManager(this);
hgs
parents: 23
diff changeset
   102
hgs
parents: 23
diff changeset
   103
	// Create the key for alarm snooze time.
hgs
parents: 23
diff changeset
   104
	mAlarmSnoozeTimeKey = new XQSettingsKey(
hgs
parents: 23
diff changeset
   105
			XQSettingsKey::TargetCentralRepository,
hgs
parents: 23
diff changeset
   106
			KCRUidClockApp,
hgs
parents: 23
diff changeset
   107
			KClockAppSnoozeTime);
75
hgs
parents: 70
diff changeset
   108
	// Create the key for clock type.
hgs
parents: 70
diff changeset
   109
	mClockTypeKey = new XQSettingsKey(
hgs
parents: 70
diff changeset
   110
			XQSettingsKey::TargetCentralRepository,
hgs
parents: 70
diff changeset
   111
			KCRUidClockApp,
hgs
parents: 70
diff changeset
   112
			KClockType);
hgs
parents: 70
diff changeset
   113
	// Start the monitoring for the alarm snooze time key and clock type.
45
hgs
parents: 23
diff changeset
   114
	mSettingsManager->startMonitoring(*mAlarmSnoozeTimeKey);
75
hgs
parents: 70
diff changeset
   115
	mSettingsManager->startMonitoring(*mClockTypeKey);
45
hgs
parents: 23
diff changeset
   116
	// Listen to the key value changes.
hgs
parents: 23
diff changeset
   117
	connect(
hgs
parents: 23
diff changeset
   118
			mSettingsManager, SIGNAL(valueChanged(XQSettingsKey, QVariant)),
hgs
parents: 23
diff changeset
   119
			this, SLOT(eventMonitor(XQSettingsKey, QVariant)));
57
hgs
parents: 55
diff changeset
   120
	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_CLOCKSETTINGSVIEW_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
	Destructor.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
ClockSettingsView::~ClockSettingsView()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
{
57
hgs
parents: 55
diff changeset
   128
	OstTraceFunctionEntry0( DUP1_CLOCKSETTINGSVIEW_CLOCKSETTINGSVIEW_ENTRY );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
	if (mDocLoader) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
		delete mDocLoader;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
	// Remove the translator
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
    if (mTranslator) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
        delete mTranslator;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
        mTranslator = 0;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
    }
45
hgs
parents: 23
diff changeset
   137
    if(mSettingsUtility){
hgs
parents: 23
diff changeset
   138
    	delete mSettingsUtility;
hgs
parents: 23
diff changeset
   139
    }
75
hgs
parents: 70
diff changeset
   140
	if(mSettingsManager) {
hgs
parents: 70
diff changeset
   141
		delete mSettingsManager;
hgs
parents: 70
diff changeset
   142
	}
hgs
parents: 70
diff changeset
   143
	// Delete cenrep keys
hgs
parents: 70
diff changeset
   144
	delete mAlarmSnoozeTimeKey;
hgs
parents: 70
diff changeset
   145
	delete mClockTypeKey;
45
hgs
parents: 23
diff changeset
   146
	
hgs
parents: 23
diff changeset
   147
	if(mSettingsModel){
hgs
parents: 23
diff changeset
   148
		delete mSettingsModel;
hgs
parents: 23
diff changeset
   149
	}
57
hgs
parents: 55
diff changeset
   150
	OstTraceFunctionExit0( DUP1_CLOCKSETTINGSVIEW_CLOCKSETTINGSVIEW_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
	Loads the settings view from the docml.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
void ClockSettingsView::loadSettingsView()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
{
57
hgs
parents: 55
diff changeset
   158
	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_LOADSETTINGSVIEW_ENTRY );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
	bool loadSuccess;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
	// Construct the document loader instance
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
	mDocLoader = new ClockSettingsDocLoader();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
	// Load the application xml.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
	mDocLoader->load(CLOCK_SETTINGS_VIEW_DOCML, &loadSuccess);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
	
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
	// Load the correct section based on orientation.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
	HbMainWindow *window = hbInstance->allMainWindows().first();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
	Qt::Orientation currentOrientation = window->orientation();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
	
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
	if (Qt::Vertical == currentOrientation) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
		// Load portrait section.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
		mDocLoader->load(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
				CLOCK_SETTINGS_VIEW_DOCML,
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
				CLOCK_SETTINGS_VIEW_PORTRAIT_SECTION,
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
				&loadSuccess);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
	} else {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
		// Load landscape section.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
		mDocLoader->load(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
				CLOCK_SETTINGS_VIEW_DOCML,
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
				CLOCK_SETTINGS_VIEW_LANDSCAPE_SECTION,
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
				&loadSuccess);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
	// Connect the required signals.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
			window, SIGNAL(orientationChanged(Qt::Orientation)),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
			this, SLOT(handleOrientationChanged(Qt::Orientation)));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
	// Find the main view.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
	mSettingsView = static_cast<HbView *> (
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
			mDocLoader->findWidget(CLOCK_SETTINGS_VIEW));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
	// Setup the view.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
	setupView();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
57
hgs
parents: 55
diff changeset
   197
	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_LOADSETTINGSVIEW_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
	Slot to handle the back action of the view.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
void ClockSettingsView::handleBackAction()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
{
57
hgs
parents: 55
diff changeset
   205
	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_HANDLEBACKACTION_ENTRY );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
	HbMainWindow *window = hbInstance->allMainWindows().first();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
	window->removeView(mSettingsView);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
	deleteLater();
57
hgs
parents: 55
diff changeset
   209
	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_HANDLEBACKACTION_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
/*!
45
hgs
parents: 23
diff changeset
   213
	Updates the zone info in the place item field.
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
 */
45
hgs
parents: 23
diff changeset
   215
void ClockSettingsView::updatePlaceItem()
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
{
57
hgs
parents: 55
diff changeset
   217
	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_UPDATEPLACEITEM_ENTRY );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
	// Get the current zone info.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
	LocationInfo currentZoneInfo = mTimezoneClient->getCurrentZoneInfoL();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
	if (mTimezoneClient->timeUpdateOn()) {
23
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   222
		mPlaceDataFormItem->setContentWidgetData(
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   223
				"text", currentZoneInfo.countryName);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
	} else {
23
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   225
		QString placeInfo = currentZoneInfo.cityName
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   226
				+ tr(", ") + currentZoneInfo.countryName;
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   227
		mPlaceDataFormItem->setContentWidgetData("text", placeInfo);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
	}
57
hgs
parents: 55
diff changeset
   229
	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_UPDATEPLACEITEM_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
	Slot to update the display of the date settings item field.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
void ClockSettingsView::updateDateItem()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
{
57
hgs
parents: 55
diff changeset
   237
	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_UPDATEDATEITEM_ENTRY );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
	mDateDataFormItem->setContentWidgetData("text", mSettingsUtility->date());
57
hgs
parents: 55
diff changeset
   239
	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_UPDATEDATEITEM_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
	Slot to update the display of the time settings item field.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   244
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   245
void ClockSettingsView::updateTimeItem()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
{
57
hgs
parents: 55
diff changeset
   247
	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_UPDATETIMEITEM_ENTRY );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
	if (!mTickTimer->isActive()) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
		mTickTimer->stop();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
    }
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
	mTimeDataFormItem->setContentWidgetData("text", mSettingsUtility->time());
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
	// Start the timer again.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
	mTickTimer->start(60000 - 1000 * QTime::currentTime().second());
57
hgs
parents: 55
diff changeset
   255
	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_UPDATETIMEITEM_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   259
	This slot is called whenever orientattion of the view changes.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   261
void ClockSettingsView::handleOrientationChanged(Qt::Orientation orientation)
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
{
57
hgs
parents: 55
diff changeset
   263
	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_HANDLEORIENTATIONCHANGED_ENTRY );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
	bool success; 
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
	// If horizontal, load the landscape section. 
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
	if (Qt::Horizontal == orientation) { 
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   267
		mDocLoader->load( 
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
				CLOCK_SETTINGS_VIEW_DOCML,
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
				CLOCK_SETTINGS_VIEW_LANDSCAPE_SECTION, 
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   270
				&success); 
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
	} else if (Qt::Vertical == orientation) { 
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
		mDocLoader->load( 
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
				CLOCK_SETTINGS_VIEW_DOCML,
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
				CLOCK_SETTINGS_VIEW_PORTRAIT_SECTION,
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
				&success); 
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
	} 
57
hgs
parents: 55
diff changeset
   277
	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_HANDLEORIENTATIONCHANGED_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   279
23
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   280
void ClockSettingsView::handleNetworkTimeStateChange(int state)
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   281
{
57
hgs
parents: 55
diff changeset
   282
	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_HANDLENETWORKTIMESTATECHANGE_ENTRY );
23
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   283
	bool cenrepValue = mTimezoneClient->timeUpdateOn();
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   284
	if ((Qt::Checked == state && !cenrepValue)
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   285
			|| (Qt::Unchecked == state && cenrepValue)) {
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   286
		if (Qt::Checked == state) {
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   287
			// Update the cenrep value.
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   288
			mTimezoneClient->setTimeUpdateOn(true);
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   289
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   290
		} else if (Qt::Unchecked == state) {
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   291
			// Update the cenrep value.
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   292
			mTimezoneClient->setTimeUpdateOn(false);
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   293
		}
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   294
	}
57
hgs
parents: 55
diff changeset
   295
	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_HANDLENETWORKTIMESTATECHANGE_EXIT );
23
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   296
}
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   297
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
	Called after loading the view from the docml.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
	The initializaion/setup of the view is done here.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
	\param docLoader Pointer to ClockSettingsDocLoader object.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
void ClockSettingsView::setupView()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
{
57
hgs
parents: 55
diff changeset
   306
	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_SETUPVIEW_ENTRY );
63
hgs
parents: 57
diff changeset
   307
	
hgs
parents: 57
diff changeset
   308
	if(!mLaunchedByClock) {
hgs
parents: 57
diff changeset
   309
	    mSettingsView->setTitle(hbTrId("txt_clock_title_control_panel"));
hgs
parents: 57
diff changeset
   310
	}
hgs
parents: 57
diff changeset
   311
	
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
	HbMainWindow *window = hbInstance->allMainWindows().first();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
	window->addView(mSettingsView);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
	window->setCurrentView(mSettingsView);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
	// Add the back softkey.
45
hgs
parents: 23
diff changeset
   317
	mBackAction = new HbAction(Hb::BackNaviAction);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
	mSettingsView->setNavigationAction(mBackAction);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   319
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
			mBackAction, SIGNAL(triggered()),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
			this, SLOT(handleBackAction()));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
	// Get the data form.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
	mSettingsForm = static_cast<HbDataForm *> (
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
			mDocLoader->findWidget(CLOCK_SETTINGS_DATA_FORM));
70
hgs
parents: 63
diff changeset
   326
	mSettingsForm->setItemPixmapCacheEnabled(true);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
	// Create the custom prototype.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
	QList <HbAbstractViewItem*> prototypes = mSettingsForm->itemPrototypes();
63
hgs
parents: 57
diff changeset
   329
	SettingsCustomItem *customPrototype = new SettingsCustomItem(mSettingsForm, mLaunchedByClock);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
	prototypes.append(customPrototype);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
	mSettingsForm->setItemPrototypes(prototypes);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
	// Create the model.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   334
	createModel();
45
hgs
parents: 23
diff changeset
   335
	updatePlaceItem();
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
	mTickTimer->start(60000 - 1000 * QTime::currentTime().second());
57
hgs
parents: 55
diff changeset
   338
	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_SETUPVIEW_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   341
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
	Creates the model for the settings form.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
void ClockSettingsView::createModel()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   345
{
57
hgs
parents: 55
diff changeset
   346
	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_CREATEMODEL_ENTRY );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   347
	// Remove the model.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   348
	if (mSettingsForm->model()) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
		delete mSettingsForm->model();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   350
		mSettingsForm->setModel(0);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   352
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   353
	// Create a model and set it.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
	mSettingsModel = new HbDataFormModel();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
	// Add the items to the view.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   356
	populateModel();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   357
	mSettingsForm->setModel(mSettingsModel);
57
hgs
parents: 55
diff changeset
   358
	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_CREATEMODEL_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   360
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   361
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   362
	Poplulates the item in the model.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
void ClockSettingsView::populateModel()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
{
57
hgs
parents: 55
diff changeset
   366
	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_POPULATEMODEL_ENTRY );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   367
	if (!mSettingsModel) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
		createModel();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   371
	// Add the network time update item.
23
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   372
	mNetworkTimeItem = mSettingsModel->appendDataFormItem(
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   373
			HbDataFormModelItem::CheckBoxItem, "");
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
	bool networkTime = mTimezoneClient->timeUpdateOn();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
	Qt::CheckState state = Qt::Unchecked;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
	if (networkTime) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
		state = Qt::Checked;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
	}
23
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   379
	mNetworkTimeItem->setContentWidgetData(
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
			"checkState", state);
23
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   381
	mNetworkTimeItem->setContentWidgetData(
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
			"text", QString(hbTrId("txt_clk_setlabel_use_network_date_time")));
51
hgs
parents: 45
diff changeset
   383
	mNetworkTimeItem->setContentWidgetData("objectName", "networkTime");
23
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   384
	mSettingsForm->addConnection(
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   385
			mNetworkTimeItem, SIGNAL(stateChanged(int)),
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   386
			this, SLOT(handleNetworkTimeStateChange(int)));
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
	// Add the time item.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   389
	// Custom data type for adding a time button to the data form.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   390
	HbDataFormModelItem::DataItemType timeItemType =
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
			static_cast<HbDataFormModelItem::DataItemType>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   392
			(HbDataFormModelItem::CustomItemBase + TimeItem);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   393
	mTimeDataFormItem = mSettingsModel->appendDataFormItem(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
			timeItemType, QString(hbTrId("txt_clock_setlabel_time")));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
	mTimeDataFormItem->setContentWidgetData("text", mSettingsUtility->time());
51
hgs
parents: 45
diff changeset
   396
	mTimeDataFormItem->setContentWidgetData("objectName", "timeItem");
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
	// Add the date item.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
	// Custom data type for adding a time button to the data form.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
	HbDataFormModelItem::DataItemType dateItemType =
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
			static_cast<HbDataFormModelItem::DataItemType>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
			(HbDataFormModelItem::CustomItemBase + DateItem);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
	mDateDataFormItem = mSettingsModel->appendDataFormItem(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
			dateItemType, QString(hbTrId("txt_clock_setlabel_date")));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
	mDateDataFormItem->setContentWidgetData("text", mSettingsUtility->date());
51
hgs
parents: 45
diff changeset
   406
	mDateDataFormItem->setContentWidgetData("objectName", "dateItem");
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
	// Add the place item.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
	HbDataFormModelItem::DataItemType placeItemType =
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
			static_cast<HbDataFormModelItem::DataItemType>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
			(HbDataFormModelItem::CustomItemBase + PlaceItem);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
	mPlaceDataFormItem = mSettingsModel->appendDataFormItem(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
			placeItemType, QString(hbTrId("txt_clock_formlabel_place")));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
	
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   415
	LocationInfo currentZoneInfo = mTimezoneClient->getCurrentZoneInfoL();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
	QString placeItemText("");
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
	if (Qt::Unchecked == state) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
		placeItemText.append(currentZoneInfo.cityName);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
		placeItemText+= tr(", ");
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
	placeItemText.append(currentZoneInfo.countryName);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
	mPlaceDataFormItem->setContentWidgetData("text", placeItemText);
51
hgs
parents: 45
diff changeset
   423
	mPlaceDataFormItem->setContentWidgetData("objectName", "placeItem");
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
	
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
	if (networkTime) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   426
		mTimeDataFormItem->setEnabled(false);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
		mDateDataFormItem->setEnabled(false);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
		mPlaceDataFormItem->setEnabled(false);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
	} else {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
		mTimeDataFormItem->setEnabled(true);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
		mDateDataFormItem->setEnabled(true);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
		mPlaceDataFormItem->setEnabled(true);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
	// Add the regional settings item.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   436
	HbDataFormModelItem::DataItemType regionalSettingsItem =
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   437
			static_cast<HbDataFormModelItem::DataItemType>
23
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   438
			(HbDataFormModelItem::CustomItemBase + RegionalSettingsItem);
55
hgs
parents: 51
diff changeset
   439
	mRegionalDataFormItem = mSettingsModel->appendDataFormItem(
hgs
parents: 51
diff changeset
   440
			regionalSettingsItem);
hgs
parents: 51
diff changeset
   441
	mRegionalDataFormItem->setContentWidgetData(
hgs
parents: 51
diff changeset
   442
			"text", hbTrId("txt_clock_button_regional_date_time_settings"));
hgs
parents: 51
diff changeset
   443
	mRegionalDataFormItem->setContentWidgetData(
51
hgs
parents: 45
diff changeset
   444
					"objectName", "regionalSettings");
45
hgs
parents: 23
diff changeset
   445
    
hgs
parents: 23
diff changeset
   446
	// Add the clock type item.
hgs
parents: 23
diff changeset
   447
    HbDataFormModelItem::DataItemType clockTypeSettingsItem =
hgs
parents: 23
diff changeset
   448
            static_cast<HbDataFormModelItem::DataItemType>
hgs
parents: 23
diff changeset
   449
            (HbDataFormModelItem::ToggleValueItem);
hgs
parents: 23
diff changeset
   450
    mClockTypeItem = mSettingsModel->appendDataFormItem(
hgs
parents: 23
diff changeset
   451
	clockTypeSettingsItem,hbTrId("txt_clock_setlabel_clock_type"));
hgs
parents: 23
diff changeset
   452
    QStringList clockTypeList;
hgs
parents: 23
diff changeset
   453
    int clockType = mSettingsUtility->clockType(clockTypeList);
hgs
parents: 23
diff changeset
   454
	int zeroIndex(0);
hgs
parents: 23
diff changeset
   455
    if( zeroIndex == clockType ){
hgs
parents: 23
diff changeset
   456
	    mClockTypeItem->setContentWidgetData("text", clockTypeList[0]);
hgs
parents: 23
diff changeset
   457
	    mClockTypeItem->setContentWidgetData("additionalText", clockTypeList[1]);
hgs
parents: 23
diff changeset
   458
    } else {
hgs
parents: 23
diff changeset
   459
	    mClockTypeItem->setContentWidgetData("text", clockTypeList[1]);
hgs
parents: 23
diff changeset
   460
	    mClockTypeItem->setContentWidgetData("additionalText", clockTypeList[0]);    
hgs
parents: 23
diff changeset
   461
    }
51
hgs
parents: 45
diff changeset
   462
    mClockTypeItem->setContentWidgetData("objectName", "clockType");
45
hgs
parents: 23
diff changeset
   463
    mSettingsForm->addConnection(
75
hgs
parents: 70
diff changeset
   464
					mClockTypeItem, SIGNAL(clicked()),
hgs
parents: 70
diff changeset
   465
					this, SLOT(handleClockTypeChanged()));
45
hgs
parents: 23
diff changeset
   466
    
hgs
parents: 23
diff changeset
   467
    // Add the alarm snooze time item.
hgs
parents: 23
diff changeset
   468
	mAlarmSnoozeItem = mSettingsModel->appendDataFormItem(
hgs
parents: 23
diff changeset
   469
			HbDataFormModelItem::ComboBoxItem,
hgs
parents: 23
diff changeset
   470
			hbTrId("txt_clock_setlabel_alarm_snooze_time"));
hgs
parents: 23
diff changeset
   471
	QStringList alramSnoozeTimes;
55
hgs
parents: 51
diff changeset
   472
	alramSnoozeTimes << hbTrId("txt_clock_setlabel_ln_mins", 5)
hgs
parents: 51
diff changeset
   473
			<< hbTrId("txt_clock_setlabel_ln_mins", 10)
hgs
parents: 51
diff changeset
   474
			<< hbTrId("txt_clock_setlabel_ln_mins", 15)
hgs
parents: 51
diff changeset
   475
			<< hbTrId("txt_clock_setlabel_ln_mins", 30);
45
hgs
parents: 23
diff changeset
   476
	
hgs
parents: 23
diff changeset
   477
	// Build the hash map for the reminder.
hgs
parents: 23
diff changeset
   478
	mAlarmSnoozeTimeHash[0] = 5;
hgs
parents: 23
diff changeset
   479
	mAlarmSnoozeTimeHash[1] = 10;
hgs
parents: 23
diff changeset
   480
	mAlarmSnoozeTimeHash[2] = 15;
hgs
parents: 23
diff changeset
   481
	mAlarmSnoozeTimeHash[3] = 30;
hgs
parents: 23
diff changeset
   482
	
hgs
parents: 23
diff changeset
   483
	mAlarmSnoozeItem->setContentWidgetData("items", alramSnoozeTimes);
hgs
parents: 23
diff changeset
   484
	QVariant value = mSettingsManager->readItemValue(*mAlarmSnoozeTimeKey);
hgs
parents: 23
diff changeset
   485
	bool success;
hgs
parents: 23
diff changeset
   486
	int index;
hgs
parents: 23
diff changeset
   487
	int alarmSnoozeTime = value.toInt(&success);
hgs
parents: 23
diff changeset
   488
	if (success) {
hgs
parents: 23
diff changeset
   489
		index = mAlarmSnoozeTimeHash.key(alarmSnoozeTime);
hgs
parents: 23
diff changeset
   490
	} else {
hgs
parents: 23
diff changeset
   491
		index = mAlarmSnoozeTimeHash.key(15);
hgs
parents: 23
diff changeset
   492
	}
hgs
parents: 23
diff changeset
   493
	mAlarmSnoozeItem->setContentWidgetData("currentIndex", index);
51
hgs
parents: 45
diff changeset
   494
	mAlarmSnoozeItem->setContentWidgetData("objectName", "alarmSnooze");
45
hgs
parents: 23
diff changeset
   495
	mSettingsForm->addConnection(
hgs
parents: 23
diff changeset
   496
			mAlarmSnoozeItem, SIGNAL(currentIndexChanged(int)),
hgs
parents: 23
diff changeset
   497
			this, SLOT(handleAlarmSnoozeTimeChanged(int)));
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   498
57
hgs
parents: 55
diff changeset
   499
	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_POPULATEMODEL_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   500
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   501
45
hgs
parents: 23
diff changeset
   502
/*!
hgs
parents: 23
diff changeset
   503
	Slot which handles the auto time update value changes in cenrep.
hgs
parents: 23
diff changeset
   504
	
hgs
parents: 23
diff changeset
   505
	/param value New value of the auto time update.
hgs
parents: 23
diff changeset
   506
 */
hgs
parents: 23
diff changeset
   507
void ClockSettingsView::handleAutoTimeUpdateChange(int value)
hgs
parents: 23
diff changeset
   508
{
57
hgs
parents: 55
diff changeset
   509
	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_HANDLEAUTOTIMEUPDATECHANGE_ENTRY );
45
hgs
parents: 23
diff changeset
   510
	int state = (mNetworkTimeItem->contentWidgetData("checkState")).toInt();
hgs
parents: 23
diff changeset
   511
	
hgs
parents: 23
diff changeset
   512
	if (value) {
hgs
parents: 23
diff changeset
   513
		// Disable the time, date and place item.
hgs
parents: 23
diff changeset
   514
		if (mTimeDataFormItem) {
hgs
parents: 23
diff changeset
   515
			mTimeDataFormItem->setEnabled(false);
hgs
parents: 23
diff changeset
   516
		}
hgs
parents: 23
diff changeset
   517
		if (mDateDataFormItem) {
hgs
parents: 23
diff changeset
   518
			mDateDataFormItem->setEnabled(false);
hgs
parents: 23
diff changeset
   519
		}
hgs
parents: 23
diff changeset
   520
		if (mPlaceDataFormItem) {
hgs
parents: 23
diff changeset
   521
			mPlaceDataFormItem->setEnabled(false);
hgs
parents: 23
diff changeset
   522
		}
hgs
parents: 23
diff changeset
   523
		if (Qt::Unchecked == state) {
hgs
parents: 23
diff changeset
   524
			mNetworkTimeItem->setContentWidgetData(
hgs
parents: 23
diff changeset
   525
						"checkState", Qt::Checked);
hgs
parents: 23
diff changeset
   526
		}
hgs
parents: 23
diff changeset
   527
	} else {
hgs
parents: 23
diff changeset
   528
		// Enable the time, date and place item.
hgs
parents: 23
diff changeset
   529
		if (mTimeDataFormItem) {
hgs
parents: 23
diff changeset
   530
			mTimeDataFormItem->setEnabled(true);
hgs
parents: 23
diff changeset
   531
		}
hgs
parents: 23
diff changeset
   532
		if (mDateDataFormItem) {
hgs
parents: 23
diff changeset
   533
			mDateDataFormItem->setEnabled(true);
hgs
parents: 23
diff changeset
   534
		}
hgs
parents: 23
diff changeset
   535
		if (mPlaceDataFormItem) {
hgs
parents: 23
diff changeset
   536
			mPlaceDataFormItem->setEnabled(true);
hgs
parents: 23
diff changeset
   537
		}
hgs
parents: 23
diff changeset
   538
		if (Qt::Checked == state) {
hgs
parents: 23
diff changeset
   539
			mNetworkTimeItem->setContentWidgetData(
hgs
parents: 23
diff changeset
   540
						"checkState", Qt::Unchecked);
hgs
parents: 23
diff changeset
   541
		}
hgs
parents: 23
diff changeset
   542
	}
hgs
parents: 23
diff changeset
   543
	updatePlaceItem();
57
hgs
parents: 55
diff changeset
   544
	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_HANDLEAUTOTIMEUPDATECHANGE_EXIT );
45
hgs
parents: 23
diff changeset
   545
}
hgs
parents: 23
diff changeset
   546
hgs
parents: 23
diff changeset
   547
/*!
hgs
parents: 23
diff changeset
   548
	Slot which handles the alarm snooze time changes.
hgs
parents: 23
diff changeset
   549
	
hgs
parents: 23
diff changeset
   550
	/param value New index of the alarm snooze time.
hgs
parents: 23
diff changeset
   551
 */
hgs
parents: 23
diff changeset
   552
void ClockSettingsView::handleAlarmSnoozeTimeChanged(int index)
hgs
parents: 23
diff changeset
   553
{
57
hgs
parents: 55
diff changeset
   554
	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_HANDLEALARMSNOOZETIMECHANGED_ENTRY );
45
hgs
parents: 23
diff changeset
   555
	if (mAlarmSnoozeTimeHash.value(index)) {
hgs
parents: 23
diff changeset
   556
		mSettingsManager->writeItemValue(
hgs
parents: 23
diff changeset
   557
				*mAlarmSnoozeTimeKey, mAlarmSnoozeTimeHash.value(index));
hgs
parents: 23
diff changeset
   558
	}
57
hgs
parents: 55
diff changeset
   559
	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_HANDLEALARMSNOOZETIMECHANGED_EXIT );
45
hgs
parents: 23
diff changeset
   560
}
hgs
parents: 23
diff changeset
   561
hgs
parents: 23
diff changeset
   562
/*!
hgs
parents: 23
diff changeset
   563
    Slot which handles the clock type change..
hgs
parents: 23
diff changeset
   564
 */
hgs
parents: 23
diff changeset
   565
void ClockSettingsView::handleClockTypeChanged()
hgs
parents: 23
diff changeset
   566
{
57
hgs
parents: 55
diff changeset
   567
	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_HANDLECLOCKTYPECHANGED_ENTRY );
75
hgs
parents: 70
diff changeset
   568
	mSettingsUtility->setClockType(mClockTypeItem->contentWidgetData("text").toString());
57
hgs
parents: 55
diff changeset
   569
	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_HANDLECLOCKTYPECHANGED_EXIT );
45
hgs
parents: 23
diff changeset
   570
}
hgs
parents: 23
diff changeset
   571
hgs
parents: 23
diff changeset
   572
/*!
hgs
parents: 23
diff changeset
   573
	Slot which is called when the value changes in cenrep.
hgs
parents: 23
diff changeset
   574
hgs
parents: 23
diff changeset
   575
	\param key The key which got changed in cenrep.
hgs
parents: 23
diff changeset
   576
	\param value The new value of that key.
hgs
parents: 23
diff changeset
   577
 */
hgs
parents: 23
diff changeset
   578
void ClockSettingsView::eventMonitor(
hgs
parents: 23
diff changeset
   579
		const XQSettingsKey& key, const QVariant& value)
hgs
parents: 23
diff changeset
   580
{
57
hgs
parents: 55
diff changeset
   581
	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_EVENTMONITOR_ENTRY );
75
hgs
parents: 70
diff changeset
   582
	if (key.uid() == KCRUidClockApp) {
hgs
parents: 70
diff changeset
   583
		// Update the snooze time
hgs
parents: 70
diff changeset
   584
		if(key.key() == KClockAppSnoozeTime) {
hgs
parents: 70
diff changeset
   585
			if (mSettingsManager->error() == XQSettingsManager::NoError) {
hgs
parents: 70
diff changeset
   586
hgs
parents: 70
diff changeset
   587
				bool success;
hgs
parents: 70
diff changeset
   588
				int alarmSnoozeTime = value.toInt(&success);
45
hgs
parents: 23
diff changeset
   589
75
hgs
parents: 70
diff changeset
   590
				if (success) {
hgs
parents: 70
diff changeset
   591
					mAlarmSnoozeItem->setContentWidgetData(
hgs
parents: 70
diff changeset
   592
							"currentIndex", mAlarmSnoozeTimeHash.key(
hgs
parents: 70
diff changeset
   593
									alarmSnoozeTime));
hgs
parents: 70
diff changeset
   594
				}
45
hgs
parents: 23
diff changeset
   595
			}
75
hgs
parents: 70
diff changeset
   596
		}else if(key.key() == KClockType) {
hgs
parents: 70
diff changeset
   597
			// Update the clock type when its changed
hgs
parents: 70
diff changeset
   598
			updateClockType();
45
hgs
parents: 23
diff changeset
   599
		}
hgs
parents: 23
diff changeset
   600
	}
57
hgs
parents: 55
diff changeset
   601
	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_EVENTMONITOR_EXIT );
45
hgs
parents: 23
diff changeset
   602
}
hgs
parents: 23
diff changeset
   603
70
hgs
parents: 63
diff changeset
   604
/*!
hgs
parents: 63
diff changeset
   605
	Slot for updating the clock type on locale change.
hgs
parents: 63
diff changeset
   606
 */
hgs
parents: 63
diff changeset
   607
void ClockSettingsView::updateClockType()
hgs
parents: 63
diff changeset
   608
{
hgs
parents: 63
diff changeset
   609
	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_UPDATECLOCKTYPE_ENTRY );
hgs
parents: 63
diff changeset
   610
	QStringList clockTypeList;
hgs
parents: 63
diff changeset
   611
	int clockType = mSettingsUtility->clockType(clockTypeList);
hgs
parents: 63
diff changeset
   612
	int zeroIndex(0);
hgs
parents: 63
diff changeset
   613
	if( zeroIndex == clockType ){
hgs
parents: 63
diff changeset
   614
		mClockTypeItem->setContentWidgetData("text", clockTypeList[0]);
hgs
parents: 63
diff changeset
   615
		mClockTypeItem->setContentWidgetData("additionalText", clockTypeList[1]);
hgs
parents: 63
diff changeset
   616
	} else {
hgs
parents: 63
diff changeset
   617
		mClockTypeItem->setContentWidgetData("text", clockTypeList[1]);
hgs
parents: 63
diff changeset
   618
		mClockTypeItem->setContentWidgetData("additionalText", clockTypeList[0]);    
hgs
parents: 63
diff changeset
   619
	}
hgs
parents: 63
diff changeset
   620
	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_UPDATECLOCKTYPE_EXIT );
hgs
parents: 63
diff changeset
   621
}
hgs
parents: 63
diff changeset
   622
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   623
// End of file	--Don't remove this.