177 hideAlarmList(false); |
165 hideAlarmList(false); |
178 mAlarmListModel->populateModel(); |
166 mAlarmListModel->populateModel(); |
179 } |
167 } |
180 } |
168 } |
181 |
169 |
|
170 mDayLabel = static_cast<HbLabel *> ( |
|
171 mDocLoader->findObject("dateLabel")); |
|
172 |
|
173 mPlaceLabel = static_cast<HbLabel *> ( |
|
174 mDocLoader->findObject("placeLabel")); |
|
175 |
|
176 |
|
177 |
|
178 mClockWidget = static_cast<ClockWidget*> ( |
|
179 mDocLoader->findObject(CLOCK_WIDGET)); |
|
180 |
|
181 // Update the date info. |
|
182 updateDateLabel(); |
|
183 // Update the place info. |
|
184 updatePlaceLabel(mTimezoneClient->timeUpdateOn()); |
|
185 // Update clock widget display. |
|
186 updateClockWidget(); |
|
187 |
|
188 // Connect to orientation change and load appropriate section. |
|
189 connect( |
|
190 window, SIGNAL(orientationChanged(Qt::Orientation)), |
|
191 this, SLOT(checkOrientationAndLoadSection(Qt::Orientation))); |
|
192 } |
|
193 |
|
194 /*! |
|
195 To defer the connects and initialization. To be done after the view is drawn. |
|
196 Should be called in the slot of view ready. |
|
197 */ |
|
198 void ClockMainView::setupAfterViewReady() |
|
199 { |
182 // Get the toolbar/menu actions. |
200 // Get the toolbar/menu actions. |
183 mRefreshMainView = static_cast<HbAction *> ( |
201 mRefreshMainView = static_cast<HbAction *> ( |
184 mDocLoader->findObject("alarmsAction")); |
202 mDocLoader->findObject("alarmsAction")); |
185 |
203 |
186 mRefreshMainView->setCheckable(true); |
204 mRefreshMainView->setCheckable(true); |
200 mDocLoader->findObject("newAlarmAction")); |
218 mDocLoader->findObject("newAlarmAction")); |
201 connect( |
219 connect( |
202 mAddNewAlarm, SIGNAL(triggered()), |
220 mAddNewAlarm, SIGNAL(triggered()), |
203 this, SLOT(addNewAlarm())); |
221 this, SLOT(addNewAlarm())); |
204 |
222 |
205 if (Qt::Vertical == currentOrienation) { |
|
206 // Remove toolbar item's texts as only icons are shown. |
|
207 // TODO to use text ids from ts file. |
|
208 mRefreshMainView->setText(tr("")); |
|
209 mDisplayWorldClockView->setText(tr("")); |
|
210 mAddNewAlarm->setText(""); |
|
211 } else if (Qt::Horizontal == currentOrienation) { |
|
212 // Display toolbar item's texts |
|
213 // TODO to use text ids from ts file. |
|
214 mRefreshMainView->setText(tr("Alarms")); |
|
215 mDisplayWorldClockView->setText(tr("World clock")); |
|
216 mAddNewAlarm->setText("New alarm"); |
|
217 } |
|
218 |
|
219 mSettingsAction = static_cast<HbAction *> ( |
223 mSettingsAction = static_cast<HbAction *> ( |
220 mDocLoader->findObject("settingsAction")); |
224 mDocLoader->findObject("settingsAction")); |
221 connect( |
225 connect( |
222 mSettingsAction, SIGNAL(triggered()), |
226 mSettingsAction, SIGNAL(triggered()), |
223 this, SLOT(openSettings())); |
227 this, SLOT(openSettings())); |
224 |
228 |
225 mDayLabel = static_cast<HbLabel *> ( |
229 // Connect the necessary timezone client call backs. |
226 mDocLoader->findObject("dateLabel")); |
230 connect( |
227 |
231 mTimezoneClient, SIGNAL(timechanged()), |
228 mPlaceLabel = static_cast<HbLabel *> ( |
232 this, SLOT(updateView())); |
229 mDocLoader->findObject("placeLabel")); |
233 connect( |
230 |
234 mTimezoneClient, SIGNAL(autoTimeUpdateChanged(int)), |
231 mClockWidget = static_cast<SkinnableClock *> ( |
235 this, SLOT(updatePlaceLabel(int))); |
232 mDocLoader->findObject("clockWidget")); |
236 connect( |
233 |
237 mTimezoneClient, SIGNAL(cityUpdated()), |
234 // Update the date info. |
238 this, SLOT(updatePlaceLabel())); |
235 updateDateLabel(); |
239 |
236 // Update the place info. |
|
237 updatePlaceLabel(); |
|
238 // Update clock widget display. |
|
239 updateClockWidget(); |
|
240 |
|
241 // Connect to orientation change and load appropriate section. |
|
242 connect( |
|
243 window, SIGNAL(orientationChanged(Qt::Orientation)), |
|
244 this, SLOT(checkOrientationAndLoadSection(Qt::Orientation))); |
|
245 |
|
246 qDebug("clock: ClockMainView::setupView() <--"); |
|
247 } |
240 } |
248 |
241 |
249 /*! |
242 /*! |
250 Slot which gets called for the status change of the alarm i.e for |
243 Slot which gets called for the status change of the alarm i.e for |
251 active/inactive. |
244 active/inactive. |
252 |
245 |
253 \param row contains the row number of the alarm in the alarm list |
246 \param row contains the row number of the alarm in the alarm list |
254 */ |
247 */ |
255 void ClockMainView::handleAlarmStatusChanged(int row) |
248 void ClockMainView::handleAlarmStatusChanged(int row) |
256 { |
249 { |
257 qDebug() << "clock: ClockMainView::handleAlarmStatusChanged -->"; |
250 AlarmInfo alarmInfo; |
258 |
251 |
259 // Get the data for the alarm. |
252 // Get the data for the alarm. |
260 QList<QVariant> alarmData = |
253 QList<QVariant> alarmData = |
261 mAlarmListModel->sourceModel()->index(row, 0).data( |
254 mAlarmListModel->sourceModel()->index(row, 0).data( |
262 AlarmDetails).toList(); |
255 AlarmDetails).toList(); |
263 int alarmStatus = alarmData.at(2).value<int>(); |
256 int alarmId = alarmData.at(0).value<int>(); |
|
257 |
|
258 mAlarmClient->getAlarmInfo(alarmId, alarmInfo); |
264 |
259 |
265 mSelectedItem = row; |
260 mSelectedItem = row; |
266 |
261 |
267 if (-1 < mSelectedItem) { |
262 if (-1 < mSelectedItem) { |
268 QList<QVariant> alarmData = |
263 QList<QVariant> alarmData = |
270 mSelectedItem, 0).data(AlarmDetails).toList(); |
265 mSelectedItem, 0).data(AlarmDetails).toList(); |
271 int alarmId = alarmData.at(0).value<int>(); |
266 int alarmId = alarmData.at(0).value<int>(); |
272 QString displayNote; |
267 QString displayNote; |
273 // Activate or deactivate the alarm depending on the alarm status. |
268 // Activate or deactivate the alarm depending on the alarm status. |
274 // Display the NotificationDialog with appropriate message. |
269 // Display the NotificationDialog with appropriate message. |
275 if (!alarmStatus) { |
270 if (Snoozed == alarmInfo.alarmState && Enabled == alarmInfo.alarmStatus |
|
271 && Once != alarmInfo.repeatType) { |
|
272 removeSnoozedAlarm(); |
|
273 displayNote.append(tr("Snoozed alarm removed")); |
|
274 }else if (Enabled == alarmInfo.alarmStatus) { |
276 mAlarmClient->toggleAlarmStatus(alarmId, Disabled); |
275 mAlarmClient->toggleAlarmStatus(alarmId, Disabled); |
277 displayNote.append(hbTrId("txt_clock_main_view_dpopinfo_alarm_deactivated")); |
276 displayNote.append( |
278 HbNotificationDialog::launchDialog(displayNote); |
277 hbTrId("txt_clock_main_view_dpopinfo_alarm_deactivated")); |
279 } else { |
278 } else { |
280 mAlarmClient->toggleAlarmStatus(alarmId, Enabled); |
279 mAlarmClient->toggleAlarmStatus(alarmId, Enabled); |
281 displayNote.append(hbTrId("txt_clock_main_view_dpopinfo_alarm_activated")); |
280 displayNote.append( |
282 HbNotificationDialog::launchDialog(displayNote); |
281 hbTrId("txt_clock_main_view_dpopinfo_alarm_activated")); |
283 } |
282 } |
|
283 |
|
284 HbNotificationDialog *dialog = new HbNotificationDialog(); |
|
285 dialog->setTitle(displayNote); |
|
286 dialog->setTimeout(HbPopup::ConfirmationNoteTimeout); |
|
287 dialog->show(); |
|
288 |
284 mSelectedItem = -1; |
289 mSelectedItem = -1; |
285 } |
290 } |
286 |
|
287 qDebug() << "clock: ClockMainView::handleAlarmStatusChanged <--"; |
|
288 } |
291 } |
289 |
292 |
290 /*! |
293 /*! |
291 Slot which gets called when `Alarm' action is triggered from the view |
294 Slot which gets called when `Alarm' action is triggered from the view |
292 toolbar. This is responsible for reloading the content of the main view. |
295 toolbar. This is responsible for reloading the content of the main view. |
293 */ |
296 */ |
294 void ClockMainView::refreshMainView() |
297 void ClockMainView::refreshMainView() |
295 { |
298 { |
296 qDebug() << "clock: ClockMainView::refreshMainView -->"; |
|
297 mRefreshMainView->setChecked(true); |
299 mRefreshMainView->setChecked(true); |
298 |
300 |
299 qDebug() << "clock: ClockMainView::refreshMainView <--"; |
|
300 } |
301 } |
301 |
302 |
302 /*! |
303 /*! |
303 Slot which gets called when `World clock' action is triggered from the view |
304 Slot which gets called when `World clock' action is triggered from the view |
304 toolbar. This is responsible for launching the world clock. |
305 toolbar. This is responsible for launching the world clock. |
305 */ |
306 */ |
306 void ClockMainView::displayWorldClockView() |
307 void ClockMainView::displayWorldClockView() |
307 { |
308 { |
308 qDebug() << "clock: ClockMainView::displayWorldClockView -->"; |
|
309 |
|
310 mAppControllerIf->switchToView(WorldClock); |
309 mAppControllerIf->switchToView(WorldClock); |
311 |
310 |
312 qDebug() << "clock: ClockMainView::displayWorldClockView <--"; |
|
313 } |
311 } |
314 |
312 |
315 /*! |
313 /*! |
316 Slot which gets called when `New alarm' action is triggered from the view |
314 Slot which gets called when `New alarm' action is triggered from the view |
317 toolbar. This is responsible for launching the editor to create a new alarm. |
315 toolbar. This is responsible for launching the editor to create a new alarm. |
318 */ |
316 */ |
319 void ClockMainView::addNewAlarm() |
317 void ClockMainView::addNewAlarm() |
320 { |
318 { |
321 qDebug() << "clock: ClockMainView::addNewAlarm -->"; |
319 ClockAlarmEditor *alarmEditor = new ClockAlarmEditor(*mAlarmClient); |
322 |
|
323 ClockAlarmEditor *alarmEditor = new ClockAlarmEditor(); |
|
324 alarmEditor->showAlarmEditor(); |
320 alarmEditor->showAlarmEditor(); |
325 |
|
326 connect( |
|
327 alarmEditor, SIGNAL(alarmSet()), |
|
328 this, SLOT(handleAlarmSet())); |
|
329 |
|
330 qDebug() << "clock: ClockMainView::addNewAlarm <--"; |
|
331 } |
321 } |
332 |
322 |
333 /*! |
323 /*! |
334 Slot which gets called when `Settings' action is triggered from the view |
324 Slot which gets called when `Settings' action is triggered from the view |
335 menu. This is responsible for launching the settings view. |
325 menu. This is responsible for launching the settings view. |
336 */ |
326 */ |
337 void ClockMainView::openSettings() |
327 void ClockMainView::openSettings() |
338 { |
328 { |
339 qDebug() << "clock: ClockMainView::openSettings -->"; |
|
340 |
|
341 // Create the settings view. |
329 // Create the settings view. |
342 ClockSettingsView *settingsView = new ClockSettingsView(this); |
330 ClockSettingsView *settingsView = new ClockSettingsView(this); |
343 settingsView->loadSettingsView(); |
331 settingsView->loadSettingsView(); |
344 |
|
345 qDebug() << "clock: ClockMainView::openSettings <--"; |
|
346 } |
332 } |
347 |
333 |
348 /*! |
334 /*! |
349 This slot handles the 'activated' signal of the alarm list. Opens the |
335 This slot handles the 'activated' signal of the alarm list. Opens the |
350 alarm editor to edit the alarm. |
336 alarm editor to edit the alarm. |
351 \param index the modelIndex in the list which has been tapped. |
337 \param index the modelIndex in the list which has been tapped. |
352 */ |
338 */ |
353 void ClockMainView::handleActivated(const QModelIndex &index) |
339 void ClockMainView::handleActivated(const QModelIndex &index) |
354 { |
340 { |
355 qDebug() << "clock: ClockMainView::handleActivated -->"; |
341 if(!mIsLongTop) {// Get the data for the alarm. |
356 |
342 int row = index.row(); |
357 // Get the data for the alarm. |
343 QList<QVariant> alarmData = |
358 int row = index.row(); |
344 mAlarmListModel->sourceModel()->index(row, 0).data( |
359 QList<QVariant> alarmData = |
345 AlarmDetails).toList(); |
360 mAlarmListModel->sourceModel()->index(row, 0).data( |
346 int alarmId = alarmData.at(0).value<int>(); |
361 AlarmDetails).toList(); |
347 |
362 int alarmId = alarmData.at(0).value<int>(); |
348 // Construct the alarm editor. |
363 |
349 ClockAlarmEditor *alarmEditor = new ClockAlarmEditor( |
364 // Construct the alarm editor. |
350 *mAlarmClient, alarmId); |
365 ClockAlarmEditor *alarmEditor = new ClockAlarmEditor(alarmId); |
351 alarmEditor->showAlarmEditor(); |
366 alarmEditor->showAlarmEditor(); |
352 } |
367 connect( |
|
368 alarmEditor, SIGNAL(alarmSet()), |
|
369 this, SLOT(handleAlarmSet())); |
|
370 |
|
371 qDebug() << "clock: ClockMainView::handleActivated <--"; |
|
372 } |
353 } |
373 |
354 |
374 /*! |
355 /*! |
375 This slot handles the 'longpressed' signal of the alarm list. Opens the |
356 This slot handles the 'longpressed' signal of the alarm list. Opens the |
376 context menu. |
357 context menu. |
396 |
376 |
397 mAlarmClient->getAlarmInfo(alarmId, alarmInfo); |
377 mAlarmClient->getAlarmInfo(alarmId, alarmInfo); |
398 |
378 |
399 // On long press we display item specific context menu. |
379 // On long press we display item specific context menu. |
400 HbMenu *itemContextMenu = new HbMenu(); |
380 HbMenu *itemContextMenu = new HbMenu(); |
|
381 connect( |
|
382 itemContextMenu,SIGNAL(aboutToClose()), |
|
383 this, SLOT(handleMenuClosed())); |
401 |
384 |
402 // Add the delete action to the context menu. |
385 // Add the delete action to the context menu. |
403 HbAction *deleteAction = itemContextMenu->addAction( |
386 mDeleteAction = itemContextMenu->addAction( |
404 hbTrId("txt_clk_main_view_menu_delete_alarm")); |
387 hbTrId("txt_clk_main_view_menu_delete_alarm")); |
405 connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteAlarm())); |
|
406 |
388 |
407 // Show the menu. |
389 // Show the menu. |
408 itemContextMenu->exec(coords); |
390 itemContextMenu->open(this, SLOT(selectedMenuAction(HbAction*))); |
409 |
391 itemContextMenu->setPreferredPos(coords); |
410 qDebug() << "clock: ClockMainView::handleLongPress <--"; |
|
411 } |
392 } |
412 |
393 |
413 /*! |
394 /*! |
414 This slot handles the deletion of the alarm from the server. |
395 This slot handles the deletion of the alarm from the server. |
415 |
396 |
416 */ |
397 */ |
417 void ClockMainView::deleteAlarm() |
398 void ClockMainView::deleteAlarm() |
418 { |
399 { |
419 qDebug() << "clock: ClockMainView::deleteAlarm -->"; |
|
420 |
|
421 if (-1 < mSelectedItem) { |
400 if (-1 < mSelectedItem) { |
422 // Get the data for the alarm. |
401 // Get the data for the alarm. |
423 QList<QVariant> alarmData = mAlarmListModel->sourceModel()-> |
402 QList<QVariant> alarmData = mAlarmListModel->sourceModel()-> |
424 index(mSelectedItem, 0).data(AlarmDetails).toList(); |
403 index(mSelectedItem, 0).data(AlarmDetails).toList(); |
425 int alarmId = alarmData.at(0).value<int>(); |
404 int alarmId = alarmData.at(0).value<int>(); |
426 mAlarmClient->deleteAlarm(alarmId); |
405 mAlarmClient->deleteAlarm(alarmId); |
427 mSelectedItem = -1; |
406 mSelectedItem = -1; |
428 } |
407 } |
429 |
408 } |
430 qDebug() << "clock: ClockMainView::deleteAlarm <--"; |
409 |
431 } |
410 /*! |
432 |
411 Deltes the snoozed alarm. |
433 /*! |
412 */ |
434 Updates the day and date in the day label. |
413 void ClockMainView::removeSnoozedAlarm() |
435 */ |
414 { |
436 void ClockMainView::updateDateLabel() |
415 if (-1 < mSelectedItem) { |
437 { |
416 // Get the data for the alarm. |
438 qDebug() << "clock: ClockMainView::updateDateLabel -->"; |
417 QList<QVariant> alarmData = mAlarmListModel->sourceModel()-> |
439 |
418 index(mSelectedItem, 0).data(AlarmDetails).toList(); |
440 // Get the current datetime. |
419 int alarmId = alarmData.at(0).value<int>(); |
441 QDateTime dateTime = QDateTime::currentDateTime(); |
420 mAlarmClient->deleteSnoozedAlarm(alarmId); |
442 // Get the day name. |
421 mSelectedItem = -1; |
443 QString dayName = dateTime.toString("dddd"); |
422 } |
444 // Get the date in correct format. |
423 } |
445 QString currentDate = mSettingsUtility->date(); |
424 |
446 // Construct the day + date string. |
425 void ClockMainView::updateView() |
447 QString dayDateString; |
426 { |
448 dayDateString+= dayName; |
427 // Update the place label. |
449 dayDateString += " "; |
428 updatePlaceLabel(mTimezoneClient->timeUpdateOn()); |
450 dayDateString += currentDate; |
429 // Update date label. |
451 |
430 updateDateLabel(); |
452 mDayLabel->setPlainText(dayDateString); |
431 // Update clock widget. |
453 |
432 updateClockWidget(); |
454 qDebug() << "clock: ClockMainView::updateDateLabel <--"; |
433 } |
455 } |
434 |
456 |
435 /*! |
457 /*! |
436 Slot which gets called for value change in auto time update in cenrep. |
458 Updates the zone info in the place label. |
437 |
459 */ |
438 \param autoTimeUpdate Value of auto time update. |
460 void ClockMainView::updatePlaceLabel() |
439 */ |
461 { |
440 void ClockMainView::updatePlaceLabel(int autoTimeUpdate) |
462 qDebug() << "clock: MainViewWidget::updateClockZoneInfo -->"; |
441 { |
463 |
442 if (-1 == autoTimeUpdate) { |
|
443 autoTimeUpdate = mTimezoneClient->timeUpdateOn(); |
|
444 } |
|
445 |
464 // Get the current zone info. |
446 // Get the current zone info. |
465 LocationInfo currentZoneInfo = mTimezoneClient->getCurrentZoneInfoL(); |
447 LocationInfo currentZoneInfo = mTimezoneClient->getCurrentZoneInfoL(); |
466 |
448 |
467 // Construct the GMT +/- X string. |
449 // Construct the GMT +/- X string. |
468 QString gmtOffset; |
450 QString gmtOffset; |
496 if (0 <= offsetInMinutes && offsetInMinutes < 10) { |
478 if (0 <= offsetInMinutes && offsetInMinutes < 10) { |
497 gmtOffset += tr("00"); |
479 gmtOffset += tr("00"); |
498 } else { |
480 } else { |
499 gmtOffset += QString::number(offsetInMinutes); |
481 gmtOffset += QString::number(offsetInMinutes); |
500 } |
482 } |
501 |
483 |
502 // Append space. |
484 // Append space. |
503 gmtOffset += tr(" "); |
485 gmtOffset += tr(" "); |
504 |
486 |
505 // Append GMT sting. |
487 // Append GMT sting. |
506 gmtOffset += hbTrId("txt_common_common_gmt"); |
488 gmtOffset += hbTrId("txt_common_common_gmt"); |
507 |
489 |
508 // Append space. |
490 // Append space. |
509 gmtOffset += tr(" "); |
491 gmtOffset += tr(" "); |
510 |
492 |
511 // Append DST info. |
493 // Append DST info. |
512 if (currentZoneInfo.dstOn) { |
494 if (currentZoneInfo.dstOn) { |
513 gmtOffset += hbTrId("txt_common_setlabel_dst"); |
495 gmtOffset += hbTrId("txt_common_setlabel_dst"); |
514 } |
496 } |
515 |
497 |
516 // Update the labels with the correct info. |
498 // Update the labels with the correct info. |
517 mPlaceLabel->clear(); |
499 mPlaceLabel->clear(); |
518 if (mTimezoneClient->timeUpdateOn()) { |
500 if(autoTimeUpdate) { |
519 mPlaceLabel->setPlainText( |
501 mPlaceLabel->setPlainText( |
520 currentZoneInfo.countryName + tr(" ") + gmtOffset); |
502 currentZoneInfo.countryName + tr(" ") + gmtOffset); |
521 } else { |
503 } else { |
522 mPlaceLabel->setPlainText( |
504 mPlaceLabel->setPlainText( |
523 currentZoneInfo.cityName + tr(", ") |
505 currentZoneInfo.cityName + tr(", ") |
524 + currentZoneInfo.countryName + tr(" ") + gmtOffset); |
506 + currentZoneInfo.countryName + tr(" ") + gmtOffset); |
525 } |
507 } |
526 |
|
527 qDebug() << "clock: MainViewWidget::updateDayDateInfo <--"; |
|
528 } |
|
529 |
|
530 /*! |
|
531 Updates the clock widget display. |
|
532 */ |
|
533 void ClockMainView::updateClockWidget() |
|
534 { |
|
535 qDebug() << "clock: ClockMainView::updateClockWidget -->"; |
|
536 |
|
537 mClockWidget->updateDisplay(true); |
|
538 |
|
539 qDebug() << "clock: ClockMainView::updateClockWidget <--"; |
|
540 } |
508 } |
541 |
509 |
542 /*! |
510 /*! |
543 Slot to either hide or show the alarmlist. |
511 Slot to either hide or show the alarmlist. |
544 */ |
512 */ |
545 void ClockMainView::handleAlarmListDisplay() |
513 void ClockMainView::handleAlarmListDisplay() |
546 { |
514 { |
547 qDebug() << "clock: ClockMainView::handleAlarmListDisplay -->"; |
|
548 |
|
549 // Get the list of pending clock alarms from server. |
515 // Get the list of pending clock alarms from server. |
550 QList<AlarmInfo> alarmInfoList; |
516 QList<AlarmInfo> alarmInfoList; |
551 QList<AlarmInfo> displayInfoList; |
517 QList<AlarmInfo> displayInfoList; |
552 AlarmInfo alarmInfo; |
518 AlarmInfo alarmInfo; |
553 mAlarmClient->getAlarmList(alarmInfoList); |
519 mAlarmClient->getAlarmList(alarmInfoList); |
565 0 == mAlarmListModel->sourceModel()->rowCount()) { |
531 0 == mAlarmListModel->sourceModel()->rowCount()) { |
566 hideAlarmList(true); |
532 hideAlarmList(true); |
567 } |
533 } |
568 } |
534 } |
569 |
535 |
570 qDebug() << "clock: ClockMainView::handleAlarmListDisplay <--"; |
|
571 } |
|
572 |
|
573 /*! |
|
574 Sets the model to the alarm list. |
|
575 */ |
|
576 void ClockMainView::setmodel() |
|
577 { |
|
578 qDebug() << "clock: ClockMainView::setmodel -->"; |
|
579 |
|
580 // Set the model. |
|
581 if (mAlarmList) { |
|
582 mAlarmList->setModel(mAlarmListModel->sourceModel()); |
|
583 ClockAlarmListItemPrototype *listItemPrototype = |
|
584 new ClockAlarmListItemPrototype(this); |
|
585 mAlarmList->setItemPrototype(listItemPrototype); |
|
586 mAlarmList->setLayoutName("layout-alarmlist"); |
|
587 } |
|
588 |
|
589 qDebug() << "clock: ClockMainView::setmodel <--"; |
|
590 } |
|
591 |
|
592 /*! |
|
593 Hides the alarmlist in the main view. |
|
594 |
|
595 \param hide 'true' if alarm list is to be hidden. |
|
596 */ |
|
597 void ClockMainView::hideAlarmList(bool hide) |
|
598 { |
|
599 qDebug() << "clock: ClockMainView::hideAlarmList -->"; |
|
600 |
|
601 if (hide) { |
|
602 mNoAlarmLabel->show(); |
|
603 mAlarmList->hide(); |
|
604 mHideAlarmList = true; |
|
605 } else { |
|
606 mAlarmList->show(); |
|
607 mNoAlarmLabel->hide(); |
|
608 mHideAlarmList = false; |
|
609 } |
|
610 |
|
611 qDebug() << "clock: ClockMainView::hideAlarmList <--"; |
|
612 } |
536 } |
613 |
537 |
614 /*! |
538 /*! |
615 Slot to check the orientation & load the appropriate section. |
539 Slot to check the orientation & load the appropriate section. |
616 |
540 |
617 \param orientation contains the current orientation of the window. |
541 \param orientation contains the current orientation of the window. |
618 */ |
542 */ |
619 void ClockMainView::checkOrientationAndLoadSection( |
543 void ClockMainView::checkOrientationAndLoadSection( |
620 Qt::Orientation orientation) |
544 Qt::Orientation orientation) |
621 { |
545 { |
622 qDebug() << "clock: ClockMainView::checkOrientationAndLoadSection -->"; |
|
623 |
|
624 bool success; |
546 bool success; |
625 // If horizontal, load the landscape section. |
547 // If horizontal, load the landscape section. |
626 if (Qt::Horizontal == orientation) { |
548 if (Qt::Horizontal == orientation) { |
627 mDocLoader->load( |
549 mDocLoader->load( |
628 CLOCK_MAIN_VIEW_DOCML, CLOCK_MAIN_VIEW_LANDSCAPE_SECTION, |
550 CLOCK_MAIN_VIEW_DOCML, CLOCK_MAIN_VIEW_LANDSCAPE_SECTION, |
629 &success); |
551 &success); |
630 |
|
631 // Display toolbar item's texts |
|
632 // TODO have to use text ids from ts file. |
|
633 mRefreshMainView->setText(tr("Alarms")); |
|
634 mDisplayWorldClockView->setText(tr("World clock")); |
|
635 mAddNewAlarm->setText("New alarm"); |
|
636 |
|
637 } else { |
552 } else { |
638 mDocLoader->load( |
553 mDocLoader->load( |
639 CLOCK_MAIN_VIEW_DOCML, CLOCK_MAIN_VIEW_PORTRAIT_SECTION, |
554 CLOCK_MAIN_VIEW_DOCML, CLOCK_MAIN_VIEW_PORTRAIT_SECTION, |
640 &success); |
555 &success); |
641 |
|
642 // Remove toolbar item's texts as only icons are shown. |
|
643 // TODO have to use text ids from ts file. |
|
644 mRefreshMainView->setText(tr("")); |
|
645 mDisplayWorldClockView->setText(tr("")); |
|
646 mAddNewAlarm->setText(""); |
|
647 } |
556 } |
648 |
557 |
649 if(success) { |
558 if(success) { |
650 QList<AlarmInfo> alarmInfoList; |
559 QList<AlarmInfo> alarmInfoList; |
651 // Get the list of all clock alarms. |
560 // Get the list of all clock alarms. |
654 hideAlarmList(true); |
563 hideAlarmList(true); |
655 } else { |
564 } else { |
656 hideAlarmList(false); |
565 hideAlarmList(false); |
657 } |
566 } |
658 } |
567 } |
659 |
568 } |
660 qDebug() << "clock: ClockMainView::checkOrientationAndLoadSection <--"; |
569 |
|
570 /*! |
|
571 Slot to handle context menu actions. |
|
572 */ |
|
573 void ClockMainView::selectedMenuAction(HbAction *action) |
|
574 { |
|
575 if (action == mDeleteAction) { |
|
576 deleteAlarm(); |
|
577 } |
|
578 } |
|
579 |
|
580 /*! |
|
581 Slot to handle the context menu closed. |
|
582 */ |
|
583 void ClockMainView::handleMenuClosed() |
|
584 { |
|
585 mIsLongTop = false; |
|
586 } |
|
587 /*! |
|
588 Sets the model to the alarm list. |
|
589 */ |
|
590 void ClockMainView::setmodel() |
|
591 { |
|
592 // Set the model. |
|
593 if (mAlarmList) { |
|
594 mAlarmList->setModel(mAlarmListModel->sourceModel()); |
|
595 ClockAlarmListItemPrototype *listItemPrototype = |
|
596 new ClockAlarmListItemPrototype(); |
|
597 connect( |
|
598 listItemPrototype, SIGNAL(alarmStatusHasChanged(int)), |
|
599 this, SLOT(handleAlarmStatusChanged(int))); |
|
600 mAlarmList->setItemPrototype(listItemPrototype); |
|
601 mAlarmList->setLayoutName("layout-alarmlist"); |
|
602 } |
|
603 |
|
604 } |
|
605 |
|
606 /*! |
|
607 Hides the alarmlist in the main view. |
|
608 |
|
609 \param hide 'true' if alarm list is to be hidden. |
|
610 */ |
|
611 void ClockMainView::hideAlarmList(bool hide) |
|
612 { |
|
613 if (hide) { |
|
614 mNoAlarmLabel->show(); |
|
615 mAlarmList->hide(); |
|
616 mHideAlarmList = true; |
|
617 } else { |
|
618 mAlarmList->show(); |
|
619 mNoAlarmLabel->hide(); |
|
620 mHideAlarmList = false; |
|
621 } |
|
622 } |
|
623 |
|
624 /*! |
|
625 Updates the day and date in the day label. |
|
626 */ |
|
627 void ClockMainView::updateDateLabel() |
|
628 { |
|
629 // Get the current datetime. |
|
630 QDateTime dateTime = QDateTime::currentDateTime(); |
|
631 // Get the day name. |
|
632 QString dayName = dateTime.toString("ddd"); |
|
633 // Get the date in correct format. |
|
634 QString currentDate = mSettingsUtility->date(); |
|
635 // Construct the day + date string. |
|
636 QString dayDateString; |
|
637 dayDateString+= dayName; |
|
638 dayDateString += " "; |
|
639 dayDateString += currentDate; |
|
640 |
|
641 mDayLabel->setPlainText(dayDateString); |
|
642 } |
|
643 |
|
644 /*! |
|
645 Updates the zone info in the place label. |
|
646 */ |
|
647 /*void ClockMainView::updatePlaceLabel() |
|
648 { |
|
649 updatePlaceLabel(mTimezoneClient->timeUpdateOn()); |
|
650 }*/ |
|
651 |
|
652 /*! |
|
653 Updates the clock widget display. |
|
654 */ |
|
655 void ClockMainView::updateClockWidget() |
|
656 { |
|
657 mClockWidget->updateTime(); |
661 } |
658 } |
662 |
659 |
663 // End of file --Don't remove. |
660 // End of file --Don't remove. |