|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Definition file for class DateTimeSettingsView. |
|
16 * |
|
17 */ |
|
18 |
|
19 // System includes |
|
20 #include <QTimer> |
|
21 #include <QDateTime> |
|
22 #include <HbExtendedLocale> |
|
23 #include <cpitemdatahelper.h> |
|
24 |
|
25 // User includes |
|
26 #include "datetimesettingsview.h" |
|
27 #include "clocksettingsview.h" |
|
28 #include "timezoneclient.h" |
|
29 #include "OstTraceDefinitions.h" |
|
30 #ifdef OST_TRACE_COMPILER_IN_USE |
|
31 #include "datetimesettingsviewTraces.h" |
|
32 #endif |
|
33 |
|
34 |
|
35 /*! |
|
36 \class DateTimeSettingsView |
|
37 |
|
38 This class launches the clock settings view from control panel. |
|
39 */ |
|
40 |
|
41 /*! |
|
42 Constructor. |
|
43 |
|
44 \param itemDataHelper CpItemDataHelper object. |
|
45 \param text text to be displayed in first line. |
|
46 \param description test to be displayed in second line. |
|
47 \param icon to be displayed. |
|
48 \param parent Parent of type HbDataFormModelItem |
|
49 */ |
|
50 DateTimeSettingsView::DateTimeSettingsView( |
|
51 CpItemDataHelper &itemDataHelper, const QString &text, |
|
52 const QString &description, const HbIcon &icon, |
|
53 const HbDataFormModelItem *parent, HbTranslator *translator): |
|
54 CpSettingFormEntryItemData( |
|
55 itemDataHelper, text, description, icon, parent) |
|
56 { |
|
57 OstTraceFunctionEntry0( DATETIMESETTINGSVIEW_DATETIMESETTINGSVIEW_ENTRY ); |
|
58 // Construct the timezone client. |
|
59 mTranslator = translator; |
|
60 mTimezoneClient = TimezoneClient::getInstance(); |
|
61 connect( |
|
62 mTimezoneClient, SIGNAL(timechanged()), |
|
63 this, SLOT(updateDisplayTime())); |
|
64 |
|
65 // Start a timer. For updating the displayed time. |
|
66 mTickTimer = new QTimer(this); |
|
67 // Start the Timer for 1 minute. |
|
68 mTickTimer->start(60000 - 1000 * QTime::currentTime().second()); |
|
69 connect( |
|
70 mTickTimer, SIGNAL(timeout()), |
|
71 this, SLOT(updateDisplayTime())); |
|
72 OstTraceFunctionExit0( DATETIMESETTINGSVIEW_DATETIMESETTINGSVIEW_EXIT ); |
|
73 } |
|
74 |
|
75 /*! |
|
76 Destructor. |
|
77 */ |
|
78 DateTimeSettingsView::~DateTimeSettingsView() |
|
79 { |
|
80 OstTraceFunctionEntry0( DUP1_DATETIMESETTINGSVIEW_DATETIMESETTINGSVIEW_ENTRY ); |
|
81 if (mTickTimer) { |
|
82 mTickTimer->stop(); |
|
83 delete mTickTimer; |
|
84 mTickTimer = 0; |
|
85 } |
|
86 |
|
87 if (!mTimezoneClient->isNull()) { |
|
88 mTimezoneClient->deleteInstance(); |
|
89 } |
|
90 OstTraceFunctionExit0( DUP1_DATETIMESETTINGSVIEW_DATETIMESETTINGSVIEW_EXIT ); |
|
91 } |
|
92 |
|
93 /*! |
|
94 Launches the clock settings view. |
|
95 */ |
|
96 void DateTimeSettingsView::onLaunchView() |
|
97 { |
|
98 OstTraceFunctionEntry0( DATETIMESETTINGSVIEW_ONLAUNCHVIEW_ENTRY ); |
|
99 ClockSettingsView *settingsView = new ClockSettingsView(this, mTranslator, false); |
|
100 settingsView->loadSettingsView(); |
|
101 OstTraceFunctionExit0( DATETIMESETTINGSVIEW_ONLAUNCHVIEW_EXIT ); |
|
102 } |
|
103 |
|
104 /*! |
|
105 Updates the second line i.e date & time. |
|
106 */ |
|
107 void DateTimeSettingsView::updateDisplayTime() |
|
108 { |
|
109 OstTraceFunctionEntry0( DATETIMESETTINGSVIEW_UPDATEDISPLAYTIME_ENTRY ); |
|
110 HbExtendedLocale locale = HbExtendedLocale::system(); |
|
111 QString timeInfo = locale.format( |
|
112 QTime::currentTime(), r_qtn_time_usual_with_zero); |
|
113 QString dateinfo = locale.format( |
|
114 QDate::currentDate(), r_qtn_date_usual_with_zero); |
|
115 QString displayString; |
|
116 displayString.append(timeInfo); |
|
117 displayString.append(" "); |
|
118 displayString.append(dateinfo); |
|
119 setDescription(displayString); |
|
120 // Start the Timer for 1 minute. |
|
121 mTickTimer->start(60000); |
|
122 OstTraceFunctionExit0( DATETIMESETTINGSVIEW_UPDATEDISPLAYTIME_EXIT ); |
|
123 } |
|
124 |
|
125 /*! |
|
126 createSettingView() |
|
127 */ |
|
128 CpBaseSettingView *DateTimeSettingsView::createSettingView() const |
|
129 { |
|
130 OstTraceFunctionEntry0( DATETIMESETTINGSVIEW_CREATESETTINGVIEW_ENTRY ); |
|
131 OstTraceFunctionExit0( DATETIMESETTINGSVIEW_CREATESETTINGVIEW_EXIT ); |
|
132 return 0; |
|
133 } |
|
134 |
|
135 // End of file --Don't remove this |