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