clock/clockui/clockviews/src/clockmainview.cpp
author hgs
Mon, 20 Sep 2010 12:44:39 +0530
changeset 75 7ac58b2aae6f
parent 70 a5ed90760192
child 81 ce92091cbd61
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
* Definition file for class ClockMainView.
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 <QGraphicsItem>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <HbInstance>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include <HbLabel>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <HbAbstractViewItem>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
#include <HbMenu>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#include <HbAction>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include <HbListView>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include <HbNotificationDialog>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include <HbStyleLoader>
57
hgs
parents: 55
diff changeset
    29
#include <HbColorScheme>
hgs
parents: 55
diff changeset
    30
#include <HbApplication> // hbapplication
hgs
parents: 55
diff changeset
    31
#include <HbActivityManager> // activity manager
75
hgs
parents: 70
diff changeset
    32
#include <xqsettingsmanager.h>
hgs
parents: 70
diff changeset
    33
#include <xqsettingskey.h>
hgs
parents: 70
diff changeset
    34
#include <clockdomaincrkeys.h>
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
// User includes
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
#include "clockmainview.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
#include "clockdocloader.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
#include "clockappcontrollerif.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
#include "alarmclient.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
#include "clocksettingsview.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
#include "clockcommon.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
#include "clockalarmeditor.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
#include "settingsutility.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
#include "timezoneclient.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
#include "clockalarmlistitemprototype.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
#include "clockalarmlistmodel.h"
45
hgs
parents: 18
diff changeset
    48
#include "clockwidget.h"
57
hgs
parents: 55
diff changeset
    49
#include "OstTraceDefinitions.h"
hgs
parents: 55
diff changeset
    50
#ifdef OST_TRACE_COMPILER_IN_USE
hgs
parents: 55
diff changeset
    51
#include "clockmainviewTraces.h"
hgs
parents: 55
diff changeset
    52
#endif
hgs
parents: 55
diff changeset
    53
18
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
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
	\class ClockMainView
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
	The main view of the clock application.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
	Constructor.
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
	\param parent The parent of type QGraphicsWidget.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
ClockMainView::ClockMainView(QGraphicsItem *parent)
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
:HbView(parent),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
 mAlarmList(0),
45
hgs
parents: 18
diff changeset
    69
 mSelectedItem(-1),
hgs
parents: 18
diff changeset
    70
 mIsLongTop(false),
hgs
parents: 18
diff changeset
    71
 mIsScreenShotCapruted(false)
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
{
57
hgs
parents: 55
diff changeset
    73
	OstTraceFunctionEntry0( CLOCKMAINVIEW_CLOCKMAINVIEW_ENTRY );
45
hgs
parents: 18
diff changeset
    74
	// Nothing yet.
57
hgs
parents: 55
diff changeset
    75
	OstTraceFunctionExit0( CLOCKMAINVIEW_CLOCKMAINVIEW_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
	Destructor.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
ClockMainView::~ClockMainView()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
{
57
hgs
parents: 55
diff changeset
    83
	OstTraceFunctionEntry0( DUP1_CLOCKMAINVIEW_CLOCKMAINVIEW_ENTRY );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
	if (mDocLoader) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
		delete mDocLoader;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
		mDocLoader = 0;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
	if (mAlarmListModel) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
		delete mAlarmListModel;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
		mAlarmListModel = 0;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
	}
75
hgs
parents: 70
diff changeset
    92
	if (mSettingsManager) {
hgs
parents: 70
diff changeset
    93
		delete mSettingsManager;
hgs
parents: 70
diff changeset
    94
	}
hgs
parents: 70
diff changeset
    95
	// Delete cenrep key
hgs
parents: 70
diff changeset
    96
	delete mClockTypeSettingsKey;
hgs
parents: 70
diff changeset
    97
	
45
hgs
parents: 18
diff changeset
    98
	HbStyleLoader::unregisterFilePath(
hgs
parents: 18
diff changeset
    99
			":/style/clockalarmlistitemprototype.css");
hgs
parents: 18
diff changeset
   100
	HbStyleLoader::unregisterFilePath(
hgs
parents: 18
diff changeset
   101
			":/style/clockalarmlistitemprototype.widgetml");
hgs
parents: 18
diff changeset
   102
	HbStyleLoader::unregisterFilePath(
hgs
parents: 18
diff changeset
   103
			":/style/clockalarmlistitemprototype_color.css");
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
57
hgs
parents: 55
diff changeset
   105
	OstTraceFunctionExit0( DUP1_CLOCKMAINVIEW_CLOCKMAINVIEW_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
	Called by the ClockViewManager after loading the view from the docml.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
	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
   111
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
	\param controller The ClockAppController object.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
	\param docLoader Pointer to ClockDocLoader object.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
void ClockMainView::setupView(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
		ClockAppControllerIf &controllerIf, ClockDocLoader *docLoader)
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
{
57
hgs
parents: 55
diff changeset
   118
	OstTraceFunctionEntry0( CLOCKMAINVIEW_SETUPVIEW_ENTRY );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
	mDocLoader = docLoader;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
	mAppControllerIf = &controllerIf;
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
	mTimezoneClient = controllerIf.timezoneClient();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
	mSettingsUtility = controllerIf.settingsUtility();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
	mAlarmClient = controllerIf.alarmClient();
57
hgs
parents: 55
diff changeset
   125
	
hgs
parents: 55
diff changeset
   126
	// Fetch the color group of the labels from the theme.
hgs
parents: 55
diff changeset
   127
	mLabelColorGroup = HbColorScheme::color("qtc_view_normal");
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
	// Create the model.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
	mAlarmListModel =  new ClockAlarmListModel(*mAppControllerIf, this);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
			mAlarmListModel, SIGNAL(changeAlarmListDisplay()),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
			this, SLOT(handleAlarmListDisplay()));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
	QList<AlarmInfo> alarmInfoList;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
	// Get the list of pending clock alarms.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
	mAlarmClient->getAlarmList(alarmInfoList);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
	QList<AlarmInfo> displayInfoList;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
	AlarmInfo alarmInfo;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
	for (int index = 0; index < alarmInfoList.count(); ++index) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
		alarmInfo = alarmInfoList[index];
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
		if (Notified == alarmInfo.alarmState) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
			continue;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
		}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
		displayInfoList.append(alarmInfo);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
	int alarmCount = displayInfoList.count();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
	HbMainWindow *window = hbInstance->allMainWindows().first();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
	bool loadSuccess = false;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
	Qt::Orientation currentOrienation = window->orientation();
45
hgs
parents: 18
diff changeset
   153
	
hgs
parents: 18
diff changeset
   154
	// Get the dividers.
hgs
parents: 18
diff changeset
   155
	mHorizontalDivider = static_cast<HbLabel *> (
hgs
parents: 18
diff changeset
   156
			mDocLoader->findObject("horizontalDivider"));
hgs
parents: 18
diff changeset
   157
	mVerticalDivider = static_cast<HbLabel *> (
hgs
parents: 18
diff changeset
   158
				mDocLoader->findObject("verticalDivider"));
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
	// Get the "No alarm set" label.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
	mNoAlarmLabel = qobject_cast<HbLabel *> (
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
			mDocLoader->findWidget(CLOCK_NOALARMLABEL));
57
hgs
parents: 55
diff changeset
   163
	mNoAlarmLabel->setTextColor(mLabelColorGroup);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
	// Get the alarm's list.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
	mAlarmList = qobject_cast<HbListView *> (
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
			mDocLoader->findWidget(CLOCK_ALARMLIST));
70
hgs
parents: 57
diff changeset
   168
	mAlarmList->setItemPixmapCacheEnabled(true);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
			mAlarmList, SIGNAL(activated(const QModelIndex &)),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
			this, SLOT(handleActivated(const QModelIndex &)));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
			mAlarmList,
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
			SIGNAL(longPressed(HbAbstractViewItem*, const QPointF&)),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
			this,
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
			SLOT(handleLongPress(HbAbstractViewItem*, const QPointF&)));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
45
hgs
parents: 18
diff changeset
   179
	HbStyleLoader::registerFilePath(":/style/clockalarmlistitemprototype.css");
hgs
parents: 18
diff changeset
   180
	HbStyleLoader::registerFilePath(
hgs
parents: 18
diff changeset
   181
			":/style/clockalarmlistitemprototype.widgetml");
hgs
parents: 18
diff changeset
   182
	HbStyleLoader::registerFilePath(
hgs
parents: 18
diff changeset
   183
			":/style/clockalarmlistitemprototype_color.css");
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
	setmodel();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
	// Load the correct section based on orientation.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
	if (Qt::Vertical == currentOrienation) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
		mDocLoader->load(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
				CLOCK_MAIN_VIEW_DOCML,
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
				CLOCK_MAIN_VIEW_PORTRAIT_SECTION,
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
				&loadSuccess);
45
hgs
parents: 18
diff changeset
   192
		mHorizontalDivider->setVisible(true);
hgs
parents: 18
diff changeset
   193
		mVerticalDivider->setVisible(false);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
	} else {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
		mDocLoader->load(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
				CLOCK_MAIN_VIEW_DOCML,
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
				CLOCK_MAIN_VIEW_LANDSCAPE_SECTION,
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
				&loadSuccess);
45
hgs
parents: 18
diff changeset
   199
		mHorizontalDivider->setVisible(false);
hgs
parents: 18
diff changeset
   200
		mVerticalDivider->setVisible(true);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
	if (loadSuccess) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
		if (0 == alarmCount) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
			hideAlarmList(true);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
		} else {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
			hideAlarmList(false);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
			mAlarmListModel->populateModel();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
		}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
45
hgs
parents: 18
diff changeset
   211
	mDayLabel = static_cast<HbLabel *> (mDocLoader->findObject("dateLabel"));
57
hgs
parents: 55
diff changeset
   212
	mDayLabel->setTextColor(mLabelColorGroup);
hgs
parents: 55
diff changeset
   213
	mPlaceLabel = static_cast<HbLabel *> (mDocLoader->findObject("placetext"));
hgs
parents: 55
diff changeset
   214
	mPlaceLabel->setTextColor(mLabelColorGroup);
hgs
parents: 55
diff changeset
   215
	mDstIcon = static_cast<HbLabel *> (mDocLoader->findObject("dstIcon"));
45
hgs
parents: 18
diff changeset
   216
	mClockWidget = static_cast<ClockWidget*> (
hgs
parents: 18
diff changeset
   217
			mDocLoader->findObject(CLOCK_WIDGET));
hgs
parents: 18
diff changeset
   218
hgs
parents: 18
diff changeset
   219
	// Update the date info.
hgs
parents: 18
diff changeset
   220
	updateDateLabel();
hgs
parents: 18
diff changeset
   221
	// Update the place info.
hgs
parents: 18
diff changeset
   222
	updatePlaceLabel(mTimezoneClient->timeUpdateOn());
hgs
parents: 18
diff changeset
   223
	// Update clock widget display.
hgs
parents: 18
diff changeset
   224
	updateClockWidget();
hgs
parents: 18
diff changeset
   225
hgs
parents: 18
diff changeset
   226
	// Connect to orientation change and load appropriate section.
hgs
parents: 18
diff changeset
   227
	connect(
hgs
parents: 18
diff changeset
   228
			window, SIGNAL(orientationChanged(Qt::Orientation)),
hgs
parents: 18
diff changeset
   229
			this, SLOT(checkOrientationAndLoadSection(Qt::Orientation)));
hgs
parents: 18
diff changeset
   230
	
hgs
parents: 18
diff changeset
   231
    // Get a pointer to activity Manager
hgs
parents: 18
diff changeset
   232
    HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();
hgs
parents: 18
diff changeset
   233
  
hgs
parents: 18
diff changeset
   234
    // clean up any previous versions of this activity from the activity manager.
hgs
parents: 18
diff changeset
   235
    // ignore return value as the first boot would always return a false
hgs
parents: 18
diff changeset
   236
    // bool declared on for debugging purpose
hgs
parents: 18
diff changeset
   237
    bool ok = activityManager->removeActivity(clockMainView);
hgs
parents: 18
diff changeset
   238
hgs
parents: 18
diff changeset
   239
	// connect for the aboutToQuit events on application Exit as to call saveActivity
hgs
parents: 18
diff changeset
   240
    connect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity()));
hgs
parents: 18
diff changeset
   241
57
hgs
parents: 55
diff changeset
   242
    OstTraceFunctionExit0( CLOCKMAINVIEW_SETUPVIEW_EXIT );
45
hgs
parents: 18
diff changeset
   243
}
hgs
parents: 18
diff changeset
   244
hgs
parents: 18
diff changeset
   245
/*!
hgs
parents: 18
diff changeset
   246
	To defer the connects and initialization. To be done after the view is drawn.
hgs
parents: 18
diff changeset
   247
	Should be called in the slot of view ready.
hgs
parents: 18
diff changeset
   248
 */
hgs
parents: 18
diff changeset
   249
void ClockMainView::setupAfterViewReady()
hgs
parents: 18
diff changeset
   250
{
57
hgs
parents: 55
diff changeset
   251
	OstTraceFunctionEntry0( CLOCKMAINVIEW_SETUPAFTERVIEWREADY_ENTRY );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
	// Get the toolbar/menu actions.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
	mRefreshMainView = static_cast<HbAction *> (
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
			mDocLoader->findObject("alarmsAction"));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
	mRefreshMainView->setCheckable(true);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
	mRefreshMainView->setChecked(true);
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
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
			mRefreshMainView, SIGNAL(changed()),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   261
			this, SLOT(refreshMainView()));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
	mDisplayWorldClockView = static_cast<HbAction *> (
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
			mDocLoader->findObject("worldClockAction"));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
			mDisplayWorldClockView, SIGNAL(triggered()),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   267
			this, SLOT(displayWorldClockView()));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
	mAddNewAlarm = static_cast<HbAction *> (
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   270
			mDocLoader->findObject("newAlarmAction"));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
			mAddNewAlarm, SIGNAL(triggered()),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
			this, SLOT(addNewAlarm()));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
	mSettingsAction = static_cast<HbAction *> (
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
			mDocLoader->findObject("settingsAction"));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
			mSettingsAction, SIGNAL(triggered()),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   279
			this, SLOT(openSettings()));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   280
45
hgs
parents: 18
diff changeset
   281
	// Connect the necessary timezone client call backs.
hgs
parents: 18
diff changeset
   282
	connect(
hgs
parents: 18
diff changeset
   283
			mTimezoneClient, SIGNAL(timechanged()),
hgs
parents: 18
diff changeset
   284
			this, SLOT(updateView()));
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
	connect(
45
hgs
parents: 18
diff changeset
   286
			mTimezoneClient, SIGNAL(autoTimeUpdateChanged(int)),
hgs
parents: 18
diff changeset
   287
			this, SLOT(updatePlaceLabel(int)));
hgs
parents: 18
diff changeset
   288
	connect(
hgs
parents: 18
diff changeset
   289
			mTimezoneClient, SIGNAL(cityUpdated()),
hgs
parents: 18
diff changeset
   290
			this, SLOT(updatePlaceLabel()));
hgs
parents: 18
diff changeset
   291
	
75
hgs
parents: 70
diff changeset
   292
	// Connect for the clock type changes to refresh the view
hgs
parents: 70
diff changeset
   293
	mSettingsManager = new XQSettingsManager(this);
hgs
parents: 70
diff changeset
   294
	mClockTypeSettingsKey = new XQSettingsKey(
hgs
parents: 70
diff changeset
   295
							XQSettingsKey::TargetCentralRepository,
hgs
parents: 70
diff changeset
   296
							KCRUidClockApp,
hgs
parents: 70
diff changeset
   297
							KClockType);
hgs
parents: 70
diff changeset
   298
	mSettingsManager->startMonitoring(*mClockTypeSettingsKey);
hgs
parents: 70
diff changeset
   299
	connect(mSettingsManager, SIGNAL(valueChanged(XQSettingsKey, QVariant)),
hgs
parents: 70
diff changeset
   300
				this, SLOT(eventMonitor(XQSettingsKey, QVariant)));
hgs
parents: 70
diff changeset
   301
	
57
hgs
parents: 55
diff changeset
   302
	OstTraceFunctionExit0( CLOCKMAINVIEW_SETUPAFTERVIEWREADY_EXIT );
18
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
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
	Slot which gets called for the status change of the alarm i.e for
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
	active/inactive.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
	\param row contains the row number of the alarm in the alarm list
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
void ClockMainView::handleAlarmStatusChanged(int row)
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
{
57
hgs
parents: 55
diff changeset
   313
	OstTraceFunctionEntry0( CLOCKMAINVIEW_HANDLEALARMSTATUSCHANGED_ENTRY );
45
hgs
parents: 18
diff changeset
   314
	AlarmInfo alarmInfo;
18
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
	// Get the data for the alarm.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
	QList<QVariant> alarmData =
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
			mAlarmListModel->sourceModel()->index(row, 0).data(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   319
					AlarmDetails).toList();
45
hgs
parents: 18
diff changeset
   320
	int alarmId = alarmData.at(0).value<int>();
hgs
parents: 18
diff changeset
   321
hgs
parents: 18
diff changeset
   322
	mAlarmClient->getAlarmInfo(alarmId, alarmInfo);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
	mSelectedItem = row;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
	if (-1 < mSelectedItem) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
		QList<QVariant> alarmData =
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
				mAlarmListModel->sourceModel()->index(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
						mSelectedItem, 0).data(AlarmDetails).toList();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
		int alarmId = alarmData.at(0).value<int>();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
		QString displayNote;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
		// Activate or deactivate the alarm depending on the alarm status.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
		// Display the NotificationDialog with appropriate message.
45
hgs
parents: 18
diff changeset
   334
		if (Snoozed == alarmInfo.alarmState && Enabled == alarmInfo.alarmStatus
hgs
parents: 18
diff changeset
   335
				&& Once != alarmInfo.repeatType) {
hgs
parents: 18
diff changeset
   336
			removeSnoozedAlarm();
hgs
parents: 18
diff changeset
   337
			displayNote.append(tr("Snoozed alarm removed"));
hgs
parents: 18
diff changeset
   338
		}else if (Enabled == alarmInfo.alarmStatus) {
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
			mAlarmClient->toggleAlarmStatus(alarmId, Disabled);
45
hgs
parents: 18
diff changeset
   340
			displayNote.append(
hgs
parents: 18
diff changeset
   341
			    hbTrId("txt_clock_main_view_dpopinfo_alarm_deactivated"));
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
		} else {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
			mAlarmClient->toggleAlarmStatus(alarmId, Enabled);
45
hgs
parents: 18
diff changeset
   344
			displayNote.append(
hgs
parents: 18
diff changeset
   345
			    hbTrId("txt_clock_main_view_dpopinfo_alarm_activated"));
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   346
		}
45
hgs
parents: 18
diff changeset
   347
hgs
parents: 18
diff changeset
   348
		HbNotificationDialog *dialog = new HbNotificationDialog();
hgs
parents: 18
diff changeset
   349
		dialog->setTitle(displayNote);
hgs
parents: 18
diff changeset
   350
		dialog->setTimeout(HbPopup::ConfirmationNoteTimeout);
hgs
parents: 18
diff changeset
   351
		dialog->show();
hgs
parents: 18
diff changeset
   352
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   353
		mSelectedItem = -1;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
	}
57
hgs
parents: 55
diff changeset
   355
	OstTraceFunctionExit0( CLOCKMAINVIEW_HANDLEALARMSTATUSCHANGED_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   356
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   357
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
	Slot which gets called when `Alarm' action is triggered from the view
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   360
	toolbar. This is responsible for reloading the content of the main view.
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
void ClockMainView::refreshMainView()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
{
57
hgs
parents: 55
diff changeset
   364
	OstTraceFunctionEntry0( CLOCKMAINVIEW_REFRESHMAINVIEW_ENTRY );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
	mRefreshMainView->setChecked(true);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   366
57
hgs
parents: 55
diff changeset
   367
	OstTraceFunctionExit0( CLOCKMAINVIEW_REFRESHMAINVIEW_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
}
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
	Slot which gets called when `World clock' action is triggered from the view
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   372
	toolbar. This is responsible for launching the world clock.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   373
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
void ClockMainView::displayWorldClockView()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
{
57
hgs
parents: 55
diff changeset
   376
	OstTraceFunctionEntry0( CLOCKMAINVIEW_DISPLAYWORLDCLOCKVIEW_ENTRY );
45
hgs
parents: 18
diff changeset
   377
	mAppControllerIf->switchToView(WorldClock);
hgs
parents: 18
diff changeset
   378
	// no need to capture the screenshot here as it's done in ClockViewManager::showView
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   379
57
hgs
parents: 55
diff changeset
   380
	OstTraceFunctionExit0( CLOCKMAINVIEW_DISPLAYWORLDCLOCKVIEW_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
	Slot which gets called when `New alarm' action is triggered from the view
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
	toolbar. This is responsible for launching the editor to create a new alarm.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
void ClockMainView::addNewAlarm()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
{
57
hgs
parents: 55
diff changeset
   389
	OstTraceFunctionEntry0( CLOCKMAINVIEW_ADDNEWALARM_ENTRY );
45
hgs
parents: 18
diff changeset
   390
	ClockAlarmEditor *alarmEditor = new ClockAlarmEditor(*mAlarmClient);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
	alarmEditor->showAlarmEditor();
45
hgs
parents: 18
diff changeset
   392
	// capture screenshot for future use, if application
hgs
parents: 18
diff changeset
   393
	// is exited/Quit from alarmEditor
hgs
parents: 18
diff changeset
   394
	captureScreenShot(true);
57
hgs
parents: 55
diff changeset
   395
	OstTraceFunctionExit0( CLOCKMAINVIEW_ADDNEWALARM_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
}
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
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
	Slot which gets called when `Settings' action is triggered from the view
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
	menu. This is responsible for launching the settings view.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
void ClockMainView::openSettings()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
{
57
hgs
parents: 55
diff changeset
   404
	OstTraceFunctionEntry0( CLOCKMAINVIEW_OPENSETTINGS_ENTRY );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
	// Create the settings view.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
	ClockSettingsView *settingsView = new ClockSettingsView(this);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
	settingsView->loadSettingsView();
45
hgs
parents: 18
diff changeset
   408
	// capture screenshot for future use, if application
hgs
parents: 18
diff changeset
   409
	// is exited/Quit from alarmEditor
hgs
parents: 18
diff changeset
   410
	captureScreenShot(true);
57
hgs
parents: 55
diff changeset
   411
	OstTraceFunctionExit0( CLOCKMAINVIEW_OPENSETTINGS_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
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
	This slot handles the 'activated' signal of the alarm list. Opens the
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
	alarm editor to edit the alarm.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
	\param index the modelIndex in the list which has been tapped.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
void ClockMainView::handleActivated(const QModelIndex &index)
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
{
57
hgs
parents: 55
diff changeset
   421
	OstTraceFunctionEntry0( CLOCKMAINVIEW_HANDLEACTIVATED_ENTRY );
45
hgs
parents: 18
diff changeset
   422
	if(!mIsLongTop) {// Get the data for the alarm.
hgs
parents: 18
diff changeset
   423
		int row = index.row();
hgs
parents: 18
diff changeset
   424
		QList<QVariant> alarmData =
hgs
parents: 18
diff changeset
   425
				mAlarmListModel->sourceModel()->index(row, 0).data(
hgs
parents: 18
diff changeset
   426
						AlarmDetails).toList();
hgs
parents: 18
diff changeset
   427
		int alarmId = alarmData.at(0).value<int>();
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
45
hgs
parents: 18
diff changeset
   429
		// Construct the alarm editor.
hgs
parents: 18
diff changeset
   430
		ClockAlarmEditor *alarmEditor = new ClockAlarmEditor(
hgs
parents: 18
diff changeset
   431
				*mAlarmClient, alarmId);
hgs
parents: 18
diff changeset
   432
		alarmEditor->showAlarmEditor();
hgs
parents: 18
diff changeset
   433
		// capture screenshot for future use, if application 
hgs
parents: 18
diff changeset
   434
		// is exited/Quit from alarmEditor
hgs
parents: 18
diff changeset
   435
		captureScreenShot(true);
hgs
parents: 18
diff changeset
   436
	}
57
hgs
parents: 55
diff changeset
   437
	OstTraceFunctionExit0( CLOCKMAINVIEW_HANDLEACTIVATED_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
	This slot handles the 'longpressed' signal of the alarm list. Opens the
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
	context menu.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
	\param item The item in the list which has been long pressed.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
	\param coords The position where mouse was pressed.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
void ClockMainView::handleLongPress(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
		HbAbstractViewItem *item, const QPointF &coords)
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
{
57
hgs
parents: 55
diff changeset
   450
	OstTraceFunctionEntry0( CLOCKMAINVIEW_HANDLELONGPRESS_ENTRY );
45
hgs
parents: 18
diff changeset
   451
	mIsLongTop = true;
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   452
	AlarmInfo alarmInfo;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
	// Save the item row number where the long press was made.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
	mSelectedItem = item->modelIndex().row();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
	// Get the data for the alarm.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   458
	QList<QVariant> alarmData =
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
			mAlarmListModel->sourceModel()->
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
			index(mSelectedItem, 0).data(AlarmDetails).toList();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   461
	int alarmId = alarmData.at(0).value<int>();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   463
	mAlarmClient->getAlarmInfo(alarmId, alarmInfo);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   464
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   465
	// On long press we display item specific context menu.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   466
	HbMenu *itemContextMenu = new HbMenu();
45
hgs
parents: 18
diff changeset
   467
	connect(
hgs
parents: 18
diff changeset
   468
			itemContextMenu,SIGNAL(aboutToClose()),
hgs
parents: 18
diff changeset
   469
			this, SLOT(handleMenuClosed()));
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   470
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   471
	// Add the delete action to the context menu.
45
hgs
parents: 18
diff changeset
   472
	mDeleteAction = itemContextMenu->addAction(
hgs
parents: 18
diff changeset
   473
			hbTrId("txt_clk_main_view_menu_delete_alarm"));
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   474
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   475
	// Show the menu.
45
hgs
parents: 18
diff changeset
   476
	itemContextMenu->open(this, SLOT(selectedMenuAction(HbAction*)));
hgs
parents: 18
diff changeset
   477
	itemContextMenu->setPreferredPos(coords);
hgs
parents: 18
diff changeset
   478
	itemContextMenu->setAttribute(Qt::WA_DeleteOnClose, true );
hgs
parents: 18
diff changeset
   479
	
57
hgs
parents: 55
diff changeset
   480
	OstTraceFunctionExit0( CLOCKMAINVIEW_HANDLELONGPRESS_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   481
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   482
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   483
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   484
	This slot handles the deletion of the alarm from the server.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   485
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   486
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   487
void ClockMainView::deleteAlarm()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   488
{
57
hgs
parents: 55
diff changeset
   489
	OstTraceFunctionEntry0( CLOCKMAINVIEW_DELETEALARM_ENTRY );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   490
	if (-1 < mSelectedItem) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   491
		// Get the data for the alarm.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   492
		QList<QVariant> alarmData = mAlarmListModel->sourceModel()->
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   493
				index(mSelectedItem, 0).data(AlarmDetails).toList();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   494
		int alarmId = alarmData.at(0).value<int>();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   495
		mAlarmClient->deleteAlarm(alarmId);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   496
		mSelectedItem = -1;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   497
	}
57
hgs
parents: 55
diff changeset
   498
	OstTraceFunctionExit0( CLOCKMAINVIEW_DELETEALARM_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   499
}
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: 18
diff changeset
   502
	Deltes the snoozed alarm.
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   503
 */
45
hgs
parents: 18
diff changeset
   504
void ClockMainView::removeSnoozedAlarm()
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   505
{
57
hgs
parents: 55
diff changeset
   506
	OstTraceFunctionEntry0( CLOCKMAINVIEW_REMOVESNOOZEDALARM_ENTRY );
45
hgs
parents: 18
diff changeset
   507
	if (-1 < mSelectedItem) {
hgs
parents: 18
diff changeset
   508
		// Get the data for the alarm.
hgs
parents: 18
diff changeset
   509
		QList<QVariant> alarmData = mAlarmListModel->sourceModel()->
hgs
parents: 18
diff changeset
   510
		index(mSelectedItem, 0).data(AlarmDetails).toList();
hgs
parents: 18
diff changeset
   511
		int alarmId = alarmData.at(0).value<int>();
hgs
parents: 18
diff changeset
   512
		mAlarmClient->deleteSnoozedAlarm(alarmId);
hgs
parents: 18
diff changeset
   513
		mSelectedItem = -1;
hgs
parents: 18
diff changeset
   514
	}
57
hgs
parents: 55
diff changeset
   515
	OstTraceFunctionExit0( CLOCKMAINVIEW_REMOVESNOOZEDALARM_EXIT );
45
hgs
parents: 18
diff changeset
   516
}
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
75
hgs
parents: 70
diff changeset
   518
/*!
hgs
parents: 70
diff changeset
   519
	Slot which is called when the value changes in cenrep.
hgs
parents: 70
diff changeset
   520
hgs
parents: 70
diff changeset
   521
	\param key The key which got changed in cenrep.
hgs
parents: 70
diff changeset
   522
	\param value The new value of that key.
hgs
parents: 70
diff changeset
   523
 */
hgs
parents: 70
diff changeset
   524
void ClockMainView::eventMonitor(
hgs
parents: 70
diff changeset
   525
		const XQSettingsKey& key, const QVariant& value)
hgs
parents: 70
diff changeset
   526
{
hgs
parents: 70
diff changeset
   527
	OstTraceFunctionEntry0( CLOCKMAINVIEW_EVENTMONITOR_ENTRY );
hgs
parents: 70
diff changeset
   528
	if (key.uid() == KCRUidClockApp && key.key() == KClockType) {
hgs
parents: 70
diff changeset
   529
		// Update view
hgs
parents: 70
diff changeset
   530
		updateView();
hgs
parents: 70
diff changeset
   531
	}
hgs
parents: 70
diff changeset
   532
	OstTraceFunctionExit0( CLOCKMAINVIEW_EVENTMONITOR_EXIT );
hgs
parents: 70
diff changeset
   533
}
hgs
parents: 70
diff changeset
   534
hgs
parents: 70
diff changeset
   535
45
hgs
parents: 18
diff changeset
   536
void ClockMainView::updateView()
hgs
parents: 18
diff changeset
   537
{
57
hgs
parents: 55
diff changeset
   538
	OstTraceFunctionEntry0( CLOCKMAINVIEW_UPDATEVIEW_ENTRY );
45
hgs
parents: 18
diff changeset
   539
	// Update the place label.
hgs
parents: 18
diff changeset
   540
	updatePlaceLabel(mTimezoneClient->timeUpdateOn());
hgs
parents: 18
diff changeset
   541
	// Update date label.
hgs
parents: 18
diff changeset
   542
	updateDateLabel();
hgs
parents: 18
diff changeset
   543
	// Update clock widget.
hgs
parents: 18
diff changeset
   544
	updateClockWidget();
57
hgs
parents: 55
diff changeset
   545
	OstTraceFunctionExit0( CLOCKMAINVIEW_UPDATEVIEW_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   546
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   547
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   548
/*!
45
hgs
parents: 18
diff changeset
   549
	Slot which gets called for value change in auto time update in cenrep.
hgs
parents: 18
diff changeset
   550
hgs
parents: 18
diff changeset
   551
	\param autoTimeUpdate Value of auto time update.
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   552
 */
45
hgs
parents: 18
diff changeset
   553
void ClockMainView::updatePlaceLabel(int autoTimeUpdate)
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   554
{
57
hgs
parents: 55
diff changeset
   555
	OstTraceFunctionEntry0( CLOCKMAINVIEW_UPDATEPLACELABEL_ENTRY );
45
hgs
parents: 18
diff changeset
   556
	if (-1 == autoTimeUpdate) {
hgs
parents: 18
diff changeset
   557
		autoTimeUpdate = mTimezoneClient->timeUpdateOn();
hgs
parents: 18
diff changeset
   558
	}
hgs
parents: 18
diff changeset
   559
	
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   560
	// Get the current zone info.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   561
	LocationInfo currentZoneInfo = mTimezoneClient->getCurrentZoneInfoL();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   562
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   563
	// Construct the GMT +/- X string.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   564
	QString gmtOffset;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   565
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   566
	int utcOffset = currentZoneInfo.zoneOffset;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   567
	int offsetInHours (utcOffset/60);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   568
	int offsetInMinutes (utcOffset%60);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   569
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   570
	// Check wether the offset is +ve or -ve.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   571
	if (0 < utcOffset) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   572
		// We have a positive offset. Append the '+' character.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   573
		gmtOffset += tr(" +");
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   574
	} else if (0 > utcOffset) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   575
		// We have a negative offset. Append the '-' character.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   576
		gmtOffset += tr(" -");
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   577
		offsetInHours = -offsetInHours;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   578
	} else {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   579
		// We dont have an offset. We are at GMT zone.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   580
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   581
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   582
	// Append the hour component.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   583
	gmtOffset += QString::number(offsetInHours);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   584
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   585
	// Get the time separator from settings and append it.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   586
	QStringList timeSeparatorList;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   587
	int index = mSettingsUtility->timeSeparator(timeSeparatorList);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   588
	gmtOffset += timeSeparatorList.at(index);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   589
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   590
	// Append the minute component.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   591
	// If minute component is less less than 10, append a '00'
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   592
	if (0 <= offsetInMinutes && offsetInMinutes < 10) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   593
		gmtOffset += tr("00");
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   594
	} else {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   595
		gmtOffset += QString::number(offsetInMinutes);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   596
	}
45
hgs
parents: 18
diff changeset
   597
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   598
	// Append space.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   599
	gmtOffset += tr(" ");
45
hgs
parents: 18
diff changeset
   600
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   601
	// Append GMT sting.
55
hgs
parents: 45
diff changeset
   602
	gmtOffset += hbTrId("txt_clock_main_view_setlabel_gmt");
45
hgs
parents: 18
diff changeset
   603
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   604
	// Append space.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   605
	gmtOffset += tr(" ");
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   606
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   607
	// Append DST info.
57
hgs
parents: 55
diff changeset
   608
	HbIcon *dstIcon = new HbIcon("");
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   609
	if (currentZoneInfo.dstOn) {
57
hgs
parents: 55
diff changeset
   610
		dstIcon->setIconName("qtg_mono_day_light_saving_time");
hgs
parents: 55
diff changeset
   611
		dstIcon->setColor(mLabelColorGroup);
hgs
parents: 55
diff changeset
   612
		
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   613
	}
57
hgs
parents: 55
diff changeset
   614
	mDstIcon->setIcon(*dstIcon);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   615
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   616
	// Update the labels with the correct info.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   617
	mPlaceLabel->clear();
45
hgs
parents: 18
diff changeset
   618
	if(autoTimeUpdate) {
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   619
		mPlaceLabel->setPlainText(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   620
				currentZoneInfo.countryName + tr(" ") + gmtOffset);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   621
	} else {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   622
		mPlaceLabel->setPlainText(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   623
				currentZoneInfo.cityName + tr(", ")
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   624
				+ currentZoneInfo.countryName + tr(" ") + gmtOffset);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   625
	}
57
hgs
parents: 55
diff changeset
   626
	OstTraceFunctionExit0( CLOCKMAINVIEW_UPDATEPLACELABEL_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   627
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   628
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   629
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   630
	Slot to either hide or show the alarmlist.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   631
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   632
void ClockMainView::handleAlarmListDisplay()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   633
{
57
hgs
parents: 55
diff changeset
   634
    OstTraceFunctionEntry0( CLOCKMAINVIEW_HANDLEALARMLISTDISPLAY_ENTRY );
45
hgs
parents: 18
diff changeset
   635
    // alarmEditor closed reset the captured screenshot, current view is main view now
hgs
parents: 18
diff changeset
   636
    captureScreenShot(false);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   637
	// Get the list of pending clock alarms from server.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   638
	QList<AlarmInfo> alarmInfoList;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   639
	QList<AlarmInfo> displayInfoList;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   640
	AlarmInfo alarmInfo;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   641
	mAlarmClient->getAlarmList(alarmInfoList);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   642
	for (int index = 0; index < alarmInfoList.count(); ++index) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   643
		alarmInfo = alarmInfoList[index];
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   644
		if (Notified == alarmInfo.alarmState) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   645
			continue;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   646
		}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   647
		displayInfoList.append(alarmInfo);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   648
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   649
	if (mHideAlarmList) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   650
		hideAlarmList(false);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   651
	} else {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   652
		if (0 == displayInfoList.count() &&
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   653
				0 == mAlarmListModel->sourceModel()->rowCount()) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   654
			hideAlarmList(true);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   655
		}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   656
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   657
57
hgs
parents: 55
diff changeset
   658
	OstTraceFunctionExit0( CLOCKMAINVIEW_HANDLEALARMLISTDISPLAY_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   659
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   660
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   661
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   662
	Slot to check the orientation & load the appropriate section.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   663
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   664
	\param orientation contains the current orientation of the window.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   665
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   666
void ClockMainView::checkOrientationAndLoadSection(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   667
		Qt::Orientation orientation)
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   668
{
57
hgs
parents: 55
diff changeset
   669
	OstTraceFunctionEntry0( CLOCKMAINVIEW_CHECKORIENTATIONANDLOADSECTION_ENTRY );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   670
	bool success;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   671
	// If horizontal, load the landscape section.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   672
	if (Qt::Horizontal == orientation) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   673
		mDocLoader->load(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   674
				CLOCK_MAIN_VIEW_DOCML, CLOCK_MAIN_VIEW_LANDSCAPE_SECTION,
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   675
				&success);
45
hgs
parents: 18
diff changeset
   676
		mHorizontalDivider->setVisible(false);
hgs
parents: 18
diff changeset
   677
		mVerticalDivider->setVisible(true);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   678
	} else {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   679
		mDocLoader->load(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   680
				CLOCK_MAIN_VIEW_DOCML, CLOCK_MAIN_VIEW_PORTRAIT_SECTION,
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   681
				&success);
45
hgs
parents: 18
diff changeset
   682
		mHorizontalDivider->setVisible(true);
hgs
parents: 18
diff changeset
   683
		mVerticalDivider->setVisible(false);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   684
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   685
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   686
	if(success) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   687
		QList<AlarmInfo> alarmInfoList;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   688
		// Get the list of all clock alarms.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   689
		mAlarmClient->getAlarmList(alarmInfoList);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   690
		if (0 == alarmInfoList.count()) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   691
			hideAlarmList(true);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   692
		} else {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   693
			hideAlarmList(false);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   694
		}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   695
	}
57
hgs
parents: 55
diff changeset
   696
	OstTraceFunctionExit0( CLOCKMAINVIEW_CHECKORIENTATIONANDLOADSECTION_EXIT );
45
hgs
parents: 18
diff changeset
   697
}
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   698
45
hgs
parents: 18
diff changeset
   699
/*!
hgs
parents: 18
diff changeset
   700
	Slot to handle context menu actions.
hgs
parents: 18
diff changeset
   701
 */
hgs
parents: 18
diff changeset
   702
void ClockMainView::selectedMenuAction(HbAction *action)
hgs
parents: 18
diff changeset
   703
{
57
hgs
parents: 55
diff changeset
   704
	OstTraceFunctionEntry0( CLOCKMAINVIEW_SELECTEDMENUACTION_ENTRY );
45
hgs
parents: 18
diff changeset
   705
	if (action == mDeleteAction) {
hgs
parents: 18
diff changeset
   706
		deleteAlarm();
hgs
parents: 18
diff changeset
   707
	}
57
hgs
parents: 55
diff changeset
   708
	OstTraceFunctionExit0( CLOCKMAINVIEW_SELECTEDMENUACTION_EXIT );
45
hgs
parents: 18
diff changeset
   709
}
hgs
parents: 18
diff changeset
   710
hgs
parents: 18
diff changeset
   711
/*!
hgs
parents: 18
diff changeset
   712
	Slot to handle the context menu closed.
hgs
parents: 18
diff changeset
   713
 */
hgs
parents: 18
diff changeset
   714
void ClockMainView::handleMenuClosed()
hgs
parents: 18
diff changeset
   715
{
57
hgs
parents: 55
diff changeset
   716
	OstTraceFunctionEntry0( CLOCKMAINVIEW_HANDLEMENUCLOSED_ENTRY );
45
hgs
parents: 18
diff changeset
   717
	mIsLongTop = false;
57
hgs
parents: 55
diff changeset
   718
	OstTraceFunctionExit0( CLOCKMAINVIEW_HANDLEMENUCLOSED_EXIT );
45
hgs
parents: 18
diff changeset
   719
}
hgs
parents: 18
diff changeset
   720
/*!
hgs
parents: 18
diff changeset
   721
	Sets the model to the alarm list.
hgs
parents: 18
diff changeset
   722
 */
hgs
parents: 18
diff changeset
   723
void ClockMainView::setmodel()
hgs
parents: 18
diff changeset
   724
{
57
hgs
parents: 55
diff changeset
   725
	OstTraceFunctionEntry0( CLOCKMAINVIEW_SETMODEL_ENTRY );
45
hgs
parents: 18
diff changeset
   726
	// Set the model.
hgs
parents: 18
diff changeset
   727
	if (mAlarmList) {
hgs
parents: 18
diff changeset
   728
		mAlarmList->setModel(mAlarmListModel->sourceModel());
hgs
parents: 18
diff changeset
   729
		ClockAlarmListItemPrototype *listItemPrototype =
hgs
parents: 18
diff changeset
   730
				new ClockAlarmListItemPrototype();
hgs
parents: 18
diff changeset
   731
		connect(
hgs
parents: 18
diff changeset
   732
				listItemPrototype, SIGNAL(alarmStatusHasChanged(int)),
hgs
parents: 18
diff changeset
   733
				this, SLOT(handleAlarmStatusChanged(int)));
hgs
parents: 18
diff changeset
   734
		mAlarmList->setItemPrototype(listItemPrototype);
hgs
parents: 18
diff changeset
   735
		mAlarmList->setLayoutName("layout-alarmlist");
hgs
parents: 18
diff changeset
   736
	}
hgs
parents: 18
diff changeset
   737
57
hgs
parents: 55
diff changeset
   738
	OstTraceFunctionExit0( CLOCKMAINVIEW_SETMODEL_EXIT );
45
hgs
parents: 18
diff changeset
   739
}
hgs
parents: 18
diff changeset
   740
hgs
parents: 18
diff changeset
   741
/*!
hgs
parents: 18
diff changeset
   742
	Hides the alarmlist in the main view.
hgs
parents: 18
diff changeset
   743
hgs
parents: 18
diff changeset
   744
	\param hide 'true' if alarm list is to be hidden.
hgs
parents: 18
diff changeset
   745
 */
hgs
parents: 18
diff changeset
   746
void ClockMainView::hideAlarmList(bool hide)
hgs
parents: 18
diff changeset
   747
{
57
hgs
parents: 55
diff changeset
   748
	OstTraceFunctionEntry0( CLOCKMAINVIEW_HIDEALARMLIST_ENTRY );
45
hgs
parents: 18
diff changeset
   749
	if (hide) {
hgs
parents: 18
diff changeset
   750
		mNoAlarmLabel->show();
hgs
parents: 18
diff changeset
   751
		mAlarmList->hide();
hgs
parents: 18
diff changeset
   752
		mHideAlarmList = true;
hgs
parents: 18
diff changeset
   753
	} else {
hgs
parents: 18
diff changeset
   754
		mAlarmList->show();
hgs
parents: 18
diff changeset
   755
		mNoAlarmLabel->hide();
hgs
parents: 18
diff changeset
   756
		mHideAlarmList = false;
hgs
parents: 18
diff changeset
   757
	}
57
hgs
parents: 55
diff changeset
   758
	OstTraceFunctionExit0( CLOCKMAINVIEW_HIDEALARMLIST_EXIT );
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   759
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   760
45
hgs
parents: 18
diff changeset
   761
/*!
hgs
parents: 18
diff changeset
   762
	Updates the day and date in the day label.
hgs
parents: 18
diff changeset
   763
 */
hgs
parents: 18
diff changeset
   764
void ClockMainView::updateDateLabel()
hgs
parents: 18
diff changeset
   765
{
57
hgs
parents: 55
diff changeset
   766
	OstTraceFunctionEntry0( CLOCKMAINVIEW_UPDATEDATELABEL_ENTRY );
45
hgs
parents: 18
diff changeset
   767
	// Get the current datetime.
hgs
parents: 18
diff changeset
   768
	QDateTime dateTime = QDateTime::currentDateTime();
hgs
parents: 18
diff changeset
   769
	// Get the day name.
hgs
parents: 18
diff changeset
   770
	QString dayName = dateTime.toString("ddd");
hgs
parents: 18
diff changeset
   771
	// Get the date in correct format.
hgs
parents: 18
diff changeset
   772
	QString currentDate = mSettingsUtility->date();
hgs
parents: 18
diff changeset
   773
	// Construct the day + date string.
hgs
parents: 18
diff changeset
   774
	QString dayDateString;
hgs
parents: 18
diff changeset
   775
	dayDateString+= dayName;
hgs
parents: 18
diff changeset
   776
	dayDateString += " ";
hgs
parents: 18
diff changeset
   777
	dayDateString += currentDate;
hgs
parents: 18
diff changeset
   778
hgs
parents: 18
diff changeset
   779
	mDayLabel->setPlainText(dayDateString);
57
hgs
parents: 55
diff changeset
   780
	OstTraceFunctionExit0( CLOCKMAINVIEW_UPDATEDATELABEL_EXIT );
45
hgs
parents: 18
diff changeset
   781
}
hgs
parents: 18
diff changeset
   782
hgs
parents: 18
diff changeset
   783
/*!
hgs
parents: 18
diff changeset
   784
	Updates the zone info in the place label.
hgs
parents: 18
diff changeset
   785
 */
hgs
parents: 18
diff changeset
   786
/*void ClockMainView::updatePlaceLabel()
hgs
parents: 18
diff changeset
   787
{
hgs
parents: 18
diff changeset
   788
	updatePlaceLabel(mTimezoneClient->timeUpdateOn());
hgs
parents: 18
diff changeset
   789
}*/
hgs
parents: 18
diff changeset
   790
hgs
parents: 18
diff changeset
   791
/*!
hgs
parents: 18
diff changeset
   792
	Updates the clock widget display.
hgs
parents: 18
diff changeset
   793
 */
hgs
parents: 18
diff changeset
   794
void ClockMainView::updateClockWidget()
hgs
parents: 18
diff changeset
   795
{
57
hgs
parents: 55
diff changeset
   796
	OstTraceFunctionEntry0( CLOCKMAINVIEW_UPDATECLOCKWIDGET_ENTRY );
45
hgs
parents: 18
diff changeset
   797
	QStringList clockType;
hgs
parents: 18
diff changeset
   798
    int index = mSettingsUtility->clockType(clockType);
hgs
parents: 18
diff changeset
   799
    int zeroIndex(0);
hgs
parents: 18
diff changeset
   800
    if(zeroIndex == index){
75
hgs
parents: 70
diff changeset
   801
    	mClockWidget->setClockType(ClockWidget::ClockTypeAnalog);
45
hgs
parents: 18
diff changeset
   802
    } else {
75
hgs
parents: 70
diff changeset
   803
    	mClockWidget->setClockType(ClockWidget::ClockTypeDigital);
45
hgs
parents: 18
diff changeset
   804
    }
hgs
parents: 18
diff changeset
   805
    
hgs
parents: 18
diff changeset
   806
    QStringList timeFormat;
hgs
parents: 18
diff changeset
   807
hgs
parents: 18
diff changeset
   808
    if (zeroIndex == mSettingsUtility->timeFormat(timeFormat)) {
hgs
parents: 18
diff changeset
   809
    	mClockWidget->setTimeFormat(ClockWidget::TimeFormat24Hrs);
hgs
parents: 18
diff changeset
   810
    } else {
hgs
parents: 18
diff changeset
   811
    	mClockWidget->setTimeFormat(ClockWidget::TimeFormat12Hrs);
hgs
parents: 18
diff changeset
   812
    }
hgs
parents: 18
diff changeset
   813
hgs
parents: 18
diff changeset
   814
	mClockWidget->updateTime();
57
hgs
parents: 55
diff changeset
   815
	OstTraceFunctionExit0( CLOCKMAINVIEW_UPDATECLOCKWIDGET_EXIT );
45
hgs
parents: 18
diff changeset
   816
}
hgs
parents: 18
diff changeset
   817
hgs
parents: 18
diff changeset
   818
/*!
hgs
parents: 18
diff changeset
   819
	CaptureScreenShot captures screen shot 
hgs
parents: 18
diff changeset
   820
	\param captureScreenShot bool to indicate if screenshot needs to be captured
hgs
parents: 18
diff changeset
   821
*/ 
hgs
parents: 18
diff changeset
   822
void ClockMainView::captureScreenShot(bool captureScreenShot)
hgs
parents: 18
diff changeset
   823
{
57
hgs
parents: 55
diff changeset
   824
	OstTraceFunctionEntry0( CLOCKMAINVIEW_CAPTURESCREENSHOT_ENTRY );
45
hgs
parents: 18
diff changeset
   825
	// check if screen shot needs to be captured
hgs
parents: 18
diff changeset
   826
    if (captureScreenShot) {
hgs
parents: 18
diff changeset
   827
        mScreenShot.clear();
hgs
parents: 18
diff changeset
   828
        mScreenShot.insert("screenshot", QPixmap::grabWidget(mainWindow(), mainWindow()->rect()));
hgs
parents: 18
diff changeset
   829
    }
hgs
parents: 18
diff changeset
   830
    mIsScreenShotCapruted = captureScreenShot; // set mIsScreenShotCapruted set validity of screenshot
57
hgs
parents: 55
diff changeset
   831
    OstTraceFunctionExit0( CLOCKMAINVIEW_CAPTURESCREENSHOT_EXIT );
45
hgs
parents: 18
diff changeset
   832
}
hgs
parents: 18
diff changeset
   833
hgs
parents: 18
diff changeset
   834
/*!    
hgs
parents: 18
diff changeset
   835
	saveActivity saves main view as an activity 
hgs
parents: 18
diff changeset
   836
*/ 
hgs
parents: 18
diff changeset
   837
void ClockMainView::saveActivity()
hgs
parents: 18
diff changeset
   838
{
57
hgs
parents: 55
diff changeset
   839
   OstTraceFunctionEntry0( CLOCKMAINVIEW_SAVEACTIVITY_ENTRY );
45
hgs
parents: 18
diff changeset
   840
   // Get a pointer to activity Manager
hgs
parents: 18
diff changeset
   841
   HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();
hgs
parents: 18
diff changeset
   842
 	// check if a valid screenshot is already captured
hgs
parents: 18
diff changeset
   843
   if (!mIsScreenShotCapruted)  {
hgs
parents: 18
diff changeset
   844
       mScreenShot.clear();
hgs
parents: 18
diff changeset
   845
       mScreenShot.insert("screenshot", QPixmap::grabWidget(mainWindow(), mainWindow()->rect()));
hgs
parents: 18
diff changeset
   846
   }
hgs
parents: 18
diff changeset
   847
 
hgs
parents: 18
diff changeset
   848
   // save any data necessary to save the state
hgs
parents: 18
diff changeset
   849
   QByteArray serializedActivity;
hgs
parents: 18
diff changeset
   850
   QDataStream stream(&serializedActivity, QIODevice::WriteOnly | QIODevice::Append);
hgs
parents: 18
diff changeset
   851
   stream << MainView;
hgs
parents: 18
diff changeset
   852
 
hgs
parents: 18
diff changeset
   853
   // add the activity to the activity manager
hgs
parents: 18
diff changeset
   854
   bool ok = activityManager->addActivity(clockMainView, serializedActivity, mScreenShot);
hgs
parents: 18
diff changeset
   855
   if ( !ok ) {
hgs
parents: 18
diff changeset
   856
       qFatal("Add failed" );
hgs
parents: 18
diff changeset
   857
   }
57
hgs
parents: 55
diff changeset
   858
   OstTraceFunctionExit0( CLOCKMAINVIEW_SAVEACTIVITY_EXIT );
45
hgs
parents: 18
diff changeset
   859
}
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   860
// End of file	--Don't remove.