calendarui/agendaeventviewer/src/agendaeventview.cpp
changeset 45 b6db4fd4947b
parent 23 fd30d51f876b
child 51 0b38fc5b94c6
equal deleted inserted replaced
23:fd30d51f876b 45:b6db4fd4947b
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // System includes
    18 // System includes
    19 #include <QObject>
    19 #include <QObject>
    20 #include <QDebug>
       
    21 #include <QDateTime>
    20 #include <QDateTime>
    22 #include <qtranslator.h>
       
    23 #include <QGraphicsLinearLayout>
    21 #include <QGraphicsLinearLayout>
       
    22 #include <QFile>
       
    23 #include <QString>
       
    24 #include <QTimer>
       
    25 #include <QPluginLoader>
       
    26 #include <QDir>
    24 #include <HbInstance>
    27 #include <HbInstance>
    25 #include <hbapplication.h>
       
    26 #include <HbMainWindow>
    28 #include <HbMainWindow>
    27 #include <HbView>
    29 #include <HbView>
    28 #include <HbMenu>
    30 #include <HbMenu>
    29 #include <HbGroupBox>
    31 #include <HbGroupBox>
    30 #include <HbScrollArea>
    32 #include <HbScrollArea>
    35 #include <hbi18ndef.h>
    37 #include <hbi18ndef.h>
    36 #include <HbRadioButtonList>
    38 #include <HbRadioButtonList>
    37 #include <HbMessageBox>
    39 #include <HbMessageBox>
    38 #include <HbDialog>
    40 #include <HbDialog>
    39 #include <HbLabel>
    41 #include <HbLabel>
    40 #include <QFile>
    42 #include <HbTranslator>
    41 #include <QString>
    43 
    42 #include <QIcon>
       
    43 #include <QPainter>
       
    44 #include <QPixmap>
       
    45 // User includes
    44 // User includes
       
    45 #include <maptileservice.h>//maptile service
    46 #include <agendautil.h>
    46 #include <agendautil.h>
    47 #include <noteseditor.h>
    47 #include <NotesEditorInterface>
    48 #include <caleneditor.h>
    48 #include <caleneditor.h>
    49 #include "agendaeventview.h"
    49 #include "agendaeventview.h"
    50 #include "agendaeventviewerdocloader.h"
    50 #include "agendaeventviewerdocloader.h"
    51 #include "agendaeventviewercommon.h"
    51 #include "agendaeventviewercommon.h"
    52 #include "agendaeventviewer_p.h"
    52 #include "agendaeventviewer_p.h"
    53 #include "agendaeventvieweritem.h"
    53 #include "agendaeventvieweritem.h"
    54 #include "calendateutils.h"
    54 #include "calendateutils.h"
    55 
       
    56 //maptile service 
       
    57 #include <maptileservice.h>
       
    58 // Constants
    55 // Constants
    59 #define CHARACTER_HYPHEN    "-"
    56 #define CHARACTER_HYPHEN    "-"
    60 #define CHARACTER_SPACE     " "
    57 #define CHARACTER_SPACE     " "
    61 #define CHARACTER_NEW_LINE  "\n"
    58 #define CHARACTER_NEW_LINE  "\n"
    62 
    59 
    63 // This is used to set the maptile image height and width ,
    60 //This Property is use for setting a primary left icon
    64 //because HbLabel by default not displaying the actual size of image 
    61 static const char *primaryLeftIconItem("leftPrimaryIconItem");
    65 const int height = 128;
    62 
    66 const int width =  330;
       
    67 /*!
    63 /*!
    68 	\class AgendaEventView.
    64 	\class AgendaEventView.
    69 
    65 
    70 	Responsible for viewing viewing agenda entries. This is friend of
    66 	Responsible for viewing viewing agenda entries. This is friend of
    71 	AgendaEventViewerPrivate and it handles all the cases
    67 	AgendaEventViewerPrivate and it handles all the cases
    79 	\param parent pointer to QGraphicsWidget.
    75 	\param parent pointer to QGraphicsWidget.
    80  */
    76  */
    81 AgendaEventView::AgendaEventView(
    77 AgendaEventView::AgendaEventView(
    82 		AgendaEventViewerPrivate *owner, QObject *parent):
    78 		AgendaEventViewerPrivate *owner, QObject *parent):
    83 		QObject(parent),
    79 		QObject(parent),
       
    80 		mMainWindow(NULL),
    84 		mOwner(owner),
    81 		mOwner(owner),
       
    82 		mTranslator(new HbTranslator("caleneventviewer")),
    85 		mReminderWidgetAdded(true),
    83 		mReminderWidgetAdded(true),
    86 		mMainWindow(NULL),
    84 		mMaptilePath(NULL),
    87 		mMaptilePath(NULL)
    85 		mMaptileService(NULL),
    88 {
    86 		mProgressTimer(NULL),
    89 	qDebug() << "AgendaEventViewer: AgendaEventView::AgendaEventView -->";
    87 		mProgressIconCount(0),
    90 
    88 		mMaptileStatusReceived(false),
    91 	// Load the translator based on locale
    89 		mMaptileStatus(-1),
    92 	mTranslator = new QTranslator;
    90 		mNotesPluginLoaded(false)
    93 	QString lang = QLocale::system().name();
    91 {
    94 	QString path = "Z:/resource/qt/translations/";
       
    95 	mTranslator->load("caleneventviewer_en_GB",":/translations");
       
    96 	// TODO: Load the appropriate .qm file based on locale
       
    97 	//bool loaded = mTranslator->load("caleneventviewer_" + lang, path);
       
    98 	HbApplication::instance()->installTranslator(mTranslator);
       
    99 	
    92 	
   100 	mDocLoader = new AgendaEventViewerDocLoader;
    93 	mDocLoader = new AgendaEventViewerDocLoader;
   101 
    94 
   102 	// Load to-do viewer's docml.
    95 	// Load to-do viewer's docml.
   103 	bool loadSuccess;
    96 	bool loadSuccess;
   111 
   104 
   112 	// Load all the widgets.
   105 	// Load all the widgets.
   113 	mSubjectWidget = qobject_cast<AgendaEventViewerItem *> (
   106 	mSubjectWidget = qobject_cast<AgendaEventViewerItem *> (
   114 			mDocLoader->findWidget(AGENDA_EVENT_VIEWER_SUBJECT_WIDGET));
   107 			mDocLoader->findWidget(AGENDA_EVENT_VIEWER_SUBJECT_WIDGET));
   115 
   108 
       
   109     //load layout that supports icon before subject label
       
   110     mSubjectWidget->setProperty(primaryLeftIconItem,true);  
       
   111 
   116 	mDateTimeWidget = qobject_cast<AgendaEventViewerItem *> (
   112 	mDateTimeWidget = qobject_cast<AgendaEventViewerItem *> (
   117 			mDocLoader->findWidget(AGENDA_EVENT_VIEWER_DATE_TIME_WIDGET));
   113 			mDocLoader->findWidget(AGENDA_EVENT_VIEWER_DATE_TIME_WIDGET));
   118 
   114 
   119 	mLocationWidget = qobject_cast<AgendaEventViewerItem *> (
   115 	mLocationWidget = qobject_cast<AgendaEventViewerItem *> (
   120 			mDocLoader->findWidget(AGENDA_EVENT_VIEWER_LOCATION_WIDGET));
   116 			mDocLoader->findWidget(AGENDA_EVENT_VIEWER_LOCATION_WIDGET));
   137                mDocLoader->findWidget(AGENDA_EVENT_VIEWER_SCROLLAREA_CONTENTS));
   133                mDocLoader->findWidget(AGENDA_EVENT_VIEWER_SCROLLAREA_CONTENTS));
   138 
   134 
   139     mLinearLayout = 
   135     mLinearLayout = 
   140     		static_cast<QGraphicsLinearLayout *> (scrollAreaWidget->layout());
   136     		static_cast<QGraphicsLinearLayout *> (scrollAreaWidget->layout());
   141 	
   137 	
   142     MapTileService::AppType appType;
   138 
   143     appType = MapTileService::AppTypeCalendar;
   139     //maptile service object , to retrive maptile path from database.
   144     mLocationFeatureEnabled = MapTileService::isLocationFeatureEnabled(appType);
   140     mMaptileService= new MapTileService();   
   145     
   141     mLocationFeatureEnabled = mMaptileService->isLocationFeatureEnabled(
       
   142         MapTileService::AppTypeCalendar);
       
   143     if (mLocationFeatureEnabled) {
       
   144         //timer to run progress indicator icon.
       
   145         mProgressTimer = new QTimer(this);
       
   146         mProgressTimer->setSingleShot(true);
       
   147         connect(mProgressTimer, SIGNAL(timeout()), this, SLOT(updateProgressIndicator()));
       
   148     }
   146         
   149         
   147     qDebug() << "AgendaEventViewer: AgendaEventView::AgendaEventView <--";
       
   148 	
   150 	
   149 }
   151 }
   150 
   152 
   151 /*!
   153 /*!
   152 	Destructor.
   154 	Destructor.
   153  */
   155  */
   154 AgendaEventView::~AgendaEventView()
   156 AgendaEventView::~AgendaEventView()
   155 {
   157 {
   156 	qDebug() << "AgendaEventViewer: AgendaEventView::~AgendaEventView -->";
       
   157 
   158 
   158 	// Remove the translator
   159 	// Remove the translator
   159 	HbApplication::instance()->removeTranslator(mTranslator);
       
   160 	if (mTranslator) {
   160 	if (mTranslator) {
   161 		delete mTranslator;
   161 		delete mTranslator;
   162 		mTranslator = 0;
   162 		mTranslator = 0;
   163 	}
   163 	}
   164 	
   164 	
   165 	mDocLoader->reset();
   165 	mDocLoader->reset();
   166 	delete mDocLoader;
   166 	delete mDocLoader;
   167 	
   167 
       
   168 	// Unload notes editor if loaded.
       
   169 	if (mNotesEditorPluginLoader) {
       
   170 		mNotesEditorPluginLoader->unload();
       
   171 		delete mNotesEditorPluginLoader;
       
   172 		mNotesEditorPluginLoader = 0;
       
   173 	}
       
   174 
   168 	// Delete the mainwindow if we have created any
   175 	// Delete the mainwindow if we have created any
   169 	if (mMainWindow) {
   176 	if (mMainWindow) {
   170 		delete mMainWindow;
   177 		delete mMainWindow;
   171 		mMainWindow = NULL;
   178 		mMainWindow = NULL;
   172 	}
   179 	}
   173 	
   180 	
   174 	qDebug() << "AgendaEventViewer: AgendaEventView::~AgendaEventView <--";
   181 	if (mMaptileService) {
       
   182         delete mMaptileService;
       
   183         mMaptileService = NULL;
       
   184     }
       
   185     
       
   186 	if (mProgressTimer) {
       
   187         delete mProgressTimer;
       
   188         mProgressTimer = NULL;
       
   189     }
       
   190 	
   175 }
   191 }
   176 
   192 
   177 /*!
   193 /*!
   178 	Displays the to-do viewer and populates the to-do entry attributes.
   194 	Displays the to-do viewer and populates the to-do entry attributes.
   179 
   195 
   180 	\param entry Agenda entry from which attributes have to be read.
   196 	\param entry Agenda entry from which attributes have to be read.
   181  */
   197  */
   182 void AgendaEventView::execute(AgendaEntry entry,
   198 void AgendaEventView::execute(AgendaEntry entry,
   183 											AgendaEventViewer::Actions action)
   199 											AgendaEventViewer::Actions action)
   184 {
   200 {
   185 	qDebug() << "AgendaEventViewer: AgendaEventView::execute -->";
       
   186 
   201 
   187 	mOriginalAgendaEntry = entry;
   202 	mOriginalAgendaEntry = entry;
   188 	mAgendaEntry = entry;
   203 	mAgendaEntry = entry;
   189 
   204 
   190 	// Add the viewer data reading from the agenda entry.
   205 	// Add the viewer data reading from the agenda entry.
   196 	// Add the menu items to event viewer.
   211 	// Add the menu items to event viewer.
   197 	addMenuItem();
   212 	addMenuItem();
   198 	
   213 	
   199 	// Add the toolbar items to event viewer
   214 	// Add the toolbar items to event viewer
   200 	addToolBarItem(action);
   215 	addToolBarItem(action);
   201 	
       
   202 	// Add the title to event viewer.
       
   203 	addGroupBoxData();
       
   204 
   216 
   205 	// Connect for the entry updation and addtion signal to refresh the view
   217 	// Connect for the entry updation and addtion signal to refresh the view
   206 	// when the same is edited in editor.
   218 	// when the same is edited in editor.
   207 	connect(mOwner->mAgendaUtil, SIGNAL(entryUpdated(ulong)),
   219 	connect(mOwner->mAgendaUtil, SIGNAL(entryUpdated(ulong)),
   208 				this, SLOT(handleEntryUpdation(ulong)));
   220 				this, SLOT(handleEntryUpdation(ulong)));
   220 		// Might be some non-ui based app called us
   232 		// Might be some non-ui based app called us
   221 		// so create mainwindow now
   233 		// so create mainwindow now
   222 		mMainWindow = new HbMainWindow();
   234 		mMainWindow = new HbMainWindow();
   223 		mMainWindow->addView(mViewer);
   235 		mMainWindow->addView(mViewer);
   224 		mMainWindow->setCurrentView(mViewer);
   236 		mMainWindow->setCurrentView(mViewer);
       
   237 	    connect(mMainWindow,SIGNAL(orientationChanged(Qt::Orientation)),this,SLOT(changedOrientation(Qt::Orientation)));		
   225 	} else {
   238 	} else {
   226 		window->addView(mViewer);
   239 		window->addView(mViewer);
   227 		window->setCurrentView(mViewer);
   240 		window->setCurrentView(mViewer);
       
   241 		connect(window,SIGNAL(orientationChanged(Qt::Orientation)),this,SLOT(changedOrientation(Qt::Orientation)));		
   228 	}
   242 	}
   229 	
   243 	
   230 	// Add softkey after adding view on window
   244 	// Add softkey after adding view on window
   231 	mBackAction = new HbAction(Hb::BackAction);
   245 	mBackAction = new HbAction(Hb::BackNaviAction);
   232 	mViewer->setNavigationAction(mBackAction);
   246 	mViewer->setNavigationAction(mBackAction);
   233 		
   247 		
   234 	connect(mBackAction, SIGNAL(triggered()), this, SLOT(close()));
   248 	connect(mBackAction, SIGNAL(triggered()), this, SLOT(close()));
   235 
   249 
   236 	qDebug() << "AgendaEventViewer: AgendaEventView::execute <--";
       
   237 }
   250 }
   238 
   251 
   239 /*!
   252 /*!
   240 	Refreshes the to-do viewer after the to-do editor is closed.
   253 	Refreshes the to-do viewer after the to-do editor is closed.
   241  */
   254  */
   242 void AgendaEventView::addViewerData()
   255 void AgendaEventView::addViewerData()
   243 {
   256 {
   244 	qDebug() << "AgendaEventViewer: AgendaEventView::addViewerData -->";
   257 	
       
   258 	// Add the title to event viewer.
       
   259 	addGroupBoxData();
   245 
   260 
   246 	// Set the summary & priority to viewer.
   261 	// Set the summary & priority to viewer.
   247 	addSubjectAndPriorityData();
   262 	addSubjectAndPriorityData();
   248 	
   263 	
   249 	// Set Date & Time to viewer.
   264 	// Set Date & Time to viewer.
   272 	}
   287 	}
   273 
   288 
   274 	// Set the description.
   289 	// Set the description.
   275 	addDescriptionData();
   290 	addDescriptionData();
   276 	
   291 	
   277 	qDebug() << "AgendaEventViewer: AgendaEventView::addViewerData <--";
       
   278 }
   292 }
   279 
   293 
   280 /*!
   294 /*!
   281 	Add the menu item depends up on entry type
   295 	Add the menu item depends up on entry type
   282  */
   296  */
   283 void AgendaEventView::addMenuItem()
   297 void AgendaEventView::addMenuItem()
   284 {
   298 {
   285 	qDebug() << "AgendaEventViewer: AgendaEventView::addMenuItem -->";
       
   286 
   299 
   287 	if (mAgendaEntry.type() == AgendaEntry::TypeTodo) {
   300 	if (mAgendaEntry.type() == AgendaEntry::TypeTodo) {
   288 
   301 
   289 		HbMenu *menu = qobject_cast<HbMenu *> (
   302 		HbMenu *menu = qobject_cast<HbMenu *> (
   290 				mDocLoader->findWidget(AGENDA_EVENT_VIEWER_MENU));
   303 				mDocLoader->findWidget(AGENDA_EVENT_VIEWER_MENU));
   298 		}
   311 		}
   299 		connect(mMarkTodoAction, SIGNAL(triggered()), this,
   312 		connect(mMarkTodoAction, SIGNAL(triggered()), this,
   300 		        SLOT(markTodoStatus()));
   313 		        SLOT(markTodoStatus()));
   301 		menu->addAction(mMarkTodoAction);
   314 		menu->addAction(mMarkTodoAction);
   302 	}
   315 	}
   303 	qDebug() << "AgendaEventViewer: AgendaEventView::addMenuItem <--";
       
   304 }
   316 }
   305 
   317 
   306 /*!
   318 /*!
   307 	Add the toolbar item
   319 	Add the toolbar item
   308  */
   320  */
   309 void AgendaEventView::addToolBarItem(AgendaEventViewer::Actions action)
   321 void AgendaEventView::addToolBarItem(AgendaEventViewer::Actions action)
   310 {
   322 {
   311 	qDebug() << "AgendaEventViewer: AgendaEventView::addToolBarItem -->";
       
   312 
   323 
   313 	HbToolBar *toolBar = qobject_cast<HbToolBar *> (
   324 	HbToolBar *toolBar = qobject_cast<HbToolBar *> (
   314 	                       mDocLoader->findWidget(AGENDA_EVENT_VIEWER_TOOLBAR));
   325 	                       mDocLoader->findWidget(AGENDA_EVENT_VIEWER_TOOLBAR));
   315 
   326 
   316 	// Load all the actions for event viewer
   327 	// Load all the actions for event viewer
   337 		saveAction->setIcon(HbIcon("qtg_mono_add_to_calendar"));
   348 		saveAction->setIcon(HbIcon("qtg_mono_add_to_calendar"));
   338 		connect(saveAction, SIGNAL(triggered()), this, SLOT(saveAgendaEntry()));
   349 		connect(saveAction, SIGNAL(triggered()), this, SLOT(saveAgendaEntry()));
   339 		toolBar->addAction(saveAction);
   350 		toolBar->addAction(saveAction);
   340 	}
   351 	}
   341 
   352 
   342 	qDebug() << "AgendaEventViewer: AgendaEventView::addToolBarItem <--";
       
   343 }
   353 }
   344 
   354 
   345 /*!
   355 /*!
   346 	Add the groupbox data depends up on entry type
   356 	Add the groupbox data depends up on entry type
   347  */
   357  */
   348 void AgendaEventView::addGroupBoxData()
   358 void AgendaEventView::addGroupBoxData()
   349 {
   359 {
   350 	qDebug() << "AgendaEventViewer: AgendaEventView::addGroupBoxData -->";
       
   351 	
   360 	
   352 	HbGroupBox *groupBox = qobject_cast<HbGroupBox *> (
   361 	HbGroupBox *groupBox = qobject_cast<HbGroupBox *> (
   353 			mDocLoader->findWidget(AGENDA_EVENT_VIEWER_GROUPBOX));
   362 			mDocLoader->findWidget(AGENDA_EVENT_VIEWER_GROUPBOX));
   354 
   363 
   355 	if (mAgendaEntry.type() == AgendaEntry::TypeTodo) {
   364 	AgendaEntry::Type entryType = mAgendaEntry.type();
       
   365 	if (entryType == AgendaEntry::TypeTodo) {
   356 		groupBox->setHeading(hbTrId("txt_calendar_subhead_to_do"));
   366 		groupBox->setHeading(hbTrId("txt_calendar_subhead_to_do"));
   357 	} else if (mAgendaEntry.type() == AgendaEntry::TypeNote) {
   367 	} else if (entryType == AgendaEntry::TypeAppoinment) {
   358 		groupBox->setHeading(tr("Note"));
   368 		groupBox->setHeading(hbTrId("txt_calendar_subhead_meeting"));
   359 	} else {
   369 	}else if (entryType == AgendaEntry::TypeEvent) {
   360 		// TODO: Add the text id based on the entry type Anniversary or meeting
   370 		//TODO: Add text id once available
   361 		groupBox->setHeading(hbTrId("txt_calendar_subhead_event"));
   371 		groupBox->setHeading(hbTrId("All day event"));
   362 	}
   372 	}
   363 
   373 		
   364 	qDebug() << "AgendaEventViewer: AgendaEventView::addGroupBoxData <--";
       
   365 }
   374 }
   366 
   375 
   367 /*!
   376 /*!
   368 	Add subject and priority data to Event viewer
   377 	Add subject and priority data to Event viewer
   369  */
   378  */
   370 void AgendaEventView::addSubjectAndPriorityData()
   379 void AgendaEventView::addSubjectAndPriorityData()
   371 {
   380 {
   372 	qDebug()
       
   373 	     << "AgendaEventViewer: AgendaEventView::addSubjectAndPriorityData -->";
       
   374 
   381 
   375 	QStringList itemList;
   382 	QStringList itemList;
   376 	itemList.append(hbTrId("txt_calendar_dblist_subject"));
   383 	itemList.append(hbTrId("txt_calendar_dblist_subject"));
   377 	if (mAgendaEntry.summary().isEmpty()) {
   384 	if (mAgendaEntry.summary().isEmpty()) {
   378 		itemList.append(hbTrId("txt_calendar_dblist_val_unnamed"));
   385 		itemList.append(hbTrId("txt_calendar_dblist_val_unnamed"));
   381 	}
   388 	}
   382 
   389 
   383 
   390 
   384 	mSubjectWidget->setEventViewerItemData(itemList, Qt::DisplayRole);
   391 	mSubjectWidget->setEventViewerItemData(itemList, Qt::DisplayRole);
   385 
   392 
   386 	itemList.clear();
   393     itemList.clear();
   387 	QString priorityIcon(QString::null);
   394     QString priorityIcon(QString::null);
   388 	getPriorityIcon(mAgendaEntry.priority(), priorityIcon);
   395     QString subjectIcon(QString::null);
   389 	itemList.append(priorityIcon);
   396     getPriorityIcon(mAgendaEntry.priority(), priorityIcon);
   390 	itemList.append(QString::null);
   397     getSubjectIcon(mAgendaEntry.type(),subjectIcon);
       
   398     itemList.append(subjectIcon);
       
   399     itemList.append(priorityIcon);
       
   400     itemList.append(QString::null);
   391 
   401 
   392 	mSubjectWidget->setEventViewerItemData(itemList, Qt::DecorationRole);
   402 	mSubjectWidget->setEventViewerItemData(itemList, Qt::DecorationRole);
   393 
   403 
   394 	qDebug()
       
   395 	     << "AgendaEventViewer: AgendaEventView::addSubjectAndPriorityData <--";
       
   396 }
   404 }
   397 
   405 
   398 /*!
   406 /*!
   399 	Add date & time data to Event viewer
   407 	Add date & time data to Event viewer
   400  */
   408  */
   401 void AgendaEventView::addDateTimeData()
   409 void AgendaEventView::addDateTimeData()
   402 {
   410 {
   403     qDebug()
       
   404          << "AgendaEventViewer: AgendaEventView::addDateTimeData -->";
       
   405     
       
   406     
   411     
   407     QStringList itemData;
   412     QStringList itemData;
   408     HbExtendedLocale systemLocale = HbExtendedLocale::system();
   413     HbExtendedLocale systemLocale = HbExtendedLocale::system();
   409     QDateTime startDateTime = mAgendaEntry.startTime();
   414     QDateTime startDateTime = mAgendaEntry.startTime();
   410     QDateTime endDateTime = mAgendaEntry.endTime();
   415     QDateTime endDateTime = mAgendaEntry.endTime();
   411     
   416     
   412     itemData.append(QString::null);
   417     itemData.append(QString::null);
       
   418     itemData.append(QString::null);
   413     itemData.append("qtg_small_calendar");
   419     itemData.append("qtg_small_calendar");
       
   420 
       
   421     mDateTimeWidget->setProperty(primaryLeftIconItem, false);  
       
   422 
   414     mDateTimeWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
   423     mDateTimeWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
   415     itemData.clear();
   424     itemData.clear();
   416     itemData.append(QString::null);
   425     itemData.append(QString::null);
   417     
   426     
   418     QString startTimeText;
   427     QString startTimeText;
   459     		break;
   468     		break;
   460     	case AgendaEntry::TypeEvent:
   469     	case AgendaEntry::TypeEvent:
   461 
   470 
   462     		dateTimeText.append(systemLocale.format(startDateTime.date(),
   471     		dateTimeText.append(systemLocale.format(startDateTime.date(),
   463 												r_qtn_date_usual_with_zero));
   472 												r_qtn_date_usual_with_zero));
   464 
   473     		if (CalenDateUtils::onSameDay(startDateTime, endDateTime.addSecs(-60))) {
   465     		if (CalenDateUtils::onSameDay(startDateTime, endDateTime)) {
       
   466     			data.append(hbTrId("txt_calendar_dblist_meeting_date").arg(
   474     			data.append(hbTrId("txt_calendar_dblist_meeting_date").arg(
   467 											dateTimeText));
   475 											dateTimeText));
   468     		} else {
   476     		} else {
   469     			QString endDate;
   477     			QString endDate;
   470     			endDate.append(
   478     			endDate.append(
   471     					systemLocale.format(endDateTime.date(),
   479     					systemLocale.format(endDateTime.addSecs(-60).date(),
   472 												r_qtn_date_usual_with_zero));
   480 												r_qtn_date_usual_with_zero));
   473     			data.append(hbTrId("txt_calendar_dblist_start_end_time").arg(
   481     			data.append(hbTrId("txt_calendar_dblist_start_end_time").arg(
   474 											dateTimeText).arg(endDate));
   482 											dateTimeText).arg(endDate));
   475     		}
   483     		}
   476     		break;
   484     		break;
   478     		break;
   486     		break;
   479     }
   487     }
   480 	itemData.append(data);
   488 	itemData.append(data);
   481     mDateTimeWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   489     mDateTimeWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   482     
   490     
   483     qDebug()
       
   484          << "AgendaEventViewer: AgendaEventView::addDateTimeData <--";
       
   485 }
   491 }
   486 
   492 
   487 /*!
   493 /*!
   488 	Add location data to Event viewer
   494 	Add location data to Event viewer
   489  */
   495  */
   490 void AgendaEventView::addLocationData()
   496 void AgendaEventView::addLocationData()
   491 {
   497 {
   492 	qDebug() << "AgendaEventViewer: AgendaEventView::addLocationData -->";
       
   493 	QStringList itemData;
   498 	QStringList itemData;
   494 	itemData.append(QString::null);
   499 	QString progressIcon(QString::null);	
   495 	itemData.append("qtg_small_location");
   500 	if ( mLocationFeatureEnabled ) {
       
   501 	    getProgressIndicatorstatus(progressIcon);	   
       
   502 	}
       
   503 	 if( progressIcon.isNull() ) {
       
   504 	     itemData.append(QString::null);
       
   505 	     itemData.append(QString::null);
       
   506 	     itemData.append("qtg_small_location");
       
   507 	     mLocationWidget->setProperty(primaryLeftIconItem, false);
       
   508 	 }
       
   509 	 else {
       
   510 	     itemData.append("qtg_small_location");
       
   511 	     itemData.append( progressIcon );  
       
   512 	     itemData.append(QString::null);
       
   513 	     mLocationWidget->setProperty(primaryLeftIconItem, true);
       
   514 	 }
   496 	mLocationWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
   515 	mLocationWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
   497 	itemData.clear();
   516 	itemData.clear();
   498 	itemData.append(QString::null);
   517 	itemData.append(QString::null);
   499 	itemData.append(mAgendaEntry.location());
   518 	itemData.append(mAgendaEntry.location());
   500 	mLocationWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   519 	mLocationWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   501 	qDebug() << "AgendaEventViewer: AgendaEventView::addLocationData <--";
       
   502 }
   520 }
   503 
   521 
   504 /*!
   522 /*!
   505     Add maptile image to Event viewer
   523     Add maptile image to Event viewer
   506  */
   524  */
   507 void AgendaEventView::addMapTileImage()
   525 void AgendaEventView::addMapTileImage()
   508 {
   526 {
   509 
   527     if (mLocationFeatureEnabled && !mAgendaEntry.location().isEmpty() && !mMaptilePath.isEmpty()) {
   510     qDebug() << "AgendaEventViewer: AgendaEventView::addMapTileImage -->";
   528 
   511     
   529         HbIcon maptile(mMaptilePath);
   512     if (!mAgendaEntry.location().isEmpty() && mLocationFeatureEnabled){
   530         mMaptileLabel->setIcon(maptile);
   513         MapTileService::AddressType addressType;
   531         mMaptileLabel->setPreferredSize(QSizeF(maptile.width(), maptile.height()));
   514         addressType = MapTileService::AddressPlain;
   532     }
   515         int eventId = mAgendaEntry.id();
       
   516         mMaptilePath = MapTileService::getMapTileImage(eventId, addressType);
       
   517         if (!mMaptilePath.isNull())
       
   518         {                        
       
   519             QIcon mapTileIcon(mMaptilePath);
       
   520             QPainter painter;
       
   521             QPixmap baloon(HbIcon("qtg_small_location.svg").pixmap());
       
   522             QPixmap map (mapTileIcon.pixmap(width,height));
       
   523             //Display pin image in the center of maptile image
       
   524             painter.begin( &map );
       
   525             painter.drawPixmap( (width/2)-(baloon.width()/2), 
       
   526                           (height/2)-baloon.height(), baloon );
       
   527             painter.end();
       
   528             mapTileIcon.addPixmap( map );          
       
   529             
       
   530             HbIcon maptile(mapTileIcon);
       
   531             mMaptileLabel->setIcon(maptile);        
       
   532 
       
   533             mMaptileLabel->setPreferredSize(QSizeF(width, height));
       
   534             mMaptileLabel->setMinimumSize(QSizeF(width, height));
       
   535             mMaptileLabel->setMaximumSize(QSizeF(width, height));
       
   536             mMaptileLabel->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
       
   537                     QSizePolicy::Fixed));            
       
   538 
       
   539         }
       
   540     }
       
   541 
       
   542     qDebug() << "AgendaEventViewer: AgendaEventView::addMapTileImage <--";
       
   543 }
   533 }
   544 /*!
   534 /*!
   545 	Add reminder data to Event viewer
   535 	Add reminder data to Event viewer
   546  */
   536  */
   547 void AgendaEventView::addReminderData()
   537 void AgendaEventView::addReminderData()
   548 {
   538 {
   549 	qDebug() << "AgendaEventViewer: AgendaEventView::addReminderData -->";
       
   550 	QStringList itemData;
   539 	QStringList itemData;
   551 	itemData.append(QString::null);
   540 	itemData.append(QString::null);
   552 	itemData.append("qtg_small_reminder");
   541     itemData.append(QString::null);
       
   542     itemData.append("qtg_small_reminder");
       
   543     mReminderWidget->setProperty(primaryLeftIconItem, false); 
   553 	mReminderWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
   544 	mReminderWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
   554 	itemData.clear();
   545 	itemData.clear();
   555 	itemData.append(QString::null);
   546 	itemData.append(QString::null);
   556 	itemData.append(alarmTimeText());
   547 	itemData.append(alarmTimeText());
   557 	mReminderWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   548 	mReminderWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   558 	qDebug() << "AgendaEventViewer: AgendaEventView::addReminderData <--";
   549     }
   559 }
       
   560 
   550 
   561 /*!
   551 /*!
   562 	Add completed to-do data to Event viewer
   552 	Add completed to-do data to Event viewer
   563  */
   553  */
   564 void AgendaEventView::addCompletedTodoData()
   554 void AgendaEventView::addCompletedTodoData()
   565 {
   555 {
   566 	qDebug() << "AgendaEventViewer: AgendaEventView::addCompletedTodoData -->";
       
   567 	QStringList itemData;
   556 	QStringList itemData;
   568 	QString     completedText;
   557 	QString     completedText;
   569 	HbExtendedLocale systemLocale = HbExtendedLocale::system();;
   558     HbExtendedLocale systemLocale = HbExtendedLocale::system();;
   570 	
   559     itemData.append(QString::null);
   571 	itemData.append(QString::null);
   560 	itemData.append(QString::null);
   572 	itemData.append(QString::null);
   561 	itemData.append(QString::null);
       
   562     mReminderWidget->setProperty(primaryLeftIconItem, false);
   573 	mReminderWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
   563 	mReminderWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
   574 	itemData.clear();
   564 	itemData.clear();
   575 	completedText = systemLocale.format(mAgendaEntry.completedDateTime().date(),
   565 	completedText = systemLocale.format(mAgendaEntry.completedDateTime().date(),
   576 					                    r_qtn_date_usual_with_zero);
   566 					                    r_qtn_date_usual_with_zero);
   577 	itemData.append(hbTrId("txt_calendar_dblist_completed_date"));
   567 	itemData.append(hbTrId("txt_calendar_dblist_completed_date"));
   578 	itemData.append(completedText);
   568 	itemData.append(completedText);
   579 	mReminderWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   569 	mReminderWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   580 	qDebug() << "AgendaEventViewer: AgendaEventView::addCompletedTodoData <--";
       
   581 }
   570 }
   582 
   571 
   583 /*!
   572 /*!
   584 	Add repeat data to Event viewer
   573 	Add repeat data to Event viewer
   585  */
   574  */
   586 void AgendaEventView::addRepeatData()
   575 void AgendaEventView::addRepeatData()
   587 {
   576 {
   588 	qDebug() << "AgendaEventViewer: AgendaEventView::addRepeatData -->";
       
   589 	QStringList itemData;
   577 	QStringList itemData;
   590 	itemData.append(QString::null);
   578 	itemData.append(QString::null);
   591 	itemData.append("qtg_mono_repeat.svg");
   579     itemData.append(QString::null);
       
   580     itemData.append("qtg_small_repeat");
       
   581     mRepeatWidget->setProperty(primaryLeftIconItem, false);
   592 	mRepeatWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
   582 	mRepeatWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
   593 	itemData.clear();
   583 	itemData.clear();
   594 	itemData.append(QString::null);
   584 	itemData.append(QString::null);
   595 	itemData.append(repeatRule());
   585 	itemData.append(repeatRule());
   596 	mRepeatWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   586 	mRepeatWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   597 	qDebug() << "AgendaEventViewer: AgendaEventView::addRepeatData <--";
       
   598 }
   587 }
   599 
   588 
   600 /*!
   589 /*!
   601 	Add description data to Event viewer
   590 	Add description data to Event viewer
   602  */
   591  */
   603 void AgendaEventView::addDescriptionData()
   592 void AgendaEventView::addDescriptionData()
   604 {
   593 {
   605 	qDebug() << "AgendaEventViewer: AgendaEventView::addDiscriptionData -->";
       
   606 	QStringList itemData;
   594 	QStringList itemData;
   607 	itemData.append(QString::null);
   595 	itemData.append(QString::null);
   608 	itemData.append(QString::null);
   596 	itemData.append(QString::null);
       
   597     itemData.append(QString::null);
       
   598     mDescriptionWidget->setProperty(primaryLeftIconItem, false);
   609 	mDescriptionWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
   599 	mDescriptionWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
   610 	itemData.clear();
   600 	itemData.clear();
   611 	itemData.append(hbTrId("txt_calendar_dblist_description"));
   601 	itemData.append(hbTrId("txt_calendar_dblist_description"));
   612 	itemData.append(mAgendaEntry.description());
   602 	itemData.append(mAgendaEntry.description());
   613 	mDescriptionWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   603 	mDescriptionWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   614 	qDebug() << "AgendaEventViewer: AgendaEventView::addDiscriptionData <--";
       
   615 }
   604 }
   616 
   605 
   617 /*!
   606 /*!
   618 	Returns priority icon
   607 	Returns priority icon
   619  */
   608  */
   620 void AgendaEventView::getPriorityIcon(int priority, QString &priorityIcon)
   609 void AgendaEventView::getPriorityIcon(int priority, QString &priorityIcon)
   621 {
   610 {
   622 	qDebug() << "AgendaEventViewer: AgendaEventView::getPriorityIcon -->";
       
   623 
   611 
   624 	switch(priority) {
   612 	switch(priority) {
   625 		case 1:priorityIcon.append("qtg_small_priority_high");
   613 		case 1:priorityIcon.append("qtg_small_priority_high");
   626 		break;
   614 		break;
   627 		case 3:priorityIcon.append("qtg_small_priority_low");
   615 		case 3:priorityIcon.append("qtg_small_priority_low");
   628 		break;
   616 		break;
   629 		default:
   617 		default:
   630 		break;
   618 		break;
   631 	}
   619 	}
   632 
   620 
   633 	qDebug() << "AgendaEventViewer: AgendaEventView::getPriorityIcon <--";
       
   634 }
   621 }
   635 
   622 
   636 /*!
   623 /*!
   637 	Returns repeat rule
   624 	Returns repeat rule
   638  */
   625  */
   639 QString AgendaEventView::repeatRule() const
   626 QString AgendaEventView::repeatRule() const
   640 {
   627 {
   641 	qDebug() << "AgendaEventViewer: AgendaEventView::repeatRule -->";
       
   642 	
   628 	
   643 	QString repeatRule;
   629 	QString repeatRule;
   644 	AgendaRepeatRule agendaRepeatRule = mAgendaEntry.repeatRule();
   630 	AgendaRepeatRule agendaRepeatRule = mAgendaEntry.repeatRule();
   645 	if (agendaRepeatRule.type() != AgendaRepeatRule::InvalidRule)
   631 	if (agendaRepeatRule.type() != AgendaRepeatRule::InvalidRule)
   646 	{
   632 	{
   648 			case AgendaRepeatRule::DailyRule:
   634 			case AgendaRepeatRule::DailyRule:
   649 				repeatRule.append(hbTrId("txt_calendar_dblist_repeats_daily"));
   635 				repeatRule.append(hbTrId("txt_calendar_dblist_repeats_daily"));
   650 			break;
   636 			break;
   651 			case AgendaRepeatRule::WeeklyRule:
   637 			case AgendaRepeatRule::WeeklyRule:
   652 				if (AgendaUtil::isWorkdaysRepeatingEntry(agendaRepeatRule)) {
   638 				if (AgendaUtil::isWorkdaysRepeatingEntry(agendaRepeatRule)) {
   653 					//TODO: Add text id for workdays
   639 					repeatRule.append(hbTrId("txt_calendar_dblist_repeats_workdays"));
   654 					repeatRule.append(hbTrId("Workdays"));
       
   655 				} else {
   640 				} else {
   656 					if (agendaRepeatRule.interval() == 2) {
   641 					if (agendaRepeatRule.interval() == 2) {
   657 						repeatRule.append(
   642 						repeatRule.append(
   658 							hbTrId("txt_calendar_dblist_repeats_fortnightly"));
   643 							hbTrId("txt_calendar_dblist_repeats_fortnightly"));
   659 					} else {
   644 					} else {
   680 				r_qtn_date_usual_with_zero);
   665 				r_qtn_date_usual_with_zero);
   681 		repeatRule.append(
   666 		repeatRule.append(
   682 			hbTrId("txt_calendar_dblist_repeats_daily_val_until_1").
   667 			hbTrId("txt_calendar_dblist_repeats_daily_val_until_1").
   683 			arg(untilDateString));
   668 			arg(untilDateString));
   684 	}
   669 	}
   685 	qDebug() << "AgendaEventViewer: AgendaEventView::repeatRule <--";
       
   686 	
   670 	
   687 	return repeatRule;
   671 	return repeatRule;
   688 }
   672 }
   689 
   673 
   690 /*!
   674 /*!
   692 
   676 
   693 	\return QString	Holds the alarm time text.
   677 	\return QString	Holds the alarm time text.
   694  */
   678  */
   695 QString AgendaEventView::alarmTimeText() const
   679 QString AgendaEventView::alarmTimeText() const
   696 {
   680 {
   697 	qDebug() << "AgendaEventViewer: AgendaEventView::alarmTimeText -->";
       
   698 
   681 
   699 	QString alarmDateTimeText;
   682 	QString alarmDateTimeText;
   700 	QDateTime startTime;
   683 	QDateTime startTime;
   701 	QDateTime alarmDateTime;
   684 	QDateTime alarmDateTime;
   702 	
   685 	
   717 						r_qtn_time_usual_with_zero)).arg(
   700 						r_qtn_time_usual_with_zero)).arg(
   718 						systemLocale.format(alarmDateTime.date(),
   701 						systemLocale.format(alarmDateTime.date(),
   719 						r_qtn_date_usual_with_zero)));
   702 						r_qtn_date_usual_with_zero)));
   720 	}
   703 	}
   721 	
   704 	
   722 	qDebug() << "AgendaEventViewer: AgendaEventView::alarmTimeText <--";
       
   723 	return alarmDateTimeText;
   705 	return alarmDateTimeText;
   724 }
   706 }
   725 
   707 
   726 /*!
   708 /*!
   727 	Remove unnecessary widget from layout.
   709 	Remove unnecessary widget from layout.
   728  */
   710  */
   729 void AgendaEventView::removeWidget()
   711 void AgendaEventView::removeWidget()
   730 {
   712 {
   731 	qDebug() << "AgendaEventViewer: AgendaEventView::removeWidget -->";
       
   732 	
   713 	
   733 	if (mAgendaEntry.location().isEmpty()) { 
   714 	if (mAgendaEntry.location().isEmpty()) { 
   734 		mLocationWidget->hide();
   715 		mLocationWidget->hide();
   735 		mLinearLayout->removeItem(mLocationWidget);
   716 		mLinearLayout->removeItem(mLocationWidget);
   736 	}
   717 	}
   740             || mAgendaEntry.location().isEmpty()){        
   721             || mAgendaEntry.location().isEmpty()){        
   741         //code added to hide and remove maptile image   
   722         //code added to hide and remove maptile image   
   742         mMaptileLabel->hide();
   723         mMaptileLabel->hide();
   743         mLinearLayout->removeItem(mMaptileLabel);
   724         mLinearLayout->removeItem(mMaptileLabel);
   744     }
   725     }
       
   726     file.close();
   745         
   727         
   746 	if (mAgendaEntry.alarm().isNull()) { 
   728 	if (mAgendaEntry.alarm().isNull()) { 
   747 		if (mAgendaEntry.type() == AgendaEntry::TypeTodo ) {
   729 		if (mAgendaEntry.type() == AgendaEntry::TypeTodo ) {
   748 				if (AgendaEntry::TodoNeedsAction == mAgendaEntry.status()) { 
   730 				if (AgendaEntry::TodoCompleted != mAgendaEntry.status()) { 
   749 					mReminderWidget->hide();
   731 					mReminderWidget->hide();
   750 					mLinearLayout->removeItem(mReminderWidget);
   732 					mLinearLayout->removeItem(mReminderWidget);
   751 					mReminderWidgetAdded = false;
   733 					mReminderWidgetAdded = false;
   752 				}
   734 				}
   753 		} else { 
   735 		} else { 
   768 	}
   750 	}
   769 	
   751 	
   770 	mLinearLayout->invalidate();
   752 	mLinearLayout->invalidate();
   771 	mLinearLayout->activate();
   753 	mLinearLayout->activate();
   772 	
   754 	
   773 	qDebug() << "AgendaEventViewer: AgendaEventView::removeWidget <--";
       
   774 }
   755 }
   775 
   756 
   776 /*!
   757 /*!
   777 	Update the completed to-do or reminder data to event viewer.
   758 	Update the completed to-do or reminder data to event viewer.
   778  */
   759  */
   779 void AgendaEventView::updateCompletedReminderData()
   760 void AgendaEventView::updateCompletedReminderData()
   780 {
   761 {
   781 	qDebug()
       
   782 	   << "AgendaEventViewer: AgendaEventView::updateCompletedReminderData -->";
       
   783 
   762 
   784 	if (AgendaEntry::TodoCompleted == mAgendaEntry.status()) {
   763 	if (AgendaEntry::TodoCompleted == mAgendaEntry.status()) {
   785 		addCompletedTodoData();
   764 		addCompletedTodoData();
   786 		if (!mReminderWidgetAdded) {
   765 		if (!mReminderWidgetAdded) {
   787 			mReminderWidget->show();
   766 			mReminderWidget->show();
   807 
   786 
   808 	}
   787 	}
   809 	
   788 	
   810 	mLinearLayout->invalidate();
   789 	mLinearLayout->invalidate();
   811 	mLinearLayout->activate();
   790 	mLinearLayout->activate();
   812 	qDebug()
       
   813 	   << "AgendaEventViewer: AgendaEventView::updateCompletedReminderData <--";
       
   814 }
   791 }
   815 
   792 
   816 /*!
   793 /*!
   817 	Remove all widgets from layout.
   794 	Remove all widgets from layout.
   818  */
   795  */
   819 void AgendaEventView::removeAllWidgets()
   796 void AgendaEventView::removeAllWidgets()
   820 {
   797 {
   821 	qDebug() << "AgendaEventViewer: AgendaEventView::removeAllWidgets -->";
       
   822 
   798 
   823 	for (int i = 2; i < mLinearLayout->count(); i++) {
   799 	for (int i = 2; i < mLinearLayout->count(); i++) {
   824 		mLinearLayout->removeAt(i);
   800 		mLinearLayout->removeAt(i);
   825 	}
   801 	}
   826 	mLinearLayout->invalidate();
   802 	mLinearLayout->invalidate();
   827 	mLinearLayout->activate();
   803 	mLinearLayout->activate();
   828 	
   804 	
   829 	qDebug() << "AgendaEventViewer: AgendaEventView::removeAllWidgets <--";
       
   830 }
   805 }
   831 
   806 
   832 /*!
   807 /*!
   833 	Add all widgets to layout.
   808 	Add all widgets to layout.
   834  */
   809  */
   835 void AgendaEventView::addAllWidgets()
   810 void AgendaEventView::addAllWidgets()
   836 {
   811 {
   837 	qDebug() << "AgendaEventViewer: AgendaEventView::addAllWidgets -->";
       
   838 	
   812 	
   839 	mLinearLayout->addItem(mLocationWidget);
   813 	mLinearLayout->addItem(mLocationWidget);
   840 	mLocationWidget->show();
   814 	mLocationWidget->show();
   841 	mLinearLayout->addItem(mMaptileLabel);
   815 	mLinearLayout->addItem(mMaptileLabel);
   842 	mMaptileLabel->show();		
   816 	mMaptileLabel->show();		
   848 	mDescriptionWidget->show();
   822 	mDescriptionWidget->show();
   849 	
   823 	
   850 	mLinearLayout->invalidate();
   824 	mLinearLayout->invalidate();
   851 	mLinearLayout->activate();
   825 	mLinearLayout->activate();
   852 	
   826 	
   853 	qDebug() << "AgendaEventViewer: AgendaEventView::addAllWidgets <--";
       
   854 }
   827 }
   855 
   828 
   856 /*!
   829 /*!
   857 	Queries user whether to delete whole series or just this single occurence
   830 	Queries user whether to delete whole series or just this single occurence
   858  */
   831  */
   859 void AgendaEventView::showDeleteOccurencePopup()
   832 void AgendaEventView::showDeleteOccurencePopup()
   860 {
   833 {
   861 	qDebug()
   834 	HbDialog *popUp = new HbDialog();
   862 	      << "AgendaEventViewer: AgendaEventView::showDeleteOccurencePopup -->";
   835 	popUp->setDismissPolicy(HbDialog::NoDismiss);
   863 	HbDialog popUp;
   836 	popUp->setTimeout(HbDialog::NoTimeout);
   864 	popUp.setDismissPolicy(HbDialog::NoDismiss);
   837 	popUp->setAttribute( Qt::WA_DeleteOnClose, true );
   865 	popUp.setTimeout(HbDialog::NoTimeout);
       
   866 
   838 
   867 	QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
   839 	QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
   868 	HbWidget *deleteWidget = new HbWidget(mViewer);
   840 	HbWidget *deleteWidget = new HbWidget(mViewer);
   869 	deleteWidget->setLayout(layout);
   841 	deleteWidget->setLayout(layout);
   870 
   842 
   871 	HbRadioButtonList *deleteButtonList = new HbRadioButtonList(mViewer);
   843 	HbRadioButtonList *deleteButtonList = new HbRadioButtonList(mViewer);
   872 
   844 
   873 	QStringList list;
   845 	QStringList list;
   874 	list << hbTrId("txt_calendar_info_this_occurrence_only") 
   846 	list << hbTrId("txt_calendar_info_this_occurrence_only") 
   875 		 << hbTrId("txt_calendar_info_all_occurences");
   847 				<< hbTrId("txt_calendar_info_all_occurences");
   876 
   848 
   877 	deleteButtonList->setItems(list);
   849 	deleteButtonList->setItems(list);
   878 
   850 
   879 	layout->addItem(deleteButtonList);
   851 	layout->addItem(deleteButtonList);
   880 
   852 
   881 	popUp.setContentWidget(deleteWidget);
   853 	popUp->setContentWidget(deleteWidget);
   882 	popUp.setHeadingWidget(new HbLabel(
   854 	popUp->setHeadingWidget(new HbLabel(
   883 						hbTrId("txt_calendar_title_delete_repeated_entry")));
   855 			hbTrId("txt_calendar_title_delete_repeated_entry")));
   884 
   856 
   885 	connect(deleteButtonList, SIGNAL(itemSelected(int)), this,
   857 	connect(deleteButtonList, SIGNAL(itemSelected(int)), this,
   886 	        SLOT(handleDeleteOccurence(int)));
   858 											SLOT(handleDeleteOccurence(int)));
   887 	connect(deleteButtonList, SIGNAL(itemSelected(int)), &popUp, SLOT(close()));
   859 	connect(deleteButtonList, SIGNAL(itemSelected(int)), popUp, SLOT(close()));
   888 
   860 
   889 	// Create secondary action
   861 	popUp->addAction(new HbAction(
   890 	HbAction *cancelAction = new HbAction(
   862 			hbTrId("txt_calendar_button_softkey1_cancel")));
   891 						hbTrId("txt_calendar_button_softkey1_cancel"));
       
   892 	popUp.setSecondaryAction(cancelAction);
       
   893 	connect(cancelAction, SIGNAL(triggered()), &popUp, SLOT(close()));
       
   894 
   863 
   895 	// Show the popup
   864 	// Show the popup
   896 	popUp.exec();
   865 	popUp->open();
   897 
   866 
   898 	qDebug()
   867 }
   899 	      << "AgendaEventViewer: AgendaEventView::showDeleteOccurencePopup <--";
   868 
   900 }
   869 /*!
   901 
   870 	Show delete confirmation query
   902 
   871  */
   903 /*!
   872 void AgendaEventView::showDeleteConfirmationQuery()
   904  * Show delete confirmation query
   873     {
   905  */
   874     
   906 int AgendaEventView::showDeleteConfirmationQuery()
   875     HbMessageBox *popup = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
   907 {
   876     popup->setDismissPolicy(HbDialog::NoDismiss);
   908 	qDebug()
   877     popup->setTimeout(HbDialog::NoTimeout);
   909 	   << "AgendaEventViewer: AgendaEventView::showDeleteConfirmationQuery -->";
   878     popup->setAttribute( Qt::WA_DeleteOnClose, true );
   910 	int retStatus = 0;
   879 
   911 
   880     QString text = 0;
   912 	HbMessageBox popup(HbMessageBox::MessageTypeQuestion);
   881 
   913 	popup.setDismissPolicy(HbDialog::NoDismiss);
   882     switch (mAgendaEntry.type()) {
   914 	popup.setTimeout(HbDialog::NoTimeout);
   883         case AgendaEntry::TypeAppoinment:
   915 	popup.setIconVisible(true);
   884         case AgendaEntry::TypeEvent: {
   916 
   885         text.append(hbTrId("txt_calendar_info_delete_meeting"));
   917 	QString text = 0;
   886         break;
   918 
   887         }
   919 	switch (mAgendaEntry.type()) {
   888         case AgendaEntry::TypeAnniversary: {
   920 		case AgendaEntry::TypeAppoinment:
   889         text.append(hbTrId("txt_calendar_info_delete_anniversary"));
   921 		case AgendaEntry::TypeEvent: {
   890         break;
   922 			text.append(hbTrId("txt_calendar_info_delete_meeting"));
   891         }
   923 			break;
   892         case AgendaEntry::TypeTodo: {
   924 		}
   893         text.append(hbTrId("txt_calendar_info_delete_todo_note"));
   925 		case AgendaEntry::TypeAnniversary: {
   894         break;
   926 			text.append(hbTrId("txt_calendar_info_delete_anniversary"));
   895         }
   927 			break;
   896         case AgendaEntry::TypeNote: {
   928 		}
   897         text.append(hbTrId("txt_calendar_info_delete_anniversary"));
   929 		case AgendaEntry::TypeTodo: {
   898         break;
   930 			text.append(hbTrId("txt_calendar_info_delete_todo_note"));
   899         }
   931 			break;
   900     }
   932 		}
   901     popup->setText(text);
   933 		case AgendaEntry::TypeNote: {
   902     
   934 			text.append(hbTrId("txt_calendar_info_delete_anniversary"));
   903     QList<QAction*> list = popup->actions();
   935 			break;
   904     for(int i=0; i < list.count(); i++)
   936 		}
   905         {
   937 	}
   906         popup->removeAction(list[i]);
   938 
   907         }
   939 	popup.setText(text);
   908     HbAction *deleteAction = 
   940 	
   909 					new HbAction(hbTrId("txt_calendar_button_delete"), popup);
   941 	popup.setPrimaryAction(new HbAction(
   910     popup->addAction(deleteAction);
   942 								hbTrId("txt_calendar_button_delete"), &popup));
   911     connect(deleteAction, SIGNAL(triggered()), this ,
   943 	popup.setSecondaryAction(new HbAction(
   912 												SLOT(handleDeleteAction()));
   944 								hbTrId("txt_calendar_button_cancel"), &popup));
   913     popup->addAction(new HbAction(hbTrId("txt_calendar_button_cancel"), popup));
   945 	HbAction *selected = popup.exec();
   914     popup->open();
   946 	if (selected == popup.primaryAction()) { 
   915 }
   947 		retStatus = 1;
   916 
   948 	}
   917 /*!
   949 
   918 	Handles the delete action
   950 	qDebug()
   919  */
   951 	   << "AgendaEventViewer: AgendaEventView::showDeleteConfirmationQuery <--";
   920 void AgendaEventView::handleDeleteAction()
   952 	return retStatus;
   921     {
       
   922     // If delete button is pressed delete the entry
       
   923     // To notify client that deleting Started
       
   924     // Calendar Application changing state from viewing to deleting.
       
   925     mOwner->deletingStarted();
       
   926 
       
   927     // Delete the entry.
       
   928     mOwner->mAgendaUtil->deleteEntry(mAgendaEntry.id());
   953 }
   929 }
   954 
   930 
   955 /*!
   931 /*!
   956 	Marks to-do entry as done or undone based on the completed value.
   932 	Marks to-do entry as done or undone based on the completed value.
   957  */
   933  */
   958 void AgendaEventView::markTodoStatus()
   934 void AgendaEventView::markTodoStatus()
   959 {
   935 {
   960 	qDebug() << "AgendaEventViewer: AgendaEventView::markTodoStatus -->";
       
   961 
   936 
   962 	QDateTime currentDateTime = QDateTime::currentDateTime();
   937 	QDateTime currentDateTime = QDateTime::currentDateTime();
   963 
   938 
   964 	// Set the to-do status using the agenda util.
   939 	// Set the to-do status using the agenda util.
   965 	if (AgendaEntry::TodoNeedsAction == mAgendaEntry.status()) {
   940 	if (AgendaEntry::TodoCompleted != mAgendaEntry.status()) {
   966 		
       
   967 		// Update the menu text to mark to-do as undone.
   941 		// Update the menu text to mark to-do as undone.
   968 		mMarkTodoAction->setText(hbTrId("txt_calendar_menu_mark_as_not_done"));
   942 		mMarkTodoAction->setText(hbTrId("txt_calendar_menu_mark_as_not_done"));
   969 		
       
   970 		mAgendaEntry.setStatus(AgendaEntry::TodoCompleted);
   943 		mAgendaEntry.setStatus(AgendaEntry::TodoCompleted);
   971 		mAgendaEntry.setCompletedDateTime(currentDateTime);
   944 		mAgendaEntry.setCompletedDateTime(currentDateTime);
   972 		mOwner->mAgendaUtil->setCompleted(mAgendaEntry, true, currentDateTime);
   945 		mOwner->mAgendaUtil->setCompleted(mAgendaEntry, true, currentDateTime);
   973 		
   946 	} else {
   974 		
       
   975 
       
   976 	} else if (AgendaEntry::TodoCompleted == mAgendaEntry.status()) {
       
   977 		
   947 		
   978 		// Update the menu text to mark to-do as done.
   948 		// Update the menu text to mark to-do as done.
   979 		mMarkTodoAction->setText(hbTrId("txt_calendar_menu_mark_as_done"));
   949 		mMarkTodoAction->setText(hbTrId("txt_calendar_menu_mark_as_done"));
   980 				
       
   981 		mAgendaEntry.setStatus(AgendaEntry::TodoNeedsAction);
   950 		mAgendaEntry.setStatus(AgendaEntry::TodoNeedsAction);
   982 		mOwner->mAgendaUtil->setCompleted(mAgendaEntry, false, currentDateTime);
   951 		mOwner->mAgendaUtil->setCompleted(mAgendaEntry, false, currentDateTime);
   983 		
       
   984 		
       
   985 	}
   952 	}
   986 
   953 
   987 	updateCompletedReminderData();
   954 	updateCompletedReminderData();
   988 	
   955 	
   989 	qDebug() << "AgendaEventViewer: AgendaEventView::markTodoStatus <--";
       
   990 }
   956 }
   991 
   957 
   992 /*!
   958 /*!
   993 	Edits the agenda entry by lanching the to-do viewer.
   959 	Edits the agenda entry by lanching the to-do viewer.
   994  */
   960  */
   995 void AgendaEventView::edit()
   961 void AgendaEventView::edit()
   996 {
   962 {
   997 	qDebug() << "AgendaEventViewer: AgendaEventView::edit -->";
       
   998 
   963 
   999 	mOwner->editingStarted();
   964 	mOwner->editingStarted();
  1000 	
   965 	
  1001 	if (AgendaEntry::TypeTodo == mAgendaEntry.type()) {
   966 	if (AgendaEntry::TypeTodo == mAgendaEntry.type()) {
  1002 		// Launch the to-do editor using notes editor api
   967 		// Load notes editor plugin if not loaded.
  1003 		// Construct Note editor for launching the to-do editor
   968 		if(!mNotesPluginLoaded) {
  1004 		mNoteEditor = new NotesEditor(mOwner->mAgendaUtil, this);
   969 			// Launch the to-do editor using notes editor plugin api
  1005 		mNoteEditor->edit(mAgendaEntry);
   970 			QDir dir(NOTES_EDITOR_PLUGIN_PATH);
       
   971 			QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME);
       
   972 
       
   973 			// Create NotesEditor plugin loader object.
       
   974 			mNotesEditorPluginLoader = new QPluginLoader(pluginName);
       
   975 
       
   976 			// Load the plugin
       
   977 			mNotesPluginLoaded = mNotesEditorPluginLoader->load();
       
   978 		}
       
   979 		QObject *plugin = qobject_cast<QObject*> (
       
   980 				mNotesEditorPluginLoader->instance());
       
   981 
       
   982 		NotesEditorInterface* interface =
       
   983 				qobject_cast<NotesEditorInterface*>(plugin);
       
   984 
       
   985 		interface->edit(mAgendaEntry, mOwner->mAgendaUtil);
  1006 
   986 
  1007 		connect(
   987 		connect(
  1008 				mNoteEditor, SIGNAL(editingCompleted(bool)),
   988 				interface, SIGNAL(editingCompleted(bool)),
  1009 				this, SLOT(handleNoteEditorClosed(bool)));
   989 				this, SLOT(handleNoteEditorClosed(bool)));
  1010 		
   990 		
  1011 
   991 
  1012 	} else {
   992 	} else {
  1013 		// Launch the calendar entry editor using calendar editor api
   993 		// Launch the calendar entry editor using calendar editor api
  1016 		                        this, SLOT(handleCalendarEditorClosed()));
   996 		                        this, SLOT(handleCalendarEditorClosed()));
  1017 		mCalenEditor->edit(mAgendaEntry, false);
   997 		mCalenEditor->edit(mAgendaEntry, false);
  1018 	
   998 	
  1019 		
   999 		
  1020 	}
  1000 	}
  1021 	qDebug() << "AgendaEventViewer: AgendaEventView::edit <--";
       
  1022 }
  1001 }
  1023 
  1002 
  1024 /*!
  1003 /*!
  1025 	Deletes the agenda entry.
  1004 	Deletes the agenda entry.
  1026  */
  1005  */
  1027 void AgendaEventView::deleteAgendaEntry()
  1006 void AgendaEventView::deleteAgendaEntry()
  1028 {
  1007 {
  1029 	qDebug() << "AgendaEventViewer: AgendaEventView::deleteAgendaEntry -->";
       
  1030 
  1008 
  1031 	// Before we do anything, check in the entry is repeating
  1009 	// Before we do anything, check in the entry is repeating
  1032 	// OR its a child item
  1010 	// OR its a child item
  1033 	bool isChild = !(mAgendaEntry.recurrenceId().isNull());
  1011 	bool isChild = !(mAgendaEntry.recurrenceId().isNull());
  1034 	bool isRepeating = mAgendaEntry.isRepeating();
  1012 	bool isRepeating = mAgendaEntry.isRepeating();
  1036 			&& (mAgendaEntry.type() != AgendaEntry::TypeAnniversary) 
  1014 			&& (mAgendaEntry.type() != AgendaEntry::TypeAnniversary) 
  1037 			&& (mAgendaEntry.type() != AgendaEntry::TypeTodo)) {
  1015 			&& (mAgendaEntry.type() != AgendaEntry::TypeTodo)) {
  1038 		// Query user if he wants to delete whole series or just this occurence
  1016 		// Query user if he wants to delete whole series or just this occurence
  1039 		showDeleteOccurencePopup();
  1017 		showDeleteOccurencePopup();
  1040 	} else {
  1018 	} else {
  1041 		if (showDeleteConfirmationQuery()) {
  1019         showDeleteConfirmationQuery();
  1042 			
  1020 	}
  1043 			// To notify client that deleting Started
  1021 
  1044 			// Calendar Application changing state from viewing to deleting.
       
  1045 			mOwner->deletingStarted();
       
  1046 				
       
  1047 			// Delete the entry.
       
  1048 			mOwner->mAgendaUtil->deleteEntry(mAgendaEntry.id());
       
  1049 		}
       
  1050 	}
       
  1051 
       
  1052 	qDebug() << "AgendaEventViewer: AgendaEventView::deleteAgendaEntry <--";
       
  1053 }
  1022 }
  1054 
  1023 
  1055 /*!
  1024 /*!
  1056 	Save the agenda entry to calendar db.
  1025 	Save the agenda entry to calendar db.
  1057  */
  1026  */
  1058 void AgendaEventView::saveAgendaEntry()
  1027 void AgendaEventView::saveAgendaEntry()
  1059 {
  1028 {
  1060 	qDebug() << "AgendaEventViewer: AgendaEventView::saveAgendaEntry -->";
       
  1061 	
  1029 	
  1062 	// Save entry to calendar.
  1030 	// Save entry to calendar.
  1063 	mOwner->mAgendaUtil->addEntry(mAgendaEntry);
  1031 	mOwner->mAgendaUtil->addEntry(mAgendaEntry);
  1064 	
  1032 	
  1065 	// Close the agenda entry viewer
  1033 	// Close the agenda entry viewer
  1066 	close();
  1034 	close();
  1067 	qDebug() << "AgendaEventViewer: AgendaEventView::saveAgendaEntry <--";
       
  1068 }
  1035 }
  1069 /*!
  1036 /*!
  1070 	Closes the event viewer
  1037 	Closes the event viewer
  1071  */
  1038  */
  1072 void AgendaEventView::close()
  1039 void AgendaEventView::close()
  1073 {
  1040 {
  1074 	qDebug() << "AgendaEventViewer: AgendaEventView::close -->";
       
  1075 
  1041 
  1076 	// Remove the view from main window.
  1042 	// Remove the view from main window.
  1077 	HbMainWindow *window = hbInstance->allMainWindows().first();
  1043 	HbMainWindow *window = hbInstance->allMainWindows().first();
  1078 
  1044 
  1079 	// Cleanup.
  1045 	// Cleanup.
  1082 			this, SLOT(close()));
  1048 			this, SLOT(close()));
  1083 
  1049 
  1084 	window->removeView(mViewer);
  1050 	window->removeView(mViewer);
  1085 	mOwner->viewingCompleted(mAgendaEntry.startTime().date());
  1051 	mOwner->viewingCompleted(mAgendaEntry.startTime().date());
  1086 
  1052 
  1087 	qDebug() << "AgendaEventViewer: AgendaEventView::close <--";
       
  1088 }
  1053 }
  1089 
  1054 
  1090 /*!
  1055 /*!
  1091 	Handles entry updation of the event entry.
  1056 	Handles entry updation of the event entry.
  1092  */
  1057  */
  1093 void AgendaEventView::handleEntryUpdation(ulong id)
  1058 void AgendaEventView::handleEntryUpdation(ulong id)
  1094 {
  1059 {
  1095 	qDebug() << "AgendaEventViewer: AgendaEventView::handleEntryUpdation -->";
       
  1096 
  1060 
  1097 	AgendaEntry updatedEntry = mOwner->mAgendaUtil->fetchById(id);
  1061 	AgendaEntry updatedEntry = mOwner->mAgendaUtil->fetchById(id);
  1098 
  1062 
  1099 	// Agenda entry is not null then refresh the view else close event viewer
  1063 	// Agenda entry is not null then refresh the view else close event viewer
  1100 	if (!updatedEntry.isNull()) {
  1064 	if (!updatedEntry.isNull()) {
  1136 	} else {
  1100 	} else {
  1137 		// Close the agenda entry viewer
  1101 		// Close the agenda entry viewer
  1138 		close();
  1102 		close();
  1139 	}
  1103 	}
  1140 
  1104 
  1141 	qDebug() << "AgendaEventViewer: AgendaEventView::handleEntryUpdation <--";
       
  1142 }
  1105 }
  1143 
  1106 
  1144 /*!
  1107 /*!
  1145 	Handles the entry deletion of the agenda entry
  1108 	Handles the entry deletion of the agenda entry
  1146 */
  1109 */
  1147 void AgendaEventView::handleEntryDeletion(ulong id)
  1110 void AgendaEventView::handleEntryDeletion(ulong id)
  1148 {
  1111 {
  1149 	qDebug() <<"AgendaEventViewer: AgendaEventView::handleEntryDeletion -->";
       
  1150 
  1112 
  1151 	if (id == mAgendaEntry.id()) {
  1113 	if (id == mAgendaEntry.id()) {
  1152 		// Close the agenda entry viewer
  1114 		// Close the agenda entry viewer
  1153 		close();
  1115 		close();
  1154 		mOwner->deletingCompleted();
  1116 		mOwner->deletingCompleted();
  1155 	}
  1117 	}
  1156 
  1118 
  1157 	qDebug() <<"AgendaEventViewer: AgendaEventView::handleEntryDeletion <--";
       
  1158 }
  1119 }
  1159 
  1120 
  1160 /*!
  1121 /*!
  1161 	Handles the Note Editor editing completion of the agenda entry
  1122 	Handles the Note Editor editing completion of the agenda entry
  1162  */
  1123  */
  1163 void AgendaEventView::handleNoteEditorClosed(bool status)
  1124 void AgendaEventView::handleNoteEditorClosed(bool status)
  1164 {
  1125 {
  1165 	Q_UNUSED(status);
  1126 	Q_UNUSED(status);
  1166 	qDebug() <<"AgendaEventViewer: AgendaEventView::handleNoteEditorClosed -->";
  1127 
  1167 
  1128 	// To avoid loading the plugin again for editing,
  1168 	// Cleanup.
  1129 	// Unload the plug-in while destruction.
  1169 	mNoteEditor->deleteLater();
  1130 
  1170 	mOwner->editingCompleted();
  1131 	mOwner->editingCompleted();
  1171 
  1132 
  1172 	qDebug() <<"AgendaEventViewer: AgendaEventView::handleNoteEditorClosed <--";
       
  1173 }
  1133 }
  1174 
  1134 
  1175 /*!
  1135 /*!
  1176 	Handles the Note Editor editing completion of the agenda entry
  1136 	Handles the Note Editor editing completion of the agenda entry
  1177  */
  1137  */
  1178 void AgendaEventView::handleCalendarEditorClosed()
  1138 void AgendaEventView::handleCalendarEditorClosed()
  1179 {
  1139 {
  1180 	qDebug() 
       
  1181 		<<"AgendaEventViewer: AgendaEventView::handleCalendarEditorClosed -->";
       
  1182 
  1140 
  1183 	// Cleanup.
  1141 	// Cleanup.
  1184 	mCalenEditor->deleteLater();
  1142 	mCalenEditor->deleteLater();
  1185 	mOwner->editingCompleted();
  1143 	mOwner->editingCompleted();
  1186 
  1144 
  1187 	qDebug() 
       
  1188 		<<"AgendaEventViewer: AgendaEventView::handleCalendarEditorClosed <--";
       
  1189 }
  1145 }
  1190 
  1146 
  1191 /*!
  1147 /*!
  1192 	Slot to handle User selection for series deleting or single occurence popup
  1148 	Slot to handle User selection for series deleting or single occurence popup
  1193  */
  1149  */
  1194 void AgendaEventView::handleDeleteOccurence(int index)
  1150 void AgendaEventView::handleDeleteOccurence(int index)
  1195 {
  1151 {
  1196 	qDebug() << "AgendaEventViewer: AgendaEventView::handleDeleteOccurence -->";
       
  1197 	
  1152 	
  1198 	// To notify client that deleting Started
  1153 	// To notify client that deleting Started
  1199 	// Calendar Application changing state from viewing to deleting.
  1154 	// Calendar Application changing state from viewing to deleting.
  1200 	mOwner->deletingStarted();
  1155 	mOwner->deletingStarted();
  1201 	
  1156 	
  1211 			mOwner->mAgendaUtil->deleteRepeatedEntry(mAgendaEntry,
  1166 			mOwner->mAgendaUtil->deleteRepeatedEntry(mAgendaEntry,
  1212 			                                         AgendaUtil::ThisAndAll);
  1167 			                                         AgendaUtil::ThisAndAll);
  1213 			break;
  1168 			break;
  1214 	}
  1169 	}
  1215 
  1170 
  1216 	qDebug() << "AgendaEventViewer: AgendaEventView::handleDeleteOccurence <--";
  1171 }
       
  1172 
       
  1173 /*!
       
  1174     Returns subject icon
       
  1175  */
       
  1176 void AgendaEventView::getSubjectIcon(AgendaEntry::Type type, QString &subjectIcon)
       
  1177     {
       
  1178     switch(type) {
       
  1179         case AgendaEntry::TypeAppoinment:
       
  1180             {
       
  1181             subjectIcon.append("qtg_small_meeting");
       
  1182             }
       
  1183             break;
       
  1184         case AgendaEntry::TypeTodo:
       
  1185             {
       
  1186             subjectIcon.append("qtg_small_todo");
       
  1187             }
       
  1188             break;
       
  1189         case AgendaEntry::TypeEvent:
       
  1190             {
       
  1191             subjectIcon.append("qtg_small_day");
       
  1192             }
       
  1193             break;
       
  1194         case AgendaEntry::TypeAnniversary:
       
  1195             {
       
  1196             subjectIcon.append("qtg_small_anniversary");
       
  1197             }
       
  1198             break;
       
  1199         default:
       
  1200             break;
       
  1201     }
       
  1202 
       
  1203     }
       
  1204 
       
  1205 /*!
       
  1206     According to maptile fetching status , update the viewer screen.
       
  1207  */
       
  1208 void AgendaEventView::updateProgressIndicator()
       
  1209 {   
       
  1210     if (!mMaptileStatusReceived) {
       
  1211         QString iconName("qtg_anim_small_loading_");
       
  1212         mProgressIconCount = mProgressIconCount % 10 + 1;
       
  1213         iconName.append(QVariant(mProgressIconCount).toString());
       
  1214         QStringList itemData;
       
  1215         itemData.append("qtg_small_location");
       
  1216         itemData.append(iconName);
       
  1217         itemData.append(QString::null);
       
  1218         mLocationWidget->setProperty(primaryLeftIconItem, true);
       
  1219         mLocationWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
       
  1220         mProgressTimer->start(100);
       
  1221     }
       
  1222     else {
       
  1223         if (mProgressTimer->isActive()) {
       
  1224             mProgressTimer->stop();
       
  1225         }
       
  1226         if (mMaptileStatus == MapTileService::MapTileFetchingCompleted) {
       
  1227             QStringList itemData;
       
  1228             itemData.append(QString::null);
       
  1229             itemData.append(QString::null);
       
  1230             itemData.append("qtg_small_location");
       
  1231             mLocationWidget->setProperty(primaryLeftIconItem, false);
       
  1232             mLocationWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
       
  1233             Qt::Orientations orientation=hbInstance->allMainWindows().first()->orientation();
       
  1234             mMaptilePath.clear();
       
  1235             mMaptileStatus = mMaptileService->getMapTileImage(mAgendaEntry.id(), MapTileService::AddressPlain, mMaptilePath ,orientation);
       
  1236             addMapTileImage();
       
  1237             QFile file(mMaptilePath);
       
  1238             if (file.exists()) {
       
  1239                 //add to linear layout  
       
  1240                 int indexMaptileLabel = 3;// index of maptile widget position
       
  1241                 mLinearLayout->insertItem(indexMaptileLabel, mMaptileLabel);
       
  1242                 mMaptileLabel->show();
       
  1243             }
       
  1244             file.close();
       
  1245 
       
  1246         }
       
  1247         else {
       
  1248             QStringList itemData;
       
  1249             itemData.append("qtg_small_location");
       
  1250             QString stopIcon;
       
  1251             stopIcon.append(QString("qtg_mono_search_stop"));
       
  1252             itemData.append(stopIcon);
       
  1253             itemData.append(QString::null);
       
  1254             mLocationWidget->setProperty(primaryLeftIconItem, true);
       
  1255             mLocationWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
       
  1256 
       
  1257         }
       
  1258     }
       
  1259 }
       
  1260 
       
  1261 /*!
       
  1262     Maptile status received from maptile service 
       
  1263  */
       
  1264 void AgendaEventView::receiveMapTileStatus(int entryid,int addressType, int status)
       
  1265 {
       
  1266     if (mAgendaEntry.id() == entryid && addressType == MapTileService::AddressPlain) {
       
  1267         mMaptileStatusReceived = true;
       
  1268         mMaptileStatus = status;
       
  1269         updateProgressIndicator();
       
  1270     }
       
  1271 }
       
  1272 
       
  1273 /*!
       
  1274     Returns progress indication icon as per status of entry in database.
       
  1275  */
       
  1276 void AgendaEventView::getProgressIndicatorstatus(QString &progressIcon)
       
  1277 {
       
  1278     MapTileService::AddressType addressType;
       
  1279     addressType = MapTileService::AddressPlain;
       
  1280     int eventId = mAgendaEntry.id();
       
  1281     mMaptilePath.clear();
       
  1282     mMaptileStatus = -1;
       
  1283     connect(mMaptileService, SIGNAL(maptileFetchingStatusUpdate(int,
       
  1284             int ,int)), this, SLOT(receiveMapTileStatus(int,int,int)));
       
  1285     Qt::Orientations orientation=hbInstance->allMainWindows().first()->orientation();
       
  1286     mMaptileStatus = mMaptileService->getMapTileImage(eventId, addressType, mMaptilePath ,orientation);    
       
  1287     if (mMaptileStatus == MapTileService::MapTileFetchingNetworkError || mMaptileStatus
       
  1288         == MapTileService::MapTileFetchingInProgress) {
       
  1289         mMaptilePath.clear();
       
  1290         mMaptileStatusReceived = false; //reseting receiving status value       
       
  1291         progressIcon.append(QString("qtg_anim_small_loading_1"));
       
  1292         mProgressTimer->start(100);
       
  1293     }
       
  1294     else if (mMaptileStatus == MapTileService::MapTileFetchingInvalidAddress || mMaptileStatus
       
  1295         == MapTileService::MapTileFetchingUnknownError) {
       
  1296         mMaptilePath.clear();
       
  1297         //no further need of this coonnection 
       
  1298         disconnect(mMaptileService, SIGNAL(maptileFetchingStatusUpdate(int,
       
  1299                 int ,int)), this, SLOT(receiveMapTileStatus(int,int,int)));
       
  1300         progressIcon.append(QString("qtg_mono_search_stop"));
       
  1301     }
       
  1302     else {
       
  1303         //no further need of this coonnection
       
  1304         disconnect(mMaptileService, SIGNAL(maptileFetchingStatusUpdate(int,
       
  1305                 int ,int)), this, SLOT(receiveMapTileStatus(int,int,int)));
       
  1306         progressIcon.append(QString::null);
       
  1307     }
       
  1308 }
       
  1309 /*!
       
  1310     Reload the maptile image on system orientation change.
       
  1311  */
       
  1312 void AgendaEventView::changedOrientation(Qt::Orientation orientation)
       
  1313 {
       
  1314     if (mMaptileStatus == MapTileService::MapTileFetchingCompleted) {
       
  1315         mMaptilePath.clear();
       
  1316         mMaptileService->getMapTileImage(mAgendaEntry.id(), MapTileService::AddressPlain, mMaptilePath,orientation);
       
  1317         addMapTileImage();
       
  1318     }
  1217 }
  1319 }
  1218 
  1320 
  1219 // End of file
  1321 // End of file