clock/clockui/clocksettingsview/src/settingscustomitem.cpp
changeset 58 ef813d54df51
parent 50 579cc610882e
child 68 a5a1242fd2e8
--- a/clock/clockui/clocksettingsview/src/settingscustomitem.cpp	Tue Jul 06 14:14:56 2010 +0300
+++ b/clock/clockui/clocksettingsview/src/settingscustomitem.cpp	Wed Aug 18 09:47:38 2010 +0300
@@ -36,6 +36,11 @@
 #include "clockcityselectionlist.h"
 #include "timezoneclient.h"
 #include "clockregionalsettingsview.h"
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "settingscustomitemTraces.h"
+#endif
+
 
 /*!
 	\class SettingsCustomItem
@@ -52,10 +57,12 @@
 SettingsCustomItem::SettingsCustomItem(QGraphicsItem *parent)
 :HbDataFormViewItem(parent)
 {
+	OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_SETTINGSCUSTOMITEM_ENTRY );
 	// Construct the settignsutility.
 	mSettingsUtility = new SettingsUtility();
 	// Construct the timezone client.
 	mTimezoneClient = TimezoneClient::getInstance();
+	OstTraceFunctionExit0( SETTINGSCUSTOMITEM_SETTINGSCUSTOMITEM_EXIT );
 }
 
 /*!
@@ -63,7 +70,9 @@
  */
 SettingsCustomItem::~SettingsCustomItem()
 {
-    // Nothing yet.
+	OstTraceFunctionEntry0( DUP1_SETTINGSCUSTOMITEM_SETTINGSCUSTOMITEM_ENTRY );
+	// Nothing yet.
+	OstTraceFunctionExit0( DUP1_SETTINGSCUSTOMITEM_SETTINGSCUSTOMITEM_EXIT );
 }
 
 /*!
@@ -72,6 +81,7 @@
  */
 HbAbstractViewItem* SettingsCustomItem::createItem()
 {
+	OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_CREATEITEM_ENTRY );
 	return new SettingsCustomItem(*this);
 }
 
@@ -81,14 +91,17 @@
  */
 bool SettingsCustomItem::canSetModelIndex(const QModelIndex &index) const
 {
+	OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_CANSETMODELINDEX_ENTRY );
 	HbDataFormModelItem::DataItemType itemType =
 			static_cast<HbDataFormModelItem::DataItemType>(
 			index.data(HbDataFormModelItem::ItemTypeRole).toInt());
 
 	if(itemType >= HbDataFormModelItem::CustomItemBase &&
 			itemType <= (HbDataFormModelItem::CustomItemBase + 50)) {
+		OstTraceFunctionExit0( SETTINGSCUSTOMITEM_CANSETMODELINDEX_EXIT );
 		return true;
 	} else {
+		OstTraceFunctionExit0( DUP1_SETTINGSCUSTOMITEM_CANSETMODELINDEX_EXIT );
 		return false;
 	}
 
@@ -96,6 +109,7 @@
 
 void SettingsCustomItem::restore()
 {
+	OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_RESTORE_ENTRY );
 	HbDataFormModelItem::DataItemType itemType =
 			static_cast<HbDataFormModelItem::DataItemType>(
 			modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt());
@@ -107,27 +121,54 @@
 
 	switch (itemType) {
 		case (TimeItemOffset + HbDataFormModelItem::CustomItemBase):
-		mTimeWidget->setProperty("text", modlItem->contentWidgetData("text"));
-		break;
-
+		{
+			mTimeWidget->setProperty(
+					"text", modlItem->contentWidgetData("text"));
+			mTimeWidget->setProperty(
+					"objectName", modlItem->contentWidgetData("objectName"));
+			break;
+		}
 		case (DateItemOffset + HbDataFormModelItem::CustomItemBase):
-		mDateWidget->setProperty("text", modlItem->contentWidgetData("text"));
-		break;
-
+		{
+			mDateWidget->setProperty(
+					"text", modlItem->contentWidgetData("text"));
+			mDateWidget->setProperty(
+					"objectName", modlItem->contentWidgetData("objectName"));
+			break;
+		}
 		case (PlaceItemOffset + HbDataFormModelItem::CustomItemBase):
-		mPlaceWidget->setProperty("text", modlItem->contentWidgetData("text"));
-		break;
+		{
+			mPlaceWidget->setProperty(
+					"text", modlItem->contentWidgetData("text"));
+			mPlaceWidget->setProperty(
+					"objectName", modlItem->contentWidgetData("objectName"));
+			break;
+		}
+		case (RegionalItemOffset + HbDataFormModelItem::CustomItemBase):
+		{
+			mRegSettingsWidget->setProperty(
+					"text", modlItem->contentWidgetData("text"));
+			mRegSettingsWidget->setProperty(
+					"objectName", modlItem->contentWidgetData("objectName"));
+			break;
+		}
 		case (50 + HbDataFormModelItem::CustomItemBase):
-
-		break;
+		{
+			mWorkdaysWidget->setProperty(
+					"objectName", modlItem->contentWidgetData("objectName"));
+			break;
+		}
 		default:
 		break;
 	}
+	OstTraceFunctionExit0( SETTINGSCUSTOMITEM_RESTORE_EXIT );
 }
 
 void SettingsCustomItem::setWeekdaysList(QStringList list)
 {
+	OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_SETWEEKDAYSLIST_ENTRY );
 	mWeekdaysList = list;
+	OstTraceFunctionExit0( SETTINGSCUSTOMITEM_SETWEEKDAYSLIST_EXIT );
 }
 
 /*!
@@ -136,6 +177,7 @@
  */
 HbWidget* SettingsCustomItem::createCustomWidget()
 {
+	OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_CREATECUSTOMWIDGET_ENTRY );
 	HbDataFormModelItem::DataItemType itemType =
 		static_cast<HbDataFormModelItem::DataItemType>(modelIndex()
 		.data(HbDataFormModelItem::ItemTypeRole).toInt());
@@ -147,6 +189,7 @@
 			connect(
 					mTimeWidget, SIGNAL(clicked()),
 					this, SLOT(launchTimePicker()));
+			OstTraceFunctionExit0( SETTINGSCUSTOMITEM_CREATECUSTOMWIDGET_EXIT );
 			return mTimeWidget;
 		}
 
@@ -156,6 +199,7 @@
 			connect(
 					mDateWidget, SIGNAL(clicked()),
 					this, SLOT(launchDatePicker()));
+			OstTraceFunctionExit0( DUP1_SETTINGSCUSTOMITEM_CREATECUSTOMWIDGET_EXIT );
 			return mDateWidget;
 		}
 
@@ -165,28 +209,31 @@
 			connect(
 					mPlaceWidget, SIGNAL(clicked()),
 					this, SLOT(launchCitySelectionList()));
+			OstTraceFunctionExit0( DUP2_SETTINGSCUSTOMITEM_CREATECUSTOMWIDGET_EXIT );
 			return mPlaceWidget;
 		}
 
 		case (RegionalItemOffset + HbDataFormModelItem::CustomItemBase):
 		{
-			HbPushButton *regSettingsItem = new HbPushButton(this);
-			regSettingsItem->setText(
-				QString(hbTrId("txt_clock_button_regional_date_time_settings")));
+			mRegSettingsWidget = new HbPushButton(this);
 			connect(
-					regSettingsItem, SIGNAL(clicked()),
+					mRegSettingsWidget, SIGNAL(clicked()),
 					this, SLOT(launchRegSettingsView()));
-			return regSettingsItem;
+			OstTraceFunctionExit0( DUP3_SETTINGSCUSTOMITEM_CREATECUSTOMWIDGET_EXIT );
+			return mRegSettingsWidget;
 		}
 
 		case (50 + HbDataFormModelItem::CustomItemBase):
 		{
-			HbListWidget *workdaysItem = new HbListWidget();
-			workdaysItem->setSelectionMode(HbAbstractItemView::MultiSelection);
+			mWorkdaysWidget = new HbListWidget(this);
+			mWorkdaysWidget->setSelectionMode(HbAbstractItemView::MultiSelection);
+			mWorkdaysWidget->setScrollDirections(0);
+			mWorkdaysWidget->ungrabGesture(Qt::PanGesture);
+			
 			QItemSelectionModel *model = 0;
-			model = workdaysItem->selectionModel();
+			model = mWorkdaysWidget->selectionModel();
 			for (int index = 0; index < mWeekdaysList.count(); ++index) {
-				workdaysItem->addItem(mWeekdaysList.at(index));
+				mWorkdaysWidget->addItem(mWeekdaysList.at(index));
 			}
 
 			QString workdaysString = workdaysSetting();
@@ -205,7 +252,8 @@
 				}
 			}
 
-			return workdaysItem;
+			OstTraceFunctionExit0( DUP4_SETTINGSCUSTOMITEM_CREATECUSTOMWIDGET_EXIT );
+			return mWorkdaysWidget;
 		}
 
 		default:
@@ -218,6 +266,7 @@
  */
 void SettingsCustomItem::launchTimePicker()
 {
+	OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_LAUNCHTIMEPICKER_ENTRY );
 	if (mTimePickerDialog) {
 		delete mTimePickerDialog;
 	}
@@ -254,6 +303,7 @@
 	mTimePickerDialog->addAction(mCancelAction);
 
 	mTimePickerDialog->open(this, SLOT(selectedAction(HbAction*)));
+	OstTraceFunctionExit0( SETTINGSCUSTOMITEM_LAUNCHTIMEPICKER_EXIT );
 }
 
 /*!
@@ -261,6 +311,7 @@
  */
 void SettingsCustomItem::handleOkAction()
 {
+	OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_HANDLEOKACTION_ENTRY );
 	if (mTimePickerDialog) {
 		// Get the time from the time picker.
 		QTime newTime = static_cast<HbDateTimePicker *> (
@@ -292,6 +343,7 @@
 					QDateTime(newDate, QTime::currentTime()));
 		}
 	}
+	OstTraceFunctionExit0( SETTINGSCUSTOMITEM_HANDLEOKACTION_EXIT );
 }
 
 /*!
@@ -299,6 +351,7 @@
  */
 void SettingsCustomItem::launchDatePicker()
 {
+	OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_LAUNCHDATEPICKER_ENTRY );
 	if (mDatePickerDialog) {
 		delete mDatePickerDialog;
 	}
@@ -332,6 +385,7 @@
 	mDatePickerDialog->addAction(mCancelAction);
 
 	mDatePickerDialog->open(this, SLOT(selectedAction(HbAction*)));
+	OstTraceFunctionExit0( SETTINGSCUSTOMITEM_LAUNCHDATEPICKER_EXIT );
 }
 
 /*!
@@ -339,12 +393,14 @@
  */
 void SettingsCustomItem::launchCitySelectionList()
 {
-	mCitySelectionList = new ClockCitySelectionList(this);
+	OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_LAUNCHCITYSELECTIONLIST_ENTRY );
+	mCitySelectionList = new ClockCitySelectionList(mTimezoneClient, this);
 	connect(
 			mCitySelectionList, SIGNAL(citySelected(LocationInfo)),
 			this, SLOT(updatePlaceItem(LocationInfo)));
 
 	mCitySelectionList->showCityList();
+	OstTraceFunctionExit0( SETTINGSCUSTOMITEM_LAUNCHCITYSELECTIONLIST_EXIT );
 }
 
 /*!
@@ -354,9 +410,11 @@
  */
 void SettingsCustomItem::updatePlaceItem(LocationInfo info)
 {
+	OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_UPDATEPLACEITEM_ENTRY );
 	if (-1 != info.timezoneId) {
 		mTimezoneClient->setAsCurrentLocationL(info);
 	}
+	OstTraceFunctionExit0( SETTINGSCUSTOMITEM_UPDATEPLACEITEM_EXIT );
 }
 
 /*!
@@ -364,12 +422,14 @@
  */
 void SettingsCustomItem::launchRegSettingsView()
 {
+	OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_LAUNCHREGSETTINGSVIEW_ENTRY );
 	ClockRegionalSettingsView *view =
 			new ClockRegionalSettingsView();
 	connect(mTimezoneClient, SIGNAL(timechanged()),
           view, SLOT(updateWeekStartOn()));
 	view->showView();
 	
+	OstTraceFunctionExit0( SETTINGSCUSTOMITEM_LAUNCHREGSETTINGSVIEW_EXIT );
 }
 
 /*!
@@ -377,9 +437,11 @@
  */
 void SettingsCustomItem::selectedAction(HbAction *action)
 {
+	OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_SELECTEDACTION_ENTRY );
 	if (action==mOkAction) {
 		handleOkAction();
 	}
+	OstTraceFunctionExit0( SETTINGSCUSTOMITEM_SELECTEDACTION_EXIT );
 }
 
 /*!
@@ -387,6 +449,7 @@
  */
 QString SettingsCustomItem::workdaysSetting()
 {
+	OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_WORKDAYSSETTING_ENTRY );
 	HbExtendedLocale locale = HbExtendedLocale::system();
 	// 0(Sun)0(sat)1(Fri)1(Thu)1(Wed)1(Tue)1(Mon)
 	QString workdaysString = locale.workDays();
@@ -405,6 +468,7 @@
     }
 //	workdays.append('\0');
 
+	OstTraceFunctionExit0( SETTINGSCUSTOMITEM_WORKDAYSSETTING_EXIT );
 	return workdays;
 }