author | hgs |
Wed, 25 Aug 2010 14:02:13 +0530 | |
changeset 63 | a3cb48f6c889 |
parent 57 | bb2d3e476f29 |
child 64 | 1881ad52dc45 |
permissions | -rw-r--r-- |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
fd30d51f876b
Revision: 201015
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". |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* Description: |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* Definition of CalenEditorReminderField class. |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
* |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
*/ |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
// System Includes |
45 | 21 |
#include <QDate> |
22 |
||
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
#include <hbdataformmodelitem.h> |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
24 |
#include <hbdataformmodel.h> |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
25 |
#include <hbdataform.h> |
45 | 26 |
#include <hbdatetimepicker.h> |
27 |
#include <hbextendedlocale.h> |
|
28 |
#include <hbi18ndef.h> |
|
29 |
#include <hbdialog.h> |
|
30 |
#include <hblabel.h> |
|
31 |
#include <hbaction.h> |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
32 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
33 |
// User Includes |
57 | 34 |
#include "calenagendautils.h" |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
35 |
#include "caleneditorreminderfield.h" |
51 | 36 |
#include "OstTraceDefinitions.h" |
37 |
#ifdef OST_TRACE_COMPILER_IN_USE |
|
38 |
#include "caleneditorreminderfieldTraces.h" |
|
39 |
#endif |
|
40 |
||
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
41 |
|
45 | 42 |
#define numberOfMinutesInADay 1440 |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
43 |
/*! |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
44 |
\class CalenEditorReminderField |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
45 |
*/ |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
46 |
/*! |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
47 |
Constructor. |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
48 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
49 |
\param parent QObject pointer |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
50 |
*/ |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
51 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
52 |
CalenEditorReminderField::CalenEditorReminderField( |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
53 |
CalenEditorPrivate* calenEditor, |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
54 |
HbDataForm* form, |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
55 |
HbDataFormModel* model, |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
56 |
QObject *parent) |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
57 |
:QObject(parent), |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
58 |
mCalenEditor(calenEditor), |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
59 |
mEditorForm(form), |
45 | 60 |
mCalenEditorModel(model), |
55 | 61 |
mCustomReminderTimeItem(0), |
45 | 62 |
mReminderTimeAdded(false) |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
63 |
{ |
51 | 64 |
OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_CALENEDITORREMINDERFIELD_ENTRY ); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
65 |
mReminderItem = new HbDataFormModelItem(); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
66 |
mReminderItem->setType(HbDataFormModelItem::ComboBoxItem); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
67 |
mReminderItem->setData(HbDataFormModelItem::LabelRole, |
45 | 68 |
hbTrId("txt_calendar_setlabel_reminder")); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
69 |
// Add it to the model |
45 | 70 |
mCalenEditorModel->appendDataFormItem(mReminderItem, |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
71 |
mCalenEditorModel->invisibleRootItem()); |
51 | 72 |
OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_CALENEDITORREMINDERFIELD_EXIT ); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
73 |
} |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
74 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
75 |
/*! |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
76 |
Destructor |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
77 |
*/ |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
78 |
CalenEditorReminderField::~CalenEditorReminderField() |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
79 |
{ |
51 | 80 |
OstTraceFunctionEntry0( DUP1_CALENEDITORREMINDERFIELD_CALENEDITORREMINDERFIELD_ENTRY ); |
45 | 81 |
if(mReminderHash.count()) { |
82 |
mReminderHash.clear(); |
|
83 |
} |
|
51 | 84 |
OstTraceFunctionExit0( DUP1_CALENEDITORREMINDERFIELD_CALENEDITORREMINDERFIELD_EXIT ); |
45 | 85 |
} |
86 |
||
87 |
/*! |
|
88 |
Set the reminder choices. |
|
89 |
*/ |
|
90 |
void CalenEditorReminderField::setReminderChoices() |
|
91 |
{ |
|
51 | 92 |
OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_SETREMINDERCHOICES_ENTRY ); |
45 | 93 |
// Create the reminder choices |
94 |
QStringList reminderChoices; |
|
95 |
reminderChoices << hbTrId("txt_calendar_setlabel_reminder_val_off") |
|
96 |
<< hbTrId("txt_calendar_setlabel_reminder_val_at_the_start") |
|
97 |
<< hbTrId("txt_calendar_setlabel_reminder_val_15_minutes_befo") |
|
98 |
<< hbTrId("txt_calendar_setlabel_reminder_val_30_minutes_befo") |
|
99 |
<< hbTrId("txt_calendar_setlabel_reminder_val_1_hour_before"); |
|
100 |
||
51 | 101 |
mReminderItem->setContentWidgetData("items", reminderChoices); |
102 |
mReminderItem->setContentWidgetData("objectName", "remainderItem"); |
|
45 | 103 |
|
104 |
// Build the hash map for the reminder. |
|
105 |
mReminderHash[0] = -1; // OFF. |
|
106 |
mReminderHash[1] = 0; |
|
107 |
mReminderHash[2] = 15; |
|
108 |
mReminderHash[3] = 30; |
|
109 |
mReminderHash[4] = 60; |
|
110 |
mReminderItem->setEnabled(true); |
|
51 | 111 |
OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_SETREMINDERCHOICES_EXIT ); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
112 |
} |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
113 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
114 |
/*! |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
115 |
Adds reminder item to the model |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
116 |
*/ |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
117 |
void CalenEditorReminderField::addItemToModel() |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
118 |
{ |
51 | 119 |
OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_ADDITEMTOMODEL_ENTRY ); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
120 |
// Add reminder to the model |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
121 |
mCalenEditorModel->appendDataFormItem( mReminderItem, |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
122 |
mCalenEditorModel->invisibleRootItem()); |
51 | 123 |
OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_ADDITEMTOMODEL_EXIT ); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
124 |
} |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
125 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
126 |
/*! |
45 | 127 |
Removes reminder item from the model |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
128 |
*/ |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
129 |
void CalenEditorReminderField::removeItemFromModel() |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
130 |
{ |
51 | 131 |
OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_REMOVEITEMFROMMODEL_ENTRY ); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
132 |
mCalenEditorModel->removeItem(modelIndex()); |
51 | 133 |
OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_REMOVEITEMFROMMODEL_EXIT ); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
134 |
} |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
135 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
136 |
/*! |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
137 |
Populates reminder item with available choices to the user |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
138 |
\param newEntry bool value to indicate if its a new entry |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
139 |
*/ |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
140 |
void CalenEditorReminderField::populateReminderItem(bool newEntry) |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
141 |
{ |
51 | 142 |
OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_POPULATEREMINDERITEM_ENTRY ); |
45 | 143 |
AgendaAlarm reminder; |
144 |
bool pastEvent = false; |
|
145 |
||
146 |
// Set reference date to start date or repeat until date accordingly to |
|
147 |
// decide whether its a past event or not. |
|
148 |
QDate referenceDate; |
|
149 |
if (!mCalenEditor->editedEntry()->isRepeating() || |
|
150 |
(mCalenEditor->isEditRangeThisOnly())) { |
|
151 |
referenceDate = mCalenEditor->editedEntry()->startTime().date(); |
|
152 |
} else { |
|
153 |
referenceDate = mCalenEditor->editedEntry()->repeatRule().until().date(); |
|
154 |
} |
|
155 |
||
156 |
if ((referenceDate < QDate::currentDate()) || |
|
157 |
(referenceDate == QDate::currentDate() |
|
158 |
&& (mCalenEditor->editedEntry()->startTime().time() < |
|
159 |
QTime::currentTime()))) { |
|
160 |
pastEvent = true; |
|
161 |
} |
|
162 |
||
163 |
if (mCalenEditor->isAllDayEvent()) { |
|
164 |
updateReminderChoicesForAllDay(referenceDate); |
|
165 |
} else { |
|
166 |
setReminderChoices(); |
|
167 |
} |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
168 |
// Set the default reminder value to 15 minutes |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
169 |
if (newEntry) { |
45 | 170 |
if (!pastEvent) { |
171 |
mReminderItem->setContentWidgetData("currentIndex", 2); |
|
172 |
// Save the reminder alarm for the entry |
|
173 |
reminder.setTimeOffset(mReminderHash.value(2)); |
|
174 |
reminder.setAlarmSoundName(QString(" ")); |
|
175 |
// Set the reminder to the entry as well as original entry. |
|
176 |
mCalenEditor->editedEntry()->setAlarm(reminder); |
|
177 |
mCalenEditor->originalEntry()->setAlarm(reminder); |
|
178 |
} else { |
|
179 |
mReminderItem->setContentWidgetData("currentIndex", 0); |
|
180 |
mReminderItem->setEnabled(false); |
|
181 |
} |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
182 |
} else { |
45 | 183 |
// If the alarm is not null, |
184 |
// Check if all day event or not and then set the choices accordingly. |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
185 |
if (mCalenEditor->editedEntry()->alarm().isNull()) { |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
186 |
// Alarm is set off |
57 | 187 |
mReminderItem->setContentWidgetData("currentIndex", ReminderOff); |
45 | 188 |
if(mReminderTimeAdded) { |
189 |
removeReminderTimeField(); |
|
190 |
} |
|
57 | 191 |
} else if (!mCalenEditor->isAllDayEvent()) { |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
192 |
// Get the reminder offset value. |
45 | 193 |
int reminderOffset = |
194 |
mCalenEditor->editedEntry()->alarm().timeOffset(); |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
195 |
// Get the index value for the reminder combo box from the hash |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
196 |
// table. |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
197 |
int index = mReminderHash.key(reminderOffset); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
198 |
mReminderItem->setContentWidgetData("currentIndex", index); |
45 | 199 |
} else { |
200 |
// Insert reminder time field and display entry's reminder time. |
|
201 |
// If past then disable the field. |
|
202 |
if (!mReminderTimeAdded) { |
|
203 |
insertReminderTimeField(); |
|
57 | 204 |
} |
205 |
if (pastEvent && mReminderTimeAdded) { |
|
206 |
mCustomReminderTimeItem->setEnabled(false); |
|
45 | 207 |
} |
208 |
QTime referenceTime(0, 0, 0); |
|
209 |
// Set the appropriate reminder depending on the value of time offset. |
|
210 |
reminder = mCalenEditor->editedEntry()->alarm(); |
|
211 |
int offsetInMins = reminder.timeOffset(); |
|
212 |
if (offsetInMins < 0 || offsetInMins == 0) { |
|
57 | 213 |
mReminderItem->setContentWidgetData("currentIndex", ReminderOnEventDay); |
45 | 214 |
mReminderTimeForAllDay = referenceTime.addSecs(-(offsetInMins |
215 |
* 60)); |
|
63 | 216 |
} else if (offsetInMins <= numberOfMinutesInADay) { |
57 | 217 |
mReminderItem->setContentWidgetData("currentIndex", ReminderOneDayBefore); |
45 | 218 |
mReminderTimeForAllDay = referenceTime.addSecs(-(offsetInMins |
219 |
* 60)); |
|
220 |
} else { |
|
57 | 221 |
mReminderItem->setContentWidgetData("currentIndex", ReminderTwoDaysBefore); |
45 | 222 |
offsetInMins %= (24 * 60); |
223 |
mReminderTimeForAllDay = referenceTime.addSecs(-(offsetInMins |
|
224 |
* 60)); |
|
225 |
} |
|
226 |
setDisplayTime(); |
|
227 |
} |
|
228 |
if (pastEvent) { |
|
229 |
mReminderItem->setEnabled(false); |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
230 |
} |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
231 |
} |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
232 |
mEditorForm->addConnection(mReminderItem, |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
233 |
SIGNAL(currentIndexChanged(int)), this, |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
234 |
SLOT(handleReminderIndexChanged(int))); |
51 | 235 |
OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_POPULATEREMINDERITEM_EXIT ); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
236 |
} |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
237 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
238 |
/*! |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
239 |
Triggerd from tapping on reminder item. |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
240 |
Handles the reminder time change and updates the same in the event. |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
241 |
\param index The new index chosen in the reminder list. |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
242 |
*/ |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
243 |
void CalenEditorReminderField::handleReminderIndexChanged(int index) |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
244 |
{ |
51 | 245 |
OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_HANDLEREMINDERINDEXCHANGED_ENTRY ); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
246 |
AgendaAlarm reminder; |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
247 |
if (!mCalenEditor->editedEntry()->alarm().isNull()) { |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
248 |
reminder = mCalenEditor->editedEntry()->alarm(); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
249 |
} |
45 | 250 |
// Check whether all day event or not and store appropriately. |
251 |
if (!mCalenEditor->isAllDayEvent()) { |
|
252 |
// If value for the index in hash table is -1 i.e reminder is "OFF", |
|
253 |
// then set the default constructed reminder to |
|
254 |
// the entry which is Null. |
|
255 |
if (mReminderHash.value(index) < 0) { |
|
256 |
// Construct the default alarm which is NULL |
|
257 |
reminder = AgendaAlarm(); |
|
258 |
} else { |
|
259 |
// If not zero then set the reminder offset |
|
260 |
// value to the entry. |
|
261 |
reminder.setTimeOffset(mReminderHash.value(index)); |
|
262 |
reminder.setAlarmSoundName(QString(" ")); |
|
263 |
} |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
264 |
} else { |
45 | 265 |
QDateTime reminderDateTimeForAllDay; |
266 |
QDateTime |
|
267 |
startDateTimeForAllDay( |
|
268 |
mCalenEditor->editedEntry()->startTime().date(), |
|
269 |
QTime(0, 0, 0)); |
|
57 | 270 |
if (mReminderItem->contentWidgetData("currentIndex") == ReminderOff) { |
45 | 271 |
reminder = AgendaAlarm(); |
57 | 272 |
removeReminderTimeField(); |
45 | 273 |
} else { |
274 |
int offset = 0; |
|
57 | 275 |
if (mReminderItem->contentWidgetData("currentIndex") == ReminderOneDayBefore) { |
45 | 276 |
offset = 1; |
57 | 277 |
} else if (mReminderItem->contentWidgetData("currentIndex") == ReminderTwoDaysBefore) { |
45 | 278 |
offset = 2; |
279 |
} |
|
280 |
if(!mReminderTimeAdded) { |
|
281 |
insertReminderTimeField() |
|
282 |
; } |
|
283 |
// If on same day as that of the event then check if time has been |
|
284 |
// changed , if changed retain that else set default time. |
|
285 |
if (offset == 0) { |
|
286 |
if(mReminderTimeForAllDay == QTime(18, 0, 0, 0)) { |
|
287 |
mReminderTimeForAllDay.setHMS(8, 0, 0); |
|
288 |
setDisplayTime(); |
|
289 |
} |
|
290 |
} |
|
291 |
reminderDateTimeForAllDay.setDate( |
|
292 |
mCalenEditor->editedEntry()->startTime().date().addDays( |
|
293 |
-offset)); |
|
294 |
reminderDateTimeForAllDay.setTime(mReminderTimeForAllDay); |
|
295 |
int seconds = |
|
296 |
reminderDateTimeForAllDay.secsTo(startDateTimeForAllDay); |
|
57 | 297 |
int timeOffset = seconds / 60; |
45 | 298 |
mCustomReminderTimeItem->setEnabled(true); |
57 | 299 |
reminder.setTimeOffset(timeOffset); |
45 | 300 |
reminder.setAlarmSoundName(QString(" ")); |
301 |
} |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
302 |
} |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
303 |
// Set the reminder to the entry. |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
304 |
mCalenEditor->editedEntry()->setAlarm(reminder); |
45 | 305 |
if(!mCalenEditor->isNewEntry()) { |
51 | 306 |
mCalenEditor->addDiscardAction(); |
45 | 307 |
} |
51 | 308 |
OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_HANDLEREMINDERINDEXCHANGED_EXIT ); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
309 |
} |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
310 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
311 |
/*! |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
312 |
Returns the mode index of the reminder item |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
313 |
\return Mode index of the reminder item |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
314 |
*/ |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
315 |
QModelIndex CalenEditorReminderField::modelIndex() |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
316 |
{ |
51 | 317 |
OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_MODELINDEX_ENTRY ); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
318 |
return mCalenEditorModel->indexFromItem(mReminderItem); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
319 |
} |
45 | 320 |
|
321 |
/*! |
|
322 |
Set reminder off. |
|
323 |
*/ |
|
324 |
void CalenEditorReminderField::setReminderOff() |
|
325 |
{ |
|
51 | 326 |
OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_SETREMINDEROFF_ENTRY ); |
45 | 327 |
// Create the remindar choices |
328 |
QStringList reminderChoices; |
|
329 |
reminderChoices << hbTrId("txt_calendar_setlabel_reminder_val_off"); |
|
330 |
mReminderItem->setContentWidgetData(QString("items"), reminderChoices); |
|
331 |
mReminderItem->setEnabled(false); |
|
51 | 332 |
OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_SETREMINDEROFF_EXIT ); |
45 | 333 |
} |
334 |
||
335 |
/*! |
|
336 |
Set the default alarm for a new all day event. |
|
337 |
*/ |
|
338 |
void CalenEditorReminderField::setDefaultAlarmForAllDay() |
|
339 |
{ |
|
51 | 340 |
OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_SETDEFAULTALARMFORALLDAY_ENTRY ); |
45 | 341 |
// Set default alarm if its a new entry. |
342 |
if (mCalenEditor->isNewEntry()) { |
|
343 |
AgendaAlarm reminder; |
|
344 |
QDate defaultDate |
|
345 |
(mCalenEditor->editedEntry()->startTime().date().addDays(-1)); |
|
55 | 346 |
// Set default time as 6pm of the previous day. |
45 | 347 |
mReminderTimeForAllDay.setHMS(18, 0, 0, 0); |
348 |
setDisplayTime(); |
|
349 |
QDateTime startDateTimeForAllDay( |
|
350 |
mCalenEditor->editedEntry()->startTime().date(), QTime(0, 0)); |
|
351 |
QDateTime defaultReminderDateTimeForAllDay |
|
352 |
(defaultDate, mReminderTimeForAllDay); |
|
353 |
int offsetInSecs = |
|
354 |
defaultReminderDateTimeForAllDay.secsTo(startDateTimeForAllDay); |
|
355 |
int offsetInMins = offsetInSecs/60; |
|
356 |
reminder.setTimeOffset(offsetInMins); |
|
357 |
reminder.setAlarmSoundName(QString(" ")); |
|
358 |
// Set the reminder to the entry as well as original entry. |
|
359 |
mCalenEditor->editedEntry()->setAlarm(reminder); |
|
360 |
mCalenEditor->originalEntry()->setAlarm(reminder); |
|
361 |
} |
|
51 | 362 |
OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_SETDEFAULTALARMFORALLDAY_EXIT ); |
45 | 363 |
} |
364 |
||
365 |
/*! |
|
366 |
Updates the reminder choices for an all day event. |
|
367 |
\param referenceDate to indicate past or not. |
|
368 |
*/ |
|
369 |
void CalenEditorReminderField::updateReminderChoicesForAllDay(QDate referenceDate) |
|
370 |
{ |
|
51 | 371 |
OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_UPDATEREMINDERCHOICESFORALLDAY_ENTRY ); |
45 | 372 |
if (!mReminderTimeAdded){ |
373 |
insertReminderTimeField(); |
|
374 |
} |
|
375 |
QStringList reminderChoicesForAllDay; |
|
376 |
QDate tomorrow = QDate::currentDate().addDays(1); |
|
377 |
QDate theDayAfterTomorrow = QDate::currentDate().addDays(2); |
|
378 |
||
57 | 379 |
// Get the previous index to retain if the alarm is valid |
380 |
QVariant countVariant = mReminderItem->contentWidgetData("currentIndex"); |
|
381 |
int previousIndex = countVariant.toInt(); |
|
382 |
AgendaAlarm previousAlarm = mCalenEditor->editedEntry()->alarm(); |
|
383 |
||
384 |
// Update the reminder choices only if the alarm set is not valid |
|
385 |
// Get the alarm offset to check for the validity |
|
386 |
int offset = mCalenEditor->editedEntry()->alarm().timeOffset(); |
|
387 |
bool update = true; |
|
388 |
||
389 |
// Calculate the alarm time |
|
390 |
QDateTime refDateTime; |
|
391 |
refDateTime.setDate(referenceDate); |
|
392 |
refDateTime.setTime(mCalenEditor->editedEntry()->startTime().time()); |
|
393 |
QTime checkTime = refDateTime.time().addSecs(-(offset * 60)); |
|
394 |
refDateTime.setTime(checkTime); |
|
395 |
// Check for valid alarm offset |
|
396 |
if(offset >= 0) { |
|
397 |
// If the alarm which was already set is valid, |
|
398 |
// then dont update the reminder choices |
|
399 |
if ((refDateTime > QDateTime::currentDateTime()) || |
|
400 |
(refDateTime.date() == QDate::currentDate() && ( |
|
401 |
refDateTime.time() > QTime::currentTime()))) { |
|
402 |
update = false; |
|
403 |
} |
|
404 |
} |
|
405 |
// If the event is on a past date the default alarm will be off. |
|
45 | 406 |
if (referenceDate < QDate::currentDate() || |
407 |
referenceDate == QDate::currentDate()) { |
|
408 |
// Set reminder off for past event. |
|
409 |
reminderChoicesForAllDay << hbTrId("txt_calendar_setlabel_reminder_val_off"); |
|
410 |
mReminderItem->setContentWidgetData(QString("items"), |
|
411 |
reminderChoicesForAllDay); |
|
57 | 412 |
mReminderItem->setEnabled(false); |
413 |
// Remove the reminder field if it was added |
|
414 |
if(mReminderTimeAdded) { |
|
415 |
removeReminderTimeField(); |
|
416 |
} |
|
45 | 417 |
} else if (theDayAfterTomorrow < referenceDate || |
418 |
theDayAfterTomorrow == referenceDate) { |
|
57 | 419 |
// If the event is on a future date which is two days after the current date |
420 |
// The options are off, on event day, 1 day before and 2 days before |
|
45 | 421 |
reminderChoicesForAllDay |
422 |
<< hbTrId("txt_calendar_setlabel_reminder_val_off") |
|
423 |
<< hbTrId("txt_calendar_setlabel_reminder_val_on_event_day") |
|
424 |
<< hbTrId("txt_calendar_setlabel_reminder_val_1_day_before") |
|
425 |
<< hbTrId("txt_calendar_setlabel_reminder_val_2_days_before"); |
|
426 |
mReminderItem->setEnabled(true); |
|
427 |
mCustomReminderTimeItem->setEnabled(true); |
|
57 | 428 |
mReminderItem->setContentWidgetData(QString("items"), |
429 |
reminderChoicesForAllDay); |
|
430 |
} else if (QTime::currentTime() < QTime(18, 0, 0, 0)) { |
|
431 |
// If the event is on a future date which is one day after the current date |
|
432 |
// and current time is before 6.00 pm. |
|
433 |
// The options are off, on event day and 1 day before |
|
45 | 434 |
reminderChoicesForAllDay |
57 | 435 |
<< hbTrId("txt_calendar_setlabel_reminder_val_off") |
436 |
<< hbTrId("txt_calendar_setlabel_reminder_val_on_event_day") |
|
437 |
<< hbTrId("txt_calendar_setlabel_reminder_val_1_day_before"); |
|
438 |
mReminderItem->setEnabled(true); |
|
439 |
mCustomReminderTimeItem->setEnabled(true); |
|
440 |
mReminderItem->setContentWidgetData(QString("items"), |
|
441 |
reminderChoicesForAllDay); |
|
442 |
}else { |
|
443 |
// If the event is on a future date which is one day after the current date |
|
444 |
// and current time is after 6.00 pm. |
|
445 |
// The options are off and on event day |
|
446 |
reminderChoicesForAllDay |
|
447 |
<< hbTrId("txt_calendar_setlabel_reminder_val_off") |
|
448 |
<< hbTrId("txt_calendar_setlabel_reminder_val_on_event_day"); |
|
45 | 449 |
mReminderItem->setEnabled(true); |
450 |
mCustomReminderTimeItem->setEnabled(true); |
|
57 | 451 |
mReminderItem->setContentWidgetData(QString("items"), |
452 |
reminderChoicesForAllDay); |
|
45 | 453 |
} |
57 | 454 |
// Set the proper index based on the validity of the previous index |
455 |
int count = reminderItemsCount(); |
|
456 |
// By default, in case of reminder updation, its been agreed to set |
|
457 |
// ReminderOneDayBefore even though ReminderTwoDaysBefore holds good |
|
458 |
// If the ReminderOneDayBefore option is available set it or |
|
459 |
// else set it to ReminderOff |
|
460 |
if(count > ReminderOneDayBefore) { |
|
461 |
// Don't make the reminder off since |
|
462 |
// the valid reminder options are there in the combobox |
|
463 |
// So check for ReminderOff is needed |
|
464 |
if (update && |
|
465 |
(previousIndex == ReminderOff || previousIndex >= ReminderOneDayBefore)) { |
|
466 |
// If the index has to be updated check the previous index value |
|
467 |
// And set the default reminder as 1 day before. |
|
468 |
mReminderItem->setContentWidgetData("currentIndex", |
|
469 |
ReminderOneDayBefore); |
|
470 |
}else { |
|
471 |
// Set the previous index since the alarm is valid |
|
472 |
mReminderItem->setContentWidgetData("currentIndex", previousIndex); |
|
473 |
// Set the previous alarm also as the value will be changed to default value |
|
474 |
// when the current index is been changed |
|
475 |
mCalenEditor->editedEntry()->setAlarm(previousAlarm); |
|
476 |
// Get the alarm time from the offset |
|
477 |
QTime alarmTime = refDateTime.time(); |
|
478 |
// Set the alarm time and display it on the button |
|
479 |
mReminderTimeForAllDay.setHMS( |
|
480 |
alarmTime.hour(),alarmTime.minute(),alarmTime.second()); |
|
481 |
setDisplayTime(); |
|
482 |
} |
|
483 |
}else { |
|
484 |
// Enters this condition if the previous index set is not valid or |
|
485 |
// the index is ReminderOff |
|
486 |
mReminderItem->setContentWidgetData("currentIndex", ReminderOff); |
|
45 | 487 |
} |
57 | 488 |
|
51 | 489 |
OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_UPDATEREMINDERCHOICESFORALLDAY_EXIT ); |
45 | 490 |
} |
491 |
||
492 |
/*! |
|
493 |
Insert the reminder time field for an all day event. |
|
494 |
*/ |
|
495 |
void CalenEditorReminderField::insertReminderTimeField() |
|
496 |
{ |
|
51 | 497 |
OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_INSERTREMINDERTIMEFIELD_ENTRY ); |
45 | 498 |
HbDataFormModelItem::DataItemType itemType = |
499 |
static_cast<HbDataFormModelItem::DataItemType> (ReminderTimeOffset); |
|
500 |
||
501 |
// If all day item is not added then insert at one level before. |
|
502 |
int index = CalenEditorPrivate::ReminderTimeForAllDayItem; |
|
503 |
if(!mCalenEditor->isAllDayFieldAdded()) { |
|
504 |
index = CalenEditorPrivate::ReminderTimeForAllDayItem - 1; |
|
505 |
} |
|
506 |
mCustomReminderTimeItem = mCalenEditorModel->insertDataFormItem( |
|
507 |
index, |
|
508 |
itemType, |
|
509 |
QString(hbTrId("txt_calendar_setlabel_reminder_time")), |
|
510 |
mCalenEditorModel->invisibleRootItem()); |
|
511 |
if (currentReminderIndex() != 1){ |
|
512 |
mReminderTimeForAllDay.setHMS(18,0,0,0); |
|
513 |
} else { |
|
514 |
mReminderTimeForAllDay.setHMS(8,0,0,0); |
|
515 |
} |
|
516 |
||
517 |
mEditorForm->addConnection(mCustomReminderTimeItem, SIGNAL(clicked()), |
|
518 |
this, SLOT(launchReminderTimePicker())); |
|
519 |
setDisplayTime(); |
|
520 |
mReminderTimeAdded = true; |
|
51 | 521 |
OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_INSERTREMINDERTIMEFIELD_EXIT ); |
45 | 522 |
} |
523 |
||
524 |
/*! |
|
525 |
Set the reminder time selected by the user. |
|
526 |
*/ |
|
527 |
void CalenEditorReminderField::setDisplayTime() |
|
528 |
{ |
|
51 | 529 |
OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_SETDISPLAYTIME_ENTRY ); |
45 | 530 |
HbExtendedLocale locale = HbExtendedLocale::system(); |
531 |
QString timeString = locale.format( |
|
532 |
mReminderTimeForAllDay, |
|
533 |
r_qtn_time_usual_with_zero); |
|
534 |
mCustomReminderTimeItem->setContentWidgetData("text", timeString); |
|
51 | 535 |
OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_SETDISPLAYTIME_EXIT ); |
45 | 536 |
} |
537 |
||
538 |
/*! |
|
539 |
Remove the reminder time field if its not an all day event. |
|
540 |
*/ |
|
541 |
void CalenEditorReminderField::removeReminderTimeField() |
|
542 |
{ |
|
51 | 543 |
OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_REMOVEREMINDERTIMEFIELD_ENTRY ); |
45 | 544 |
mReminderTimeAdded = false; |
63 | 545 |
mEditorForm->removeConnection(mCustomReminderTimeItem, SIGNAL(clicked()), |
546 |
this, SLOT(launchReminderTimePicker())); |
|
45 | 547 |
if (mCustomReminderTimeItem) { |
548 |
QModelIndex reminderIndex = |
|
549 |
mCalenEditorModel->indexFromItem(mCustomReminderTimeItem); |
|
550 |
mCalenEditorModel->removeItem( |
|
551 |
mCalenEditorModel->index( |
|
552 |
reminderIndex.row(), 0)); |
|
55 | 553 |
mCustomReminderTimeItem = 0; |
45 | 554 |
} |
51 | 555 |
OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_REMOVEREMINDERTIMEFIELD_EXIT ); |
45 | 556 |
} |
557 |
||
558 |
/*! |
|
559 |
Launches time picker to select time. |
|
560 |
*/ |
|
561 |
void CalenEditorReminderField::launchReminderTimePicker() |
|
562 |
{ |
|
51 | 563 |
OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_LAUNCHREMINDERTIMEPICKER_ENTRY ); |
57 | 564 |
|
45 | 565 |
HbDialog *popUp = new HbDialog(); |
566 |
popUp->setDismissPolicy(HbDialog::NoDismiss); |
|
567 |
popUp->setTimeout(HbDialog::NoTimeout); |
|
57 | 568 |
popUp->setAttribute( Qt::WA_DeleteOnClose, true ); |
45 | 569 |
popUp->setHeadingWidget( new HbLabel( |
57 | 570 |
hbTrId("Reminder Time"))); |
571 |
||
572 |
HbExtendedLocale locale = HbExtendedLocale::system(); |
|
573 |
mTimePicker = new HbDateTimePicker(mReminderTimeForAllDay); |
|
574 |
if(locale.timeStyle() == HbExtendedLocale::Time12) { |
|
575 |
mTimePicker->setDisplayFormat("hh:mm ap"); |
|
576 |
}else { |
|
577 |
mTimePicker->setDisplayFormat("hh:mm"); |
|
578 |
} |
|
579 |
mTimePicker->setTime(mReminderTimeForAllDay); |
|
580 |
popUp->setContentWidget(mTimePicker); |
|
581 |
||
582 |
HbAction *okAction = new HbAction(hbTrId("txt_common_button_ok"), popUp); |
|
45 | 583 |
popUp->addAction(okAction); |
584 |
connect(okAction, SIGNAL(triggered()), this, SLOT(setReminderTimeForAllDay())); |
|
585 |
popUp->addAction(new HbAction(hbTrId("txt_common_button_cancel"), |
|
586 |
popUp)); |
|
587 |
popUp->open(); |
|
51 | 588 |
OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_LAUNCHREMINDERTIMEPICKER_EXIT ); |
45 | 589 |
} |
590 |
||
591 |
/*! |
|
592 |
Set the reminder time chosen. |
|
593 |
*/ |
|
594 |
void CalenEditorReminderField::setReminderTimeForAllDay() |
|
595 |
{ |
|
51 | 596 |
OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_SETREMINDERTIMEFORALLDAY_ENTRY ); |
45 | 597 |
mReminderTimeForAllDay = mTimePicker->time(); |
598 |
if (mReminderTimeForAllDay.isValid()) { |
|
599 |
// Change the time displayed to that selected by the user. |
|
600 |
setDisplayTime(); |
|
601 |
handleReminderIndexChanged(currentReminderIndex()); |
|
602 |
} |
|
51 | 603 |
OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_SETREMINDERTIMEFORALLDAY_EXIT ); |
45 | 604 |
} |
605 |
||
606 |
/*! |
|
607 |
Checks if reminder field is enabled or not. |
|
608 |
*/ |
|
609 |
bool CalenEditorReminderField::isReminderFieldEnabled() |
|
610 |
{ |
|
51 | 611 |
OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_ISREMINDERFIELDENABLED_ENTRY ); |
45 | 612 |
return mReminderItem->isEnabled(); |
613 |
} |
|
614 |
||
615 |
/*! |
|
616 |
Returns the number of items present in the reminder option. |
|
617 |
*/ |
|
618 |
int CalenEditorReminderField::reminderItemsCount() |
|
619 |
{ |
|
51 | 620 |
OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_REMINDERITEMSCOUNT_ENTRY ); |
45 | 621 |
QVariant strings = mReminderItem->contentWidgetData("items"); |
622 |
QStringList stringList(strings.toStringList()); |
|
623 |
int count = stringList.count(); |
|
51 | 624 |
OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_REMINDERITEMSCOUNT_EXIT ); |
45 | 625 |
return count; |
626 |
} |
|
627 |
||
628 |
/*! |
|
629 |
Returns the current chosen index. |
|
630 |
*/ |
|
631 |
int CalenEditorReminderField::currentReminderIndex() |
|
632 |
{ |
|
51 | 633 |
OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_CURRENTREMINDERINDEX_ENTRY ); |
45 | 634 |
QVariant countVariant = mReminderItem->contentWidgetData("currentIndex"); |
635 |
int index = countVariant.toInt(); |
|
51 | 636 |
OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_CURRENTREMINDERINDEX_EXIT ); |
45 | 637 |
return index; |
638 |
} |
|
639 |
||
640 |
/*! |
|
641 |
Sets the chosen index as current index. |
|
642 |
/param index indicates the idex value to be set. |
|
643 |
*/ |
|
644 |
void CalenEditorReminderField::setCurrentIndex(int index) |
|
645 |
{ |
|
51 | 646 |
OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_SETCURRENTINDEX_ENTRY ); |
45 | 647 |
mReminderItem->setContentWidgetData("currentIndex", index); |
51 | 648 |
OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_SETCURRENTINDEX_EXIT ); |
45 | 649 |
} |
650 |
||
651 |
/*! |
|
652 |
Disables the reminder time field. |
|
653 |
*/ |
|
654 |
void CalenEditorReminderField::disableReminderTimeField() |
|
655 |
{ |
|
51 | 656 |
OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_DISABLEREMINDERTIMEFIELD_ENTRY ); |
45 | 657 |
if (mReminderTimeAdded) { |
658 |
mCustomReminderTimeItem->setEnabled(false); |
|
659 |
} |
|
51 | 660 |
OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_DISABLEREMINDERTIMEFIELD_EXIT ); |
45 | 661 |
} |
662 |
||
663 |
/*! |
|
664 |
Checks if reminder time field is added or not. |
|
665 |
*/ |
|
666 |
bool CalenEditorReminderField::isReminderTimeForAllDayAdded() |
|
667 |
{ |
|
51 | 668 |
OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_ISREMINDERTIMEFORALLDAYADDED_ENTRY ); |
669 |
OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_ISREMINDERTIMEFORALLDAYADDED_EXIT ); |
|
45 | 670 |
return mReminderTimeAdded; |
671 |
} |
|
672 |
||
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
673 |
// End of file --Don't remove this. |