clock/clockui/clocksettingsview/src/clocksettingsview.cpp
branchRCL_3
changeset 65 12af337248b1
equal deleted inserted replaced
60:96907930389d 65:12af337248b1
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Implementation file for class ClockSettingsView.
       
    16 *
       
    17 */
       
    18 
       
    19 // System includes
       
    20 #include <HbInstance>
       
    21 #include <HbDataForm>
       
    22 #include <HbAction>
       
    23 #include <HbDataFormModel>
       
    24 #include <HbDataFormModelItem>
       
    25 #include <HbLabel>
       
    26 #include <HbPushButton>
       
    27 #include <HbCheckBox>
       
    28 #include <HbTranslator>
       
    29 #include <xqsettingsmanager.h>
       
    30 #include <xqsettingskey.h>
       
    31 #include <clockdomaincrkeys.h>
       
    32 
       
    33 // User includes
       
    34 #include "clocksettingsview.h"
       
    35 #include "clocksettingsdefines.h"
       
    36 #include "clocksettingsdocloader.h"
       
    37 #include "settingsutility.h"
       
    38 #include "timezoneclient.h"
       
    39 #include "settingsdatatypes.h"
       
    40 #include "settingscustomitem.h"
       
    41 #include "OstTraceDefinitions.h"
       
    42 #ifdef OST_TRACE_COMPILER_IN_USE
       
    43 #include "clocksettingsviewTraces.h"
       
    44 #endif
       
    45 
       
    46 
       
    47 /*!
       
    48 	\class ClockSettingsView
       
    49 
       
    50 	This implements the clock settings which allows user to set the
       
    51 	date, time, location and other related parameters.
       
    52  */
       
    53 
       
    54 /*!
       
    55 	Constructor.
       
    56 
       
    57 	\param parent The parent of type QGraphicsWidget.
       
    58  */
       
    59 ClockSettingsView::ClockSettingsView(QObject *parent, HbTranslator *translator, bool launchedByClock)
       
    60 :QObject(parent), mTranslator(0), mLaunchedByClock(launchedByClock)
       
    61 {
       
    62 	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_CLOCKSETTINGSVIEW_ENTRY );
       
    63 	
       
    64 	// Load the translation file and install the editor specific translator
       
    65     if(!translator) {
       
    66         mTranslator = new HbTranslator("clocksettingsview");
       
    67         mTranslator->loadCommon();   
       
    68     }
       
    69 
       
    70 	// Construct the settings utility.
       
    71 	mSettingsUtility = new SettingsUtility();
       
    72 
       
    73 	// Construct the timezone client.
       
    74 	mTimezoneClient = TimezoneClient::getInstance();
       
    75 	connect(
       
    76 			mTimezoneClient, SIGNAL(timechanged()),
       
    77 			this, SLOT(updatePlaceItem()));
       
    78 	connect(
       
    79 			mTimezoneClient, SIGNAL(timechanged()),
       
    80 			this, SLOT(updateDateItem()));
       
    81 	connect(
       
    82 			mTimezoneClient, SIGNAL(timechanged()),
       
    83 			this, SLOT(updateTimeItem()));
       
    84 	connect(
       
    85 			mTimezoneClient, SIGNAL(autoTimeUpdateChanged(int)),
       
    86 			this, SLOT(handleAutoTimeUpdateChange(int)));
       
    87 	connect(
       
    88 			mTimezoneClient, SIGNAL(cityUpdated()),
       
    89 			this, SLOT(updatePlaceItem()));
       
    90 
       
    91 	// Start a timer. For updating the remaining alarm time.
       
    92 	mTickTimer = new QTimer(this);
       
    93 	connect(
       
    94 			mTickTimer, SIGNAL(timeout()),
       
    95 			this, SLOT(updateTimeItem()));
       
    96 
       
    97 	// Create the settings manager.
       
    98 	mSettingsManager = new XQSettingsManager(this);
       
    99 
       
   100 	// Create the key for alarm snooze time.
       
   101 	mAlarmSnoozeTimeKey = new XQSettingsKey(
       
   102 			XQSettingsKey::TargetCentralRepository,
       
   103 			KCRUidClockApp,
       
   104 			KClockAppSnoozeTime);
       
   105 	
       
   106 	// Start the monitoring for the alarm snooze time key.
       
   107 	mSettingsManager->startMonitoring(*mAlarmSnoozeTimeKey);
       
   108 
       
   109 	// Listen to the key value changes.
       
   110 	connect(
       
   111 			mSettingsManager, SIGNAL(valueChanged(XQSettingsKey, QVariant)),
       
   112 			this, SLOT(eventMonitor(XQSettingsKey, QVariant)));
       
   113 	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_CLOCKSETTINGSVIEW_EXIT );
       
   114 }
       
   115 
       
   116 /*!
       
   117 	Destructor.
       
   118  */
       
   119 ClockSettingsView::~ClockSettingsView()
       
   120 {
       
   121 	OstTraceFunctionEntry0( DUP1_CLOCKSETTINGSVIEW_CLOCKSETTINGSVIEW_ENTRY );
       
   122 	if (mDocLoader) {
       
   123 		delete mDocLoader;
       
   124 	}
       
   125 	
       
   126 	// Remove the translator
       
   127     if (mTranslator) {
       
   128         delete mTranslator;
       
   129         mTranslator = 0;
       
   130     }
       
   131     if(mSettingsUtility){
       
   132     	delete mSettingsUtility;
       
   133     }
       
   134 	
       
   135 	if(mSettingsModel){
       
   136 		delete mSettingsModel;
       
   137 	}
       
   138 		
       
   139 
       
   140 	OstTraceFunctionExit0( DUP1_CLOCKSETTINGSVIEW_CLOCKSETTINGSVIEW_EXIT );
       
   141 }
       
   142 
       
   143 /*!
       
   144 	Loads the settings view from the docml.
       
   145  */
       
   146 void ClockSettingsView::loadSettingsView()
       
   147 {
       
   148 	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_LOADSETTINGSVIEW_ENTRY );
       
   149 	bool loadSuccess;
       
   150 
       
   151 	// Construct the document loader instance
       
   152 	mDocLoader = new ClockSettingsDocLoader();
       
   153 
       
   154 	// Load the application xml.
       
   155 	mDocLoader->load(CLOCK_SETTINGS_VIEW_DOCML, &loadSuccess);
       
   156 	
       
   157 	// Load the correct section based on orientation.
       
   158 	HbMainWindow *window = hbInstance->allMainWindows().first();
       
   159 	Qt::Orientation currentOrientation = window->orientation();
       
   160 	
       
   161 	if (Qt::Vertical == currentOrientation) {
       
   162 		// Load portrait section.
       
   163 		mDocLoader->load(
       
   164 				CLOCK_SETTINGS_VIEW_DOCML,
       
   165 				CLOCK_SETTINGS_VIEW_PORTRAIT_SECTION,
       
   166 				&loadSuccess);
       
   167 	} else {
       
   168 		// Load landscape section.
       
   169 		mDocLoader->load(
       
   170 				CLOCK_SETTINGS_VIEW_DOCML,
       
   171 				CLOCK_SETTINGS_VIEW_LANDSCAPE_SECTION,
       
   172 				&loadSuccess);
       
   173 	}
       
   174 
       
   175 	// Connect the required signals.
       
   176 	connect(
       
   177 			window, SIGNAL(orientationChanged(Qt::Orientation)),
       
   178 			this, SLOT(handleOrientationChanged(Qt::Orientation)));
       
   179 
       
   180 	// Find the main view.
       
   181 	mSettingsView = static_cast<HbView *> (
       
   182 			mDocLoader->findWidget(CLOCK_SETTINGS_VIEW));
       
   183 
       
   184 	// Setup the view.
       
   185 	setupView();
       
   186 
       
   187 	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_LOADSETTINGSVIEW_EXIT );
       
   188 }
       
   189 
       
   190 /*!
       
   191 	Slot to handle the back action of the view.
       
   192  */
       
   193 void ClockSettingsView::handleBackAction()
       
   194 {
       
   195 	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_HANDLEBACKACTION_ENTRY );
       
   196 	HbMainWindow *window = hbInstance->allMainWindows().first();
       
   197 	window->removeView(mSettingsView);
       
   198 	deleteLater();
       
   199 	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_HANDLEBACKACTION_EXIT );
       
   200 }
       
   201 
       
   202 /*!
       
   203 	Updates the zone info in the place item field.
       
   204  */
       
   205 void ClockSettingsView::updatePlaceItem()
       
   206 {
       
   207 	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_UPDATEPLACEITEM_ENTRY );
       
   208 	// Get the current zone info.
       
   209 	LocationInfo currentZoneInfo = mTimezoneClient->getCurrentZoneInfoL();
       
   210 
       
   211 	if (mTimezoneClient->timeUpdateOn()) {
       
   212 		mPlaceDataFormItem->setContentWidgetData(
       
   213 				"text", currentZoneInfo.countryName);
       
   214 	} else {
       
   215 		QString placeInfo = currentZoneInfo.cityName
       
   216 				+ tr(", ") + currentZoneInfo.countryName;
       
   217 		mPlaceDataFormItem->setContentWidgetData("text", placeInfo);
       
   218 	}
       
   219 	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_UPDATEPLACEITEM_EXIT );
       
   220 }
       
   221 
       
   222 /*!
       
   223 	Slot to update the display of the date settings item field.
       
   224  */
       
   225 void ClockSettingsView::updateDateItem()
       
   226 {
       
   227 	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_UPDATEDATEITEM_ENTRY );
       
   228 	mDateDataFormItem->setContentWidgetData("text", mSettingsUtility->date());
       
   229 	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_UPDATEDATEITEM_EXIT );
       
   230 }
       
   231 
       
   232 /*!
       
   233 	Slot to update the display of the time settings item field.
       
   234  */
       
   235 void ClockSettingsView::updateTimeItem()
       
   236 {
       
   237 	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_UPDATETIMEITEM_ENTRY );
       
   238 	if (!mTickTimer->isActive()) {
       
   239 		mTickTimer->stop();
       
   240     }
       
   241 	mTimeDataFormItem->setContentWidgetData("text", mSettingsUtility->time());
       
   242 
       
   243 	// Start the timer again.
       
   244 	mTickTimer->start(60000 - 1000 * QTime::currentTime().second());
       
   245 	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_UPDATETIMEITEM_EXIT );
       
   246 }
       
   247 
       
   248 /*!
       
   249 	This slot is called whenever orientattion of the view changes.
       
   250  */
       
   251 void ClockSettingsView::handleOrientationChanged(Qt::Orientation orientation)
       
   252 {
       
   253 	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_HANDLEORIENTATIONCHANGED_ENTRY );
       
   254 	bool success; 
       
   255 	// If horizontal, load the landscape section. 
       
   256 	if (Qt::Horizontal == orientation) { 
       
   257 		mDocLoader->load( 
       
   258 				CLOCK_SETTINGS_VIEW_DOCML,
       
   259 				CLOCK_SETTINGS_VIEW_LANDSCAPE_SECTION, 
       
   260 				&success); 
       
   261 	} else if (Qt::Vertical == orientation) { 
       
   262 		mDocLoader->load( 
       
   263 				CLOCK_SETTINGS_VIEW_DOCML,
       
   264 				CLOCK_SETTINGS_VIEW_PORTRAIT_SECTION,
       
   265 				&success); 
       
   266 	} 
       
   267 	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_HANDLEORIENTATIONCHANGED_EXIT );
       
   268 }
       
   269 
       
   270 void ClockSettingsView::handleNetworkTimeStateChange(int state)
       
   271 {
       
   272 	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_HANDLENETWORKTIMESTATECHANGE_ENTRY );
       
   273 	bool cenrepValue = mTimezoneClient->timeUpdateOn();
       
   274 	if ((Qt::Checked == state && !cenrepValue)
       
   275 			|| (Qt::Unchecked == state && cenrepValue)) {
       
   276 		if (Qt::Checked == state) {
       
   277 			// Update the cenrep value.
       
   278 			mTimezoneClient->setTimeUpdateOn(true);
       
   279 
       
   280 		} else if (Qt::Unchecked == state) {
       
   281 			// Update the cenrep value.
       
   282 			mTimezoneClient->setTimeUpdateOn(false);
       
   283 		}
       
   284 	}
       
   285 	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_HANDLENETWORKTIMESTATECHANGE_EXIT );
       
   286 }
       
   287 
       
   288 /*!
       
   289 	Called after loading the view from the docml.
       
   290 	The initializaion/setup of the view is done here.
       
   291 
       
   292 	\param docLoader Pointer to ClockSettingsDocLoader object.
       
   293  */
       
   294 void ClockSettingsView::setupView()
       
   295 {
       
   296 	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_SETUPVIEW_ENTRY );
       
   297 	
       
   298 	if(!mLaunchedByClock) {
       
   299 	    mSettingsView->setTitle(hbTrId("txt_clock_title_control_panel"));
       
   300 	}
       
   301 	
       
   302 	HbMainWindow *window = hbInstance->allMainWindows().first();
       
   303 	window->addView(mSettingsView);
       
   304 	window->setCurrentView(mSettingsView);
       
   305 
       
   306 	// Add the back softkey.
       
   307 	mBackAction = new HbAction(Hb::BackNaviAction);
       
   308 	mSettingsView->setNavigationAction(mBackAction);
       
   309 	connect(
       
   310 			mBackAction, SIGNAL(triggered()),
       
   311 			this, SLOT(handleBackAction()));
       
   312 
       
   313 	// Get the data form.
       
   314 	mSettingsForm = static_cast<HbDataForm *> (
       
   315 			mDocLoader->findWidget(CLOCK_SETTINGS_DATA_FORM));
       
   316 
       
   317 	// Create the custom prototype.
       
   318 	QList <HbAbstractViewItem*> prototypes = mSettingsForm->itemPrototypes();
       
   319 	SettingsCustomItem *customPrototype = new SettingsCustomItem(mSettingsForm, mLaunchedByClock);
       
   320 	prototypes.append(customPrototype);
       
   321 	mSettingsForm->setItemPrototypes(prototypes);
       
   322 
       
   323 	// Create the model.
       
   324 	createModel();
       
   325 	updatePlaceItem();
       
   326 
       
   327 	mTickTimer->start(60000 - 1000 * QTime::currentTime().second());
       
   328 	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_SETUPVIEW_EXIT );
       
   329 }
       
   330 
       
   331 /*!
       
   332 	Creates the model for the settings form.
       
   333  */
       
   334 void ClockSettingsView::createModel()
       
   335 {
       
   336 	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_CREATEMODEL_ENTRY );
       
   337 	// Remove the model.
       
   338 	if (mSettingsForm->model()) {
       
   339 		delete mSettingsForm->model();
       
   340 		mSettingsForm->setModel(0);
       
   341 	}
       
   342 
       
   343 	// Create a model and set it.
       
   344 	mSettingsModel = new HbDataFormModel();
       
   345 	// Add the items to the view.
       
   346 	populateModel();
       
   347 	mSettingsForm->setModel(mSettingsModel);
       
   348 	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_CREATEMODEL_EXIT );
       
   349 }
       
   350 
       
   351 /*!
       
   352 	Poplulates the item in the model.
       
   353  */
       
   354 void ClockSettingsView::populateModel()
       
   355 {
       
   356 	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_POPULATEMODEL_ENTRY );
       
   357 	if (!mSettingsModel) {
       
   358 		createModel();
       
   359 	}
       
   360 
       
   361 	// Add the network time update item.
       
   362 	mNetworkTimeItem = mSettingsModel->appendDataFormItem(
       
   363 			HbDataFormModelItem::CheckBoxItem, "");
       
   364 	bool networkTime = mTimezoneClient->timeUpdateOn();
       
   365 	Qt::CheckState state = Qt::Unchecked;
       
   366 	if (networkTime) {
       
   367 		state = Qt::Checked;
       
   368 	}
       
   369 	mNetworkTimeItem->setContentWidgetData(
       
   370 			"checkState", state);
       
   371 	mNetworkTimeItem->setContentWidgetData(
       
   372 			"text", QString(hbTrId("txt_clk_setlabel_use_network_date_time")));
       
   373 	mNetworkTimeItem->setContentWidgetData("objectName", "networkTime");
       
   374 	mSettingsForm->addConnection(
       
   375 			mNetworkTimeItem, SIGNAL(stateChanged(int)),
       
   376 			this, SLOT(handleNetworkTimeStateChange(int)));
       
   377 
       
   378 	// Add the time item.
       
   379 	// Custom data type for adding a time button to the data form.
       
   380 	HbDataFormModelItem::DataItemType timeItemType =
       
   381 			static_cast<HbDataFormModelItem::DataItemType>
       
   382 			(HbDataFormModelItem::CustomItemBase + TimeItem);
       
   383 	mTimeDataFormItem = mSettingsModel->appendDataFormItem(
       
   384 			timeItemType, QString(hbTrId("txt_clock_setlabel_time")));
       
   385 	mTimeDataFormItem->setContentWidgetData("text", mSettingsUtility->time());
       
   386 	mTimeDataFormItem->setContentWidgetData("objectName", "timeItem");
       
   387 
       
   388 	// Add the date item.
       
   389 	// Custom data type for adding a time button to the data form.
       
   390 	HbDataFormModelItem::DataItemType dateItemType =
       
   391 			static_cast<HbDataFormModelItem::DataItemType>
       
   392 			(HbDataFormModelItem::CustomItemBase + DateItem);
       
   393 	mDateDataFormItem = mSettingsModel->appendDataFormItem(
       
   394 			dateItemType, QString(hbTrId("txt_clock_setlabel_date")));
       
   395 	mDateDataFormItem->setContentWidgetData("text", mSettingsUtility->date());
       
   396 	mDateDataFormItem->setContentWidgetData("objectName", "dateItem");
       
   397 
       
   398 	// Add the place item.
       
   399 	HbDataFormModelItem::DataItemType placeItemType =
       
   400 			static_cast<HbDataFormModelItem::DataItemType>
       
   401 			(HbDataFormModelItem::CustomItemBase + PlaceItem);
       
   402 	mPlaceDataFormItem = mSettingsModel->appendDataFormItem(
       
   403 			placeItemType, QString(hbTrId("txt_clock_formlabel_place")));
       
   404 	
       
   405 	LocationInfo currentZoneInfo = mTimezoneClient->getCurrentZoneInfoL();
       
   406 	QString placeItemText("");
       
   407 	if (Qt::Unchecked == state) {
       
   408 		placeItemText.append(currentZoneInfo.cityName);
       
   409 		placeItemText+= tr(", ");
       
   410 	}
       
   411 	placeItemText.append(currentZoneInfo.countryName);
       
   412 	mPlaceDataFormItem->setContentWidgetData("text", placeItemText);
       
   413 	mPlaceDataFormItem->setContentWidgetData("objectName", "placeItem");
       
   414 	
       
   415 	if (networkTime) {
       
   416 		mTimeDataFormItem->setEnabled(false);
       
   417 		mDateDataFormItem->setEnabled(false);
       
   418 		mPlaceDataFormItem->setEnabled(false);
       
   419 	} else {
       
   420 		mTimeDataFormItem->setEnabled(true);
       
   421 		mDateDataFormItem->setEnabled(true);
       
   422 		mPlaceDataFormItem->setEnabled(true);
       
   423 	}
       
   424 
       
   425 	// Add the regional settings item.
       
   426 	HbDataFormModelItem::DataItemType regionalSettingsItem =
       
   427 			static_cast<HbDataFormModelItem::DataItemType>
       
   428 			(HbDataFormModelItem::CustomItemBase + RegionalSettingsItem);
       
   429 	mRegionalDataFormItem = mSettingsModel->appendDataFormItem(
       
   430 			regionalSettingsItem);
       
   431 	mRegionalDataFormItem->setContentWidgetData(
       
   432 			"text", hbTrId("txt_clock_button_regional_date_time_settings"));
       
   433 	mRegionalDataFormItem->setContentWidgetData(
       
   434 					"objectName", "regionalSettings");
       
   435     
       
   436 	// Add the clock type item.
       
   437     HbDataFormModelItem::DataItemType clockTypeSettingsItem =
       
   438             static_cast<HbDataFormModelItem::DataItemType>
       
   439             (HbDataFormModelItem::ToggleValueItem);
       
   440     mClockTypeItem = mSettingsModel->appendDataFormItem(
       
   441 	clockTypeSettingsItem,hbTrId("txt_clock_setlabel_clock_type"));
       
   442     QStringList clockTypeList;
       
   443     int clockType = mSettingsUtility->clockType(clockTypeList);
       
   444 	int zeroIndex(0);
       
   445     if( zeroIndex == clockType ){
       
   446 	    mClockTypeItem->setContentWidgetData("text", clockTypeList[0]);
       
   447 	    mClockTypeItem->setContentWidgetData("additionalText", clockTypeList[1]);
       
   448     } else {
       
   449 	    mClockTypeItem->setContentWidgetData("text", clockTypeList[1]);
       
   450 	    mClockTypeItem->setContentWidgetData("additionalText", clockTypeList[0]);    
       
   451     }
       
   452     mClockTypeItem->setContentWidgetData("objectName", "clockType");
       
   453     mSettingsForm->addConnection(
       
   454             mClockTypeItem, SIGNAL(clicked()),
       
   455             this, SLOT(handleClockTypeChanged()));
       
   456     
       
   457     // Add the alarm snooze time item.
       
   458 	mAlarmSnoozeItem = mSettingsModel->appendDataFormItem(
       
   459 			HbDataFormModelItem::ComboBoxItem,
       
   460 			hbTrId("txt_clock_setlabel_alarm_snooze_time"));
       
   461 	QStringList alramSnoozeTimes;
       
   462 	alramSnoozeTimes << hbTrId("txt_clock_setlabel_ln_mins", 5)
       
   463 			<< hbTrId("txt_clock_setlabel_ln_mins", 10)
       
   464 			<< hbTrId("txt_clock_setlabel_ln_mins", 15)
       
   465 			<< hbTrId("txt_clock_setlabel_ln_mins", 30);
       
   466 	
       
   467 	// Build the hash map for the reminder.
       
   468 	mAlarmSnoozeTimeHash[0] = 5;
       
   469 	mAlarmSnoozeTimeHash[1] = 10;
       
   470 	mAlarmSnoozeTimeHash[2] = 15;
       
   471 	mAlarmSnoozeTimeHash[3] = 30;
       
   472 	
       
   473 	mAlarmSnoozeItem->setContentWidgetData("items", alramSnoozeTimes);
       
   474 	QVariant value = mSettingsManager->readItemValue(*mAlarmSnoozeTimeKey);
       
   475 	bool success;
       
   476 	int index;
       
   477 	int alarmSnoozeTime = value.toInt(&success);
       
   478 	if (success) {
       
   479 		index = mAlarmSnoozeTimeHash.key(alarmSnoozeTime);
       
   480 	} else {
       
   481 		index = mAlarmSnoozeTimeHash.key(15);
       
   482 	}
       
   483 	mAlarmSnoozeItem->setContentWidgetData("currentIndex", index);
       
   484 	mAlarmSnoozeItem->setContentWidgetData("objectName", "alarmSnooze");
       
   485 	mSettingsForm->addConnection(
       
   486 			mAlarmSnoozeItem, SIGNAL(currentIndexChanged(int)),
       
   487 			this, SLOT(handleAlarmSnoozeTimeChanged(int)));
       
   488 
       
   489 	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_POPULATEMODEL_EXIT );
       
   490 }
       
   491 
       
   492 /*!
       
   493 	Slot which handles the auto time update value changes in cenrep.
       
   494 	
       
   495 	/param value New value of the auto time update.
       
   496  */
       
   497 void ClockSettingsView::handleAutoTimeUpdateChange(int value)
       
   498 {
       
   499 	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_HANDLEAUTOTIMEUPDATECHANGE_ENTRY );
       
   500 	int state = (mNetworkTimeItem->contentWidgetData("checkState")).toInt();
       
   501 	
       
   502 	if (value) {
       
   503 		// Disable the time, date and place item.
       
   504 		if (mTimeDataFormItem) {
       
   505 			mTimeDataFormItem->setEnabled(false);
       
   506 		}
       
   507 		if (mDateDataFormItem) {
       
   508 			mDateDataFormItem->setEnabled(false);
       
   509 		}
       
   510 		if (mPlaceDataFormItem) {
       
   511 			mPlaceDataFormItem->setEnabled(false);
       
   512 		}
       
   513 		if (Qt::Unchecked == state) {
       
   514 			mNetworkTimeItem->setContentWidgetData(
       
   515 						"checkState", Qt::Checked);
       
   516 		}
       
   517 	} else {
       
   518 		// Enable the time, date and place item.
       
   519 		if (mTimeDataFormItem) {
       
   520 			mTimeDataFormItem->setEnabled(true);
       
   521 		}
       
   522 		if (mDateDataFormItem) {
       
   523 			mDateDataFormItem->setEnabled(true);
       
   524 		}
       
   525 		if (mPlaceDataFormItem) {
       
   526 			mPlaceDataFormItem->setEnabled(true);
       
   527 		}
       
   528 		if (Qt::Checked == state) {
       
   529 			mNetworkTimeItem->setContentWidgetData(
       
   530 						"checkState", Qt::Unchecked);
       
   531 		}
       
   532 	}
       
   533 	updatePlaceItem();
       
   534 	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_HANDLEAUTOTIMEUPDATECHANGE_EXIT );
       
   535 }
       
   536 
       
   537 /*!
       
   538 	Slot which handles the alarm snooze time changes.
       
   539 	
       
   540 	/param value New index of the alarm snooze time.
       
   541  */
       
   542 void ClockSettingsView::handleAlarmSnoozeTimeChanged(int index)
       
   543 {
       
   544 	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_HANDLEALARMSNOOZETIMECHANGED_ENTRY );
       
   545 	if (mAlarmSnoozeTimeHash.value(index)) {
       
   546 		mSettingsManager->writeItemValue(
       
   547 				*mAlarmSnoozeTimeKey, mAlarmSnoozeTimeHash.value(index));
       
   548 	}
       
   549 	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_HANDLEALARMSNOOZETIMECHANGED_EXIT );
       
   550 }
       
   551 
       
   552 /*!
       
   553     Slot which handles the clock type change..
       
   554  */
       
   555 void ClockSettingsView::handleClockTypeChanged()
       
   556 {
       
   557 	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_HANDLECLOCKTYPECHANGED_ENTRY );
       
   558 	mSettingsUtility->setClockType(
       
   559 			mClockTypeItem->contentWidgetData("text").toString());
       
   560 	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_HANDLECLOCKTYPECHANGED_EXIT );
       
   561 }
       
   562 
       
   563 /*!
       
   564 	Slot which is called when the value changes in cenrep.
       
   565 
       
   566 	\param key The key which got changed in cenrep.
       
   567 	\param value The new value of that key.
       
   568  */
       
   569 void ClockSettingsView::eventMonitor(
       
   570 		const XQSettingsKey& key, const QVariant& value)
       
   571 {
       
   572 	OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_EVENTMONITOR_ENTRY );
       
   573 	if (key.uid() == KCRUidClockApp && key.key() == KClockAppSnoozeTime) {
       
   574 		if (mSettingsManager->error() == XQSettingsManager::NoError) {
       
   575 
       
   576 			bool success;
       
   577 			int alarmSnoozeTime = value.toInt(&success);
       
   578 			
       
   579 			if (success) {
       
   580 				mAlarmSnoozeItem->setContentWidgetData(
       
   581 						"currentIndex", mAlarmSnoozeTimeHash.key(
       
   582 								alarmSnoozeTime));
       
   583 			}
       
   584 		}
       
   585 	}
       
   586 	OstTraceFunctionExit0( CLOCKSETTINGSVIEW_EVENTMONITOR_EXIT );
       
   587 }
       
   588 
       
   589 // End of file	--Don't remove this.