calendarui/agendaeventviewer/src/agendaeventview.cpp
changeset 45 b6db4fd4947b
parent 23 fd30d51f876b
child 51 0b38fc5b94c6
--- a/calendarui/agendaeventviewer/src/agendaeventview.cpp	Mon May 03 12:30:32 2010 +0300
+++ b/calendarui/agendaeventviewer/src/agendaeventview.cpp	Mon Jun 28 15:22:02 2010 +0530
@@ -17,12 +17,14 @@
 
 // System includes
 #include <QObject>
-#include <QDebug>
 #include <QDateTime>
-#include <qtranslator.h>
 #include <QGraphicsLinearLayout>
+#include <QFile>
+#include <QString>
+#include <QTimer>
+#include <QPluginLoader>
+#include <QDir>
 #include <HbInstance>
-#include <hbapplication.h>
 #include <HbMainWindow>
 #include <HbView>
 #include <HbMenu>
@@ -37,14 +39,12 @@
 #include <HbMessageBox>
 #include <HbDialog>
 #include <HbLabel>
-#include <QFile>
-#include <QString>
-#include <QIcon>
-#include <QPainter>
-#include <QPixmap>
+#include <HbTranslator>
+
 // User includes
+#include <maptileservice.h>//maptile service
 #include <agendautil.h>
-#include <noteseditor.h>
+#include <NotesEditorInterface>
 #include <caleneditor.h>
 #include "agendaeventview.h"
 #include "agendaeventviewerdocloader.h"
@@ -52,18 +52,14 @@
 #include "agendaeventviewer_p.h"
 #include "agendaeventvieweritem.h"
 #include "calendateutils.h"
-
-//maptile service 
-#include <maptileservice.h>
 // Constants
 #define CHARACTER_HYPHEN    "-"
 #define CHARACTER_SPACE     " "
 #define CHARACTER_NEW_LINE  "\n"
 
-// This is used to set the maptile image height and width ,
-//because HbLabel by default not displaying the actual size of image 
-const int height = 128;
-const int width =  330;
+//This Property is use for setting a primary left icon
+static const char *primaryLeftIconItem("leftPrimaryIconItem");
+
 /*!
 	\class AgendaEventView.
 
@@ -81,21 +77,18 @@
 AgendaEventView::AgendaEventView(
 		AgendaEventViewerPrivate *owner, QObject *parent):
 		QObject(parent),
+		mMainWindow(NULL),
 		mOwner(owner),
+		mTranslator(new HbTranslator("caleneventviewer")),
 		mReminderWidgetAdded(true),
-		mMainWindow(NULL),
-		mMaptilePath(NULL)
+		mMaptilePath(NULL),
+		mMaptileService(NULL),
+		mProgressTimer(NULL),
+		mProgressIconCount(0),
+		mMaptileStatusReceived(false),
+		mMaptileStatus(-1),
+		mNotesPluginLoaded(false)
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::AgendaEventView -->";
-
-	// Load the translator based on locale
-	mTranslator = new QTranslator;
-	QString lang = QLocale::system().name();
-	QString path = "Z:/resource/qt/translations/";
-	mTranslator->load("caleneventviewer_en_GB",":/translations");
-	// TODO: Load the appropriate .qm file based on locale
-	//bool loaded = mTranslator->load("caleneventviewer_" + lang, path);
-	HbApplication::instance()->installTranslator(mTranslator);
 	
 	mDocLoader = new AgendaEventViewerDocLoader;
 
@@ -113,6 +106,9 @@
 	mSubjectWidget = qobject_cast<AgendaEventViewerItem *> (
 			mDocLoader->findWidget(AGENDA_EVENT_VIEWER_SUBJECT_WIDGET));
 
+    //load layout that supports icon before subject label
+    mSubjectWidget->setProperty(primaryLeftIconItem,true);  
+
 	mDateTimeWidget = qobject_cast<AgendaEventViewerItem *> (
 			mDocLoader->findWidget(AGENDA_EVENT_VIEWER_DATE_TIME_WIDGET));
 
@@ -139,12 +135,18 @@
     mLinearLayout = 
     		static_cast<QGraphicsLinearLayout *> (scrollAreaWidget->layout());
 	
-    MapTileService::AppType appType;
-    appType = MapTileService::AppTypeCalendar;
-    mLocationFeatureEnabled = MapTileService::isLocationFeatureEnabled(appType);
-    
+
+    //maptile service object , to retrive maptile path from database.
+    mMaptileService= new MapTileService();   
+    mLocationFeatureEnabled = mMaptileService->isLocationFeatureEnabled(
+        MapTileService::AppTypeCalendar);
+    if (mLocationFeatureEnabled) {
+        //timer to run progress indicator icon.
+        mProgressTimer = new QTimer(this);
+        mProgressTimer->setSingleShot(true);
+        connect(mProgressTimer, SIGNAL(timeout()), this, SLOT(updateProgressIndicator()));
+    }
         
-    qDebug() << "AgendaEventViewer: AgendaEventView::AgendaEventView <--";
 	
 }
 
@@ -153,10 +155,8 @@
  */
 AgendaEventView::~AgendaEventView()
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::~AgendaEventView -->";
 
 	// Remove the translator
-	HbApplication::instance()->removeTranslator(mTranslator);
 	if (mTranslator) {
 		delete mTranslator;
 		mTranslator = 0;
@@ -164,14 +164,30 @@
 	
 	mDocLoader->reset();
 	delete mDocLoader;
-	
+
+	// Unload notes editor if loaded.
+	if (mNotesEditorPluginLoader) {
+		mNotesEditorPluginLoader->unload();
+		delete mNotesEditorPluginLoader;
+		mNotesEditorPluginLoader = 0;
+	}
+
 	// Delete the mainwindow if we have created any
 	if (mMainWindow) {
 		delete mMainWindow;
 		mMainWindow = NULL;
 	}
 	
-	qDebug() << "AgendaEventViewer: AgendaEventView::~AgendaEventView <--";
+	if (mMaptileService) {
+        delete mMaptileService;
+        mMaptileService = NULL;
+    }
+    
+	if (mProgressTimer) {
+        delete mProgressTimer;
+        mProgressTimer = NULL;
+    }
+	
 }
 
 /*!
@@ -182,7 +198,6 @@
 void AgendaEventView::execute(AgendaEntry entry,
 											AgendaEventViewer::Actions action)
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::execute -->";
 
 	mOriginalAgendaEntry = entry;
 	mAgendaEntry = entry;
@@ -198,9 +213,6 @@
 	
 	// Add the toolbar items to event viewer
 	addToolBarItem(action);
-	
-	// Add the title to event viewer.
-	addGroupBoxData();
 
 	// Connect for the entry updation and addtion signal to refresh the view
 	// when the same is edited in editor.
@@ -222,18 +234,19 @@
 		mMainWindow = new HbMainWindow();
 		mMainWindow->addView(mViewer);
 		mMainWindow->setCurrentView(mViewer);
+	    connect(mMainWindow,SIGNAL(orientationChanged(Qt::Orientation)),this,SLOT(changedOrientation(Qt::Orientation)));		
 	} else {
 		window->addView(mViewer);
 		window->setCurrentView(mViewer);
+		connect(window,SIGNAL(orientationChanged(Qt::Orientation)),this,SLOT(changedOrientation(Qt::Orientation)));		
 	}
 	
 	// Add softkey after adding view on window
-	mBackAction = new HbAction(Hb::BackAction);
+	mBackAction = new HbAction(Hb::BackNaviAction);
 	mViewer->setNavigationAction(mBackAction);
 		
 	connect(mBackAction, SIGNAL(triggered()), this, SLOT(close()));
 
-	qDebug() << "AgendaEventViewer: AgendaEventView::execute <--";
 }
 
 /*!
@@ -241,7 +254,9 @@
  */
 void AgendaEventView::addViewerData()
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::addViewerData -->";
+	
+	// Add the title to event viewer.
+	addGroupBoxData();
 
 	// Set the summary & priority to viewer.
 	addSubjectAndPriorityData();
@@ -274,7 +289,6 @@
 	// Set the description.
 	addDescriptionData();
 	
-	qDebug() << "AgendaEventViewer: AgendaEventView::addViewerData <--";
 }
 
 /*!
@@ -282,7 +296,6 @@
  */
 void AgendaEventView::addMenuItem()
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::addMenuItem -->";
 
 	if (mAgendaEntry.type() == AgendaEntry::TypeTodo) {
 
@@ -300,7 +313,6 @@
 		        SLOT(markTodoStatus()));
 		menu->addAction(mMarkTodoAction);
 	}
-	qDebug() << "AgendaEventViewer: AgendaEventView::addMenuItem <--";
 }
 
 /*!
@@ -308,7 +320,6 @@
  */
 void AgendaEventView::addToolBarItem(AgendaEventViewer::Actions action)
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::addToolBarItem -->";
 
 	HbToolBar *toolBar = qobject_cast<HbToolBar *> (
 	                       mDocLoader->findWidget(AGENDA_EVENT_VIEWER_TOOLBAR));
@@ -339,7 +350,6 @@
 		toolBar->addAction(saveAction);
 	}
 
-	qDebug() << "AgendaEventViewer: AgendaEventView::addToolBarItem <--";
 }
 
 /*!
@@ -347,21 +357,20 @@
  */
 void AgendaEventView::addGroupBoxData()
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::addGroupBoxData -->";
 	
 	HbGroupBox *groupBox = qobject_cast<HbGroupBox *> (
 			mDocLoader->findWidget(AGENDA_EVENT_VIEWER_GROUPBOX));
 
-	if (mAgendaEntry.type() == AgendaEntry::TypeTodo) {
+	AgendaEntry::Type entryType = mAgendaEntry.type();
+	if (entryType == AgendaEntry::TypeTodo) {
 		groupBox->setHeading(hbTrId("txt_calendar_subhead_to_do"));
-	} else if (mAgendaEntry.type() == AgendaEntry::TypeNote) {
-		groupBox->setHeading(tr("Note"));
-	} else {
-		// TODO: Add the text id based on the entry type Anniversary or meeting
-		groupBox->setHeading(hbTrId("txt_calendar_subhead_event"));
+	} else if (entryType == AgendaEntry::TypeAppoinment) {
+		groupBox->setHeading(hbTrId("txt_calendar_subhead_meeting"));
+	}else if (entryType == AgendaEntry::TypeEvent) {
+		//TODO: Add text id once available
+		groupBox->setHeading(hbTrId("All day event"));
 	}
-
-	qDebug() << "AgendaEventViewer: AgendaEventView::addGroupBoxData <--";
+		
 }
 
 /*!
@@ -369,8 +378,6 @@
  */
 void AgendaEventView::addSubjectAndPriorityData()
 {
-	qDebug()
-	     << "AgendaEventViewer: AgendaEventView::addSubjectAndPriorityData -->";
 
 	QStringList itemList;
 	itemList.append(hbTrId("txt_calendar_dblist_subject"));
@@ -383,16 +390,17 @@
 
 	mSubjectWidget->setEventViewerItemData(itemList, Qt::DisplayRole);
 
-	itemList.clear();
-	QString priorityIcon(QString::null);
-	getPriorityIcon(mAgendaEntry.priority(), priorityIcon);
-	itemList.append(priorityIcon);
-	itemList.append(QString::null);
+    itemList.clear();
+    QString priorityIcon(QString::null);
+    QString subjectIcon(QString::null);
+    getPriorityIcon(mAgendaEntry.priority(), priorityIcon);
+    getSubjectIcon(mAgendaEntry.type(),subjectIcon);
+    itemList.append(subjectIcon);
+    itemList.append(priorityIcon);
+    itemList.append(QString::null);
 
 	mSubjectWidget->setEventViewerItemData(itemList, Qt::DecorationRole);
 
-	qDebug()
-	     << "AgendaEventViewer: AgendaEventView::addSubjectAndPriorityData <--";
 }
 
 /*!
@@ -400,9 +408,6 @@
  */
 void AgendaEventView::addDateTimeData()
 {
-    qDebug()
-         << "AgendaEventViewer: AgendaEventView::addDateTimeData -->";
-    
     
     QStringList itemData;
     HbExtendedLocale systemLocale = HbExtendedLocale::system();
@@ -410,7 +415,11 @@
     QDateTime endDateTime = mAgendaEntry.endTime();
     
     itemData.append(QString::null);
+    itemData.append(QString::null);
     itemData.append("qtg_small_calendar");
+
+    mDateTimeWidget->setProperty(primaryLeftIconItem, false);  
+
     mDateTimeWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
     itemData.clear();
     itemData.append(QString::null);
@@ -461,14 +470,13 @@
 
     		dateTimeText.append(systemLocale.format(startDateTime.date(),
 												r_qtn_date_usual_with_zero));
-
-    		if (CalenDateUtils::onSameDay(startDateTime, endDateTime)) {
+    		if (CalenDateUtils::onSameDay(startDateTime, endDateTime.addSecs(-60))) {
     			data.append(hbTrId("txt_calendar_dblist_meeting_date").arg(
 											dateTimeText));
     		} else {
     			QString endDate;
     			endDate.append(
-    					systemLocale.format(endDateTime.date(),
+    					systemLocale.format(endDateTime.addSecs(-60).date(),
 												r_qtn_date_usual_with_zero));
     			data.append(hbTrId("txt_calendar_dblist_start_end_time").arg(
 											dateTimeText).arg(endDate));
@@ -480,8 +488,6 @@
 	itemData.append(data);
     mDateTimeWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
     
-    qDebug()
-         << "AgendaEventViewer: AgendaEventView::addDateTimeData <--";
 }
 
 /*!
@@ -489,16 +495,28 @@
  */
 void AgendaEventView::addLocationData()
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::addLocationData -->";
 	QStringList itemData;
-	itemData.append(QString::null);
-	itemData.append("qtg_small_location");
+	QString progressIcon(QString::null);	
+	if ( mLocationFeatureEnabled ) {
+	    getProgressIndicatorstatus(progressIcon);	   
+	}
+	 if( progressIcon.isNull() ) {
+	     itemData.append(QString::null);
+	     itemData.append(QString::null);
+	     itemData.append("qtg_small_location");
+	     mLocationWidget->setProperty(primaryLeftIconItem, false);
+	 }
+	 else {
+	     itemData.append("qtg_small_location");
+	     itemData.append( progressIcon );  
+	     itemData.append(QString::null);
+	     mLocationWidget->setProperty(primaryLeftIconItem, true);
+	 }
 	mLocationWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
 	itemData.clear();
 	itemData.append(QString::null);
 	itemData.append(mAgendaEntry.location());
 	mLocationWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
-	qDebug() << "AgendaEventViewer: AgendaEventView::addLocationData <--";
 }
 
 /*!
@@ -506,70 +524,42 @@
  */
 void AgendaEventView::addMapTileImage()
 {
+    if (mLocationFeatureEnabled && !mAgendaEntry.location().isEmpty() && !mMaptilePath.isEmpty()) {
 
-    qDebug() << "AgendaEventViewer: AgendaEventView::addMapTileImage -->";
-    
-    if (!mAgendaEntry.location().isEmpty() && mLocationFeatureEnabled){
-        MapTileService::AddressType addressType;
-        addressType = MapTileService::AddressPlain;
-        int eventId = mAgendaEntry.id();
-        mMaptilePath = MapTileService::getMapTileImage(eventId, addressType);
-        if (!mMaptilePath.isNull())
-        {                        
-            QIcon mapTileIcon(mMaptilePath);
-            QPainter painter;
-            QPixmap baloon(HbIcon("qtg_small_location.svg").pixmap());
-            QPixmap map (mapTileIcon.pixmap(width,height));
-            //Display pin image in the center of maptile image
-            painter.begin( &map );
-            painter.drawPixmap( (width/2)-(baloon.width()/2), 
-                          (height/2)-baloon.height(), baloon );
-            painter.end();
-            mapTileIcon.addPixmap( map );          
-            
-            HbIcon maptile(mapTileIcon);
-            mMaptileLabel->setIcon(maptile);        
-
-            mMaptileLabel->setPreferredSize(QSizeF(width, height));
-            mMaptileLabel->setMinimumSize(QSizeF(width, height));
-            mMaptileLabel->setMaximumSize(QSizeF(width, height));
-            mMaptileLabel->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
-                    QSizePolicy::Fixed));            
-
-        }
+        HbIcon maptile(mMaptilePath);
+        mMaptileLabel->setIcon(maptile);
+        mMaptileLabel->setPreferredSize(QSizeF(maptile.width(), maptile.height()));
     }
-
-    qDebug() << "AgendaEventViewer: AgendaEventView::addMapTileImage <--";
 }
 /*!
 	Add reminder data to Event viewer
  */
 void AgendaEventView::addReminderData()
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::addReminderData -->";
 	QStringList itemData;
 	itemData.append(QString::null);
-	itemData.append("qtg_small_reminder");
+    itemData.append(QString::null);
+    itemData.append("qtg_small_reminder");
+    mReminderWidget->setProperty(primaryLeftIconItem, false); 
 	mReminderWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
 	itemData.clear();
 	itemData.append(QString::null);
 	itemData.append(alarmTimeText());
 	mReminderWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
-	qDebug() << "AgendaEventViewer: AgendaEventView::addReminderData <--";
-}
+    }
 
 /*!
 	Add completed to-do data to Event viewer
  */
 void AgendaEventView::addCompletedTodoData()
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::addCompletedTodoData -->";
 	QStringList itemData;
 	QString     completedText;
-	HbExtendedLocale systemLocale = HbExtendedLocale::system();;
-	
+    HbExtendedLocale systemLocale = HbExtendedLocale::system();;
+    itemData.append(QString::null);
 	itemData.append(QString::null);
 	itemData.append(QString::null);
+    mReminderWidget->setProperty(primaryLeftIconItem, false);
 	mReminderWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
 	itemData.clear();
 	completedText = systemLocale.format(mAgendaEntry.completedDateTime().date(),
@@ -577,7 +567,6 @@
 	itemData.append(hbTrId("txt_calendar_dblist_completed_date"));
 	itemData.append(completedText);
 	mReminderWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
-	qDebug() << "AgendaEventViewer: AgendaEventView::addCompletedTodoData <--";
 }
 
 /*!
@@ -585,16 +574,16 @@
  */
 void AgendaEventView::addRepeatData()
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::addRepeatData -->";
 	QStringList itemData;
 	itemData.append(QString::null);
-	itemData.append("qtg_mono_repeat.svg");
+    itemData.append(QString::null);
+    itemData.append("qtg_small_repeat");
+    mRepeatWidget->setProperty(primaryLeftIconItem, false);
 	mRepeatWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
 	itemData.clear();
 	itemData.append(QString::null);
 	itemData.append(repeatRule());
 	mRepeatWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
-	qDebug() << "AgendaEventViewer: AgendaEventView::addRepeatData <--";
 }
 
 /*!
@@ -602,16 +591,16 @@
  */
 void AgendaEventView::addDescriptionData()
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::addDiscriptionData -->";
 	QStringList itemData;
 	itemData.append(QString::null);
 	itemData.append(QString::null);
+    itemData.append(QString::null);
+    mDescriptionWidget->setProperty(primaryLeftIconItem, false);
 	mDescriptionWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
 	itemData.clear();
 	itemData.append(hbTrId("txt_calendar_dblist_description"));
 	itemData.append(mAgendaEntry.description());
 	mDescriptionWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
-	qDebug() << "AgendaEventViewer: AgendaEventView::addDiscriptionData <--";
 }
 
 /*!
@@ -619,7 +608,6 @@
  */
 void AgendaEventView::getPriorityIcon(int priority, QString &priorityIcon)
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::getPriorityIcon -->";
 
 	switch(priority) {
 		case 1:priorityIcon.append("qtg_small_priority_high");
@@ -630,7 +618,6 @@
 		break;
 	}
 
-	qDebug() << "AgendaEventViewer: AgendaEventView::getPriorityIcon <--";
 }
 
 /*!
@@ -638,7 +625,6 @@
  */
 QString AgendaEventView::repeatRule() const
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::repeatRule -->";
 	
 	QString repeatRule;
 	AgendaRepeatRule agendaRepeatRule = mAgendaEntry.repeatRule();
@@ -650,8 +636,7 @@
 			break;
 			case AgendaRepeatRule::WeeklyRule:
 				if (AgendaUtil::isWorkdaysRepeatingEntry(agendaRepeatRule)) {
-					//TODO: Add text id for workdays
-					repeatRule.append(hbTrId("Workdays"));
+					repeatRule.append(hbTrId("txt_calendar_dblist_repeats_workdays"));
 				} else {
 					if (agendaRepeatRule.interval() == 2) {
 						repeatRule.append(
@@ -682,7 +667,6 @@
 			hbTrId("txt_calendar_dblist_repeats_daily_val_until_1").
 			arg(untilDateString));
 	}
-	qDebug() << "AgendaEventViewer: AgendaEventView::repeatRule <--";
 	
 	return repeatRule;
 }
@@ -694,7 +678,6 @@
  */
 QString AgendaEventView::alarmTimeText() const
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::alarmTimeText -->";
 
 	QString alarmDateTimeText;
 	QDateTime startTime;
@@ -719,7 +702,6 @@
 						r_qtn_date_usual_with_zero)));
 	}
 	
-	qDebug() << "AgendaEventViewer: AgendaEventView::alarmTimeText <--";
 	return alarmDateTimeText;
 }
 
@@ -728,7 +710,6 @@
  */
 void AgendaEventView::removeWidget()
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::removeWidget -->";
 	
 	if (mAgendaEntry.location().isEmpty()) { 
 		mLocationWidget->hide();
@@ -742,10 +723,11 @@
         mMaptileLabel->hide();
         mLinearLayout->removeItem(mMaptileLabel);
     }
+    file.close();
         
 	if (mAgendaEntry.alarm().isNull()) { 
 		if (mAgendaEntry.type() == AgendaEntry::TypeTodo ) {
-				if (AgendaEntry::TodoNeedsAction == mAgendaEntry.status()) { 
+				if (AgendaEntry::TodoCompleted != mAgendaEntry.status()) { 
 					mReminderWidget->hide();
 					mLinearLayout->removeItem(mReminderWidget);
 					mReminderWidgetAdded = false;
@@ -770,7 +752,6 @@
 	mLinearLayout->invalidate();
 	mLinearLayout->activate();
 	
-	qDebug() << "AgendaEventViewer: AgendaEventView::removeWidget <--";
 }
 
 /*!
@@ -778,8 +759,6 @@
  */
 void AgendaEventView::updateCompletedReminderData()
 {
-	qDebug()
-	   << "AgendaEventViewer: AgendaEventView::updateCompletedReminderData -->";
 
 	if (AgendaEntry::TodoCompleted == mAgendaEntry.status()) {
 		addCompletedTodoData();
@@ -809,8 +788,6 @@
 	
 	mLinearLayout->invalidate();
 	mLinearLayout->activate();
-	qDebug()
-	   << "AgendaEventViewer: AgendaEventView::updateCompletedReminderData <--";
 }
 
 /*!
@@ -818,7 +795,6 @@
  */
 void AgendaEventView::removeAllWidgets()
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::removeAllWidgets -->";
 
 	for (int i = 2; i < mLinearLayout->count(); i++) {
 		mLinearLayout->removeAt(i);
@@ -826,7 +802,6 @@
 	mLinearLayout->invalidate();
 	mLinearLayout->activate();
 	
-	qDebug() << "AgendaEventViewer: AgendaEventView::removeAllWidgets <--";
 }
 
 /*!
@@ -834,7 +809,6 @@
  */
 void AgendaEventView::addAllWidgets()
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::addAllWidgets -->";
 	
 	mLinearLayout->addItem(mLocationWidget);
 	mLocationWidget->show();
@@ -850,7 +824,6 @@
 	mLinearLayout->invalidate();
 	mLinearLayout->activate();
 	
-	qDebug() << "AgendaEventViewer: AgendaEventView::addAllWidgets <--";
 }
 
 /*!
@@ -858,11 +831,10 @@
  */
 void AgendaEventView::showDeleteOccurencePopup()
 {
-	qDebug()
-	      << "AgendaEventViewer: AgendaEventView::showDeleteOccurencePopup -->";
-	HbDialog popUp;
-	popUp.setDismissPolicy(HbDialog::NoDismiss);
-	popUp.setTimeout(HbDialog::NoTimeout);
+	HbDialog *popUp = new HbDialog();
+	popUp->setDismissPolicy(HbDialog::NoDismiss);
+	popUp->setTimeout(HbDialog::NoTimeout);
+	popUp->setAttribute( Qt::WA_DeleteOnClose, true );
 
 	QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
 	HbWidget *deleteWidget = new HbWidget(mViewer);
@@ -872,84 +844,88 @@
 
 	QStringList list;
 	list << hbTrId("txt_calendar_info_this_occurrence_only") 
-		 << hbTrId("txt_calendar_info_all_occurences");
+				<< hbTrId("txt_calendar_info_all_occurences");
 
 	deleteButtonList->setItems(list);
 
 	layout->addItem(deleteButtonList);
 
-	popUp.setContentWidget(deleteWidget);
-	popUp.setHeadingWidget(new HbLabel(
-						hbTrId("txt_calendar_title_delete_repeated_entry")));
+	popUp->setContentWidget(deleteWidget);
+	popUp->setHeadingWidget(new HbLabel(
+			hbTrId("txt_calendar_title_delete_repeated_entry")));
 
 	connect(deleteButtonList, SIGNAL(itemSelected(int)), this,
-	        SLOT(handleDeleteOccurence(int)));
-	connect(deleteButtonList, SIGNAL(itemSelected(int)), &popUp, SLOT(close()));
+											SLOT(handleDeleteOccurence(int)));
+	connect(deleteButtonList, SIGNAL(itemSelected(int)), popUp, SLOT(close()));
 
-	// Create secondary action
-	HbAction *cancelAction = new HbAction(
-						hbTrId("txt_calendar_button_softkey1_cancel"));
-	popUp.setSecondaryAction(cancelAction);
-	connect(cancelAction, SIGNAL(triggered()), &popUp, SLOT(close()));
+	popUp->addAction(new HbAction(
+			hbTrId("txt_calendar_button_softkey1_cancel")));
 
 	// Show the popup
-	popUp.exec();
+	popUp->open();
 
-	qDebug()
-	      << "AgendaEventViewer: AgendaEventView::showDeleteOccurencePopup <--";
 }
 
-
 /*!
- * Show delete confirmation query
+	Show delete confirmation query
  */
-int AgendaEventView::showDeleteConfirmationQuery()
-{
-	qDebug()
-	   << "AgendaEventViewer: AgendaEventView::showDeleteConfirmationQuery -->";
-	int retStatus = 0;
+void AgendaEventView::showDeleteConfirmationQuery()
+    {
+    
+    HbMessageBox *popup = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
+    popup->setDismissPolicy(HbDialog::NoDismiss);
+    popup->setTimeout(HbDialog::NoTimeout);
+    popup->setAttribute( Qt::WA_DeleteOnClose, true );
 
-	HbMessageBox popup(HbMessageBox::MessageTypeQuestion);
-	popup.setDismissPolicy(HbDialog::NoDismiss);
-	popup.setTimeout(HbDialog::NoTimeout);
-	popup.setIconVisible(true);
-
-	QString text = 0;
+    QString text = 0;
 
-	switch (mAgendaEntry.type()) {
-		case AgendaEntry::TypeAppoinment:
-		case AgendaEntry::TypeEvent: {
-			text.append(hbTrId("txt_calendar_info_delete_meeting"));
-			break;
-		}
-		case AgendaEntry::TypeAnniversary: {
-			text.append(hbTrId("txt_calendar_info_delete_anniversary"));
-			break;
-		}
-		case AgendaEntry::TypeTodo: {
-			text.append(hbTrId("txt_calendar_info_delete_todo_note"));
-			break;
-		}
-		case AgendaEntry::TypeNote: {
-			text.append(hbTrId("txt_calendar_info_delete_anniversary"));
-			break;
-		}
-	}
+    switch (mAgendaEntry.type()) {
+        case AgendaEntry::TypeAppoinment:
+        case AgendaEntry::TypeEvent: {
+        text.append(hbTrId("txt_calendar_info_delete_meeting"));
+        break;
+        }
+        case AgendaEntry::TypeAnniversary: {
+        text.append(hbTrId("txt_calendar_info_delete_anniversary"));
+        break;
+        }
+        case AgendaEntry::TypeTodo: {
+        text.append(hbTrId("txt_calendar_info_delete_todo_note"));
+        break;
+        }
+        case AgendaEntry::TypeNote: {
+        text.append(hbTrId("txt_calendar_info_delete_anniversary"));
+        break;
+        }
+    }
+    popup->setText(text);
+    
+    QList<QAction*> list = popup->actions();
+    for(int i=0; i < list.count(); i++)
+        {
+        popup->removeAction(list[i]);
+        }
+    HbAction *deleteAction = 
+					new HbAction(hbTrId("txt_calendar_button_delete"), popup);
+    popup->addAction(deleteAction);
+    connect(deleteAction, SIGNAL(triggered()), this ,
+												SLOT(handleDeleteAction()));
+    popup->addAction(new HbAction(hbTrId("txt_calendar_button_cancel"), popup));
+    popup->open();
+}
 
-	popup.setText(text);
-	
-	popup.setPrimaryAction(new HbAction(
-								hbTrId("txt_calendar_button_delete"), &popup));
-	popup.setSecondaryAction(new HbAction(
-								hbTrId("txt_calendar_button_cancel"), &popup));
-	HbAction *selected = popup.exec();
-	if (selected == popup.primaryAction()) { 
-		retStatus = 1;
-	}
+/*!
+	Handles the delete action
+ */
+void AgendaEventView::handleDeleteAction()
+    {
+    // If delete button is pressed delete the entry
+    // To notify client that deleting Started
+    // Calendar Application changing state from viewing to deleting.
+    mOwner->deletingStarted();
 
-	qDebug()
-	   << "AgendaEventViewer: AgendaEventView::showDeleteConfirmationQuery <--";
-	return retStatus;
+    // Delete the entry.
+    mOwner->mAgendaUtil->deleteEntry(mAgendaEntry.id());
 }
 
 /*!
@@ -957,36 +933,26 @@
  */
 void AgendaEventView::markTodoStatus()
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::markTodoStatus -->";
 
 	QDateTime currentDateTime = QDateTime::currentDateTime();
 
 	// Set the to-do status using the agenda util.
-	if (AgendaEntry::TodoNeedsAction == mAgendaEntry.status()) {
-		
+	if (AgendaEntry::TodoCompleted != mAgendaEntry.status()) {
 		// Update the menu text to mark to-do as undone.
 		mMarkTodoAction->setText(hbTrId("txt_calendar_menu_mark_as_not_done"));
-		
 		mAgendaEntry.setStatus(AgendaEntry::TodoCompleted);
 		mAgendaEntry.setCompletedDateTime(currentDateTime);
 		mOwner->mAgendaUtil->setCompleted(mAgendaEntry, true, currentDateTime);
-		
-		
-
-	} else if (AgendaEntry::TodoCompleted == mAgendaEntry.status()) {
+	} else {
 		
 		// Update the menu text to mark to-do as done.
 		mMarkTodoAction->setText(hbTrId("txt_calendar_menu_mark_as_done"));
-				
 		mAgendaEntry.setStatus(AgendaEntry::TodoNeedsAction);
 		mOwner->mAgendaUtil->setCompleted(mAgendaEntry, false, currentDateTime);
-		
-		
 	}
 
 	updateCompletedReminderData();
 	
-	qDebug() << "AgendaEventViewer: AgendaEventView::markTodoStatus <--";
 }
 
 /*!
@@ -994,18 +960,32 @@
  */
 void AgendaEventView::edit()
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::edit -->";
 
 	mOwner->editingStarted();
 	
 	if (AgendaEntry::TypeTodo == mAgendaEntry.type()) {
-		// Launch the to-do editor using notes editor api
-		// Construct Note editor for launching the to-do editor
-		mNoteEditor = new NotesEditor(mOwner->mAgendaUtil, this);
-		mNoteEditor->edit(mAgendaEntry);
+		// Load notes editor plugin if not loaded.
+		if(!mNotesPluginLoaded) {
+			// Launch the to-do editor using notes editor plugin api
+			QDir dir(NOTES_EDITOR_PLUGIN_PATH);
+			QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME);
+
+			// Create NotesEditor plugin loader object.
+			mNotesEditorPluginLoader = new QPluginLoader(pluginName);
+
+			// Load the plugin
+			mNotesPluginLoaded = mNotesEditorPluginLoader->load();
+		}
+		QObject *plugin = qobject_cast<QObject*> (
+				mNotesEditorPluginLoader->instance());
+
+		NotesEditorInterface* interface =
+				qobject_cast<NotesEditorInterface*>(plugin);
+
+		interface->edit(mAgendaEntry, mOwner->mAgendaUtil);
 
 		connect(
-				mNoteEditor, SIGNAL(editingCompleted(bool)),
+				interface, SIGNAL(editingCompleted(bool)),
 				this, SLOT(handleNoteEditorClosed(bool)));
 		
 
@@ -1018,7 +998,6 @@
 	
 		
 	}
-	qDebug() << "AgendaEventViewer: AgendaEventView::edit <--";
 }
 
 /*!
@@ -1026,7 +1005,6 @@
  */
 void AgendaEventView::deleteAgendaEntry()
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::deleteAgendaEntry -->";
 
 	// Before we do anything, check in the entry is repeating
 	// OR its a child item
@@ -1038,18 +1016,9 @@
 		// Query user if he wants to delete whole series or just this occurence
 		showDeleteOccurencePopup();
 	} else {
-		if (showDeleteConfirmationQuery()) {
-			
-			// To notify client that deleting Started
-			// Calendar Application changing state from viewing to deleting.
-			mOwner->deletingStarted();
-				
-			// Delete the entry.
-			mOwner->mAgendaUtil->deleteEntry(mAgendaEntry.id());
-		}
+        showDeleteConfirmationQuery();
 	}
 
-	qDebug() << "AgendaEventViewer: AgendaEventView::deleteAgendaEntry <--";
 }
 
 /*!
@@ -1057,21 +1026,18 @@
  */
 void AgendaEventView::saveAgendaEntry()
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::saveAgendaEntry -->";
 	
 	// Save entry to calendar.
 	mOwner->mAgendaUtil->addEntry(mAgendaEntry);
 	
 	// Close the agenda entry viewer
 	close();
-	qDebug() << "AgendaEventViewer: AgendaEventView::saveAgendaEntry <--";
 }
 /*!
 	Closes the event viewer
  */
 void AgendaEventView::close()
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::close -->";
 
 	// Remove the view from main window.
 	HbMainWindow *window = hbInstance->allMainWindows().first();
@@ -1084,7 +1050,6 @@
 	window->removeView(mViewer);
 	mOwner->viewingCompleted(mAgendaEntry.startTime().date());
 
-	qDebug() << "AgendaEventViewer: AgendaEventView::close <--";
 }
 
 /*!
@@ -1092,7 +1057,6 @@
  */
 void AgendaEventView::handleEntryUpdation(ulong id)
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::handleEntryUpdation -->";
 
 	AgendaEntry updatedEntry = mOwner->mAgendaUtil->fetchById(id);
 
@@ -1138,7 +1102,6 @@
 		close();
 	}
 
-	qDebug() << "AgendaEventViewer: AgendaEventView::handleEntryUpdation <--";
 }
 
 /*!
@@ -1146,7 +1109,6 @@
 */
 void AgendaEventView::handleEntryDeletion(ulong id)
 {
-	qDebug() <<"AgendaEventViewer: AgendaEventView::handleEntryDeletion -->";
 
 	if (id == mAgendaEntry.id()) {
 		// Close the agenda entry viewer
@@ -1154,7 +1116,6 @@
 		mOwner->deletingCompleted();
 	}
 
-	qDebug() <<"AgendaEventViewer: AgendaEventView::handleEntryDeletion <--";
 }
 
 /*!
@@ -1163,13 +1124,12 @@
 void AgendaEventView::handleNoteEditorClosed(bool status)
 {
 	Q_UNUSED(status);
-	qDebug() <<"AgendaEventViewer: AgendaEventView::handleNoteEditorClosed -->";
 
-	// Cleanup.
-	mNoteEditor->deleteLater();
+	// To avoid loading the plugin again for editing,
+	// Unload the plug-in while destruction.
+
 	mOwner->editingCompleted();
 
-	qDebug() <<"AgendaEventViewer: AgendaEventView::handleNoteEditorClosed <--";
 }
 
 /*!
@@ -1177,15 +1137,11 @@
  */
 void AgendaEventView::handleCalendarEditorClosed()
 {
-	qDebug() 
-		<<"AgendaEventViewer: AgendaEventView::handleCalendarEditorClosed -->";
 
 	// Cleanup.
 	mCalenEditor->deleteLater();
 	mOwner->editingCompleted();
 
-	qDebug() 
-		<<"AgendaEventViewer: AgendaEventView::handleCalendarEditorClosed <--";
 }
 
 /*!
@@ -1193,7 +1149,6 @@
  */
 void AgendaEventView::handleDeleteOccurence(int index)
 {
-	qDebug() << "AgendaEventViewer: AgendaEventView::handleDeleteOccurence -->";
 	
 	// To notify client that deleting Started
 	// Calendar Application changing state from viewing to deleting.
@@ -1213,7 +1168,154 @@
 			break;
 	}
 
-	qDebug() << "AgendaEventViewer: AgendaEventView::handleDeleteOccurence <--";
+}
+
+/*!
+    Returns subject icon
+ */
+void AgendaEventView::getSubjectIcon(AgendaEntry::Type type, QString &subjectIcon)
+    {
+    switch(type) {
+        case AgendaEntry::TypeAppoinment:
+            {
+            subjectIcon.append("qtg_small_meeting");
+            }
+            break;
+        case AgendaEntry::TypeTodo:
+            {
+            subjectIcon.append("qtg_small_todo");
+            }
+            break;
+        case AgendaEntry::TypeEvent:
+            {
+            subjectIcon.append("qtg_small_day");
+            }
+            break;
+        case AgendaEntry::TypeAnniversary:
+            {
+            subjectIcon.append("qtg_small_anniversary");
+            }
+            break;
+        default:
+            break;
+    }
+
+    }
+
+/*!
+    According to maptile fetching status , update the viewer screen.
+ */
+void AgendaEventView::updateProgressIndicator()
+{   
+    if (!mMaptileStatusReceived) {
+        QString iconName("qtg_anim_small_loading_");
+        mProgressIconCount = mProgressIconCount % 10 + 1;
+        iconName.append(QVariant(mProgressIconCount).toString());
+        QStringList itemData;
+        itemData.append("qtg_small_location");
+        itemData.append(iconName);
+        itemData.append(QString::null);
+        mLocationWidget->setProperty(primaryLeftIconItem, true);
+        mLocationWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
+        mProgressTimer->start(100);
+    }
+    else {
+        if (mProgressTimer->isActive()) {
+            mProgressTimer->stop();
+        }
+        if (mMaptileStatus == MapTileService::MapTileFetchingCompleted) {
+            QStringList itemData;
+            itemData.append(QString::null);
+            itemData.append(QString::null);
+            itemData.append("qtg_small_location");
+            mLocationWidget->setProperty(primaryLeftIconItem, false);
+            mLocationWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
+            Qt::Orientations orientation=hbInstance->allMainWindows().first()->orientation();
+            mMaptilePath.clear();
+            mMaptileStatus = mMaptileService->getMapTileImage(mAgendaEntry.id(), MapTileService::AddressPlain, mMaptilePath ,orientation);
+            addMapTileImage();
+            QFile file(mMaptilePath);
+            if (file.exists()) {
+                //add to linear layout  
+                int indexMaptileLabel = 3;// index of maptile widget position
+                mLinearLayout->insertItem(indexMaptileLabel, mMaptileLabel);
+                mMaptileLabel->show();
+            }
+            file.close();
+
+        }
+        else {
+            QStringList itemData;
+            itemData.append("qtg_small_location");
+            QString stopIcon;
+            stopIcon.append(QString("qtg_mono_search_stop"));
+            itemData.append(stopIcon);
+            itemData.append(QString::null);
+            mLocationWidget->setProperty(primaryLeftIconItem, true);
+            mLocationWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
+
+        }
+    }
+}
+
+/*!
+    Maptile status received from maptile service 
+ */
+void AgendaEventView::receiveMapTileStatus(int entryid,int addressType, int status)
+{
+    if (mAgendaEntry.id() == entryid && addressType == MapTileService::AddressPlain) {
+        mMaptileStatusReceived = true;
+        mMaptileStatus = status;
+        updateProgressIndicator();
+    }
+}
+
+/*!
+    Returns progress indication icon as per status of entry in database.
+ */
+void AgendaEventView::getProgressIndicatorstatus(QString &progressIcon)
+{
+    MapTileService::AddressType addressType;
+    addressType = MapTileService::AddressPlain;
+    int eventId = mAgendaEntry.id();
+    mMaptilePath.clear();
+    mMaptileStatus = -1;
+    connect(mMaptileService, SIGNAL(maptileFetchingStatusUpdate(int,
+            int ,int)), this, SLOT(receiveMapTileStatus(int,int,int)));
+    Qt::Orientations orientation=hbInstance->allMainWindows().first()->orientation();
+    mMaptileStatus = mMaptileService->getMapTileImage(eventId, addressType, mMaptilePath ,orientation);    
+    if (mMaptileStatus == MapTileService::MapTileFetchingNetworkError || mMaptileStatus
+        == MapTileService::MapTileFetchingInProgress) {
+        mMaptilePath.clear();
+        mMaptileStatusReceived = false; //reseting receiving status value       
+        progressIcon.append(QString("qtg_anim_small_loading_1"));
+        mProgressTimer->start(100);
+    }
+    else if (mMaptileStatus == MapTileService::MapTileFetchingInvalidAddress || mMaptileStatus
+        == MapTileService::MapTileFetchingUnknownError) {
+        mMaptilePath.clear();
+        //no further need of this coonnection 
+        disconnect(mMaptileService, SIGNAL(maptileFetchingStatusUpdate(int,
+                int ,int)), this, SLOT(receiveMapTileStatus(int,int,int)));
+        progressIcon.append(QString("qtg_mono_search_stop"));
+    }
+    else {
+        //no further need of this coonnection
+        disconnect(mMaptileService, SIGNAL(maptileFetchingStatusUpdate(int,
+                int ,int)), this, SLOT(receiveMapTileStatus(int,int,int)));
+        progressIcon.append(QString::null);
+    }
+}
+/*!
+    Reload the maptile image on system orientation change.
+ */
+void AgendaEventView::changedOrientation(Qt::Orientation orientation)
+{
+    if (mMaptileStatus == MapTileService::MapTileFetchingCompleted) {
+        mMaptilePath.clear();
+        mMaptileService->getMapTileImage(mAgendaEntry.id(), MapTileService::AddressPlain, mMaptilePath,orientation);
+        addMapTileImage();
+    }
 }
 
 // End of file