31 #include <HbCheckBox> |
31 #include <HbCheckBox> |
32 #include <HbExtendedLocale> |
32 #include <HbExtendedLocale> |
33 #include <HbGroupBox> |
33 #include <HbGroupBox> |
34 #include <HbDocumentLoader> |
34 #include <HbDocumentLoader> |
35 #include <HbTranslator> |
35 #include <HbTranslator> |
|
36 #include <HbAbstractVkbHost> |
|
37 #include <HbLineEdit> |
36 #include <xqsettingsmanager.h> |
38 #include <xqsettingsmanager.h> |
37 #include <xqsettingskey.h> |
39 #include <xqsettingskey.h> |
38 |
40 #include <QLocale> |
39 |
41 |
40 // User includes |
42 // User includes |
41 #include "clockprivatecrkeys.h" |
43 #include "clockprivatecrkeys.h" |
42 #include "clockalarmeditor.h" |
44 #include "clockalarmeditor.h" |
43 #include "alarmclient.h" |
45 #include "alarmclient.h" |
44 #include "settingsutility.h" |
46 #include "settingsutility.h" |
45 #include "timezoneclient.h" |
47 #include "timezoneclient.h" |
46 #include "clockalarmcustomitem.h" |
48 #include "clockalarmcustomitem.h" |
|
49 #include "OstTraceDefinitions.h" |
|
50 #ifdef OST_TRACE_COMPILER_IN_USE |
|
51 #include "clockalarmeditorTraces.h" |
|
52 #endif |
|
53 |
47 |
54 |
48 // Constants |
55 // Constants |
49 const int KOneHourInMinute(60); |
56 const int KOneHourInMinute(60); |
50 const int KOneMinuteInSecons(60); |
57 const int KOneMinuteInSecons(60); |
51 const int KOneMinute(1); |
58 const int KOneMinute(1); |
73 QObject *parent) |
80 QObject *parent) |
74 :QObject(parent), |
81 :QObject(parent), |
75 mAlarmId(alarmId), |
82 mAlarmId(alarmId), |
76 mStartOfWeek(0), |
83 mStartOfWeek(0), |
77 mAlarmDayItemInserted(false), |
84 mAlarmDayItemInserted(false), |
|
85 mIsQuickAlarm(true), |
78 mAlarmEditorForm(0), |
86 mAlarmEditorForm(0), |
79 mAlarmEditorModel(0), |
87 mAlarmEditorModel(0), |
80 mAlarmTimeItem(0), |
88 mAlarmTimeItem(0), |
81 mAlarmOccurenceItem(0), |
89 mAlarmOccurenceItem(0), |
82 mAlarmDayItem(0), |
90 mAlarmDayItem(0), |
83 mAlarmSoundItem(0), |
91 mAlarmSoundItem(0), |
84 mAlarmDescription(0), |
92 mAlarmDescription(0), |
85 mAlarmClient(alarmClient) |
93 mAlarmClient(alarmClient) |
86 { |
94 { |
|
95 OstTraceFunctionEntry0( CLOCKALARMEDITOR_CLOCKALARMEDITOR_ENTRY ); |
87 // Load the translation file and install the alarmeditor specific translator |
96 // Load the translation file and install the alarmeditor specific translator |
88 mTranslator = new HbTranslator("clockalarmeditor"); |
97 mTranslator = new HbTranslator("clockalarmeditor"); |
89 mTranslator->loadCommon(); |
98 mTranslator->loadCommon(); |
90 |
99 |
91 // create the timezone client object |
100 // create the timezone client object |
144 mAlarmEditorForm->setItemPrototypes(prototypes); |
153 mAlarmEditorForm->setItemPrototypes(prototypes); |
145 |
154 |
146 // Get the menu items for the alarm editor. |
155 // Get the menu items for the alarm editor. |
147 mDeleteAction = qobject_cast<HbAction *> ( |
156 mDeleteAction = qobject_cast<HbAction *> ( |
148 loader->findObject("deleteAction")); |
157 loader->findObject("deleteAction")); |
149 mDiscardAction = qobject_cast<HbAction *>( |
|
150 loader->findObject("discardChanges")); |
|
151 |
158 |
152 // Connect the signals for the menu item. |
159 // Connect the signals for the menu item. |
153 connect( |
160 connect( |
154 mDeleteAction, SIGNAL(triggered()), |
161 mDeleteAction, SIGNAL(triggered()), |
155 this, SLOT(handleDeleteAction())); |
162 this, SLOT(handleDeleteAction())); |
156 connect( |
|
157 mDiscardAction, SIGNAL(triggered()), |
|
158 this, SLOT(handleDiscardAction())); |
|
159 |
163 |
160 // Add the done soft key action. |
164 // Add the done soft key action. |
161 mDoneAction = new HbAction(Hb::DoneNaviAction); |
165 mDoneAction = new HbAction(Hb::DoneNaviAction); |
162 connect( |
166 connect( |
163 mDoneAction, SIGNAL(triggered()), |
167 mDoneAction, SIGNAL(triggered()), |
164 this, SLOT(handleDoneAction())); |
168 this, SLOT(handleDoneAction())); |
165 mAlarmEditorView->setNavigationAction(mDoneAction); |
169 mAlarmEditorView->setNavigationAction(mDoneAction); |
166 |
170 |
|
171 if (mAlarmEditorView) { |
|
172 mVirtualKeyboard = new HbAbstractVkbHost(mAlarmEditorView); |
|
173 } |
|
174 connect( |
|
175 mVirtualKeyboard, SIGNAL(keypadOpened()), |
|
176 this, SLOT(handleKeypadOpen())); |
|
177 connect( |
|
178 mVirtualKeyboard, SIGNAL(keypadClosed()), |
|
179 this, SLOT(handleKeypadClosed())); |
|
180 |
|
181 |
|
182 OstTraceFunctionExit0( CLOCKALARMEDITOR_CLOCKALARMEDITOR_EXIT ); |
167 } |
183 } |
168 |
184 |
169 /*! |
185 /*! |
170 Destructor. |
186 Destructor. |
171 */ |
187 */ |
172 ClockAlarmEditor::~ClockAlarmEditor() |
188 ClockAlarmEditor::~ClockAlarmEditor() |
173 { |
189 { |
|
190 OstTraceFunctionEntry0( DUP1_CLOCKALARMEDITOR_CLOCKALARMEDITOR_ENTRY ); |
174 // Remove the translator |
191 // Remove the translator |
175 if (mTranslator) { |
192 if (mTranslator) { |
176 delete mTranslator; |
193 delete mTranslator; |
177 mTranslator = 0; |
194 mTranslator = 0; |
178 } |
195 } |
179 |
196 |
|
197 OstTraceFunctionExit0( DUP1_CLOCKALARMEDITOR_CLOCKALARMEDITOR_EXIT ); |
180 } |
198 } |
181 |
199 |
182 /*! |
200 /*! |
183 Show the alarm editor. |
201 Show the alarm editor. |
184 */ |
202 */ |
185 void ClockAlarmEditor::showAlarmEditor() |
203 void ClockAlarmEditor::showAlarmEditor() |
186 { |
204 { |
|
205 OstTraceFunctionEntry0( CLOCKALARMEDITOR_SHOWALARMEDITOR_ENTRY ); |
187 // Store the current view and set alarm editor as current view. |
206 // Store the current view and set alarm editor as current view. |
188 HbMainWindow *window = hbInstance->allMainWindows().first(); |
207 HbMainWindow *window = hbInstance->allMainWindows().first(); |
189 window->addView(mAlarmEditorView); |
208 window->addView(mAlarmEditorView); |
190 window->setCurrentView(mAlarmEditorView); |
209 window->setCurrentView(mAlarmEditorView); |
|
210 OstTraceFunctionExit0( CLOCKALARMEDITOR_SHOWALARMEDITOR_EXIT ); |
191 } |
211 } |
192 |
212 |
193 /*! |
213 /*! |
194 Handles done action on the editor. Saves the alarm |
214 Handles done action on the editor. Saves the alarm |
195 */ |
215 */ |
196 void ClockAlarmEditor::handleDoneAction() |
216 void ClockAlarmEditor::handleDoneAction() |
197 { |
217 { |
|
218 OstTraceFunctionEntry0( CLOCKALARMEDITOR_HANDLEDONEACTION_ENTRY ); |
198 int alarmDayIndex = -1; |
219 int alarmDayIndex = -1; |
199 if (mAlarmDayItemInserted) { |
220 if (mAlarmDayItemInserted) { |
200 alarmDayIndex = mAlarmDayItem->contentWidgetData("currentIndex").toInt(); |
221 alarmDayIndex = mAlarmDayItem->contentWidgetData("currentIndex").toInt(); |
201 alarmDayIndex += mStartOfWeek; |
222 alarmDayIndex += mStartOfWeek; |
202 if(alarmDayIndex >= KDaysInWeek){ |
223 if(alarmDayIndex >= KDaysInWeek){ |
213 mAlarmDayItemInserted = false; |
234 mAlarmDayItemInserted = false; |
214 |
235 |
215 emit alarmSet(); |
236 emit alarmSet(); |
216 |
237 |
217 closeAlarmEditor(); |
238 closeAlarmEditor(); |
|
239 OstTraceFunctionExit0( CLOCKALARMEDITOR_HANDLEDONEACTION_EXIT ); |
218 } |
240 } |
219 |
241 |
220 /*! |
242 /*! |
221 Handles delete action on the editor. Deletes the alarm. |
243 Handles delete action on the editor. Deletes the alarm. |
222 */ |
244 */ |
223 void ClockAlarmEditor::handleDeleteAction() |
245 void ClockAlarmEditor::handleDeleteAction() |
224 { |
246 { |
|
247 OstTraceFunctionEntry0( CLOCKALARMEDITOR_HANDLEDELETEACTION_ENTRY ); |
225 closeAlarmEditor(); |
248 closeAlarmEditor(); |
226 } |
249 OstTraceFunctionExit0( CLOCKALARMEDITOR_HANDLEDELETEACTION_EXIT ); |
227 |
|
228 /*! |
|
229 Handles discard changes action on the editor. |
|
230 */ |
|
231 void ClockAlarmEditor::handleDiscardAction() |
|
232 { |
|
233 // Reset alarm time. |
|
234 mAlarmTimeItem->setContentWidgetData( |
|
235 "text",mAlarmInfo.nextDueTime.toString(mTimeFormat)); |
|
236 // Reset repeat info. |
|
237 mAlarmOccurenceItem->setContentWidgetData("currentIndex", mAlarmInfo.repeatType); |
|
238 |
|
239 // Reset alarm day item. |
|
240 if (mAlarmDayItemInserted) { |
|
241 int currentIndex = mAlarmInfo.alarmDateTime.dayOfWeek() - 1; |
|
242 currentIndex -= mStartOfWeek; |
|
243 if(0 > currentIndex){ |
|
244 currentIndex += KDaysInWeek; |
|
245 } |
|
246 mAlarmDayItem->setContentWidgetData( |
|
247 "currentIndex",currentIndex); |
|
248 } |
|
249 |
|
250 // Reset for alarm sound. |
|
251 if (AlarmVolumeOn == mAlarmInfo.volumeStatus) { |
|
252 mAlarmSoundItem->setContentWidgetData("checkState", Qt::Checked); |
|
253 } else { |
|
254 mAlarmSoundItem->setContentWidgetData("checkState", Qt::Unchecked); |
|
255 } |
|
256 |
|
257 mAlarmDescription->setContentWidgetData("text", mAlarmInfo.alarmDesc); |
|
258 } |
250 } |
259 |
251 |
260 /*! |
252 /*! |
261 Handles change in alarmtime item of the data form. |
253 Handles change in alarmtime item of the data form. |
262 */ |
254 */ |
263 void ClockAlarmEditor::handleTimeChange(const QString &text) |
255 void ClockAlarmEditor::handleTimeChange(const QString &text) |
264 { |
256 { |
|
257 OstTraceFunctionEntry0( CLOCKALARMEDITOR_HANDLETIMECHANGE_ENTRY ); |
265 // If it is a new alarm. |
258 // If it is a new alarm. |
266 if (!mAlarmId) { |
259 if (!mAlarmId) { |
267 // Decide the day to focus. |
260 // Decide the day to focus. |
268 int alarmDayIndex = (QDate::currentDate()).dayOfWeek() - 1; |
261 int alarmDayIndex = (QDate::currentDate()).dayOfWeek() - 1; |
269 |
262 |
270 QTime alarmTime = QTime::fromString( |
263 QTime alarmTime = QTime::fromString( |
271 text, |
264 text, |
272 mTimeFormat); |
265 mTimeFormat); |
273 if (!alarmTime.isValid()) { |
266 if (!alarmTime.isValid()) { |
|
267 OstTraceFunctionExit0( CLOCKALARMEDITOR_HANDLETIMECHANGE_EXIT ); |
274 return; |
268 return; |
275 } |
269 } |
276 |
270 |
277 QTime homeTime = QTime::currentTime(); |
271 QTime homeTime = QTime::currentTime(); |
278 if (-1 == alarmDayIndex) { |
272 if (-1 == alarmDayIndex) { |
|
273 OstTraceFunctionExit0( DUP1_CLOCKALARMEDITOR_HANDLETIMECHANGE_EXIT ); |
279 return; |
274 return; |
280 } |
275 } |
281 if (homeTime > alarmTime) { |
276 if (homeTime > alarmTime) { |
282 alarmDayIndex++; |
277 alarmDayIndex++; |
283 } |
278 } |
288 alarmDayIndex -= mStartOfWeek; |
283 alarmDayIndex -= mStartOfWeek; |
289 |
284 |
290 if(0 > alarmDayIndex){ |
285 if(0 > alarmDayIndex){ |
291 alarmDayIndex += KDaysInWeek; |
286 alarmDayIndex += KDaysInWeek; |
292 } |
287 } |
|
288 mAlarmEditorForm->removeConnection( |
|
289 mAlarmDayItem, SIGNAL(currentIndexChanged(int)), |
|
290 this, SLOT(handleDayChanged(int))); |
|
291 mIsQuickAlarm = true; |
293 mAlarmDayItem->setContentWidgetData( |
292 mAlarmDayItem->setContentWidgetData( |
294 "currentIndex", |
293 "currentIndex", |
295 alarmDayIndex); |
294 alarmDayIndex); |
296 } |
295 mAlarmEditorForm->addConnection( |
297 } |
296 mAlarmDayItem, SIGNAL(currentIndexChanged(int)), |
|
297 this, SLOT(handleDayChanged(int))); |
|
298 } |
|
299 } |
|
300 OstTraceFunctionExit0( DUP2_CLOCKALARMEDITOR_HANDLETIMECHANGE_EXIT ); |
298 } |
301 } |
299 |
302 |
300 /*! |
303 /*! |
301 Handles change in alarm occurence item of the data form. |
304 Handles change in alarm occurence item of the data form. |
302 */ |
305 */ |
303 void ClockAlarmEditor:: handleOccurenceChanged(int index) |
306 void ClockAlarmEditor:: handleOccurenceChanged(int index) |
304 { |
307 { |
|
308 OstTraceFunctionEntry0( CLOCKALARMEDITOR_HANDLEOCCURENCECHANGED_ENTRY ); |
305 Q_UNUSED(index) |
309 Q_UNUSED(index) |
|
310 |
|
311 mIsQuickAlarm = false; |
306 |
312 |
307 int repeatIndex = |
313 int repeatIndex = |
308 mAlarmOccurenceItem->contentWidgetData("currentIndex").toInt(); |
314 mAlarmOccurenceItem->contentWidgetData("currentIndex").toInt(); |
309 |
315 |
310 if ((Weekly == repeatIndex || Once == repeatIndex)) { |
316 if ((Weekly == repeatIndex || Once == repeatIndex)) { |
325 } |
332 } |
326 if (!mAlarmDayItemInserted) { |
333 if (!mAlarmDayItemInserted) { |
327 // Show the alarm days field to select the day. |
334 // Show the alarm days field to select the day. |
328 mAlarmDayItem = new HbDataFormModelItem( |
335 mAlarmDayItem = new HbDataFormModelItem( |
329 HbDataFormModelItem::ComboBoxItem, |
336 HbDataFormModelItem::ComboBoxItem, |
330 QString(hbTrId("txt_clock_formlabel_day"))); |
337 QString(hbTrId("txt_clk_setlabel_day"))); |
|
338 mAlarmEditorForm->addConnection( |
|
339 mAlarmDayItem, SIGNAL(currentIndexChanged(int)), |
|
340 this, SLOT(handleDayChanged(int))); |
331 |
341 |
332 // Add the alarm days beginning from the start of week. |
342 // Add the alarm days beginning from the start of week. |
333 QStringList alarmDays; |
343 QStringList alarmDays; |
334 sortAlarmDaysList(alarmDays); |
344 sortAlarmDaysList(alarmDays); |
335 alarmDayIndex -= mStartOfWeek; |
345 alarmDayIndex -= mStartOfWeek; |
354 if (mAlarmDayItemInserted) { |
364 if (mAlarmDayItemInserted) { |
355 mAlarmEditorModel->removeItem(mAlarmDayItem); |
365 mAlarmEditorModel->removeItem(mAlarmDayItem); |
356 mAlarmDayItemInserted = false; |
366 mAlarmDayItemInserted = false; |
357 } |
367 } |
358 } |
368 } |
|
369 OstTraceFunctionExit0( DUP1_CLOCKALARMEDITOR_HANDLEOCCURENCECHANGED_EXIT ); |
359 } |
370 } |
360 |
371 |
361 /*! |
372 /*! |
362 Called when `OK' is pressed on the Dialog. |
373 Called when `OK' is pressed on the Dialog. |
363 */ |
374 */ |
364 void ClockAlarmEditor::handleOkAction() |
375 void ClockAlarmEditor::handleOkAction() |
365 { |
376 { |
|
377 OstTraceFunctionEntry0( CLOCKALARMEDITOR_HANDLEOKACTION_ENTRY ); |
366 // Get the time from the time picker. |
378 // Get the time from the time picker. |
367 QTime newAlarmTime = static_cast<HbDateTimePicker *> ( |
379 QTime newAlarmTime = static_cast<HbDateTimePicker *> ( |
368 mTimePickerDialog->contentWidget())->time(); |
380 mTimePickerDialog->contentWidget())->time(); |
369 |
381 |
370 // Update the selected time value. |
382 // Update the selected time value. |
371 mAlarmTimeItem->setContentWidgetData("text",newAlarmTime.toString(mTimeFormat)); |
383 mAlarmTimeItem->setContentWidgetData("text",newAlarmTime.toString(mTimeFormat)); |
372 |
384 |
373 if (mAlarmInfo.nextDueTime != newAlarmTime ) { |
385 if (mOldAlarmTime != newAlarmTime && mIsQuickAlarm) { |
374 handleTimeChange(newAlarmTime.toString(mTimeFormat)); |
386 handleTimeChange(newAlarmTime.toString(mTimeFormat)); |
375 } |
387 } |
|
388 |
|
389 mOldAlarmTime = newAlarmTime; |
|
390 OstTraceFunctionExit0( CLOCKALARMEDITOR_HANDLEOKACTION_EXIT ); |
376 } |
391 } |
377 |
392 |
378 /*! |
393 /*! |
379 Launches datetimepicker when Alarm time button is clicked. |
394 Launches datetimepicker when Alarm time button is clicked. |
380 */ |
395 */ |
381 void ClockAlarmEditor::launchTimePicker() |
396 void ClockAlarmEditor::launchTimePicker() |
382 { |
397 { |
|
398 OstTraceFunctionEntry0( CLOCKALARMEDITOR_LAUNCHTIMEPICKER_ENTRY ); |
383 if (mTimePickerDialog) { |
399 if (mTimePickerDialog) { |
384 delete mTimePickerDialog; |
400 delete mTimePickerDialog; |
385 } |
401 } |
386 |
402 |
387 // Create the dialog. |
403 // Create the dialog. |
422 |
438 |
423 mTimePickerDialog->addAction(mOkAction); |
439 mTimePickerDialog->addAction(mOkAction); |
424 mTimePickerDialog->addAction(mCancelAction); |
440 mTimePickerDialog->addAction(mCancelAction); |
425 |
441 |
426 mTimePickerDialog->open(this, SLOT(selectedAction(HbAction*))); |
442 mTimePickerDialog->open(this, SLOT(selectedAction(HbAction*))); |
|
443 OstTraceFunctionExit0( CLOCKALARMEDITOR_LAUNCHTIMEPICKER_EXIT ); |
427 } |
444 } |
428 |
445 |
429 /*! |
446 /*! |
430 Handles the alarm sound change. |
447 Handles the alarm sound change. |
431 */ |
448 */ |
432 void ClockAlarmEditor::handleAlarmSoundChanged(int checkedState) |
449 void ClockAlarmEditor::handleAlarmSoundChanged(int checkedState) |
433 { |
450 { |
|
451 OstTraceFunctionEntry0( CLOCKALARMEDITOR_HANDLEALARMSOUNDCHANGED_ENTRY ); |
434 Q_UNUSED(checkedState) |
452 Q_UNUSED(checkedState) |
435 if (AlarmVolumeOff == mAlarmInfo.volumeStatus) { |
453 mIsQuickAlarm = false; |
|
454 /* if (AlarmVolumeOff == mAlarmInfo.volumeStatus) { |
436 mAlarmInfo.volumeStatus = AlarmVolumeOn; |
455 mAlarmInfo.volumeStatus = AlarmVolumeOn; |
437 } else { |
456 } else { |
438 mAlarmInfo.volumeStatus = AlarmVolumeOff; |
457 mAlarmInfo.volumeStatus = AlarmVolumeOff; |
439 } |
458 }*/ |
|
459 OstTraceFunctionExit0( CLOCKALARMEDITOR_HANDLEALARMSOUNDCHANGED_EXIT ); |
440 } |
460 } |
441 |
461 |
442 /*! |
462 /*! |
443 Slot to handle the selected action |
463 Slot to handle the selected action |
444 */ |
464 */ |
445 void ClockAlarmEditor::selectedAction(HbAction *action) |
465 void ClockAlarmEditor::selectedAction(HbAction *action) |
446 { |
466 { |
|
467 OstTraceFunctionEntry0( CLOCKALARMEDITOR_SELECTEDACTION_ENTRY ); |
447 if (action == mOkAction) { |
468 if (action == mOkAction) { |
448 handleOkAction(); |
469 handleOkAction(); |
449 } |
470 } |
|
471 OstTraceFunctionExit0( CLOCKALARMEDITOR_SELECTEDACTION_EXIT ); |
|
472 } |
|
473 |
|
474 /*! |
|
475 Slot to handle the change in day item. |
|
476 */ |
|
477 void ClockAlarmEditor::handleDayChanged(int index) |
|
478 { |
|
479 Q_UNUSED(index) |
|
480 mIsQuickAlarm = false; |
|
481 } |
|
482 |
|
483 /*! |
|
484 Slot to handle the change in description. |
|
485 */ |
|
486 void ClockAlarmEditor::handleDescriptionChanged(const QString &text) |
|
487 { |
|
488 Q_UNUSED(text) |
|
489 mIsQuickAlarm = false; |
|
490 } |
|
491 |
|
492 /*! |
|
493 Slot to handle the open event of vkb. |
|
494 */ |
|
495 void ClockAlarmEditor::handleKeypadOpen() |
|
496 { |
|
497 QModelIndex descriptionItemIndex = |
|
498 mAlarmEditorModel->indexFromItem(mAlarmDescription); |
|
499 HbDataFormViewItem *viewItem = static_cast<HbDataFormViewItem *> ( |
|
500 mAlarmEditorForm->itemByIndex(descriptionItemIndex)); |
|
501 if (viewItem) { |
|
502 HbLineEdit *editor = static_cast<HbLineEdit *>( |
|
503 viewItem->dataItemContentWidget()); |
|
504 int temp = editor->text().length(); |
|
505 bool flag = editor->hasSelectedText(); |
|
506 if (!flag) { |
|
507 editor->setSelection(0, temp); |
|
508 } |
|
509 } |
|
510 } |
|
511 |
|
512 /*! |
|
513 Slot to handle the close event of vkb. |
|
514 */ |
|
515 void ClockAlarmEditor::handleKeypadClosed() |
|
516 { |
|
517 QModelIndex descriptionItemIndex = |
|
518 mAlarmEditorModel->indexFromItem(mAlarmDescription); |
|
519 HbDataFormViewItem *viewItem = static_cast<HbDataFormViewItem *> ( |
|
520 mAlarmEditorForm->itemByIndex(descriptionItemIndex)); |
|
521 if (viewItem) { |
|
522 HbLineEdit *editor = static_cast<HbLineEdit *>( |
|
523 viewItem->dataItemContentWidget()); |
|
524 |
|
525 editor->setSelection(0, 0); |
|
526 if (editor->text().isEmpty()) { |
|
527 editor->setText(hbTrId("txt_clk_formlabel_val_alarm")); |
|
528 } |
|
529 |
|
530 } |
450 } |
531 } |
451 |
532 |
452 /*! |
533 /*! |
453 Initialises the Model & sets for the AlarmEditorForm. |
534 Initialises the Model & sets for the AlarmEditorForm. |
454 */ |
535 */ |
455 void ClockAlarmEditor::initModel() |
536 void ClockAlarmEditor::initModel() |
456 { |
537 { |
|
538 OstTraceFunctionEntry0( CLOCKALARMEDITOR_INITMODEL_ENTRY ); |
457 // Remove the model. |
539 // Remove the model. |
458 if (mAlarmEditorForm->model()) { |
540 if (mAlarmEditorForm->model()) { |
459 delete mAlarmEditorForm->model(); |
541 delete mAlarmEditorForm->model(); |
460 mAlarmEditorForm->setModel(0); |
542 mAlarmEditorForm->setModel(0); |
461 } |
543 } |
464 mAlarmEditorModel = new HbDataFormModel(mAlarmEditorForm); |
546 mAlarmEditorModel = new HbDataFormModel(mAlarmEditorForm); |
465 // Populates the model items. |
547 // Populates the model items. |
466 populateModelItems(); |
548 populateModelItems(); |
467 // Set the model. |
549 // Set the model. |
468 mAlarmEditorForm->setModel(mAlarmEditorModel); |
550 mAlarmEditorForm->setModel(mAlarmEditorModel); |
|
551 OstTraceFunctionExit0( CLOCKALARMEDITOR_INITMODEL_EXIT ); |
469 } |
552 } |
470 |
553 |
471 /*! |
554 /*! |
472 Populates the items for the alarm editor. |
555 Populates the items for the alarm editor. |
473 */ |
556 */ |
474 void ClockAlarmEditor::populateModelItems() |
557 void ClockAlarmEditor::populateModelItems() |
475 { |
558 { |
|
559 OstTraceFunctionEntry0( CLOCKALARMEDITOR_POPULATEMODELITEMS_ENTRY ); |
476 // Time. |
560 // Time. |
477 // Creats a data form model item to set time. |
561 // Creates a data form model item to set time. |
478 mAlarmTimeItem = mAlarmEditorModel->appendDataFormItem( |
562 mAlarmTimeItem = mAlarmEditorModel->appendDataFormItem( |
479 HbDataFormModelItem::CustomItemBase, |
563 HbDataFormModelItem::CustomItemBase, |
480 QString(hbTrId("txt_clk_setlabel_time")), |
564 QString(hbTrId("txt_clk_setlabel_time")), |
481 mAlarmEditorModel->invisibleRootItem()); |
565 mAlarmEditorModel->invisibleRootItem()); |
482 mAlarmTimeItem->setContentWidgetData( |
566 mAlarmTimeItem->setContentWidgetData( |
515 // Show the alarm days item. |
599 // Show the alarm days item. |
516 mAlarmDayItem = mAlarmEditorModel->appendDataFormItem( |
600 mAlarmDayItem = mAlarmEditorModel->appendDataFormItem( |
517 HbDataFormModelItem::ComboBoxItem, |
601 HbDataFormModelItem::ComboBoxItem, |
518 QString(hbTrId("txt_clk_setlabel_day")), |
602 QString(hbTrId("txt_clk_setlabel_day")), |
519 mAlarmEditorModel->invisibleRootItem()); |
603 mAlarmEditorModel->invisibleRootItem()); |
|
604 mAlarmEditorForm->addConnection( |
|
605 mAlarmDayItem, SIGNAL(currentIndexChanged(int)), |
|
606 this, SLOT(handleDayChanged(int))); |
520 |
607 |
521 // Add the alarm days beginning from the start of week. |
608 // Add the alarm days beginning from the start of week. |
522 QStringList alarmDays; |
609 QStringList alarmDays; |
523 sortAlarmDaysList(alarmDays); |
610 sortAlarmDaysList(alarmDays); |
524 |
611 |
551 "text", QString(hbTrId("txt_clk_setlabel_alarm_sound"))); |
638 "text", QString(hbTrId("txt_clk_setlabel_alarm_sound"))); |
552 |
639 |
553 if (AlarmVolumeOn == mAlarmInfo.volumeStatus) { |
640 if (AlarmVolumeOn == mAlarmInfo.volumeStatus) { |
554 mAlarmSoundItem->setContentWidgetData("checkState",Qt::Checked); |
641 mAlarmSoundItem->setContentWidgetData("checkState",Qt::Checked); |
555 } |
642 } |
556 mAlarmSoundItem->setContentWidgetData("objectName", "alarmaSound"); |
643 mAlarmSoundItem->setContentWidgetData("objectName", "alarmSound"); |
557 mAlarmEditorForm->addConnection( |
644 mAlarmEditorForm->addConnection( |
558 mAlarmSoundItem, SIGNAL(stateChanged(int)), |
645 mAlarmSoundItem, SIGNAL(stateChanged(int)), |
559 this,SLOT(handleAlarmSoundChanged(int))); |
646 this,SLOT(handleAlarmSoundChanged(int))); |
560 |
647 |
561 // Description. |
648 // Description. |
563 HbDataFormModelItem::TextItem, |
650 HbDataFormModelItem::TextItem, |
564 QString(hbTrId("txt_clk_formlabel_description")), |
651 QString(hbTrId("txt_clk_formlabel_description")), |
565 mAlarmEditorModel->invisibleRootItem()); |
652 mAlarmEditorModel->invisibleRootItem()); |
566 mAlarmDescription->setContentWidgetData("text", mAlarmInfo.alarmDesc); |
653 mAlarmDescription->setContentWidgetData("text", mAlarmInfo.alarmDesc); |
567 mAlarmDescription->setContentWidgetData("objectName", "alaramDescription"); |
654 mAlarmDescription->setContentWidgetData("objectName", "alaramDescription"); |
568 |
655 mAlarmEditorForm->addConnection( |
|
656 mAlarmDescription, SIGNAL(textChanged (const QString &)), |
|
657 this, SLOT(handleDescriptionChanged(const QString &))); |
|
658 |
|
659 OstTraceFunctionExit0( CLOCKALARMEDITOR_POPULATEMODELITEMS_EXIT ); |
569 } |
660 } |
570 |
661 |
571 /*! |
662 /*! |
572 Create the alarm info structure with desired values. |
663 Create the alarm info structure with desired values. |
573 If new alarm: fill with default values |
664 If new alarm: fill with default values |
574 else: fill with the values of the alram being editted. |
665 else: fill with the values of the alram being editted. |
575 */ |
666 */ |
576 void ClockAlarmEditor::initAlarmInfo() |
667 void ClockAlarmEditor::initAlarmInfo() |
577 { |
668 { |
|
669 OstTraceFunctionEntry0( CLOCKALARMEDITOR_INITALARMINFO_ENTRY ); |
578 // Fill default values for alarmInfo. |
670 // Fill default values for alarmInfo. |
579 mAlarmInfo.nextDueTime = getPreviousAlarmTime(); |
671 mAlarmInfo.nextDueTime = getPreviousAlarmTime(); |
580 mAlarmInfo.alarmDesc = |
672 mAlarmInfo.alarmDesc = |
581 hbTrId("txt_clk_formlabel_val_alarm"); |
673 hbTrId("txt_clk_formlabel_val_alarm"); |
582 mAlarmInfo.repeatType = Once; |
674 mAlarmInfo.repeatType = Once; |
600 // get the alarm details and fill it in mAlarmInfo. |
692 // get the alarm details and fill it in mAlarmInfo. |
601 if (mAlarmId) { |
693 if (mAlarmId) { |
602 mAlarmClient.getAlarmInfo(mAlarmId, mAlarmInfo); |
694 mAlarmClient.getAlarmInfo(mAlarmId, mAlarmInfo); |
603 mAlarmClient.deleteAlarm(mAlarmId); |
695 mAlarmClient.deleteAlarm(mAlarmId); |
604 } |
696 } |
|
697 |
|
698 // Set the value for previous alarm time. |
|
699 mOldAlarmTime = mAlarmInfo.nextDueTime; |
|
700 |
|
701 OstTraceFunctionExit0( CLOCKALARMEDITOR_INITALARMINFO_EXIT ); |
605 } |
702 } |
606 |
703 |
607 /*! |
704 /*! |
608 Sets the alarm to the alarm server. |
705 Sets the alarm to the alarm server. |
609 */ |
706 */ |
610 void ClockAlarmEditor::setAlarm( |
707 void ClockAlarmEditor::setAlarm( |
611 QString timeInfo, QString descInfo, int repeatType, int alarmDayIndex) |
708 QString timeInfo, QString descInfo, int repeatType, int alarmDayIndex) |
612 { |
709 { |
|
710 OstTraceFunctionEntry0( CLOCKALARMEDITOR_SETALARM_ENTRY ); |
613 QTime alarmTime; |
711 QTime alarmTime; |
614 AlarmInfo alarmInfo; |
712 AlarmInfo alarmInfo; |
615 |
713 |
616 // First the description. |
714 // First the description. |
617 alarmInfo.alarmDesc = descInfo; |
715 alarmInfo.alarmDesc = descInfo; |
653 displayRemainingTimeNote(alarmInfo); |
756 displayRemainingTimeNote(alarmInfo); |
654 } |
757 } |
655 |
758 |
656 // Save previous alarm time. |
759 // Save previous alarm time. |
657 setPreviosAlarmTime(alarmTime); |
760 setPreviosAlarmTime(alarmTime); |
|
761 OstTraceFunctionExit0( CLOCKALARMEDITOR_SETALARM_EXIT ); |
658 } |
762 } |
659 |
763 |
660 /*! |
764 /*! |
661 Gets the previous alarm time. |
765 Gets the previous alarm time. |
662 Fetches the time from cenrep. Default value is 09:00. |
766 Fetches the time from cenrep. Default value is 09:00. |
663 If there is an error in reading the cenrep the default time |
767 If there is an error in reading the cenrep the default time |
664 is returned. |
768 is returned. |
665 */ |
769 */ |
666 QTime ClockAlarmEditor::getPreviousAlarmTime() |
770 QTime ClockAlarmEditor::getPreviousAlarmTime() |
667 { |
771 { |
|
772 OstTraceFunctionEntry0( CLOCKALARMEDITOR_GETPREVIOUSALARMTIME_ENTRY ); |
668 QTime previousTime(9,0,0); |
773 QTime previousTime(9,0,0); |
669 |
774 |
670 // Read the initial values from the cenrep. |
775 // Read the initial values from the cenrep. |
671 QVariant value = mSettingsManager->readItemValue(*mPreviosAlarmTime); |
776 QVariant value = mSettingsManager->readItemValue(*mPreviosAlarmTime); |
672 |
777 |
675 |
780 |
676 if (ok) { |
781 if (ok) { |
677 previousTime.setHMS( |
782 previousTime.setHMS( |
678 alarmTimeMinutes / 60, alarmTimeMinutes % 60, 0); |
783 alarmTimeMinutes / 60, alarmTimeMinutes % 60, 0); |
679 |
784 |
|
785 OstTraceFunctionExit0( CLOCKALARMEDITOR_GETPREVIOUSALARMTIME_EXIT ); |
680 return previousTime; |
786 return previousTime; |
681 } |
787 } |
682 |
788 |
|
789 OstTraceFunctionExit0( DUP1_CLOCKALARMEDITOR_GETPREVIOUSALARMTIME_EXIT ); |
683 return previousTime; |
790 return previousTime; |
684 } |
791 } |
685 |
792 |
686 /*! |
793 /*! |
687 Saves the previous alarm time in cenrep. |
794 Saves the previous alarm time in cenrep. |
688 */ |
795 */ |
689 void ClockAlarmEditor::setPreviosAlarmTime(QTime time) |
796 void ClockAlarmEditor::setPreviosAlarmTime(QTime time) |
690 { |
797 { |
|
798 OstTraceFunctionEntry0( CLOCKALARMEDITOR_SETPREVIOSALARMTIME_ENTRY ); |
691 int alarmTimeMinutes = (time.hour() * 60) + (time.minute()); |
799 int alarmTimeMinutes = (time.hour() * 60) + (time.minute()); |
692 |
800 |
693 // Write the value to cenrep. |
801 // Write the value to cenrep. |
694 mSettingsManager->writeItemValue(*mPreviosAlarmTime, alarmTimeMinutes); |
802 mSettingsManager->writeItemValue(*mPreviosAlarmTime, alarmTimeMinutes); |
|
803 OstTraceFunctionExit0( CLOCKALARMEDITOR_SETPREVIOSALARMTIME_EXIT ); |
695 } |
804 } |
696 |
805 |
697 void ClockAlarmEditor::closeAlarmEditor() |
806 void ClockAlarmEditor::closeAlarmEditor() |
698 { |
807 { |
|
808 OstTraceFunctionEntry0( CLOCKALARMEDITOR_CLOSEALARMEDITOR_ENTRY ); |
699 // Remove the alarm editor. |
809 // Remove the alarm editor. |
700 HbMainWindow *window = hbInstance->allMainWindows().first(); |
810 HbMainWindow *window = hbInstance->allMainWindows().first(); |
701 window->removeView(mAlarmEditorView); |
811 window->removeView(mAlarmEditorView); |
702 deleteLater(); |
812 deleteLater(); |
|
813 OstTraceFunctionExit0( CLOCKALARMEDITOR_CLOSEALARMEDITOR_EXIT ); |
703 } |
814 } |
704 |
815 |
705 /*! |
816 /*! |
706 Displays DST rollover note |
817 Displays DST rollover note |
707 |
818 |
708 \param alarmInfo reference to alarm info |
819 \param alarmInfo reference to alarm info |
709 */ |
820 */ |
710 void ClockAlarmEditor::displayDSTRollOverNote(AlarmInfo& alarmInfo) |
821 void ClockAlarmEditor::displayDSTRollOverNote(AlarmInfo& alarmInfo) |
711 { |
822 { |
|
823 OstTraceFunctionEntry0( CLOCKALARMEDITOR_DISPLAYDSTROLLOVERNOTE_ENTRY ); |
712 |
824 |
713 QString alarmTime = alarmInfo.nextDueTime.toString(mTimeFormat); |
825 QString alarmTime = alarmInfo.nextDueTime.toString(mTimeFormat); |
714 QString dstRollOverText = |
826 QString dstRollOverText = |
715 hbTrId("txt_clock_dpopinfo_alarm_will_occur_at_1_after_au"); |
827 hbTrId("txt_clock_dpopinfo_alarm_will_occur_at_1_after_au"); |
716 QString displayText = dstRollOverText.arg(alarmTime); |
828 QString displayText = dstRollOverText.arg(alarmTime); |
717 // show the note |
829 // show the note |
718 launchDialog(displayText); |
830 launchDialog(displayText); |
|
831 OstTraceFunctionExit0( CLOCKALARMEDITOR_DISPLAYDSTROLLOVERNOTE_EXIT ); |
719 } |
832 } |
720 |
833 |
721 /*! |
834 /*! |
722 Displays remaining time note after saving the alarm |
835 Displays remaining time note after saving the alarm |
723 |
836 |
724 \param alarmInfo reference to alarm info |
837 \param alarmInfo reference to alarm info |
725 */ |
838 */ |
726 void ClockAlarmEditor::displayRemainingTimeNote(AlarmInfo& alarmInfo) |
839 void ClockAlarmEditor::displayRemainingTimeNote(AlarmInfo& alarmInfo) |
727 { |
840 { |
|
841 OstTraceFunctionEntry0( CLOCKALARMEDITOR_DISPLAYREMAININGTIMENOTE_ENTRY ); |
728 QDateTime currentDateTime= QDateTime::currentDateTime(); |
842 QDateTime currentDateTime= QDateTime::currentDateTime(); |
729 |
843 |
730 QTime alarmTime = alarmInfo.origAlarmTime; |
844 QTime alarmTime = alarmInfo.origAlarmTime; |
731 QDate alarmDate = alarmInfo.alarmDateTime; |
845 QDate alarmDate = alarmInfo.alarmDateTime; |
732 QDateTime alarmDateTime(alarmDate,alarmTime); |
846 QDateTime alarmDateTime(alarmDate,alarmTime); |
860 } |
974 } |
861 } |
975 } |
862 if (showDisplayText) { |
976 if (showDisplayText) { |
863 launchDialog(displayText); |
977 launchDialog(displayText); |
864 } |
978 } |
|
979 OstTraceFunctionExit0( CLOCKALARMEDITOR_DISPLAYREMAININGTIMENOTE_EXIT ); |
865 } |
980 } |
866 |
981 |
867 /*! |
982 /*! |
868 gets day text for the week day |
983 gets day text for the week day |
869 |
984 |
870 \param alarmDay for which the day text is required |
985 \param alarmDay for which the day text is required |
871 \param dayText week day's text in QString |
986 \param dayText week day's text in QString |
872 */ |
987 */ |
873 void ClockAlarmEditor::getDayText(int alarmDay,QString& dayText) |
988 void ClockAlarmEditor::getDayText(int alarmDay,QString& dayText) |
874 { |
989 { |
|
990 OstTraceFunctionEntry0( CLOCKALARMEDITOR_GETDAYTEXT_ENTRY ); |
|
991 QLocale qLocale; |
875 switch(alarmDay) { |
992 switch(alarmDay) { |
876 case 1:dayText.append(hbTrId("txt_clk_setlabel_val_monday")); |
993 case 1:dayText.append(qLocale.dayName(1)); |
877 break; |
994 break; |
878 case 2:dayText.append(hbTrId("txt_clk_setlabel_val_tuesday")); |
995 case 2:dayText.append(qLocale.dayName(2)); |
879 break; |
996 break; |
880 case 3:dayText.append(hbTrId("txt_clk_setlabel_val_wednesday")); |
997 case 3:dayText.append(qLocale.dayName(3)); |
881 break; |
998 break; |
882 case 4:dayText.append(hbTrId("txt_clk_setlabel_val_thursday")); |
999 case 4:dayText.append(qLocale.dayName(4)); |
883 break; |
1000 break; |
884 case 5:dayText.append(hbTrId("txt_clk_setlabel_val_friday")); |
1001 case 5:dayText.append(qLocale.dayName(5)); |
885 break; |
1002 break; |
886 case 6:dayText.append(hbTrId("txt_clk_setlabel_val_saturday")); |
1003 case 6:dayText.append(qLocale.dayName(6)); |
887 break; |
1004 break; |
888 case 7:dayText.append(hbTrId("txt_clk_setlabel_val_sunday")); |
1005 case 7:dayText.append(qLocale.dayName(7)); |
889 break; |
1006 break; |
890 default: |
1007 default: |
891 break; |
1008 break; |
892 } |
1009 } |
|
1010 OstTraceFunctionExit0( CLOCKALARMEDITOR_GETDAYTEXT_EXIT ); |
893 } |
1011 } |
894 /*! |
1012 /*! |
895 gets remaining seconds to the alarm time from current date time |
1013 gets remaining seconds to the alarm time from current date time |
896 |
1014 |
897 \param alarmDateTime reference to the alarm date time |
1015 \param alarmDateTime reference to the alarm date time |
898 */ |
1016 */ |
899 int ClockAlarmEditor::getRemainingSeconds(QDateTime& alarmDateTime) |
1017 int ClockAlarmEditor::getRemainingSeconds(QDateTime& alarmDateTime) |
900 { |
1018 { |
|
1019 OstTraceFunctionEntry0( CLOCKALARMEDITOR_GETREMAININGSECONDS_ENTRY ); |
901 QDateTime currentDateTime = QDateTime::currentDateTime(); |
1020 QDateTime currentDateTime = QDateTime::currentDateTime(); |
902 |
1021 |
903 int currentDateTimeSec = |
1022 int currentDateTimeSec = |
904 (currentDateTime.time().hour() * KOneHourInMinute * KOneMinuteInSecons) |
1023 (currentDateTime.time().hour() * KOneHourInMinute * KOneMinuteInSecons) |
905 + (currentDateTime.time().minute() * KOneMinuteInSecons) |
1024 + (currentDateTime.time().minute() * KOneMinuteInSecons) |
916 if (dayInterval) { |
1035 if (dayInterval) { |
917 alarmDateTimeSec += (dayInterval * KSecondsInOneDay); |
1036 alarmDateTimeSec += (dayInterval * KSecondsInOneDay); |
918 } |
1037 } |
919 |
1038 |
920 int remainingSeconds = alarmDateTimeSec - currentDateTimeSec; |
1039 int remainingSeconds = alarmDateTimeSec - currentDateTimeSec; |
|
1040 OstTraceFunctionExit0( CLOCKALARMEDITOR_GETREMAININGSECONDS_EXIT ); |
921 return remainingSeconds; |
1041 return remainingSeconds; |
922 } |
1042 } |
923 |
1043 |
924 /*! |
1044 /*! |
925 Launches the soft notification. |
1045 Launches the soft notification. |
926 */ |
1046 */ |
927 void ClockAlarmEditor::launchDialog(QString title, QString text) |
1047 void ClockAlarmEditor::launchDialog(QString title, QString text) |
928 { |
1048 { |
|
1049 OstTraceFunctionEntry0( CLOCKALARMEDITOR_LAUNCHDIALOG_ENTRY ); |
929 HbNotificationDialog *notificationDialog = new HbNotificationDialog(); |
1050 HbNotificationDialog *notificationDialog = new HbNotificationDialog(); |
930 notificationDialog->setTitle(title); |
1051 notificationDialog->setTitle(title); |
931 |
1052 |
932 if (!text.isNull()) { |
1053 if (!text.isNull()) { |
933 notificationDialog->setText(text); |
1054 notificationDialog->setText(text); |
934 } |
1055 } |
935 |
1056 |
936 notificationDialog->setTimeout(HbPopup::ConfirmationNoteTimeout); |
1057 notificationDialog->setTimeout(HbPopup::ConfirmationNoteTimeout); |
937 notificationDialog->show(); |
1058 notificationDialog->show(); |
|
1059 OstTraceFunctionExit0( CLOCKALARMEDITOR_LAUNCHDIALOG_EXIT ); |
938 } |
1060 } |
939 |
1061 |
940 /*! |
1062 /*! |
941 Sorts and appends alarm days on the basis of start of week. |
1063 Sorts and appends alarm days on the basis of start of week. |
942 */ |
1064 */ |
943 void ClockAlarmEditor::sortAlarmDaysList(QStringList& alarmDaysList) |
1065 void ClockAlarmEditor::sortAlarmDaysList(QStringList& alarmDaysList) |
944 |
1066 |
945 { |
1067 { |
|
1068 OstTraceFunctionEntry0( CLOCKALARMEDITOR_SORTALARMDAYSLIST_ENTRY ); |
946 for(int index=(mStartOfWeek + 1),j=KDaysInWeek;j!=0 ;index++,j--){ |
1069 for(int index=(mStartOfWeek + 1),j=KDaysInWeek;j!=0 ;index++,j--){ |
947 if(index > KDaysInWeek){ |
1070 if(index > KDaysInWeek){ |
948 index = index - KDaysInWeek; |
1071 index = index - KDaysInWeek; |
949 } |
1072 } |
950 QString alarmDayText; |
1073 QString alarmDayText; |
951 getDayText(index, alarmDayText ); |
1074 getDayText(index, alarmDayText ); |
952 alarmDaysList.append(alarmDayText); |
1075 alarmDaysList.append(alarmDayText); |
953 } |
1076 } |
|
1077 OstTraceFunctionExit0( CLOCKALARMEDITOR_SORTALARMDAYSLIST_EXIT ); |
954 } |
1078 } |
955 // End of file --Don't remove this. |
1079 // End of file --Don't remove this. |