calendarui/caleneditor/src/caleneditorcustomitem.cpp
changeset 58 ef813d54df51
parent 50 579cc610882e
child 68 a5a1242fd2e8
--- a/calendarui/caleneditor/src/caleneditorcustomitem.cpp	Tue Jul 06 14:14:56 2010 +0300
+++ b/calendarui/caleneditor/src/caleneditorcustomitem.cpp	Wed Aug 18 09:47:38 2010 +0300
@@ -33,17 +33,22 @@
 #include <QGraphicsLinearLayout>
 #include <QDate>
 #include <QTime>
+#include <xqaiwrequest.h>
+#include <xqappmgr.h>
 
 //LI related headers
 #include "qlocationpickeritem.h"
-#include <xqaiwrequest.h>
-#include <xqappmgr.h>
 
 // User includes
 #include "caleneditorcustomitem.h"
 #include "calendateutils.h"
 #include "caleneditorcommon.h"
 #include "caleneditordocloader.h"
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "caleneditorcustomitemTraces.h"
+#endif
+
 
 /*!
 	\class CalenEditorCustomItem
@@ -56,33 +61,44 @@
  */
 CalenEditorCustomItem::CalenEditorCustomItem(QGraphicsItem *parent)
 :HbDataFormViewItem(parent),
- mPushButtonTime(NULL),
- mPushButtonDate(NULL),
- mRepeatUntilWidget(NULL),
- mReminderTimeWidget(NULL),
- mDatePicker(NULL),
- mTimePicker(NULL)
+ mAppManager(0),
+ mRequest(0),
+ mPushButtonTime(0),
+ mPushButtonDate(0),
+ mRepeatUntilWidget(0),
+ mReminderTimeWidget(0),
+ mDatePicker(0),
+ mTimePicker(0),
+ mRequestPending(false)
 {
+	OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_CALENEDITORCUSTOMITEM_ENTRY );
 	mMinDate = CalenDateUtils::minTime().date();
 	mMaxDate = CalenDateUtils::maxTime().date();
 	mMinTime.setHMS(0,0,0,0);
 	mMaxTime.setHMS(23,59,59,999);
 	mLocale = HbExtendedLocale::system();
-	mLocationLineEdit = NULL;
-	mLocationPushButton = NULL;
+	mLocationLineEdit = 0;
+	mLocationPushButton = 0;
+	OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_CALENEDITORCUSTOMITEM_EXIT );
 }
 /*!
 	Destructor.
  */
 CalenEditorCustomItem::~CalenEditorCustomItem()
 {
+	OstTraceFunctionEntry0( DUP1_CALENEDITORCUSTOMITEM_CALENEDITORCUSTOMITEM_ENTRY );
 	// Nothing yet.
+	OstTraceFunctionExit0( DUP1_CALENEDITORCUSTOMITEM_CALENEDITORCUSTOMITEM_EXIT );
+	
+  delete mAppManager;
+  delete mRequest;
 }
 /*!
 	Creates a new CalenEditorCustomItem.
  */
 HbAbstractViewItem* CalenEditorCustomItem::createItem()
 {
+	OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_CREATEITEM_ENTRY );
 	return new CalenEditorCustomItem(*this);
 }
 /*!
@@ -90,6 +106,7 @@
  */
 HbWidget* CalenEditorCustomItem::createCustomWidget()
 {
+	OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_ENTRY );
 	HbDataFormModelItem::DataItemType itemType =
 			static_cast<HbDataFormModelItem::DataItemType> (modelIndex() .data(
 					HbDataFormModelItem::ItemTypeRole).toInt());
@@ -103,15 +120,18 @@
 		widgetTop->setLayout(layoutTop);
 
 			mPushButtonTime = new HbPushButton();
+			mPushButtonTime->setObjectName("startTime");
 			connect(mPushButtonTime, SIGNAL(clicked()),
 									this, SLOT(handleTime()));
 			layoutTop->addItem(mPushButtonTime);
 
 			mPushButtonDate =
 			                new HbPushButton();
+			mPushButtonDate->setObjectName("startDate");
 			connect(mPushButtonDate, SIGNAL(clicked()),
 												this, SLOT(handleDate()));
 			layoutTop->addItem(mPushButtonDate);
+			OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT );
 			return widgetTop;
 		}
 
@@ -124,14 +144,17 @@
 		widgetBottom->setLayout(layoutBottom);
 
 		mPushButtonTime = new HbPushButton(this);
+		mPushButtonTime->setObjectName("endTime");
 		connect(mPushButtonTime, SIGNAL(clicked()),
 											this, SLOT(handleTime()));
 		layoutBottom->addItem(mPushButtonTime);
 		
 		mPushButtonDate = new HbPushButton(this);
+		mPushButtonDate->setObjectName("endDate");
 		connect(mPushButtonDate, SIGNAL(clicked()),
 												this, SLOT(handleDate()));
 		layoutBottom->addItem(mPushButtonDate);
+			OstTraceFunctionExit0( DUP1_CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT );
 		return widgetBottom;
 		}
 				
@@ -150,11 +173,13 @@
 			mLocationLineEdit = qobject_cast<HbLineEdit *>( 
 									editorLocationDocLoader.findWidget(
 											CALEN_EDITOR_LOCATION_LINEEDIT));
+			mLocationLineEdit->setObjectName("locationLineEdit");
 			mLocationLineEdit->setMinRows(1);
-			mLocationLineEdit->setMaxRows(4);
+			mLocationLineEdit->setMaxRows(MaxRowsInTextItem);
 			mLocationPushButton = qobject_cast<HbPushButton*>(
 									editorLocationDocLoader.findWidget(
 											CALEN_EDITOR_LOCATION_PUSHBUTTON));
+			mLocationPushButton->setObjectName("locationIcon");
 			mLocationPushButton->setIcon( HbIcon("qtg_mono_location"));
 			
 			connect(mLocationPushButton, SIGNAL(clicked()), this, 
@@ -165,18 +190,23 @@
 			connect(mLocationLineEdit, SIGNAL(editingFinished()),
 			            this, SLOT(handleEditingFinished()));
 			
+			OstTraceFunctionExit0( DUP2_CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT );
 			return widgetLocation;
 		}
 		
 		case RepeatUntilOffset:
 		{
 		mRepeatUntilWidget = new HbPushButton(this);
+		mRepeatUntilWidget->setObjectName("repeatUntilItem");
+		OstTraceFunctionExit0( DUP3_CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT );
 		return mRepeatUntilWidget;
 		}
 				
 		case ReminderTimeOffset:
 		{
 			mReminderTimeWidget = new HbPushButton(this);
+			mReminderTimeWidget->setObjectName("remainderTimeItem");
+			OstTraceFunctionExit0( DUP4_CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT );
 			return mReminderTimeWidget;
 		}
 		
@@ -190,24 +220,34 @@
 
 void CalenEditorCustomItem::launchLocationPicker()
 {
-	XQApplicationManager *appManager = new XQApplicationManager();
-
-    XQAiwRequest *request = appManager->create("com.nokia.symbian", "ILocationPick", "pick()", true);
-    if( request )
+		OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_LAUNCHLOCATIONPICKER_ENTRY );
+   	if(!mAppManager)
+	{
+    	mAppManager = new XQApplicationManager();
+    }
+	if(!mRequest)
+	{
+    	mRequest = mAppManager->create("com.nokia.symbian", "ILocationPick", "pick()", true);
+    	mRequest->setSynchronous(false);
+    	connect(mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(setSelectedLocation(const QVariant&)));
+    }
+	if(!mRequestPending)
     {
-		QVariant retValue;
-		if( request->send( retValue ) )
-		{
-			setSelectedLocation(retValue);
-		}
-	}
+    	if( mRequest->send() )
+    	{
+    		mRequestPending = true;
+    	}
+    }
+    OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_LAUNCHLOCATIONPICKER_EXIT );
 }
 /*!
 	set the selected location from the picker to the line edit widget 
 	and notify the other observers.
 */
-void CalenEditorCustomItem::setSelectedLocation( QVariant &aValue )
+void CalenEditorCustomItem::setSelectedLocation( const QVariant &aValue )
 {
+	OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_SETSELECTEDLOCATION_ENTRY );
+	mRequestPending = false;
 	QLocationPickerItem selectedLocation = aValue.value<QLocationPickerItem>();
 	if( selectedLocation.mIsValid )
     {
@@ -226,6 +266,7 @@
 		emit locationTextChanged(locationString, selectedLocation.mLatitude, selectedLocation.mLongitude);
 		mLocationLineEdit->setText(locationString );
     }
+	OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_SETSELECTEDLOCATION_EXIT );
 }
 
 /*!
@@ -233,6 +274,7 @@
  */
 void CalenEditorCustomItem::populateDateTime(QDateTime defaultDateTime, bool isFromItem)
 {
+	OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_POPULATEDATETIME_ENTRY );
 	// Store the date and time to be shown
     mDate = defaultDateTime.date();
 	mTime = defaultDateTime.time();
@@ -243,6 +285,7 @@
 												r_qtn_date_usual_with_zero));
 	mPushButtonTime->setText(mLocale.format(defaultDateTime.time(), 
 												r_qtn_time_usual_with_zero));
+	OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_POPULATEDATETIME_EXIT );
 }
 
 /*!
@@ -250,7 +293,9 @@
  */
 void CalenEditorCustomItem::populateLocation(QString location )
 {
+	OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_POPULATELOCATION_ENTRY );
 	mLocationLineEdit->setText( location );
+	OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_POPULATELOCATION_EXIT );
 }
 
 /*!
@@ -258,6 +303,7 @@
  */
 void CalenEditorCustomItem::setDateRange(QDate start, QDate end)
 {
+	OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_SETDATERANGE_ENTRY );
 	mMaxDate = end;
 	mMinDate = start;
 	// Check if both are falling on same day
@@ -266,6 +312,7 @@
 			(mMaxDate.day() == mMinDate.day())) {
 		enableDateButton(false);
 	}
+	OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_SETDATERANGE_EXIT );
 }
 
 /*!
@@ -273,8 +320,10 @@
  */
 void CalenEditorCustomItem::setTimeRange(QTime start, QTime end)
 {
+	OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_SETTIMERANGE_ENTRY );
 	mMaxTime = start;
 	mMinTime = end;
+	OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_SETTIMERANGE_EXIT );
 }
 
 /*!
@@ -282,7 +331,9 @@
  */
 void CalenEditorCustomItem::enableDateButton(bool value)
 {
+	OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_ENABLEDATEBUTTON_ENTRY );
 	mPushButtonDate->setEnabled(value);
+	OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_ENABLEDATEBUTTON_EXIT );
 }
 
 /*!
@@ -290,7 +341,9 @@
  */
 void CalenEditorCustomItem::handleLocationTextChange(QString location)
 {
+	OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_HANDLELOCATIONTEXTCHANGE_ENTRY );
 	emit locationTextChanged(location);
+	OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_HANDLELOCATIONTEXTCHANGE_EXIT );
 }
 
 /*!
@@ -298,7 +351,9 @@
  */
 void CalenEditorCustomItem::handleEditingFinished()
 {
+    OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_HANDLEEDITINGFINISHED_ENTRY );
     emit locationEditingFinished();
+    OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_HANDLEEDITINGFINISHED_EXIT );
 }
 
 /*!
@@ -306,6 +361,7 @@
  */
 void CalenEditorCustomItem::handleDate()
 {
+	OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_HANDLEDATE_ENTRY );
 	// Create a popup with datepicker for the user to select date.
 	HbDialog *popUp = new HbDialog();
 	popUp->setDismissPolicy(HbDialog::NoDismiss);
@@ -322,7 +378,7 @@
 	}
 	// Create a date picker
 	if(mDatePicker) {
-		mDatePicker = NULL;
+		mDatePicker = 0;
 	}
 	mDatePicker = new HbDateTimePicker(mDate, popUp);
 	mDatePicker->setMinimumDate(mMinDate);
@@ -334,6 +390,7 @@
 	connect(okAction, SIGNAL(triggered()), this, SLOT(saveDate()));
 	popUp->addAction(new HbAction(hbTrId("txt_common_button_cancel"), popUp));
 	popUp->open();
+	OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_HANDLEDATE_EXIT );
 }
 
 /*!
@@ -341,6 +398,7 @@
  */
 void CalenEditorCustomItem::handleTime()
 {
+	OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_HANDLETIME_ENTRY );
 	// Create a popup with time picker for the user to select time.
 	HbDialog *popUp = new HbDialog();
 	popUp->setDismissPolicy(HbDialog::NoDismiss);
@@ -357,7 +415,7 @@
 	}
 	// Create a time picker.
 	if(mTimePicker) {
-		mTimePicker = NULL;
+		mTimePicker = 0;
 	}
 	mTimePicker = new HbDateTimePicker(mTime, popUp);
 	
@@ -374,6 +432,7 @@
 	connect(okAction, SIGNAL(triggered()), this, SLOT(saveTime()));
 	popUp->addAction(new HbAction(hbTrId("txt_common_button_cancel"), popUp));
 	popUp->open();
+	OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_HANDLETIME_EXIT );
 }
 
 /*!
@@ -381,6 +440,7 @@
  */
 void CalenEditorCustomItem::saveDate()
 {
+	OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_SAVEDATE_ENTRY );
 	mDate = mDatePicker->date(); 
 	if (mDate.isValid()) {
 		mPushButtonDate->setText(mLocale.format(mDate, 
@@ -388,6 +448,7 @@
 		QDateTime dateTime(mDate,mTime);
 		emit dateTimeUpdated(dateTime);
 		}
+	OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_SAVEDATE_EXIT );
 }
 
 /*!
@@ -395,6 +456,7 @@
  */
 void CalenEditorCustomItem::saveTime()
 {
+	OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_SAVETIME_ENTRY );
 	mTime = mTimePicker->time();
 	if (mTime.isValid()) {
 		mPushButtonTime->setText(mLocale.format(mTime, 
@@ -403,6 +465,7 @@
 		QDateTime dateTime(mDate,mTime);
 		emit dateTimeUpdated(dateTime);
 	}
+	OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_SAVETIME_EXIT );
 }
 
 /*!
@@ -410,6 +473,7 @@
  */
 void CalenEditorCustomItem::enableFromTimeFieldAndSetTime(bool enableTimeFiles, QDateTime fromDateTime)
 {
+	OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_ENABLEFROMTIMEFIELDANDSETTIME_ENTRY );
 	// Set FromTime filed Read-Only/Editable 
 	mPushButtonTime->setEnabled(enableTimeFiles);
 	
@@ -418,6 +482,7 @@
 	
 	// Store the time
     mTime = fromDateTime.time();
+    OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_ENABLEFROMTIMEFIELDANDSETTIME_EXIT );
 }
 
 /*!
@@ -425,8 +490,10 @@
  */
 void CalenEditorCustomItem::disableFromToDateField()
 {
+	OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_DISABLEFROMTODATEFIELD_ENTRY );
 	// disable the date field.
 	mPushButtonDate->setEnabled(false);
+	OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_DISABLEFROMTODATEFIELD_EXIT );
 }
 
 /*!
@@ -434,6 +501,7 @@
  */
 void CalenEditorCustomItem::enableToTimeFieldAndSetTime(bool enableTimeFiles, QDateTime toDateTime)
 {
+	OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_ENABLETOTIMEFIELDANDSETTIME_ENTRY );
 	// Set ToTime filed Read-Only/Editable 
 	mPushButtonTime->setEnabled(enableTimeFiles);
 	
@@ -443,6 +511,7 @@
 	
 	// Store the time
 	mTime = toDateTime.time();
+	OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_ENABLETOTIMEFIELDANDSETTIME_EXIT );
 }
 
 /*!
@@ -450,20 +519,24 @@
  */
 bool CalenEditorCustomItem::canSetModelIndex(const QModelIndex &index) const
 {
+    OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_CANSETMODELINDEX_ENTRY );
     HbDataFormModelItem::DataItemType itemType = 
         static_cast<HbDataFormModelItem::DataItemType>(
         index.data(HbDataFormModelItem::ItemTypeRole).toInt());
 
     if(itemType == CustomWidgetFrom || itemType == CustomWidgetTo || itemType == RepeatUntilOffset 
 			|| itemType == CustomWidgetLocation || itemType == ReminderTimeOffset ) {
+        OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_CANSETMODELINDEX_EXIT );
         return true;
     } else {
+        OstTraceFunctionExit0( DUP1_CALENEDITORCUSTOMITEM_CANSETMODELINDEX_EXIT );
         return false;
     }
 }
 
 void CalenEditorCustomItem::restore()
 {
+    OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_RESTORE_ENTRY );
     HbDataFormModelItem::DataItemType itemType = 
         static_cast<HbDataFormModelItem::DataItemType>(
         modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt());
@@ -485,10 +558,12 @@
     	}
     	break;
     }
+    OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_RESTORE_EXIT );
 }
 
 QDateTime CalenEditorCustomItem::getDateTime()
 {
+    OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_GETDATETIME_ENTRY );
     return QDateTime(mDate, mTime);
 }