clock/clockui/clockviews/src/clockmainview.cpp
changeset 57 bb2d3e476f29
parent 55 2c54b51f39c4
child 70 a5ed90760192
equal deleted inserted replaced
55:2c54b51f39c4 57:bb2d3e476f29
    24 #include <HbMenu>
    24 #include <HbMenu>
    25 #include <HbAction>
    25 #include <HbAction>
    26 #include <HbListView>
    26 #include <HbListView>
    27 #include <HbNotificationDialog>
    27 #include <HbNotificationDialog>
    28 #include <HbStyleLoader>
    28 #include <HbStyleLoader>
    29 #include <hbapplication> // hbapplication
    29 #include <HbColorScheme>
    30 #include <hbactivitymanager> // activity manager
    30 #include <HbApplication> // hbapplication
       
    31 #include <HbActivityManager> // activity manager
    31 
    32 
    32 // User includes
    33 // User includes
    33 #include "clockmainview.h"
    34 #include "clockmainview.h"
    34 #include "clockdocloader.h"
    35 #include "clockdocloader.h"
    35 #include "clockappcontrollerif.h"
    36 #include "clockappcontrollerif.h"
    40 #include "settingsutility.h"
    41 #include "settingsutility.h"
    41 #include "timezoneclient.h"
    42 #include "timezoneclient.h"
    42 #include "clockalarmlistitemprototype.h"
    43 #include "clockalarmlistitemprototype.h"
    43 #include "clockalarmlistmodel.h"
    44 #include "clockalarmlistmodel.h"
    44 #include "clockwidget.h"
    45 #include "clockwidget.h"
       
    46 #include "OstTraceDefinitions.h"
       
    47 #ifdef OST_TRACE_COMPILER_IN_USE
       
    48 #include "clockmainviewTraces.h"
       
    49 #endif
       
    50 
    45 
    51 
    46 /*!
    52 /*!
    47 	\class ClockMainView
    53 	\class ClockMainView
    48 
    54 
    49 	The main view of the clock application.
    55 	The main view of the clock application.
    59  mAlarmList(0),
    65  mAlarmList(0),
    60  mSelectedItem(-1),
    66  mSelectedItem(-1),
    61  mIsLongTop(false),
    67  mIsLongTop(false),
    62  mIsScreenShotCapruted(false)
    68  mIsScreenShotCapruted(false)
    63 {
    69 {
       
    70 	OstTraceFunctionEntry0( CLOCKMAINVIEW_CLOCKMAINVIEW_ENTRY );
    64 	// Nothing yet.
    71 	// Nothing yet.
       
    72 	OstTraceFunctionExit0( CLOCKMAINVIEW_CLOCKMAINVIEW_EXIT );
    65 }
    73 }
    66 
    74 
    67 /*!
    75 /*!
    68 	Destructor.
    76 	Destructor.
    69  */
    77  */
    70 ClockMainView::~ClockMainView()
    78 ClockMainView::~ClockMainView()
    71 {
    79 {
       
    80 	OstTraceFunctionEntry0( DUP1_CLOCKMAINVIEW_CLOCKMAINVIEW_ENTRY );
    72 	if (mDocLoader) {
    81 	if (mDocLoader) {
    73 		delete mDocLoader;
    82 		delete mDocLoader;
    74 		mDocLoader = 0;
    83 		mDocLoader = 0;
    75 	}
    84 	}
    76 	if (mAlarmListModel) {
    85 	if (mAlarmListModel) {
    82 	HbStyleLoader::unregisterFilePath(
    91 	HbStyleLoader::unregisterFilePath(
    83 			":/style/clockalarmlistitemprototype.widgetml");
    92 			":/style/clockalarmlistitemprototype.widgetml");
    84 	HbStyleLoader::unregisterFilePath(
    93 	HbStyleLoader::unregisterFilePath(
    85 			":/style/clockalarmlistitemprototype_color.css");
    94 			":/style/clockalarmlistitemprototype_color.css");
    86 
    95 
       
    96 	OstTraceFunctionExit0( DUP1_CLOCKMAINVIEW_CLOCKMAINVIEW_EXIT );
    87 }
    97 }
    88 
    98 
    89 /*!
    99 /*!
    90 	Called by the ClockViewManager after loading the view from the docml.
   100 	Called by the ClockViewManager after loading the view from the docml.
    91 	The initializaion/setup of the view is done here.
   101 	The initializaion/setup of the view is done here.
    94 	\param docLoader Pointer to ClockDocLoader object.
   104 	\param docLoader Pointer to ClockDocLoader object.
    95  */
   105  */
    96 void ClockMainView::setupView(
   106 void ClockMainView::setupView(
    97 		ClockAppControllerIf &controllerIf, ClockDocLoader *docLoader)
   107 		ClockAppControllerIf &controllerIf, ClockDocLoader *docLoader)
    98 {
   108 {
       
   109 	OstTraceFunctionEntry0( CLOCKMAINVIEW_SETUPVIEW_ENTRY );
    99 	mDocLoader = docLoader;
   110 	mDocLoader = docLoader;
   100 	mAppControllerIf = &controllerIf;
   111 	mAppControllerIf = &controllerIf;
   101 
   112 
   102 	mTimezoneClient = controllerIf.timezoneClient();
   113 	mTimezoneClient = controllerIf.timezoneClient();
   103 	mSettingsUtility = controllerIf.settingsUtility();
   114 	mSettingsUtility = controllerIf.settingsUtility();
   104 	mAlarmClient = controllerIf.alarmClient();
   115 	mAlarmClient = controllerIf.alarmClient();
       
   116 	
       
   117 	// Fetch the color group of the labels from the theme.
       
   118 	mLabelColorGroup = HbColorScheme::color("qtc_view_normal");
   105 
   119 
   106 	// Create the model.
   120 	// Create the model.
   107 	mAlarmListModel =  new ClockAlarmListModel(*mAppControllerIf, this);
   121 	mAlarmListModel =  new ClockAlarmListModel(*mAppControllerIf, this);
   108 	connect(
   122 	connect(
   109 			mAlarmListModel, SIGNAL(changeAlarmListDisplay()),
   123 			mAlarmListModel, SIGNAL(changeAlarmListDisplay()),
   135 				mDocLoader->findObject("verticalDivider"));
   149 				mDocLoader->findObject("verticalDivider"));
   136 
   150 
   137 	// Get the "No alarm set" label.
   151 	// Get the "No alarm set" label.
   138 	mNoAlarmLabel = qobject_cast<HbLabel *> (
   152 	mNoAlarmLabel = qobject_cast<HbLabel *> (
   139 			mDocLoader->findWidget(CLOCK_NOALARMLABEL));
   153 			mDocLoader->findWidget(CLOCK_NOALARMLABEL));
       
   154 	mNoAlarmLabel->setTextColor(mLabelColorGroup);
   140 
   155 
   141 	// Get the alarm's list.
   156 	// Get the alarm's list.
   142 	mAlarmList = qobject_cast<HbListView *> (
   157 	mAlarmList = qobject_cast<HbListView *> (
   143 			mDocLoader->findWidget(CLOCK_ALARMLIST));
   158 			mDocLoader->findWidget(CLOCK_ALARMLIST));
   144 
   159 
   183 			mAlarmListModel->populateModel();
   198 			mAlarmListModel->populateModel();
   184 		}
   199 		}
   185 	}
   200 	}
   186 
   201 
   187 	mDayLabel = static_cast<HbLabel *> (mDocLoader->findObject("dateLabel"));
   202 	mDayLabel = static_cast<HbLabel *> (mDocLoader->findObject("dateLabel"));
   188 	mPlaceLabel = static_cast<HbLabel *> (mDocLoader->findObject("placeLabel"));
   203 	mDayLabel->setTextColor(mLabelColorGroup);
       
   204 	mPlaceLabel = static_cast<HbLabel *> (mDocLoader->findObject("placetext"));
       
   205 	mPlaceLabel->setTextColor(mLabelColorGroup);
       
   206 	mDstIcon = static_cast<HbLabel *> (mDocLoader->findObject("dstIcon"));
   189 	mClockWidget = static_cast<ClockWidget*> (
   207 	mClockWidget = static_cast<ClockWidget*> (
   190 			mDocLoader->findObject(CLOCK_WIDGET));
   208 			mDocLoader->findObject(CLOCK_WIDGET));
   191 
   209 
   192 	// Update the date info.
   210 	// Update the date info.
   193 	updateDateLabel();
   211 	updateDateLabel();
   210     bool ok = activityManager->removeActivity(clockMainView);
   228     bool ok = activityManager->removeActivity(clockMainView);
   211 
   229 
   212 	// connect for the aboutToQuit events on application Exit as to call saveActivity
   230 	// connect for the aboutToQuit events on application Exit as to call saveActivity
   213     connect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity()));
   231     connect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity()));
   214 
   232 
       
   233     OstTraceFunctionExit0( CLOCKMAINVIEW_SETUPVIEW_EXIT );
   215 }
   234 }
   216 
   235 
   217 /*!
   236 /*!
   218 	To defer the connects and initialization. To be done after the view is drawn.
   237 	To defer the connects and initialization. To be done after the view is drawn.
   219 	Should be called in the slot of view ready.
   238 	Should be called in the slot of view ready.
   220  */
   239  */
   221 void ClockMainView::setupAfterViewReady()
   240 void ClockMainView::setupAfterViewReady()
   222 {
   241 {
       
   242 	OstTraceFunctionEntry0( CLOCKMAINVIEW_SETUPAFTERVIEWREADY_ENTRY );
   223 	// Get the toolbar/menu actions.
   243 	// Get the toolbar/menu actions.
   224 	mRefreshMainView = static_cast<HbAction *> (
   244 	mRefreshMainView = static_cast<HbAction *> (
   225 			mDocLoader->findObject("alarmsAction"));
   245 			mDocLoader->findObject("alarmsAction"));
   226 
   246 
   227 	mRefreshMainView->setCheckable(true);
   247 	mRefreshMainView->setCheckable(true);
   258 			this, SLOT(updatePlaceLabel(int)));
   278 			this, SLOT(updatePlaceLabel(int)));
   259 	connect(
   279 	connect(
   260 			mTimezoneClient, SIGNAL(cityUpdated()),
   280 			mTimezoneClient, SIGNAL(cityUpdated()),
   261 			this, SLOT(updatePlaceLabel()));
   281 			this, SLOT(updatePlaceLabel()));
   262 	
   282 	
       
   283 	OstTraceFunctionExit0( CLOCKMAINVIEW_SETUPAFTERVIEWREADY_EXIT );
   263 }
   284 }
   264 
   285 
   265 /*!
   286 /*!
   266 	Slot which gets called for the status change of the alarm i.e for
   287 	Slot which gets called for the status change of the alarm i.e for
   267 	active/inactive.
   288 	active/inactive.
   268 
   289 
   269 	\param row contains the row number of the alarm in the alarm list
   290 	\param row contains the row number of the alarm in the alarm list
   270  */
   291  */
   271 void ClockMainView::handleAlarmStatusChanged(int row)
   292 void ClockMainView::handleAlarmStatusChanged(int row)
   272 {
   293 {
       
   294 	OstTraceFunctionEntry0( CLOCKMAINVIEW_HANDLEALARMSTATUSCHANGED_ENTRY );
   273 	AlarmInfo alarmInfo;
   295 	AlarmInfo alarmInfo;
   274 
   296 
   275 	// Get the data for the alarm.
   297 	// Get the data for the alarm.
   276 	QList<QVariant> alarmData =
   298 	QList<QVariant> alarmData =
   277 			mAlarmListModel->sourceModel()->index(row, 0).data(
   299 			mAlarmListModel->sourceModel()->index(row, 0).data(
   309 		dialog->setTimeout(HbPopup::ConfirmationNoteTimeout);
   331 		dialog->setTimeout(HbPopup::ConfirmationNoteTimeout);
   310 		dialog->show();
   332 		dialog->show();
   311 
   333 
   312 		mSelectedItem = -1;
   334 		mSelectedItem = -1;
   313 	}
   335 	}
       
   336 	OstTraceFunctionExit0( CLOCKMAINVIEW_HANDLEALARMSTATUSCHANGED_EXIT );
   314 }
   337 }
   315 
   338 
   316 /*!
   339 /*!
   317 	Slot which gets called when `Alarm' action is triggered from the view
   340 	Slot which gets called when `Alarm' action is triggered from the view
   318 	toolbar. This is responsible for reloading the content of the main view.
   341 	toolbar. This is responsible for reloading the content of the main view.
   319  */
   342  */
   320 void ClockMainView::refreshMainView()
   343 void ClockMainView::refreshMainView()
   321 {
   344 {
       
   345 	OstTraceFunctionEntry0( CLOCKMAINVIEW_REFRESHMAINVIEW_ENTRY );
   322 	mRefreshMainView->setChecked(true);
   346 	mRefreshMainView->setChecked(true);
   323 
   347 
       
   348 	OstTraceFunctionExit0( CLOCKMAINVIEW_REFRESHMAINVIEW_EXIT );
   324 }
   349 }
   325 
   350 
   326 /*!
   351 /*!
   327 	Slot which gets called when `World clock' action is triggered from the view
   352 	Slot which gets called when `World clock' action is triggered from the view
   328 	toolbar. This is responsible for launching the world clock.
   353 	toolbar. This is responsible for launching the world clock.
   329  */
   354  */
   330 void ClockMainView::displayWorldClockView()
   355 void ClockMainView::displayWorldClockView()
   331 {
   356 {
       
   357 	OstTraceFunctionEntry0( CLOCKMAINVIEW_DISPLAYWORLDCLOCKVIEW_ENTRY );
   332 	mAppControllerIf->switchToView(WorldClock);
   358 	mAppControllerIf->switchToView(WorldClock);
   333 	// no need to capture the screenshot here as it's done in ClockViewManager::showView
   359 	// no need to capture the screenshot here as it's done in ClockViewManager::showView
   334 
   360 
       
   361 	OstTraceFunctionExit0( CLOCKMAINVIEW_DISPLAYWORLDCLOCKVIEW_EXIT );
   335 }
   362 }
   336 
   363 
   337 /*!
   364 /*!
   338 	Slot which gets called when `New alarm' action is triggered from the view
   365 	Slot which gets called when `New alarm' action is triggered from the view
   339 	toolbar. This is responsible for launching the editor to create a new alarm.
   366 	toolbar. This is responsible for launching the editor to create a new alarm.
   340  */
   367  */
   341 void ClockMainView::addNewAlarm()
   368 void ClockMainView::addNewAlarm()
   342 {
   369 {
       
   370 	OstTraceFunctionEntry0( CLOCKMAINVIEW_ADDNEWALARM_ENTRY );
   343 	ClockAlarmEditor *alarmEditor = new ClockAlarmEditor(*mAlarmClient);
   371 	ClockAlarmEditor *alarmEditor = new ClockAlarmEditor(*mAlarmClient);
   344 	alarmEditor->showAlarmEditor();
   372 	alarmEditor->showAlarmEditor();
   345 	// capture screenshot for future use, if application
   373 	// capture screenshot for future use, if application
   346 	// is exited/Quit from alarmEditor
   374 	// is exited/Quit from alarmEditor
   347 	captureScreenShot(true);
   375 	captureScreenShot(true);
       
   376 	OstTraceFunctionExit0( CLOCKMAINVIEW_ADDNEWALARM_EXIT );
   348 }
   377 }
   349 
   378 
   350 /*!
   379 /*!
   351 	Slot which gets called when `Settings' action is triggered from the view
   380 	Slot which gets called when `Settings' action is triggered from the view
   352 	menu. This is responsible for launching the settings view.
   381 	menu. This is responsible for launching the settings view.
   353  */
   382  */
   354 void ClockMainView::openSettings()
   383 void ClockMainView::openSettings()
   355 {
   384 {
       
   385 	OstTraceFunctionEntry0( CLOCKMAINVIEW_OPENSETTINGS_ENTRY );
   356 	// Create the settings view.
   386 	// Create the settings view.
   357 	ClockSettingsView *settingsView = new ClockSettingsView(this);
   387 	ClockSettingsView *settingsView = new ClockSettingsView(this);
   358 	settingsView->loadSettingsView();
   388 	settingsView->loadSettingsView();
   359 	// capture screenshot for future use, if application
   389 	// capture screenshot for future use, if application
   360 	// is exited/Quit from alarmEditor
   390 	// is exited/Quit from alarmEditor
   361 	captureScreenShot(true);
   391 	captureScreenShot(true);
       
   392 	OstTraceFunctionExit0( CLOCKMAINVIEW_OPENSETTINGS_EXIT );
   362 }
   393 }
   363 
   394 
   364 /*!
   395 /*!
   365 	This slot handles the 'activated' signal of the alarm list. Opens the
   396 	This slot handles the 'activated' signal of the alarm list. Opens the
   366 	alarm editor to edit the alarm.
   397 	alarm editor to edit the alarm.
   367 	\param index the modelIndex in the list which has been tapped.
   398 	\param index the modelIndex in the list which has been tapped.
   368  */
   399  */
   369 void ClockMainView::handleActivated(const QModelIndex &index)
   400 void ClockMainView::handleActivated(const QModelIndex &index)
   370 {
   401 {
       
   402 	OstTraceFunctionEntry0( CLOCKMAINVIEW_HANDLEACTIVATED_ENTRY );
   371 	if(!mIsLongTop) {// Get the data for the alarm.
   403 	if(!mIsLongTop) {// Get the data for the alarm.
   372 		int row = index.row();
   404 		int row = index.row();
   373 		QList<QVariant> alarmData =
   405 		QList<QVariant> alarmData =
   374 				mAlarmListModel->sourceModel()->index(row, 0).data(
   406 				mAlarmListModel->sourceModel()->index(row, 0).data(
   375 						AlarmDetails).toList();
   407 						AlarmDetails).toList();
   381 		alarmEditor->showAlarmEditor();
   413 		alarmEditor->showAlarmEditor();
   382 		// capture screenshot for future use, if application 
   414 		// capture screenshot for future use, if application 
   383 		// is exited/Quit from alarmEditor
   415 		// is exited/Quit from alarmEditor
   384 		captureScreenShot(true);
   416 		captureScreenShot(true);
   385 	}
   417 	}
       
   418 	OstTraceFunctionExit0( CLOCKMAINVIEW_HANDLEACTIVATED_EXIT );
   386 }
   419 }
   387 
   420 
   388 /*!
   421 /*!
   389 	This slot handles the 'longpressed' signal of the alarm list. Opens the
   422 	This slot handles the 'longpressed' signal of the alarm list. Opens the
   390 	context menu.
   423 	context menu.
   393 	\param coords The position where mouse was pressed.
   426 	\param coords The position where mouse was pressed.
   394  */
   427  */
   395 void ClockMainView::handleLongPress(
   428 void ClockMainView::handleLongPress(
   396 		HbAbstractViewItem *item, const QPointF &coords)
   429 		HbAbstractViewItem *item, const QPointF &coords)
   397 {
   430 {
       
   431 	OstTraceFunctionEntry0( CLOCKMAINVIEW_HANDLELONGPRESS_ENTRY );
   398 	mIsLongTop = true;
   432 	mIsLongTop = true;
   399 	AlarmInfo alarmInfo;
   433 	AlarmInfo alarmInfo;
   400 
   434 
   401 	// Save the item row number where the long press was made.
   435 	// Save the item row number where the long press was made.
   402 	mSelectedItem = item->modelIndex().row();
   436 	mSelectedItem = item->modelIndex().row();
   422 	// Show the menu.
   456 	// Show the menu.
   423 	itemContextMenu->open(this, SLOT(selectedMenuAction(HbAction*)));
   457 	itemContextMenu->open(this, SLOT(selectedMenuAction(HbAction*)));
   424 	itemContextMenu->setPreferredPos(coords);
   458 	itemContextMenu->setPreferredPos(coords);
   425 	itemContextMenu->setAttribute(Qt::WA_DeleteOnClose, true );
   459 	itemContextMenu->setAttribute(Qt::WA_DeleteOnClose, true );
   426 	
   460 	
       
   461 	OstTraceFunctionExit0( CLOCKMAINVIEW_HANDLELONGPRESS_EXIT );
   427 }
   462 }
   428 
   463 
   429 /*!
   464 /*!
   430 	This slot handles the deletion of the alarm from the server.
   465 	This slot handles the deletion of the alarm from the server.
   431 
   466 
   432  */
   467  */
   433 void ClockMainView::deleteAlarm()
   468 void ClockMainView::deleteAlarm()
   434 {
   469 {
       
   470 	OstTraceFunctionEntry0( CLOCKMAINVIEW_DELETEALARM_ENTRY );
   435 	if (-1 < mSelectedItem) {
   471 	if (-1 < mSelectedItem) {
   436 		// Get the data for the alarm.
   472 		// Get the data for the alarm.
   437 		QList<QVariant> alarmData = mAlarmListModel->sourceModel()->
   473 		QList<QVariant> alarmData = mAlarmListModel->sourceModel()->
   438 				index(mSelectedItem, 0).data(AlarmDetails).toList();
   474 				index(mSelectedItem, 0).data(AlarmDetails).toList();
   439 		int alarmId = alarmData.at(0).value<int>();
   475 		int alarmId = alarmData.at(0).value<int>();
   440 		mAlarmClient->deleteAlarm(alarmId);
   476 		mAlarmClient->deleteAlarm(alarmId);
   441 		mSelectedItem = -1;
   477 		mSelectedItem = -1;
   442 	}
   478 	}
       
   479 	OstTraceFunctionExit0( CLOCKMAINVIEW_DELETEALARM_EXIT );
   443 }
   480 }
   444 
   481 
   445 /*!
   482 /*!
   446 	Deltes the snoozed alarm.
   483 	Deltes the snoozed alarm.
   447  */
   484  */
   448 void ClockMainView::removeSnoozedAlarm()
   485 void ClockMainView::removeSnoozedAlarm()
   449 {
   486 {
       
   487 	OstTraceFunctionEntry0( CLOCKMAINVIEW_REMOVESNOOZEDALARM_ENTRY );
   450 	if (-1 < mSelectedItem) {
   488 	if (-1 < mSelectedItem) {
   451 		// Get the data for the alarm.
   489 		// Get the data for the alarm.
   452 		QList<QVariant> alarmData = mAlarmListModel->sourceModel()->
   490 		QList<QVariant> alarmData = mAlarmListModel->sourceModel()->
   453 		index(mSelectedItem, 0).data(AlarmDetails).toList();
   491 		index(mSelectedItem, 0).data(AlarmDetails).toList();
   454 		int alarmId = alarmData.at(0).value<int>();
   492 		int alarmId = alarmData.at(0).value<int>();
   455 		mAlarmClient->deleteSnoozedAlarm(alarmId);
   493 		mAlarmClient->deleteSnoozedAlarm(alarmId);
   456 		mSelectedItem = -1;
   494 		mSelectedItem = -1;
   457 	}
   495 	}
       
   496 	OstTraceFunctionExit0( CLOCKMAINVIEW_REMOVESNOOZEDALARM_EXIT );
   458 }
   497 }
   459 
   498 
   460 void ClockMainView::updateView()
   499 void ClockMainView::updateView()
   461 {
   500 {
       
   501 	OstTraceFunctionEntry0( CLOCKMAINVIEW_UPDATEVIEW_ENTRY );
   462 	// Update the place label.
   502 	// Update the place label.
   463 	updatePlaceLabel(mTimezoneClient->timeUpdateOn());
   503 	updatePlaceLabel(mTimezoneClient->timeUpdateOn());
   464 	// Update date label.
   504 	// Update date label.
   465 	updateDateLabel();
   505 	updateDateLabel();
   466 	// Update clock widget.
   506 	// Update clock widget.
   467 	updateClockWidget();
   507 	updateClockWidget();
       
   508 	OstTraceFunctionExit0( CLOCKMAINVIEW_UPDATEVIEW_EXIT );
   468 }
   509 }
   469 
   510 
   470 /*!
   511 /*!
   471 	Slot which gets called for value change in auto time update in cenrep.
   512 	Slot which gets called for value change in auto time update in cenrep.
   472 
   513 
   473 	\param autoTimeUpdate Value of auto time update.
   514 	\param autoTimeUpdate Value of auto time update.
   474  */
   515  */
   475 void ClockMainView::updatePlaceLabel(int autoTimeUpdate)
   516 void ClockMainView::updatePlaceLabel(int autoTimeUpdate)
   476 {
   517 {
       
   518 	OstTraceFunctionEntry0( CLOCKMAINVIEW_UPDATEPLACELABEL_ENTRY );
   477 	if (-1 == autoTimeUpdate) {
   519 	if (-1 == autoTimeUpdate) {
   478 		autoTimeUpdate = mTimezoneClient->timeUpdateOn();
   520 		autoTimeUpdate = mTimezoneClient->timeUpdateOn();
   479 	}
   521 	}
   480 	
   522 	
   481 	// Get the current zone info.
   523 	// Get the current zone info.
   524 
   566 
   525 	// Append space.
   567 	// Append space.
   526 	gmtOffset += tr(" ");
   568 	gmtOffset += tr(" ");
   527 
   569 
   528 	// Append DST info.
   570 	// Append DST info.
       
   571 	HbIcon *dstIcon = new HbIcon("");
   529 	if (currentZoneInfo.dstOn) {
   572 	if (currentZoneInfo.dstOn) {
   530 		gmtOffset += hbTrId("txt_common_setlabel_dst");
   573 		dstIcon->setIconName("qtg_mono_day_light_saving_time");
   531 	}
   574 		dstIcon->setColor(mLabelColorGroup);
       
   575 		
       
   576 	}
       
   577 	mDstIcon->setIcon(*dstIcon);
   532 
   578 
   533 	// Update the labels with the correct info.
   579 	// Update the labels with the correct info.
   534 	mPlaceLabel->clear();
   580 	mPlaceLabel->clear();
   535 	if(autoTimeUpdate) {
   581 	if(autoTimeUpdate) {
   536 		mPlaceLabel->setPlainText(
   582 		mPlaceLabel->setPlainText(
   538 	} else {
   584 	} else {
   539 		mPlaceLabel->setPlainText(
   585 		mPlaceLabel->setPlainText(
   540 				currentZoneInfo.cityName + tr(", ")
   586 				currentZoneInfo.cityName + tr(", ")
   541 				+ currentZoneInfo.countryName + tr(" ") + gmtOffset);
   587 				+ currentZoneInfo.countryName + tr(" ") + gmtOffset);
   542 	}
   588 	}
       
   589 	OstTraceFunctionExit0( CLOCKMAINVIEW_UPDATEPLACELABEL_EXIT );
   543 }
   590 }
   544 
   591 
   545 /*!
   592 /*!
   546 	Slot to either hide or show the alarmlist.
   593 	Slot to either hide or show the alarmlist.
   547  */
   594  */
   548 void ClockMainView::handleAlarmListDisplay()
   595 void ClockMainView::handleAlarmListDisplay()
   549 {
   596 {
       
   597     OstTraceFunctionEntry0( CLOCKMAINVIEW_HANDLEALARMLISTDISPLAY_ENTRY );
   550     // alarmEditor closed reset the captured screenshot, current view is main view now
   598     // alarmEditor closed reset the captured screenshot, current view is main view now
   551     captureScreenShot(false);
   599     captureScreenShot(false);
   552 	// Get the list of pending clock alarms from server.
   600 	// Get the list of pending clock alarms from server.
   553 	QList<AlarmInfo> alarmInfoList;
   601 	QList<AlarmInfo> alarmInfoList;
   554 	QList<AlarmInfo> displayInfoList;
   602 	QList<AlarmInfo> displayInfoList;
   568 				0 == mAlarmListModel->sourceModel()->rowCount()) {
   616 				0 == mAlarmListModel->sourceModel()->rowCount()) {
   569 			hideAlarmList(true);
   617 			hideAlarmList(true);
   570 		}
   618 		}
   571 	}
   619 	}
   572 
   620 
       
   621 	OstTraceFunctionExit0( CLOCKMAINVIEW_HANDLEALARMLISTDISPLAY_EXIT );
   573 }
   622 }
   574 
   623 
   575 /*!
   624 /*!
   576 	Slot to check the orientation & load the appropriate section.
   625 	Slot to check the orientation & load the appropriate section.
   577 
   626 
   578 	\param orientation contains the current orientation of the window.
   627 	\param orientation contains the current orientation of the window.
   579  */
   628  */
   580 void ClockMainView::checkOrientationAndLoadSection(
   629 void ClockMainView::checkOrientationAndLoadSection(
   581 		Qt::Orientation orientation)
   630 		Qt::Orientation orientation)
   582 {
   631 {
       
   632 	OstTraceFunctionEntry0( CLOCKMAINVIEW_CHECKORIENTATIONANDLOADSECTION_ENTRY );
   583 	bool success;
   633 	bool success;
   584 	// If horizontal, load the landscape section.
   634 	// If horizontal, load the landscape section.
   585 	if (Qt::Horizontal == orientation) {
   635 	if (Qt::Horizontal == orientation) {
   586 		mDocLoader->load(
   636 		mDocLoader->load(
   587 				CLOCK_MAIN_VIEW_DOCML, CLOCK_MAIN_VIEW_LANDSCAPE_SECTION,
   637 				CLOCK_MAIN_VIEW_DOCML, CLOCK_MAIN_VIEW_LANDSCAPE_SECTION,
   604 			hideAlarmList(true);
   654 			hideAlarmList(true);
   605 		} else {
   655 		} else {
   606 			hideAlarmList(false);
   656 			hideAlarmList(false);
   607 		}
   657 		}
   608 	}
   658 	}
       
   659 	OstTraceFunctionExit0( CLOCKMAINVIEW_CHECKORIENTATIONANDLOADSECTION_EXIT );
   609 }
   660 }
   610 
   661 
   611 /*!
   662 /*!
   612 	Slot to handle context menu actions.
   663 	Slot to handle context menu actions.
   613  */
   664  */
   614 void ClockMainView::selectedMenuAction(HbAction *action)
   665 void ClockMainView::selectedMenuAction(HbAction *action)
   615 {
   666 {
       
   667 	OstTraceFunctionEntry0( CLOCKMAINVIEW_SELECTEDMENUACTION_ENTRY );
   616 	if (action == mDeleteAction) {
   668 	if (action == mDeleteAction) {
   617 		deleteAlarm();
   669 		deleteAlarm();
   618 	}
   670 	}
       
   671 	OstTraceFunctionExit0( CLOCKMAINVIEW_SELECTEDMENUACTION_EXIT );
   619 }
   672 }
   620 
   673 
   621 /*!
   674 /*!
   622 	Slot to handle the context menu closed.
   675 	Slot to handle the context menu closed.
   623  */
   676  */
   624 void ClockMainView::handleMenuClosed()
   677 void ClockMainView::handleMenuClosed()
   625 {
   678 {
       
   679 	OstTraceFunctionEntry0( CLOCKMAINVIEW_HANDLEMENUCLOSED_ENTRY );
   626 	mIsLongTop = false;
   680 	mIsLongTop = false;
       
   681 	OstTraceFunctionExit0( CLOCKMAINVIEW_HANDLEMENUCLOSED_EXIT );
   627 }
   682 }
   628 /*!
   683 /*!
   629 	Sets the model to the alarm list.
   684 	Sets the model to the alarm list.
   630  */
   685  */
   631 void ClockMainView::setmodel()
   686 void ClockMainView::setmodel()
   632 {
   687 {
       
   688 	OstTraceFunctionEntry0( CLOCKMAINVIEW_SETMODEL_ENTRY );
   633 	// Set the model.
   689 	// Set the model.
   634 	if (mAlarmList) {
   690 	if (mAlarmList) {
   635 		mAlarmList->setModel(mAlarmListModel->sourceModel());
   691 		mAlarmList->setModel(mAlarmListModel->sourceModel());
   636 		ClockAlarmListItemPrototype *listItemPrototype =
   692 		ClockAlarmListItemPrototype *listItemPrototype =
   637 				new ClockAlarmListItemPrototype();
   693 				new ClockAlarmListItemPrototype();
   640 				this, SLOT(handleAlarmStatusChanged(int)));
   696 				this, SLOT(handleAlarmStatusChanged(int)));
   641 		mAlarmList->setItemPrototype(listItemPrototype);
   697 		mAlarmList->setItemPrototype(listItemPrototype);
   642 		mAlarmList->setLayoutName("layout-alarmlist");
   698 		mAlarmList->setLayoutName("layout-alarmlist");
   643 	}
   699 	}
   644 
   700 
       
   701 	OstTraceFunctionExit0( CLOCKMAINVIEW_SETMODEL_EXIT );
   645 }
   702 }
   646 
   703 
   647 /*!
   704 /*!
   648 	Hides the alarmlist in the main view.
   705 	Hides the alarmlist in the main view.
   649 
   706 
   650 	\param hide 'true' if alarm list is to be hidden.
   707 	\param hide 'true' if alarm list is to be hidden.
   651  */
   708  */
   652 void ClockMainView::hideAlarmList(bool hide)
   709 void ClockMainView::hideAlarmList(bool hide)
   653 {
   710 {
       
   711 	OstTraceFunctionEntry0( CLOCKMAINVIEW_HIDEALARMLIST_ENTRY );
   654 	if (hide) {
   712 	if (hide) {
   655 		mNoAlarmLabel->show();
   713 		mNoAlarmLabel->show();
   656 		mAlarmList->hide();
   714 		mAlarmList->hide();
   657 		mHideAlarmList = true;
   715 		mHideAlarmList = true;
   658 	} else {
   716 	} else {
   659 		mAlarmList->show();
   717 		mAlarmList->show();
   660 		mNoAlarmLabel->hide();
   718 		mNoAlarmLabel->hide();
   661 		mHideAlarmList = false;
   719 		mHideAlarmList = false;
   662 	}
   720 	}
       
   721 	OstTraceFunctionExit0( CLOCKMAINVIEW_HIDEALARMLIST_EXIT );
   663 }
   722 }
   664 
   723 
   665 /*!
   724 /*!
   666 	Updates the day and date in the day label.
   725 	Updates the day and date in the day label.
   667  */
   726  */
   668 void ClockMainView::updateDateLabel()
   727 void ClockMainView::updateDateLabel()
   669 {
   728 {
       
   729 	OstTraceFunctionEntry0( CLOCKMAINVIEW_UPDATEDATELABEL_ENTRY );
   670 	// Get the current datetime.
   730 	// Get the current datetime.
   671 	QDateTime dateTime = QDateTime::currentDateTime();
   731 	QDateTime dateTime = QDateTime::currentDateTime();
   672 	// Get the day name.
   732 	// Get the day name.
   673 	QString dayName = dateTime.toString("ddd");
   733 	QString dayName = dateTime.toString("ddd");
   674 	// Get the date in correct format.
   734 	// Get the date in correct format.
   678 	dayDateString+= dayName;
   738 	dayDateString+= dayName;
   679 	dayDateString += " ";
   739 	dayDateString += " ";
   680 	dayDateString += currentDate;
   740 	dayDateString += currentDate;
   681 
   741 
   682 	mDayLabel->setPlainText(dayDateString);
   742 	mDayLabel->setPlainText(dayDateString);
       
   743 	OstTraceFunctionExit0( CLOCKMAINVIEW_UPDATEDATELABEL_EXIT );
   683 }
   744 }
   684 
   745 
   685 /*!
   746 /*!
   686 	Updates the zone info in the place label.
   747 	Updates the zone info in the place label.
   687  */
   748  */
   693 /*!
   754 /*!
   694 	Updates the clock widget display.
   755 	Updates the clock widget display.
   695  */
   756  */
   696 void ClockMainView::updateClockWidget()
   757 void ClockMainView::updateClockWidget()
   697 {
   758 {
       
   759 	OstTraceFunctionEntry0( CLOCKMAINVIEW_UPDATECLOCKWIDGET_ENTRY );
   698 	QStringList clockType;
   760 	QStringList clockType;
   699     int index = mSettingsUtility->clockType(clockType);
   761     int index = mSettingsUtility->clockType(clockType);
   700     int zeroIndex(0);
   762     int zeroIndex(0);
   701     if(zeroIndex == index){
   763     if(zeroIndex == index){
   702     	mClockWidget->setClockType(ClockWidget::ClockTypeDigital);
   764     	mClockWidget->setClockType(ClockWidget::ClockTypeDigital);
   711     } else {
   773     } else {
   712     	mClockWidget->setTimeFormat(ClockWidget::TimeFormat12Hrs);
   774     	mClockWidget->setTimeFormat(ClockWidget::TimeFormat12Hrs);
   713     }
   775     }
   714 
   776 
   715 	mClockWidget->updateTime();
   777 	mClockWidget->updateTime();
       
   778 	OstTraceFunctionExit0( CLOCKMAINVIEW_UPDATECLOCKWIDGET_EXIT );
   716 }
   779 }
   717 
   780 
   718 /*!
   781 /*!
   719 	CaptureScreenShot captures screen shot 
   782 	CaptureScreenShot captures screen shot 
   720 	\param captureScreenShot bool to indicate if screenshot needs to be captured
   783 	\param captureScreenShot bool to indicate if screenshot needs to be captured
   721 */ 
   784 */ 
   722 void ClockMainView::captureScreenShot(bool captureScreenShot)
   785 void ClockMainView::captureScreenShot(bool captureScreenShot)
   723 {
   786 {
       
   787 	OstTraceFunctionEntry0( CLOCKMAINVIEW_CAPTURESCREENSHOT_ENTRY );
   724 	// check if screen shot needs to be captured
   788 	// check if screen shot needs to be captured
   725     if (captureScreenShot) {
   789     if (captureScreenShot) {
   726         mScreenShot.clear();
   790         mScreenShot.clear();
   727         mScreenShot.insert("screenshot", QPixmap::grabWidget(mainWindow(), mainWindow()->rect()));
   791         mScreenShot.insert("screenshot", QPixmap::grabWidget(mainWindow(), mainWindow()->rect()));
   728     }
   792     }
   729     mIsScreenShotCapruted = captureScreenShot; // set mIsScreenShotCapruted set validity of screenshot
   793     mIsScreenShotCapruted = captureScreenShot; // set mIsScreenShotCapruted set validity of screenshot
       
   794     OstTraceFunctionExit0( CLOCKMAINVIEW_CAPTURESCREENSHOT_EXIT );
   730 }
   795 }
   731 
   796 
   732 /*!    
   797 /*!    
   733 	saveActivity saves main view as an activity 
   798 	saveActivity saves main view as an activity 
   734 */ 
   799 */ 
   735 void ClockMainView::saveActivity()
   800 void ClockMainView::saveActivity()
   736 {
   801 {
       
   802    OstTraceFunctionEntry0( CLOCKMAINVIEW_SAVEACTIVITY_ENTRY );
   737    // Get a pointer to activity Manager
   803    // Get a pointer to activity Manager
   738    HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();
   804    HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();
   739  	// check if a valid screenshot is already captured
   805  	// check if a valid screenshot is already captured
   740    if (!mIsScreenShotCapruted)  {
   806    if (!mIsScreenShotCapruted)  {
   741        mScreenShot.clear();
   807        mScreenShot.clear();
   750    // add the activity to the activity manager
   816    // add the activity to the activity manager
   751    bool ok = activityManager->addActivity(clockMainView, serializedActivity, mScreenShot);
   817    bool ok = activityManager->addActivity(clockMainView, serializedActivity, mScreenShot);
   752    if ( !ok ) {
   818    if ( !ok ) {
   753        qFatal("Add failed" );
   819        qFatal("Add failed" );
   754    }
   820    }
       
   821    OstTraceFunctionExit0( CLOCKMAINVIEW_SAVEACTIVITY_EXIT );
   755 }
   822 }
   756 // End of file	--Don't remove.
   823 // End of file	--Don't remove.