119 } |
121 } |
120 displayInfoList.append(alarmInfo); |
122 displayInfoList.append(alarmInfo); |
121 } |
123 } |
122 int alarmCount = displayInfoList.count(); |
124 int alarmCount = displayInfoList.count(); |
123 |
125 |
124 |
|
125 connect( |
|
126 mTimezoneClient, SIGNAL(timechanged()), |
|
127 this, SLOT(updatePlaceLabel())); |
|
128 connect( |
|
129 mTimezoneClient, SIGNAL(timechanged()), |
|
130 this, SLOT(updateDateLabel())); |
|
131 connect( |
|
132 mTimezoneClient, SIGNAL(timechanged()), |
|
133 this, SLOT(updateClockWidget())); |
|
134 |
|
135 HbMainWindow *window = hbInstance->allMainWindows().first(); |
126 HbMainWindow *window = hbInstance->allMainWindows().first(); |
136 |
127 |
137 bool loadSuccess = false; |
128 bool loadSuccess = false; |
138 Qt::Orientation currentOrienation = window->orientation(); |
129 Qt::Orientation currentOrienation = window->orientation(); |
|
130 |
|
131 // Get the dividers. |
|
132 mHorizontalDivider = static_cast<HbLabel *> ( |
|
133 mDocLoader->findObject("horizontalDivider")); |
|
134 mVerticalDivider = static_cast<HbLabel *> ( |
|
135 mDocLoader->findObject("verticalDivider")); |
139 |
136 |
140 // Get the "No alarm set" label. |
137 // Get the "No alarm set" label. |
141 mNoAlarmLabel = qobject_cast<HbLabel *> ( |
138 mNoAlarmLabel = qobject_cast<HbLabel *> ( |
142 mDocLoader->findWidget(CLOCK_NOALARMLABEL)); |
139 mDocLoader->findWidget(CLOCK_NOALARMLABEL)); |
143 |
140 |
153 mAlarmList, |
150 mAlarmList, |
154 SIGNAL(longPressed(HbAbstractViewItem*, const QPointF&)), |
151 SIGNAL(longPressed(HbAbstractViewItem*, const QPointF&)), |
155 this, |
152 this, |
156 SLOT(handleLongPress(HbAbstractViewItem*, const QPointF&))); |
153 SLOT(handleLongPress(HbAbstractViewItem*, const QPointF&))); |
157 |
154 |
158 HbStyleLoader::registerFilePath(CLOCK_VIEWS_STYLE_PATH); |
155 HbStyleLoader::registerFilePath(":/style/clockalarmlistitemprototype.css"); |
|
156 HbStyleLoader::registerFilePath( |
|
157 ":/style/clockalarmlistitemprototype.widgetml"); |
|
158 HbStyleLoader::registerFilePath( |
|
159 ":/style/clockalarmlistitemprototype_color.css"); |
159 setmodel(); |
160 setmodel(); |
160 |
161 |
161 // Load the correct section based on orientation. |
162 // Load the correct section based on orientation. |
162 if (Qt::Vertical == currentOrienation) { |
163 if (Qt::Vertical == currentOrienation) { |
163 mDocLoader->load( |
164 mDocLoader->load( |
164 CLOCK_MAIN_VIEW_DOCML, |
165 CLOCK_MAIN_VIEW_DOCML, |
165 CLOCK_MAIN_VIEW_PORTRAIT_SECTION, |
166 CLOCK_MAIN_VIEW_PORTRAIT_SECTION, |
166 &loadSuccess); |
167 &loadSuccess); |
|
168 mHorizontalDivider->setVisible(true); |
|
169 mVerticalDivider->setVisible(false); |
167 } else { |
170 } else { |
168 mDocLoader->load( |
171 mDocLoader->load( |
169 CLOCK_MAIN_VIEW_DOCML, |
172 CLOCK_MAIN_VIEW_DOCML, |
170 CLOCK_MAIN_VIEW_LANDSCAPE_SECTION, |
173 CLOCK_MAIN_VIEW_LANDSCAPE_SECTION, |
171 &loadSuccess); |
174 &loadSuccess); |
|
175 mHorizontalDivider->setVisible(false); |
|
176 mVerticalDivider->setVisible(true); |
172 } |
177 } |
173 if (loadSuccess) { |
178 if (loadSuccess) { |
174 if (0 == alarmCount) { |
179 if (0 == alarmCount) { |
175 hideAlarmList(true); |
180 hideAlarmList(true); |
176 } else { |
181 } else { |
177 hideAlarmList(false); |
182 hideAlarmList(false); |
178 mAlarmListModel->populateModel(); |
183 mAlarmListModel->populateModel(); |
179 } |
184 } |
180 } |
185 } |
181 |
186 |
|
187 mDayLabel = static_cast<HbLabel *> (mDocLoader->findObject("dateLabel")); |
|
188 mPlaceLabel = static_cast<HbLabel *> (mDocLoader->findObject("placeLabel")); |
|
189 mClockWidget = static_cast<ClockWidget*> ( |
|
190 mDocLoader->findObject(CLOCK_WIDGET)); |
|
191 |
|
192 // Update the date info. |
|
193 updateDateLabel(); |
|
194 // Update the place info. |
|
195 updatePlaceLabel(mTimezoneClient->timeUpdateOn()); |
|
196 // Update clock widget display. |
|
197 updateClockWidget(); |
|
198 |
|
199 // Connect to orientation change and load appropriate section. |
|
200 connect( |
|
201 window, SIGNAL(orientationChanged(Qt::Orientation)), |
|
202 this, SLOT(checkOrientationAndLoadSection(Qt::Orientation))); |
|
203 |
|
204 // Get a pointer to activity Manager |
|
205 HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager(); |
|
206 |
|
207 // clean up any previous versions of this activity from the activity manager. |
|
208 // ignore return value as the first boot would always return a false |
|
209 // bool declared on for debugging purpose |
|
210 bool ok = activityManager->removeActivity(clockMainView); |
|
211 |
|
212 // connect for the aboutToQuit events on application Exit as to call saveActivity |
|
213 connect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity())); |
|
214 |
|
215 } |
|
216 |
|
217 /*! |
|
218 To defer the connects and initialization. To be done after the view is drawn. |
|
219 Should be called in the slot of view ready. |
|
220 */ |
|
221 void ClockMainView::setupAfterViewReady() |
|
222 { |
182 // Get the toolbar/menu actions. |
223 // Get the toolbar/menu actions. |
183 mRefreshMainView = static_cast<HbAction *> ( |
224 mRefreshMainView = static_cast<HbAction *> ( |
184 mDocLoader->findObject("alarmsAction")); |
225 mDocLoader->findObject("alarmsAction")); |
185 |
226 |
186 mRefreshMainView->setCheckable(true); |
227 mRefreshMainView->setCheckable(true); |
200 mDocLoader->findObject("newAlarmAction")); |
241 mDocLoader->findObject("newAlarmAction")); |
201 connect( |
242 connect( |
202 mAddNewAlarm, SIGNAL(triggered()), |
243 mAddNewAlarm, SIGNAL(triggered()), |
203 this, SLOT(addNewAlarm())); |
244 this, SLOT(addNewAlarm())); |
204 |
245 |
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 *> ( |
246 mSettingsAction = static_cast<HbAction *> ( |
220 mDocLoader->findObject("settingsAction")); |
247 mDocLoader->findObject("settingsAction")); |
221 connect( |
248 connect( |
222 mSettingsAction, SIGNAL(triggered()), |
249 mSettingsAction, SIGNAL(triggered()), |
223 this, SLOT(openSettings())); |
250 this, SLOT(openSettings())); |
224 |
251 |
225 mDayLabel = static_cast<HbLabel *> ( |
252 // Connect the necessary timezone client call backs. |
226 mDocLoader->findObject("dateLabel")); |
253 connect( |
227 |
254 mTimezoneClient, SIGNAL(timechanged()), |
228 mPlaceLabel = static_cast<HbLabel *> ( |
255 this, SLOT(updateView())); |
229 mDocLoader->findObject("placeLabel")); |
256 connect( |
230 |
257 mTimezoneClient, SIGNAL(autoTimeUpdateChanged(int)), |
231 mClockWidget = static_cast<SkinnableClock *> ( |
258 this, SLOT(updatePlaceLabel(int))); |
232 mDocLoader->findObject("clockWidget")); |
259 connect( |
233 |
260 mTimezoneClient, SIGNAL(cityUpdated()), |
234 // Update the date info. |
261 this, SLOT(updatePlaceLabel())); |
235 updateDateLabel(); |
262 |
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 } |
263 } |
248 |
264 |
249 /*! |
265 /*! |
250 Slot which gets called for the status change of the alarm i.e for |
266 Slot which gets called for the status change of the alarm i.e for |
251 active/inactive. |
267 active/inactive. |
252 |
268 |
253 \param row contains the row number of the alarm in the alarm list |
269 \param row contains the row number of the alarm in the alarm list |
254 */ |
270 */ |
255 void ClockMainView::handleAlarmStatusChanged(int row) |
271 void ClockMainView::handleAlarmStatusChanged(int row) |
256 { |
272 { |
257 qDebug() << "clock: ClockMainView::handleAlarmStatusChanged -->"; |
273 AlarmInfo alarmInfo; |
258 |
274 |
259 // Get the data for the alarm. |
275 // Get the data for the alarm. |
260 QList<QVariant> alarmData = |
276 QList<QVariant> alarmData = |
261 mAlarmListModel->sourceModel()->index(row, 0).data( |
277 mAlarmListModel->sourceModel()->index(row, 0).data( |
262 AlarmDetails).toList(); |
278 AlarmDetails).toList(); |
263 int alarmStatus = alarmData.at(2).value<int>(); |
279 int alarmId = alarmData.at(0).value<int>(); |
|
280 |
|
281 mAlarmClient->getAlarmInfo(alarmId, alarmInfo); |
264 |
282 |
265 mSelectedItem = row; |
283 mSelectedItem = row; |
266 |
284 |
267 if (-1 < mSelectedItem) { |
285 if (-1 < mSelectedItem) { |
268 QList<QVariant> alarmData = |
286 QList<QVariant> alarmData = |
270 mSelectedItem, 0).data(AlarmDetails).toList(); |
288 mSelectedItem, 0).data(AlarmDetails).toList(); |
271 int alarmId = alarmData.at(0).value<int>(); |
289 int alarmId = alarmData.at(0).value<int>(); |
272 QString displayNote; |
290 QString displayNote; |
273 // Activate or deactivate the alarm depending on the alarm status. |
291 // Activate or deactivate the alarm depending on the alarm status. |
274 // Display the NotificationDialog with appropriate message. |
292 // Display the NotificationDialog with appropriate message. |
275 if (!alarmStatus) { |
293 if (Snoozed == alarmInfo.alarmState && Enabled == alarmInfo.alarmStatus |
|
294 && Once != alarmInfo.repeatType) { |
|
295 removeSnoozedAlarm(); |
|
296 displayNote.append(tr("Snoozed alarm removed")); |
|
297 }else if (Enabled == alarmInfo.alarmStatus) { |
276 mAlarmClient->toggleAlarmStatus(alarmId, Disabled); |
298 mAlarmClient->toggleAlarmStatus(alarmId, Disabled); |
277 displayNote.append(hbTrId("txt_clock_main_view_dpopinfo_alarm_deactivated")); |
299 displayNote.append( |
278 HbNotificationDialog::launchDialog(displayNote); |
300 hbTrId("txt_clock_main_view_dpopinfo_alarm_deactivated")); |
279 } else { |
301 } else { |
280 mAlarmClient->toggleAlarmStatus(alarmId, Enabled); |
302 mAlarmClient->toggleAlarmStatus(alarmId, Enabled); |
281 displayNote.append(hbTrId("txt_clock_main_view_dpopinfo_alarm_activated")); |
303 displayNote.append( |
282 HbNotificationDialog::launchDialog(displayNote); |
304 hbTrId("txt_clock_main_view_dpopinfo_alarm_activated")); |
283 } |
305 } |
|
306 |
|
307 HbNotificationDialog *dialog = new HbNotificationDialog(); |
|
308 dialog->setTitle(displayNote); |
|
309 dialog->setTimeout(HbPopup::ConfirmationNoteTimeout); |
|
310 dialog->show(); |
|
311 |
284 mSelectedItem = -1; |
312 mSelectedItem = -1; |
285 } |
313 } |
286 |
|
287 qDebug() << "clock: ClockMainView::handleAlarmStatusChanged <--"; |
|
288 } |
314 } |
289 |
315 |
290 /*! |
316 /*! |
291 Slot which gets called when `Alarm' action is triggered from the view |
317 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. |
318 toolbar. This is responsible for reloading the content of the main view. |
293 */ |
319 */ |
294 void ClockMainView::refreshMainView() |
320 void ClockMainView::refreshMainView() |
295 { |
321 { |
296 qDebug() << "clock: ClockMainView::refreshMainView -->"; |
|
297 mRefreshMainView->setChecked(true); |
322 mRefreshMainView->setChecked(true); |
298 |
323 |
299 qDebug() << "clock: ClockMainView::refreshMainView <--"; |
|
300 } |
324 } |
301 |
325 |
302 /*! |
326 /*! |
303 Slot which gets called when `World clock' action is triggered from the view |
327 Slot which gets called when `World clock' action is triggered from the view |
304 toolbar. This is responsible for launching the world clock. |
328 toolbar. This is responsible for launching the world clock. |
305 */ |
329 */ |
306 void ClockMainView::displayWorldClockView() |
330 void ClockMainView::displayWorldClockView() |
307 { |
331 { |
308 qDebug() << "clock: ClockMainView::displayWorldClockView -->"; |
|
309 |
|
310 mAppControllerIf->switchToView(WorldClock); |
332 mAppControllerIf->switchToView(WorldClock); |
311 |
333 // no need to capture the screenshot here as it's done in ClockViewManager::showView |
312 qDebug() << "clock: ClockMainView::displayWorldClockView <--"; |
334 |
313 } |
335 } |
314 |
336 |
315 /*! |
337 /*! |
316 Slot which gets called when `New alarm' action is triggered from the view |
338 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. |
339 toolbar. This is responsible for launching the editor to create a new alarm. |
318 */ |
340 */ |
319 void ClockMainView::addNewAlarm() |
341 void ClockMainView::addNewAlarm() |
320 { |
342 { |
321 qDebug() << "clock: ClockMainView::addNewAlarm -->"; |
343 ClockAlarmEditor *alarmEditor = new ClockAlarmEditor(*mAlarmClient); |
322 |
|
323 ClockAlarmEditor *alarmEditor = new ClockAlarmEditor(); |
|
324 alarmEditor->showAlarmEditor(); |
344 alarmEditor->showAlarmEditor(); |
325 |
345 // capture screenshot for future use, if application |
326 connect( |
346 // is exited/Quit from alarmEditor |
327 alarmEditor, SIGNAL(alarmSet()), |
347 captureScreenShot(true); |
328 this, SLOT(handleAlarmSet())); |
|
329 |
|
330 qDebug() << "clock: ClockMainView::addNewAlarm <--"; |
|
331 } |
348 } |
332 |
349 |
333 /*! |
350 /*! |
334 Slot which gets called when `Settings' action is triggered from the view |
351 Slot which gets called when `Settings' action is triggered from the view |
335 menu. This is responsible for launching the settings view. |
352 menu. This is responsible for launching the settings view. |
336 */ |
353 */ |
337 void ClockMainView::openSettings() |
354 void ClockMainView::openSettings() |
338 { |
355 { |
339 qDebug() << "clock: ClockMainView::openSettings -->"; |
|
340 |
|
341 // Create the settings view. |
356 // Create the settings view. |
342 ClockSettingsView *settingsView = new ClockSettingsView(this); |
357 ClockSettingsView *settingsView = new ClockSettingsView(this); |
343 settingsView->loadSettingsView(); |
358 settingsView->loadSettingsView(); |
344 |
359 // capture screenshot for future use, if application |
345 qDebug() << "clock: ClockMainView::openSettings <--"; |
360 // is exited/Quit from alarmEditor |
|
361 captureScreenShot(true); |
346 } |
362 } |
347 |
363 |
348 /*! |
364 /*! |
349 This slot handles the 'activated' signal of the alarm list. Opens the |
365 This slot handles the 'activated' signal of the alarm list. Opens the |
350 alarm editor to edit the alarm. |
366 alarm editor to edit the alarm. |
351 \param index the modelIndex in the list which has been tapped. |
367 \param index the modelIndex in the list which has been tapped. |
352 */ |
368 */ |
353 void ClockMainView::handleActivated(const QModelIndex &index) |
369 void ClockMainView::handleActivated(const QModelIndex &index) |
354 { |
370 { |
355 qDebug() << "clock: ClockMainView::handleActivated -->"; |
371 if(!mIsLongTop) {// Get the data for the alarm. |
356 |
372 int row = index.row(); |
357 // Get the data for the alarm. |
373 QList<QVariant> alarmData = |
358 int row = index.row(); |
374 mAlarmListModel->sourceModel()->index(row, 0).data( |
359 QList<QVariant> alarmData = |
375 AlarmDetails).toList(); |
360 mAlarmListModel->sourceModel()->index(row, 0).data( |
376 int alarmId = alarmData.at(0).value<int>(); |
361 AlarmDetails).toList(); |
377 |
362 int alarmId = alarmData.at(0).value<int>(); |
378 // Construct the alarm editor. |
363 |
379 ClockAlarmEditor *alarmEditor = new ClockAlarmEditor( |
364 // Construct the alarm editor. |
380 *mAlarmClient, alarmId); |
365 ClockAlarmEditor *alarmEditor = new ClockAlarmEditor(alarmId); |
381 alarmEditor->showAlarmEditor(); |
366 alarmEditor->showAlarmEditor(); |
382 // capture screenshot for future use, if application |
367 connect( |
383 // is exited/Quit from alarmEditor |
368 alarmEditor, SIGNAL(alarmSet()), |
384 captureScreenShot(true); |
369 this, SLOT(handleAlarmSet())); |
385 } |
370 |
|
371 qDebug() << "clock: ClockMainView::handleActivated <--"; |
|
372 } |
386 } |
373 |
387 |
374 /*! |
388 /*! |
375 This slot handles the 'longpressed' signal of the alarm list. Opens the |
389 This slot handles the 'longpressed' signal of the alarm list. Opens the |
376 context menu. |
390 context menu. |
396 |
409 |
397 mAlarmClient->getAlarmInfo(alarmId, alarmInfo); |
410 mAlarmClient->getAlarmInfo(alarmId, alarmInfo); |
398 |
411 |
399 // On long press we display item specific context menu. |
412 // On long press we display item specific context menu. |
400 HbMenu *itemContextMenu = new HbMenu(); |
413 HbMenu *itemContextMenu = new HbMenu(); |
|
414 connect( |
|
415 itemContextMenu,SIGNAL(aboutToClose()), |
|
416 this, SLOT(handleMenuClosed())); |
401 |
417 |
402 // Add the delete action to the context menu. |
418 // Add the delete action to the context menu. |
403 HbAction *deleteAction = itemContextMenu->addAction( |
419 mDeleteAction = itemContextMenu->addAction( |
404 hbTrId("txt_clk_main_view_menu_delete_alarm")); |
420 hbTrId("txt_clk_main_view_menu_delete_alarm")); |
405 connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteAlarm())); |
|
406 |
421 |
407 // Show the menu. |
422 // Show the menu. |
408 itemContextMenu->exec(coords); |
423 itemContextMenu->open(this, SLOT(selectedMenuAction(HbAction*))); |
409 |
424 itemContextMenu->setPreferredPos(coords); |
410 qDebug() << "clock: ClockMainView::handleLongPress <--"; |
425 itemContextMenu->setAttribute(Qt::WA_DeleteOnClose, true ); |
|
426 |
411 } |
427 } |
412 |
428 |
413 /*! |
429 /*! |
414 This slot handles the deletion of the alarm from the server. |
430 This slot handles the deletion of the alarm from the server. |
415 |
431 |
416 */ |
432 */ |
417 void ClockMainView::deleteAlarm() |
433 void ClockMainView::deleteAlarm() |
418 { |
434 { |
419 qDebug() << "clock: ClockMainView::deleteAlarm -->"; |
|
420 |
|
421 if (-1 < mSelectedItem) { |
435 if (-1 < mSelectedItem) { |
422 // Get the data for the alarm. |
436 // Get the data for the alarm. |
423 QList<QVariant> alarmData = mAlarmListModel->sourceModel()-> |
437 QList<QVariant> alarmData = mAlarmListModel->sourceModel()-> |
424 index(mSelectedItem, 0).data(AlarmDetails).toList(); |
438 index(mSelectedItem, 0).data(AlarmDetails).toList(); |
425 int alarmId = alarmData.at(0).value<int>(); |
439 int alarmId = alarmData.at(0).value<int>(); |
426 mAlarmClient->deleteAlarm(alarmId); |
440 mAlarmClient->deleteAlarm(alarmId); |
427 mSelectedItem = -1; |
441 mSelectedItem = -1; |
428 } |
442 } |
429 |
443 } |
430 qDebug() << "clock: ClockMainView::deleteAlarm <--"; |
444 |
431 } |
445 /*! |
432 |
446 Deltes the snoozed alarm. |
433 /*! |
447 */ |
434 Updates the day and date in the day label. |
448 void ClockMainView::removeSnoozedAlarm() |
435 */ |
449 { |
436 void ClockMainView::updateDateLabel() |
450 if (-1 < mSelectedItem) { |
437 { |
451 // Get the data for the alarm. |
438 qDebug() << "clock: ClockMainView::updateDateLabel -->"; |
452 QList<QVariant> alarmData = mAlarmListModel->sourceModel()-> |
439 |
453 index(mSelectedItem, 0).data(AlarmDetails).toList(); |
440 // Get the current datetime. |
454 int alarmId = alarmData.at(0).value<int>(); |
441 QDateTime dateTime = QDateTime::currentDateTime(); |
455 mAlarmClient->deleteSnoozedAlarm(alarmId); |
442 // Get the day name. |
456 mSelectedItem = -1; |
443 QString dayName = dateTime.toString("dddd"); |
457 } |
444 // Get the date in correct format. |
458 } |
445 QString currentDate = mSettingsUtility->date(); |
459 |
446 // Construct the day + date string. |
460 void ClockMainView::updateView() |
447 QString dayDateString; |
461 { |
448 dayDateString+= dayName; |
462 // Update the place label. |
449 dayDateString += " "; |
463 updatePlaceLabel(mTimezoneClient->timeUpdateOn()); |
450 dayDateString += currentDate; |
464 // Update date label. |
451 |
465 updateDateLabel(); |
452 mDayLabel->setPlainText(dayDateString); |
466 // Update clock widget. |
453 |
467 updateClockWidget(); |
454 qDebug() << "clock: ClockMainView::updateDateLabel <--"; |
468 } |
455 } |
469 |
456 |
470 /*! |
457 /*! |
471 Slot which gets called for value change in auto time update in cenrep. |
458 Updates the zone info in the place label. |
472 |
459 */ |
473 \param autoTimeUpdate Value of auto time update. |
460 void ClockMainView::updatePlaceLabel() |
474 */ |
461 { |
475 void ClockMainView::updatePlaceLabel(int autoTimeUpdate) |
462 qDebug() << "clock: MainViewWidget::updateClockZoneInfo -->"; |
476 { |
463 |
477 if (-1 == autoTimeUpdate) { |
|
478 autoTimeUpdate = mTimezoneClient->timeUpdateOn(); |
|
479 } |
|
480 |
464 // Get the current zone info. |
481 // Get the current zone info. |
465 LocationInfo currentZoneInfo = mTimezoneClient->getCurrentZoneInfoL(); |
482 LocationInfo currentZoneInfo = mTimezoneClient->getCurrentZoneInfoL(); |
466 |
483 |
467 // Construct the GMT +/- X string. |
484 // Construct the GMT +/- X string. |
468 QString gmtOffset; |
485 QString gmtOffset; |
496 if (0 <= offsetInMinutes && offsetInMinutes < 10) { |
513 if (0 <= offsetInMinutes && offsetInMinutes < 10) { |
497 gmtOffset += tr("00"); |
514 gmtOffset += tr("00"); |
498 } else { |
515 } else { |
499 gmtOffset += QString::number(offsetInMinutes); |
516 gmtOffset += QString::number(offsetInMinutes); |
500 } |
517 } |
501 |
518 |
502 // Append space. |
519 // Append space. |
503 gmtOffset += tr(" "); |
520 gmtOffset += tr(" "); |
504 |
521 |
505 // Append GMT sting. |
522 // Append GMT sting. |
506 gmtOffset += hbTrId("txt_common_common_gmt"); |
523 gmtOffset += hbTrId("txt_common_common_gmt"); |
507 |
524 |
508 // Append space. |
525 // Append space. |
509 gmtOffset += tr(" "); |
526 gmtOffset += tr(" "); |
510 |
527 |
511 // Append DST info. |
528 // Append DST info. |
512 if (currentZoneInfo.dstOn) { |
529 if (currentZoneInfo.dstOn) { |
513 gmtOffset += hbTrId("txt_common_setlabel_dst"); |
530 gmtOffset += hbTrId("txt_common_setlabel_dst"); |
514 } |
531 } |
515 |
532 |
516 // Update the labels with the correct info. |
533 // Update the labels with the correct info. |
517 mPlaceLabel->clear(); |
534 mPlaceLabel->clear(); |
518 if (mTimezoneClient->timeUpdateOn()) { |
535 if(autoTimeUpdate) { |
519 mPlaceLabel->setPlainText( |
536 mPlaceLabel->setPlainText( |
520 currentZoneInfo.countryName + tr(" ") + gmtOffset); |
537 currentZoneInfo.countryName + tr(" ") + gmtOffset); |
521 } else { |
538 } else { |
522 mPlaceLabel->setPlainText( |
539 mPlaceLabel->setPlainText( |
523 currentZoneInfo.cityName + tr(", ") |
540 currentZoneInfo.cityName + tr(", ") |
524 + currentZoneInfo.countryName + tr(" ") + gmtOffset); |
541 + currentZoneInfo.countryName + tr(" ") + gmtOffset); |
525 } |
542 } |
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 } |
543 } |
541 |
544 |
542 /*! |
545 /*! |
543 Slot to either hide or show the alarmlist. |
546 Slot to either hide or show the alarmlist. |
544 */ |
547 */ |
545 void ClockMainView::handleAlarmListDisplay() |
548 void ClockMainView::handleAlarmListDisplay() |
546 { |
549 { |
547 qDebug() << "clock: ClockMainView::handleAlarmListDisplay -->"; |
550 // alarmEditor closed reset the captured screenshot, current view is main view now |
548 |
551 captureScreenShot(false); |
549 // Get the list of pending clock alarms from server. |
552 // Get the list of pending clock alarms from server. |
550 QList<AlarmInfo> alarmInfoList; |
553 QList<AlarmInfo> alarmInfoList; |
551 QList<AlarmInfo> displayInfoList; |
554 QList<AlarmInfo> displayInfoList; |
552 AlarmInfo alarmInfo; |
555 AlarmInfo alarmInfo; |
553 mAlarmClient->getAlarmList(alarmInfoList); |
556 mAlarmClient->getAlarmList(alarmInfoList); |
565 0 == mAlarmListModel->sourceModel()->rowCount()) { |
568 0 == mAlarmListModel->sourceModel()->rowCount()) { |
566 hideAlarmList(true); |
569 hideAlarmList(true); |
567 } |
570 } |
568 } |
571 } |
569 |
572 |
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 } |
573 } |
613 |
574 |
614 /*! |
575 /*! |
615 Slot to check the orientation & load the appropriate section. |
576 Slot to check the orientation & load the appropriate section. |
616 |
577 |
617 \param orientation contains the current orientation of the window. |
578 \param orientation contains the current orientation of the window. |
618 */ |
579 */ |
619 void ClockMainView::checkOrientationAndLoadSection( |
580 void ClockMainView::checkOrientationAndLoadSection( |
620 Qt::Orientation orientation) |
581 Qt::Orientation orientation) |
621 { |
582 { |
622 qDebug() << "clock: ClockMainView::checkOrientationAndLoadSection -->"; |
|
623 |
|
624 bool success; |
583 bool success; |
625 // If horizontal, load the landscape section. |
584 // If horizontal, load the landscape section. |
626 if (Qt::Horizontal == orientation) { |
585 if (Qt::Horizontal == orientation) { |
627 mDocLoader->load( |
586 mDocLoader->load( |
628 CLOCK_MAIN_VIEW_DOCML, CLOCK_MAIN_VIEW_LANDSCAPE_SECTION, |
587 CLOCK_MAIN_VIEW_DOCML, CLOCK_MAIN_VIEW_LANDSCAPE_SECTION, |
629 &success); |
588 &success); |
630 |
589 mHorizontalDivider->setVisible(false); |
631 // Display toolbar item's texts |
590 mVerticalDivider->setVisible(true); |
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 { |
591 } else { |
638 mDocLoader->load( |
592 mDocLoader->load( |
639 CLOCK_MAIN_VIEW_DOCML, CLOCK_MAIN_VIEW_PORTRAIT_SECTION, |
593 CLOCK_MAIN_VIEW_DOCML, CLOCK_MAIN_VIEW_PORTRAIT_SECTION, |
640 &success); |
594 &success); |
641 |
595 mHorizontalDivider->setVisible(true); |
642 // Remove toolbar item's texts as only icons are shown. |
596 mVerticalDivider->setVisible(false); |
643 // TODO have to use text ids from ts file. |
|
644 mRefreshMainView->setText(tr("")); |
|
645 mDisplayWorldClockView->setText(tr("")); |
|
646 mAddNewAlarm->setText(""); |
|
647 } |
597 } |
648 |
598 |
649 if(success) { |
599 if(success) { |
650 QList<AlarmInfo> alarmInfoList; |
600 QList<AlarmInfo> alarmInfoList; |
651 // Get the list of all clock alarms. |
601 // Get the list of all clock alarms. |
654 hideAlarmList(true); |
604 hideAlarmList(true); |
655 } else { |
605 } else { |
656 hideAlarmList(false); |
606 hideAlarmList(false); |
657 } |
607 } |
658 } |
608 } |
659 |
609 } |
660 qDebug() << "clock: ClockMainView::checkOrientationAndLoadSection <--"; |
610 |
661 } |
611 /*! |
662 |
612 Slot to handle context menu actions. |
|
613 */ |
|
614 void ClockMainView::selectedMenuAction(HbAction *action) |
|
615 { |
|
616 if (action == mDeleteAction) { |
|
617 deleteAlarm(); |
|
618 } |
|
619 } |
|
620 |
|
621 /*! |
|
622 Slot to handle the context menu closed. |
|
623 */ |
|
624 void ClockMainView::handleMenuClosed() |
|
625 { |
|
626 mIsLongTop = false; |
|
627 } |
|
628 /*! |
|
629 Sets the model to the alarm list. |
|
630 */ |
|
631 void ClockMainView::setmodel() |
|
632 { |
|
633 // Set the model. |
|
634 if (mAlarmList) { |
|
635 mAlarmList->setModel(mAlarmListModel->sourceModel()); |
|
636 ClockAlarmListItemPrototype *listItemPrototype = |
|
637 new ClockAlarmListItemPrototype(); |
|
638 connect( |
|
639 listItemPrototype, SIGNAL(alarmStatusHasChanged(int)), |
|
640 this, SLOT(handleAlarmStatusChanged(int))); |
|
641 mAlarmList->setItemPrototype(listItemPrototype); |
|
642 mAlarmList->setLayoutName("layout-alarmlist"); |
|
643 } |
|
644 |
|
645 } |
|
646 |
|
647 /*! |
|
648 Hides the alarmlist in the main view. |
|
649 |
|
650 \param hide 'true' if alarm list is to be hidden. |
|
651 */ |
|
652 void ClockMainView::hideAlarmList(bool hide) |
|
653 { |
|
654 if (hide) { |
|
655 mNoAlarmLabel->show(); |
|
656 mAlarmList->hide(); |
|
657 mHideAlarmList = true; |
|
658 } else { |
|
659 mAlarmList->show(); |
|
660 mNoAlarmLabel->hide(); |
|
661 mHideAlarmList = false; |
|
662 } |
|
663 } |
|
664 |
|
665 /*! |
|
666 Updates the day and date in the day label. |
|
667 */ |
|
668 void ClockMainView::updateDateLabel() |
|
669 { |
|
670 // Get the current datetime. |
|
671 QDateTime dateTime = QDateTime::currentDateTime(); |
|
672 // Get the day name. |
|
673 QString dayName = dateTime.toString("ddd"); |
|
674 // Get the date in correct format. |
|
675 QString currentDate = mSettingsUtility->date(); |
|
676 // Construct the day + date string. |
|
677 QString dayDateString; |
|
678 dayDateString+= dayName; |
|
679 dayDateString += " "; |
|
680 dayDateString += currentDate; |
|
681 |
|
682 mDayLabel->setPlainText(dayDateString); |
|
683 } |
|
684 |
|
685 /*! |
|
686 Updates the zone info in the place label. |
|
687 */ |
|
688 /*void ClockMainView::updatePlaceLabel() |
|
689 { |
|
690 updatePlaceLabel(mTimezoneClient->timeUpdateOn()); |
|
691 }*/ |
|
692 |
|
693 /*! |
|
694 Updates the clock widget display. |
|
695 */ |
|
696 void ClockMainView::updateClockWidget() |
|
697 { |
|
698 QStringList clockType; |
|
699 int index = mSettingsUtility->clockType(clockType); |
|
700 int zeroIndex(0); |
|
701 if(zeroIndex == index){ |
|
702 mClockWidget->setClockType(ClockWidget::ClockTypeDigital); |
|
703 } else { |
|
704 mClockWidget->setClockType(ClockWidget::ClockTypeAnalog); |
|
705 } |
|
706 |
|
707 QStringList timeFormat; |
|
708 |
|
709 if (zeroIndex == mSettingsUtility->timeFormat(timeFormat)) { |
|
710 mClockWidget->setTimeFormat(ClockWidget::TimeFormat24Hrs); |
|
711 } else { |
|
712 mClockWidget->setTimeFormat(ClockWidget::TimeFormat12Hrs); |
|
713 } |
|
714 |
|
715 mClockWidget->updateTime(); |
|
716 } |
|
717 |
|
718 /*! |
|
719 CaptureScreenShot captures screen shot |
|
720 \param captureScreenShot bool to indicate if screenshot needs to be captured |
|
721 */ |
|
722 void ClockMainView::captureScreenShot(bool captureScreenShot) |
|
723 { |
|
724 // check if screen shot needs to be captured |
|
725 if (captureScreenShot) { |
|
726 mScreenShot.clear(); |
|
727 mScreenShot.insert("screenshot", QPixmap::grabWidget(mainWindow(), mainWindow()->rect())); |
|
728 } |
|
729 mIsScreenShotCapruted = captureScreenShot; // set mIsScreenShotCapruted set validity of screenshot |
|
730 } |
|
731 |
|
732 /*! |
|
733 saveActivity saves main view as an activity |
|
734 */ |
|
735 void ClockMainView::saveActivity() |
|
736 { |
|
737 // Get a pointer to activity Manager |
|
738 HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager(); |
|
739 // check if a valid screenshot is already captured |
|
740 if (!mIsScreenShotCapruted) { |
|
741 mScreenShot.clear(); |
|
742 mScreenShot.insert("screenshot", QPixmap::grabWidget(mainWindow(), mainWindow()->rect())); |
|
743 } |
|
744 |
|
745 // save any data necessary to save the state |
|
746 QByteArray serializedActivity; |
|
747 QDataStream stream(&serializedActivity, QIODevice::WriteOnly | QIODevice::Append); |
|
748 stream << MainView; |
|
749 |
|
750 // add the activity to the activity manager |
|
751 bool ok = activityManager->addActivity(clockMainView, serializedActivity, mScreenShot); |
|
752 if ( !ok ) { |
|
753 qFatal("Add failed" ); |
|
754 } |
|
755 } |
663 // End of file --Don't remove. |
756 // End of file --Don't remove. |