calendarui/agendaeventviewer/src/agendaeventview.cpp
changeset 18 c198609911f9
child 23 fd30d51f876b
equal deleted inserted replaced
0:f979ecb2b13e 18:c198609911f9
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 // System includes
       
    19 #include <QObject>
       
    20 #include <QDebug>
       
    21 #include <QDateTime>
       
    22 #include <qtranslator.h>
       
    23 #include <QGraphicsLinearLayout>
       
    24 #include <HbInstance>
       
    25 #include <hbapplication.h>
       
    26 #include <HbMainWindow>
       
    27 #include <HbView>
       
    28 #include <HbMenu>
       
    29 #include <HbGroupBox>
       
    30 #include <HbScrollArea>
       
    31 #include <HbIcon>
       
    32 #include <HbAction>
       
    33 #include <HbExtendedLocale>
       
    34 #include <HbToolBar>
       
    35 #include <hbi18ndef.h>
       
    36 #include <HbRadioButtonList>
       
    37 #include <HbMessageBox>
       
    38 #include <HbDialog>
       
    39 #include <HbLabel>
       
    40 
       
    41 // User includes
       
    42 #include <agendautil.h>
       
    43 #include <noteseditor.h>
       
    44 #include <caleneditor.h>
       
    45 #include "agendaeventview.h"
       
    46 #include "agendaeventviewerdocloader.h"
       
    47 #include "agendaeventviewercommon.h"
       
    48 #include "agendaeventviewer_p.h"
       
    49 #include "agendaeventvieweritem.h"
       
    50 #include "calendateutils.h"
       
    51 
       
    52 // Constants
       
    53 #define CHARACTER_HYPHEN    "-"
       
    54 #define CHARACTER_SPACE     " "
       
    55 #define CHARACTER_NEW_LINE  "\n"
       
    56 /*!
       
    57 	\class AgendaEventView.
       
    58 
       
    59 	Responsible for viewing viewing agenda entries. This is friend of
       
    60 	AgendaEventViewerPrivate and it handles all the cases
       
    61 	related to agenda entry viewing.
       
    62  */
       
    63 
       
    64 /*!
       
    65 	Default constructor.
       
    66 
       
    67 	\param owner pointer to AgendaEventViewerPrivate.
       
    68 	\param parent pointer to QGraphicsWidget.
       
    69  */
       
    70 AgendaEventView::AgendaEventView(
       
    71 		AgendaEventViewerPrivate *owner, QObject *parent):
       
    72 		QObject(parent),
       
    73 		mOwner(owner),
       
    74 		mReminderWidgetAdded(true),
       
    75 		mMainWindow(NULL)
       
    76 {
       
    77 	qDebug() << "AgendaEventViewer: AgendaEventView::AgendaEventView -->";
       
    78 
       
    79 	// Load the translator based on locale
       
    80 	mTranslator = new QTranslator;
       
    81 	QString lang = QLocale::system().name();
       
    82 	QString path = "Z:/resource/qt/translations/";
       
    83 	mTranslator->load("caleneventviewer_en_GB",":/translations");
       
    84 	// TODO: Load the appropriate .qm file based on locale
       
    85 	//bool loaded = mTranslator->load("caleneventviewer_" + lang, path);
       
    86 	HbApplication::instance()->installTranslator(mTranslator);
       
    87 	
       
    88 	mDocLoader = new AgendaEventViewerDocLoader;
       
    89 
       
    90 	// Load to-do viewer's docml.
       
    91 	bool loadSuccess;
       
    92 	mDocLoader->load(AGENDA_EVENT_VIEWER_DOCML, &loadSuccess);
       
    93 	if (!loadSuccess) {
       
    94 		    qFatal("agendaeventview.cpp : Unable to load XML");
       
    95 	}
       
    96 	// Load the to-viewer's view.
       
    97 	mViewer = qobject_cast<HbView *> (mDocLoader->findWidget(
       
    98 			AGENDA_EVENT_VIEWER_VIEW_OBJECT));
       
    99 
       
   100 	// Load all the widgets.
       
   101 	mSubjectWidget = qobject_cast<AgendaEventViewerItem *> (
       
   102 			mDocLoader->findWidget(AGENDA_EVENT_VIEWER_SUBJECT_WIDGET));
       
   103 
       
   104 	mDateTimeWidget = qobject_cast<AgendaEventViewerItem *> (
       
   105 			mDocLoader->findWidget(AGENDA_EVENT_VIEWER_DATE_TIME_WIDGET));
       
   106 
       
   107 	mLocationWidget = qobject_cast<AgendaEventViewerItem *> (
       
   108 			mDocLoader->findWidget(AGENDA_EVENT_VIEWER_LOCATION_WIDGET));
       
   109 	
       
   110 	mReminderWidget = qobject_cast<AgendaEventViewerItem *> (
       
   111 			mDocLoader->findWidget(AGENDA_EVENT_VIEWER_REMINDER_WIDGET));
       
   112 	
       
   113 	mRepeatWidget = qobject_cast<AgendaEventViewerItem *> (
       
   114 			mDocLoader->findWidget(AGENDA_EVENT_VIEWER_REPEAT_WIDGET));
       
   115 	
       
   116 	mDescriptionWidget = qobject_cast<AgendaEventViewerItem *> (
       
   117 			mDocLoader->findWidget(AGENDA_EVENT_VIEWER_DESCRIPTION_WIDGET));
       
   118 
       
   119     HbWidget *scrollAreaWidget = qobject_cast<HbWidget *>(
       
   120                mDocLoader->findWidget(AGENDA_EVENT_VIEWER_SCROLLAREA_CONTENTS));
       
   121 
       
   122     mLinearLayout = 
       
   123     		static_cast<QGraphicsLinearLayout *> (scrollAreaWidget->layout());
       
   124 
       
   125 	qDebug() << "AgendaEventViewer: AgendaEventView::AgendaEventView <--";
       
   126 	
       
   127 }
       
   128 
       
   129 /*!
       
   130 	Destructor.
       
   131  */
       
   132 AgendaEventView::~AgendaEventView()
       
   133 {
       
   134 	qDebug() << "AgendaEventViewer: AgendaEventView::~AgendaEventView -->";
       
   135 
       
   136 	// Remove the translator
       
   137 	HbApplication::instance()->removeTranslator(mTranslator);
       
   138 	if (mTranslator) {
       
   139 		delete mTranslator;
       
   140 		mTranslator = 0;
       
   141 	}
       
   142 	
       
   143 	mDocLoader->reset();
       
   144 	delete mDocLoader;
       
   145 	
       
   146 	// Delete the mainwindow if we have created any
       
   147 	if (mMainWindow) {
       
   148 		delete mMainWindow;
       
   149 		mMainWindow = NULL;
       
   150 	}
       
   151 	
       
   152 	qDebug() << "AgendaEventViewer: AgendaEventView::~AgendaEventView <--";
       
   153 }
       
   154 
       
   155 /*!
       
   156 	Displays the to-do viewer and populates the to-do entry attributes.
       
   157 
       
   158 	\param entry Agenda entry from which attributes have to be read.
       
   159  */
       
   160 void AgendaEventView::execute(AgendaEntry entry,
       
   161 											AgendaEventViewer::Actions action)
       
   162 {
       
   163 	qDebug() << "AgendaEventViewer: AgendaEventView::execute -->";
       
   164 
       
   165 	mOriginalAgendaEntry = entry;
       
   166 	mAgendaEntry = entry;
       
   167 
       
   168 	// Add the viewer data reading from the agenda entry.
       
   169 	addViewerData();
       
   170 	
       
   171 	// Remove unnecessary widget from event viewer.
       
   172 	removeWidget();
       
   173 	
       
   174 	// Add the menu items to event viewer.
       
   175 	addMenuItem();
       
   176 	
       
   177 	// Add the toolbar items to event viewer
       
   178 	addToolBarItem(action);
       
   179 	
       
   180 	// Add the title to event viewer.
       
   181 	addGroupBoxData();
       
   182 
       
   183 	// Connect for the entry updation and addtion signal to refresh the view
       
   184 	// when the same is edited in editor.
       
   185 	connect(mOwner->mAgendaUtil, SIGNAL(entryUpdated(ulong)),
       
   186 				this, SLOT(handleEntryUpdation(ulong)));
       
   187 	
       
   188 	connect(mOwner->mAgendaUtil, SIGNAL(entryAdded(ulong)),
       
   189 				this, SLOT(handleEntryUpdation(ulong)));
       
   190 
       
   191 	// Connect for entry deletion signal to close the event viewer.
       
   192 	connect(mOwner->mAgendaUtil, SIGNAL(entryDeleted(ulong)), this,
       
   193 	        SLOT(handleEntryDeletion(ulong)));
       
   194 
       
   195 	// Add the view to the main window.
       
   196 	HbMainWindow *window = hbInstance->allMainWindows().first();
       
   197 	if (!window) {
       
   198 		// Might be some non-ui based app called us
       
   199 		// so create mainwindow now
       
   200 		mMainWindow = new HbMainWindow();
       
   201 		mMainWindow->addView(mViewer);
       
   202 		mMainWindow->setCurrentView(mViewer);
       
   203 	} else {
       
   204 		window->addView(mViewer);
       
   205 		window->setCurrentView(mViewer);
       
   206 	}
       
   207 	
       
   208 	// Add softkey after adding view on window
       
   209 	mBackAction = new HbAction(Hb::BackAction);
       
   210 	mViewer->setNavigationAction(mBackAction);
       
   211 		
       
   212 	connect(mBackAction, SIGNAL(triggered()), this, SLOT(close()));
       
   213 
       
   214 	qDebug() << "AgendaEventViewer: AgendaEventView::execute <--";
       
   215 }
       
   216 
       
   217 /*!
       
   218 	Refreshes the to-do viewer after the to-do editor is closed.
       
   219  */
       
   220 void AgendaEventView::addViewerData()
       
   221 {
       
   222 	qDebug() << "AgendaEventViewer: AgendaEventView::addViewerData -->";
       
   223 
       
   224 	// Set the summary & priority to viewer.
       
   225 	addSubjectAndPriorityData();
       
   226 	
       
   227 	// Set Date & Time to viewer.
       
   228 	addDateTimeData();
       
   229 	
       
   230 	// Add agenda entry specific fields to the viewer
       
   231 	switch (mAgendaEntry.type()) {
       
   232 		case AgendaEntry::TypeAppoinment:
       
   233 		case AgendaEntry::TypeEvent:
       
   234 			addLocationData();
       
   235 			addReminderData();
       
   236 			addRepeatData();
       
   237 			break;
       
   238 		case AgendaEntry::TypeAnniversary:
       
   239 			break;
       
   240 		case AgendaEntry::TypeTodo:
       
   241 			if (AgendaEntry::TodoCompleted == mAgendaEntry.status()) { 
       
   242 				addCompletedTodoData();
       
   243 			} else {
       
   244 				addReminderData();
       
   245 			}
       
   246 			break;
       
   247 		default:
       
   248 			break;
       
   249 	}
       
   250 
       
   251 	// Set the description.
       
   252 	addDescriptionData();
       
   253 	
       
   254 	qDebug() << "AgendaEventViewer: AgendaEventView::addViewerData <--";
       
   255 }
       
   256 
       
   257 /*!
       
   258 	Add the menu item depends up on entry type
       
   259  */
       
   260 void AgendaEventView::addMenuItem()
       
   261 {
       
   262 	qDebug() << "AgendaEventViewer: AgendaEventView::addMenuItem -->";
       
   263 
       
   264 	if (mAgendaEntry.type() == AgendaEntry::TypeTodo) {
       
   265 
       
   266 		HbMenu *menu = qobject_cast<HbMenu *> (
       
   267 				mDocLoader->findWidget(AGENDA_EVENT_VIEWER_MENU));
       
   268 		
       
   269 		mMarkTodoAction = new HbAction(this);
       
   270 		if (mAgendaEntry.status() == AgendaEntry::TodoCompleted) {
       
   271 			mMarkTodoAction->setText(
       
   272 								hbTrId("txt_calendar_menu_mark_as_not_done"));
       
   273 		} else {
       
   274 			mMarkTodoAction->setText(hbTrId("txt_calendar_menu_mark_as_done"));
       
   275 		}
       
   276 		connect(mMarkTodoAction, SIGNAL(triggered()), this,
       
   277 		        SLOT(markTodoStatus()));
       
   278 		menu->addAction(mMarkTodoAction);
       
   279 	}
       
   280 	qDebug() << "AgendaEventViewer: AgendaEventView::addMenuItem <--";
       
   281 }
       
   282 
       
   283 /*!
       
   284 	Add the toolbar item
       
   285  */
       
   286 void AgendaEventView::addToolBarItem(AgendaEventViewer::Actions action)
       
   287 {
       
   288 	qDebug() << "AgendaEventViewer: AgendaEventView::addToolBarItem -->";
       
   289 
       
   290 	HbToolBar *toolBar = qobject_cast<HbToolBar *> (
       
   291 	                       mDocLoader->findWidget(AGENDA_EVENT_VIEWER_TOOLBAR));
       
   292 
       
   293 	// Load all the actions for event viewer
       
   294 	
       
   295 	if ((action == AgendaEventViewer::ActionEditDelete) || (action
       
   296 	        == AgendaEventViewer::ActionEdit)) {
       
   297 		HbAction *editAction = new HbAction(HbIcon("qtg_mono_edit"), 
       
   298 		                                  hbTrId("txt_calendar_button_edit"));
       
   299 		connect(editAction, SIGNAL(triggered()), this, SLOT(edit()));
       
   300 		toolBar->addAction(editAction);
       
   301 	}
       
   302 
       
   303 	if ((action == AgendaEventViewer::ActionEditDelete) || (action
       
   304 	        == AgendaEventViewer::ActionDelete)) {
       
   305 		HbAction *deleteAction = new HbAction(HbIcon("qtg_mono_delete"), 
       
   306 		                                  hbTrId("txt_calendar_button_delete"));
       
   307 		connect(deleteAction, SIGNAL(triggered()), this,
       
   308 		        SLOT(deleteAgendaEntry()));
       
   309 		toolBar->addAction(deleteAction);
       
   310 	}
       
   311 
       
   312 	if (action == AgendaEventViewer::ActionSave) {
       
   313 		HbAction *saveAction = new HbAction(
       
   314 							hbTrId("txt_calendar_button_save_to_calendar"));
       
   315 		connect(saveAction, SIGNAL(triggered()), this, SLOT(saveAgendaEntry()));
       
   316 		toolBar->addAction(saveAction);
       
   317 	}
       
   318 
       
   319 	qDebug() << "AgendaEventViewer: AgendaEventView::addToolBarItem <--";
       
   320 }
       
   321 
       
   322 /*!
       
   323 	Add the groupbox data depends up on entry type
       
   324  */
       
   325 void AgendaEventView::addGroupBoxData()
       
   326 {
       
   327 	qDebug() << "AgendaEventViewer: AgendaEventView::addGroupBoxData -->";
       
   328 	
       
   329 	HbGroupBox *groupBox = qobject_cast<HbGroupBox *> (
       
   330 			mDocLoader->findWidget(AGENDA_EVENT_VIEWER_GROUPBOX));
       
   331 
       
   332 	if (mAgendaEntry.type() == AgendaEntry::TypeTodo) {
       
   333 		groupBox->setHeading(hbTrId("txt_calendar_subhead_to_do"));
       
   334 	} else if (mAgendaEntry.type() == AgendaEntry::TypeNote) {
       
   335 		groupBox->setHeading(tr("Note"));
       
   336 	} else {
       
   337 		// TODO: Add the text id based on the entry type Anniversary or meeting
       
   338 		groupBox->setHeading(hbTrId("txt_calendar_subhead_event"));
       
   339 	}
       
   340 
       
   341 	qDebug() << "AgendaEventViewer: AgendaEventView::addGroupBoxData <--";
       
   342 }
       
   343 
       
   344 /*!
       
   345 	Add subject and priority data to Event viewer
       
   346  */
       
   347 void AgendaEventView::addSubjectAndPriorityData()
       
   348 {
       
   349 	qDebug()
       
   350 	     << "AgendaEventViewer: AgendaEventView::addSubjectAndPriorityData -->";
       
   351 
       
   352 	QStringList itemList;
       
   353 	itemList.append(hbTrId("txt_calendar_dblist_subject"));
       
   354 	if (mAgendaEntry.summary().isEmpty()) {
       
   355 		itemList.append(hbTrId("txt_calendar_dblist_val_unnamed"));
       
   356 	} else {
       
   357 		itemList.append(mAgendaEntry.summary());
       
   358 	}
       
   359 
       
   360 
       
   361 	mSubjectWidget->setEventViewerItemData(itemList, Qt::DisplayRole);
       
   362 
       
   363 	itemList.clear();
       
   364 	QString priorityIcon(QString::null);
       
   365 	getPriorityIcon(mAgendaEntry.priority(), priorityIcon);
       
   366 	itemList.append(priorityIcon);
       
   367 	itemList.append(QString::null);
       
   368 
       
   369 	mSubjectWidget->setEventViewerItemData(itemList, Qt::DecorationRole);
       
   370 
       
   371 	qDebug()
       
   372 	     << "AgendaEventViewer: AgendaEventView::addSubjectAndPriorityData <--";
       
   373 }
       
   374 
       
   375 /*!
       
   376 	Add date & time data to Event viewer
       
   377  */
       
   378 void AgendaEventView::addDateTimeData()
       
   379 {
       
   380     qDebug()
       
   381          << "AgendaEventViewer: AgendaEventView::addDateTimeData -->";
       
   382     
       
   383     
       
   384     QStringList itemData;
       
   385     HbExtendedLocale systemLocale = HbExtendedLocale::system();
       
   386     QDateTime startDateTime = mAgendaEntry.startTime();
       
   387     QDateTime endDateTime = mAgendaEntry.endTime();
       
   388     
       
   389     itemData.append(QString::null);
       
   390     itemData.append("qtg_small_calendar");
       
   391     mDateTimeWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
       
   392     itemData.clear();
       
   393     itemData.append(QString::null);
       
   394     
       
   395     QString startTimeText;
       
   396     QString endTimeText;
       
   397     QString startDateText;
       
   398     QString dateTimeText;
       
   399     QString data;
       
   400     
       
   401     // Add agenda entry specific fields to the viewer
       
   402     switch (mAgendaEntry.type()) {
       
   403     	case AgendaEntry::TypeAppoinment:
       
   404 
       
   405     		startTimeText.append(systemLocale.format(
       
   406 							startDateTime.time(), r_qtn_time_usual_with_zero));
       
   407 
       
   408     		endTimeText.append(systemLocale.format(endDateTime.time(),
       
   409 												r_qtn_time_usual_with_zero));
       
   410     		startDateText.append(
       
   411     				systemLocale.format(startDateTime.date(),
       
   412 												r_qtn_date_usual_with_zero));
       
   413     		if (CalenDateUtils::onSameDay(startDateTime, endDateTime)) {
       
   414     			data.append(hbTrId("txt_calendar_dblist_start_end_time").arg(
       
   415 											startTimeText).arg(endTimeText));
       
   416     			data.append(CHARACTER_SPACE);
       
   417     			data.append(hbTrId("txt_calendar_dblist_meeting_date").arg(
       
   418 											startDateText));
       
   419     		} else {
       
   420     			data.append(hbTrId("txt_calendar_dblist_start_time_date").arg(
       
   421 											startTimeText).arg(startDateText));
       
   422     			QString endDateText;
       
   423     			endDateText.append(
       
   424     					systemLocale.format(endDateTime.date(),
       
   425 												r_qtn_date_usual_with_zero));
       
   426     			data.append(hbTrId("txt_calendar_dblist_end_time_date").arg(
       
   427 											endTimeText).arg(endDateText));
       
   428     		}
       
   429     		break;
       
   430     	case AgendaEntry::TypeAnniversary:
       
   431     	case AgendaEntry::TypeTodo:
       
   432     		dateTimeText.append(systemLocale.format(endDateTime.date(),
       
   433 												r_qtn_date_usual_with_zero));
       
   434     		data.append(hbTrId(
       
   435 						"txt_calendar_dblist_meeting_date").arg(dateTimeText));
       
   436     		break;
       
   437     	case AgendaEntry::TypeEvent:
       
   438 
       
   439     		dateTimeText.append(systemLocale.format(startDateTime.date(),
       
   440 												r_qtn_date_usual_with_zero));
       
   441 
       
   442     		if (CalenDateUtils::onSameDay(startDateTime, endDateTime)) {
       
   443     			data.append(hbTrId("txt_calendar_dblist_meeting_date").arg(
       
   444 											dateTimeText));
       
   445     		} else {
       
   446     			QString endDate;
       
   447     			endDate.append(
       
   448     					systemLocale.format(endDateTime.date(),
       
   449 												r_qtn_date_usual_with_zero));
       
   450     			data.append(hbTrId("txt_calendar_dblist_start_end_time").arg(
       
   451 											dateTimeText).arg(endDate));
       
   452     		}
       
   453     		break;
       
   454     	default:
       
   455     		break;
       
   456     }
       
   457 	itemData.append(data);
       
   458     mDateTimeWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
       
   459     
       
   460     qDebug()
       
   461          << "AgendaEventViewer: AgendaEventView::addDateTimeData <--";
       
   462 }
       
   463 
       
   464 /*!
       
   465 	Add location data to Event viewer
       
   466  */
       
   467 void AgendaEventView::addLocationData()
       
   468 {
       
   469 	qDebug() << "AgendaEventViewer: AgendaEventView::addLocationData -->";
       
   470 	QStringList itemData;
       
   471 	itemData.append(QString::null);
       
   472 	itemData.append("qtg_small_location");
       
   473 	mLocationWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
       
   474 	itemData.clear();
       
   475 	itemData.append(QString::null);
       
   476 	itemData.append(mAgendaEntry.location());
       
   477 	mLocationWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
       
   478 	qDebug() << "AgendaEventViewer: AgendaEventView::addLocationData <--";
       
   479 }
       
   480 
       
   481 /*!
       
   482 	Add reminder data to Event viewer
       
   483  */
       
   484 void AgendaEventView::addReminderData()
       
   485 {
       
   486 	qDebug() << "AgendaEventViewer: AgendaEventView::addReminderData -->";
       
   487 	QStringList itemData;
       
   488 	itemData.append(QString::null);
       
   489 	itemData.append("qtg_small_reminder");
       
   490 	mReminderWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
       
   491 	itemData.clear();
       
   492 	itemData.append(QString::null);
       
   493 	itemData.append(alarmTimeText());
       
   494 	mReminderWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
       
   495 	qDebug() << "AgendaEventViewer: AgendaEventView::addReminderData <--";
       
   496 }
       
   497 
       
   498 /*!
       
   499 	Add completed to-do data to Event viewer
       
   500  */
       
   501 void AgendaEventView::addCompletedTodoData()
       
   502 {
       
   503 	qDebug() << "AgendaEventViewer: AgendaEventView::addCompletedTodoData -->";
       
   504 	QStringList itemData;
       
   505 	QString     completedText;
       
   506 	HbExtendedLocale systemLocale = HbExtendedLocale::system();;
       
   507 	
       
   508 	itemData.append(QString::null);
       
   509 	itemData.append(QString::null);
       
   510 	mReminderWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
       
   511 	itemData.clear();
       
   512 	completedText = systemLocale.format(mAgendaEntry.completedDateTime().date(),
       
   513 					                    r_qtn_date_usual_with_zero);
       
   514 	itemData.append(hbTrId("txt_calendar_dblist_completed_date"));
       
   515 	itemData.append(completedText);
       
   516 	mReminderWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
       
   517 	qDebug() << "AgendaEventViewer: AgendaEventView::addCompletedTodoData <--";
       
   518 }
       
   519 
       
   520 /*!
       
   521 	Add repeat data to Event viewer
       
   522  */
       
   523 void AgendaEventView::addRepeatData()
       
   524 {
       
   525 	qDebug() << "AgendaEventViewer: AgendaEventView::addRepeatData -->";
       
   526 	QStringList itemData;
       
   527 	itemData.append(QString::null);
       
   528 	itemData.append("qtg_mono_repeat.svg");
       
   529 	mRepeatWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
       
   530 	itemData.clear();
       
   531 	itemData.append(QString::null);
       
   532 	itemData.append(repeatRule());
       
   533 	mRepeatWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
       
   534 	qDebug() << "AgendaEventViewer: AgendaEventView::addRepeatData <--";
       
   535 }
       
   536 
       
   537 /*!
       
   538 	Add description data to Event viewer
       
   539  */
       
   540 void AgendaEventView::addDescriptionData()
       
   541 {
       
   542 	qDebug() << "AgendaEventViewer: AgendaEventView::addDiscriptionData -->";
       
   543 	QStringList itemData;
       
   544 	itemData.append(QString::null);
       
   545 	itemData.append(QString::null);
       
   546 	mDescriptionWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
       
   547 	itemData.clear();
       
   548 	itemData.append(hbTrId("txt_calendar_dblist_description"));
       
   549 	itemData.append(mAgendaEntry.description());
       
   550 	mDescriptionWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
       
   551 	qDebug() << "AgendaEventViewer: AgendaEventView::addDiscriptionData <--";
       
   552 }
       
   553 
       
   554 /*!
       
   555 	Returns priority icon
       
   556  */
       
   557 void AgendaEventView::getPriorityIcon(int priority, QString &priorityIcon)
       
   558 {
       
   559 	qDebug() << "AgendaEventViewer: AgendaEventView::getPriorityIcon -->";
       
   560 
       
   561 	switch(priority) {
       
   562 		case 1:priorityIcon.append("qtg_small_priority_high");
       
   563 		break;
       
   564 		case 3:priorityIcon.append("qtg_small_priority_low");
       
   565 		break;
       
   566 		default:
       
   567 		break;
       
   568 	}
       
   569 
       
   570 	qDebug() << "AgendaEventViewer: AgendaEventView::getPriorityIcon <--";
       
   571 }
       
   572 
       
   573 /*!
       
   574 	Returns repeat rule
       
   575  */
       
   576 QString AgendaEventView::repeatRule() const
       
   577 {
       
   578 	qDebug() << "AgendaEventViewer: AgendaEventView::repeatRule -->";
       
   579 	
       
   580 	QString repeatRule;
       
   581 	if (mAgendaEntry.repeatRule().type() != AgendaRepeatRule::InvalidRule)
       
   582 	{
       
   583 		switch (mAgendaEntry.repeatRule().type()) {
       
   584 			case AgendaRepeatRule::DailyRule:
       
   585 				repeatRule.append(hbTrId("txt_calendar_dblist_repeats_daily"));
       
   586 			break;
       
   587 			case AgendaRepeatRule::WeeklyRule:
       
   588 				if (mAgendaEntry.repeatRule().interval() == 2) {
       
   589 					repeatRule.append(
       
   590 							hbTrId("txt_calendar_dblist_repeats_fortnightly"));
       
   591 				} else {
       
   592 					repeatRule.append(
       
   593 							hbTrId("txt_calendar_dblist_repeats_weekly"));
       
   594 				}
       
   595 			break;
       
   596 			case AgendaRepeatRule::MonthlyRule:
       
   597 				repeatRule.append(
       
   598 						hbTrId("txt_calendar_dblist_repeats_monthly"));
       
   599 			break;
       
   600 			case AgendaRepeatRule::YearlyRule:
       
   601 				repeatRule.append(
       
   602 						hbTrId("txt_calendar_dblist_repeats_yearly"));
       
   603 			break;
       
   604 			default:
       
   605 			break;
       
   606 		}
       
   607 		repeatRule.append(CHARACTER_NEW_LINE);
       
   608 		HbExtendedLocale systemLocale = HbExtendedLocale::system();
       
   609 		QString untilDateString = systemLocale.format(
       
   610 				mAgendaEntry.repeatRule().until(), r_qtn_date_usual_with_zero);
       
   611 		repeatRule.append(
       
   612 			hbTrId("txt_calendar_dblist_repeats_daily_val_until_1").
       
   613 			arg(untilDateString));
       
   614 	}
       
   615 	qDebug() << "AgendaEventViewer: AgendaEventView::repeatRule <--";
       
   616 	
       
   617 	return repeatRule;
       
   618 }
       
   619 
       
   620 /*!
       
   621 	Alarm time text to display in the viewer.
       
   622 
       
   623 	\return QString	Holds the alarm time text.
       
   624  */
       
   625 QString AgendaEventView::alarmTimeText() const
       
   626 {
       
   627 	qDebug() << "AgendaEventViewer: AgendaEventView::alarmTimeText -->";
       
   628 
       
   629 	QString alarmDateTimeText;
       
   630 	QDateTime startTime;
       
   631 	QDateTime alarmDateTime;
       
   632 	
       
   633 	if (mAgendaEntry.type() == AgendaEntry::TypeTodo) { 
       
   634 		startTime = mAgendaEntry.endTime();
       
   635 	} else { 
       
   636 		startTime = mAgendaEntry.startTime();
       
   637 	}
       
   638 	if (!mAgendaEntry.alarm().isNull()) { 
       
   639 		
       
   640 		int alarmTimeOffsetInMinutes = mAgendaEntry.alarm().timeOffset();
       
   641 		alarmDateTime = startTime.addSecs(-alarmTimeOffsetInMinutes * 60);
       
   642 
       
   643 		HbExtendedLocale systemLocale = HbExtendedLocale::system();
       
   644 		alarmDateTimeText.append(
       
   645 						hbTrId("txt_calendar_list_reminder_time_date").arg(
       
   646 						systemLocale.format(alarmDateTime.time(),
       
   647 						r_qtn_time_usual_with_zero)).arg(
       
   648 						systemLocale.format(alarmDateTime.date(),
       
   649 						r_qtn_date_usual_with_zero)));
       
   650 	}
       
   651 	
       
   652 	qDebug() << "AgendaEventViewer: AgendaEventView::alarmTimeText <--";
       
   653 	return alarmDateTimeText;
       
   654 }
       
   655 
       
   656 /*!
       
   657 	Remove unnecessary widget from layout.
       
   658  */
       
   659 void AgendaEventView::removeWidget()
       
   660 {
       
   661 	qDebug() << "AgendaEventViewer: AgendaEventView::removeWidget -->";
       
   662 	
       
   663 	if (mAgendaEntry.location().isEmpty()) { 
       
   664 		mLocationWidget->hide();
       
   665 		mLinearLayout->removeItem(mLocationWidget);
       
   666 	}
       
   667 	
       
   668 	if (mAgendaEntry.alarm().isNull()) { 
       
   669 		if (mAgendaEntry.type() == AgendaEntry::TypeTodo ) {
       
   670 				if (AgendaEntry::TodoNeedsAction == mAgendaEntry.status()) { 
       
   671 					mReminderWidget->hide();
       
   672 					mLinearLayout->removeItem(mReminderWidget);
       
   673 					mReminderWidgetAdded = false;
       
   674 				}
       
   675 		} else { 
       
   676 			mReminderWidget->hide();
       
   677 			mLinearLayout->removeItem(mReminderWidget);
       
   678 			mReminderWidgetAdded = false;
       
   679 		}
       
   680 	}
       
   681 	
       
   682 	if (mAgendaEntry.repeatRule().type() == AgendaRepeatRule::InvalidRule) { 
       
   683 		mRepeatWidget->hide();
       
   684 		mLinearLayout->removeItem(mRepeatWidget);
       
   685 	}
       
   686 	
       
   687 	if (mAgendaEntry.description().isEmpty()) { 
       
   688 		mDescriptionWidget->hide();
       
   689 		mLinearLayout->removeItem(mDescriptionWidget);
       
   690 	}
       
   691 	
       
   692 	mLinearLayout->invalidate();
       
   693 	mLinearLayout->activate();
       
   694 	
       
   695 	qDebug() << "AgendaEventViewer: AgendaEventView::removeWidget <--";
       
   696 }
       
   697 
       
   698 /*!
       
   699 	Update the completed to-do or reminder data to event viewer.
       
   700  */
       
   701 void AgendaEventView::updateCompletedReminderData()
       
   702 {
       
   703 	qDebug()
       
   704 	   << "AgendaEventViewer: AgendaEventView::updateCompletedReminderData -->";
       
   705 
       
   706 	if (AgendaEntry::TodoCompleted == mAgendaEntry.status()) {
       
   707 		addCompletedTodoData();
       
   708 		if (!mReminderWidgetAdded) {
       
   709 			mReminderWidget->show();
       
   710 			mLinearLayout->insertItem(2, mReminderWidget);
       
   711 			mReminderWidgetAdded = true;
       
   712 		}
       
   713 
       
   714 	} else {
       
   715 		if (!mAgendaEntry.alarm().isNull()) {
       
   716 			addReminderData();
       
   717 			if (!mReminderWidgetAdded) {
       
   718 				mReminderWidget->show();
       
   719 				mLinearLayout->insertItem(2, mReminderWidget);
       
   720 				mReminderWidgetAdded = true;
       
   721 			}
       
   722 		} else {
       
   723 			if (mReminderWidgetAdded) {
       
   724 				mReminderWidget->hide();
       
   725 				mLinearLayout->removeItem(mReminderWidget);
       
   726 				mReminderWidgetAdded = false;
       
   727 			}
       
   728 		}
       
   729 
       
   730 	}
       
   731 	
       
   732 	mLinearLayout->invalidate();
       
   733 	mLinearLayout->activate();
       
   734 	qDebug()
       
   735 	   << "AgendaEventViewer: AgendaEventView::updateCompletedReminderData <--";
       
   736 }
       
   737 
       
   738 /*!
       
   739 	Remove all widgets from layout.
       
   740  */
       
   741 void AgendaEventView::removeAllWidgets()
       
   742 {
       
   743 	qDebug() << "AgendaEventViewer: AgendaEventView::removeAllWidgets -->";
       
   744 
       
   745 	for (int i = 2; i < mLinearLayout->count(); i++) {
       
   746 		mLinearLayout->removeAt(i);
       
   747 	}
       
   748 	mLinearLayout->invalidate();
       
   749 	mLinearLayout->activate();
       
   750 	
       
   751 	qDebug() << "AgendaEventViewer: AgendaEventView::removeAllWidgets <--";
       
   752 }
       
   753 
       
   754 /*!
       
   755 	Add all widgets to layout.
       
   756  */
       
   757 void AgendaEventView::addAllWidgets()
       
   758 {
       
   759 	qDebug() << "AgendaEventViewer: AgendaEventView::addAllWidgets -->";
       
   760 	
       
   761 	mLinearLayout->addItem(mLocationWidget);
       
   762 	mLocationWidget->show();
       
   763 	mLinearLayout->addItem(mReminderWidget);
       
   764 	mReminderWidget->show();
       
   765 	mLinearLayout->addItem(mRepeatWidget);
       
   766 	mRepeatWidget->show();
       
   767 	mLinearLayout->addItem(mDescriptionWidget);
       
   768 	mDescriptionWidget->show();
       
   769 	
       
   770 	mLinearLayout->invalidate();
       
   771 	mLinearLayout->activate();
       
   772 	
       
   773 	qDebug() << "AgendaEventViewer: AgendaEventView::addAllWidgets <--";
       
   774 }
       
   775 
       
   776 /*!
       
   777 	Queries user whether to delete whole series or just this single occurence
       
   778  */
       
   779 void AgendaEventView::showDeleteOccurencePopup()
       
   780 {
       
   781 	qDebug()
       
   782 	      << "AgendaEventViewer: AgendaEventView::showDeleteOccurencePopup -->";
       
   783 	HbDialog popUp;
       
   784 	popUp.setDismissPolicy(HbDialog::NoDismiss);
       
   785 	popUp.setTimeout(HbDialog::NoTimeout);
       
   786 
       
   787 	QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
       
   788 	HbWidget *deleteWidget = new HbWidget(mViewer);
       
   789 	deleteWidget->setLayout(layout);
       
   790 
       
   791 	HbRadioButtonList *deleteButtonList = new HbRadioButtonList(mViewer);
       
   792 
       
   793 	QStringList list;
       
   794 	list << hbTrId("txt_calendar_info_this_occurrence_only") 
       
   795 		 << hbTrId("txt_calendar_info_all_occurences");
       
   796 
       
   797 	deleteButtonList->setItems(list);
       
   798 
       
   799 	layout->addItem(deleteButtonList);
       
   800 
       
   801 	popUp.setContentWidget(deleteWidget);
       
   802 	popUp.setHeadingWidget(new HbLabel(
       
   803 						hbTrId("txt_calendar_title_delete_repeated_entry")));
       
   804 
       
   805 	connect(deleteButtonList, SIGNAL(itemSelected(int)), this,
       
   806 	        SLOT(handleDeleteOccurence(int)));
       
   807 	connect(deleteButtonList, SIGNAL(itemSelected(int)), &popUp, SLOT(close()));
       
   808 
       
   809 	// Create secondary action
       
   810 	HbAction *cancelAction = new HbAction(
       
   811 						hbTrId("txt_calendar_button_softkey1_cancel"));
       
   812 	popUp.setSecondaryAction(cancelAction);
       
   813 	connect(cancelAction, SIGNAL(triggered()), &popUp, SLOT(close()));
       
   814 
       
   815 	// Show the popup
       
   816 	popUp.exec();
       
   817 
       
   818 	qDebug()
       
   819 	      << "AgendaEventViewer: AgendaEventView::showDeleteOccurencePopup <--";
       
   820 }
       
   821 
       
   822 
       
   823 /*!
       
   824  * Show delete confirmation query
       
   825  */
       
   826 int AgendaEventView::showDeleteConfirmationQuery()
       
   827 {
       
   828 	qDebug()
       
   829 	   << "AgendaEventViewer: AgendaEventView::showDeleteConfirmationQuery -->";
       
   830 	int retStatus = 0;
       
   831 
       
   832 	HbMessageBox popup(HbMessageBox::MessageTypeQuestion);
       
   833 	popup.setDismissPolicy(HbDialog::NoDismiss);
       
   834 	popup.setTimeout(HbDialog::NoTimeout);
       
   835 	popup.setIconVisible(true);
       
   836 
       
   837 	QString text = 0;
       
   838 
       
   839 	switch (mAgendaEntry.type()) {
       
   840 		case AgendaEntry::TypeAppoinment:
       
   841 		case AgendaEntry::TypeEvent: {
       
   842 			text.append(hbTrId("txt_calendar_info_delete_meeting"));
       
   843 			break;
       
   844 		}
       
   845 		case AgendaEntry::TypeAnniversary: {
       
   846 			text.append(hbTrId("txt_calendar_info_delete_anniversary"));
       
   847 			break;
       
   848 		}
       
   849 		case AgendaEntry::TypeTodo: {
       
   850 			text.append(hbTrId("txt_calendar_info_delete_todo_note"));
       
   851 			break;
       
   852 		}
       
   853 		case AgendaEntry::TypeNote: {
       
   854 			text.append(hbTrId("txt_calendar_info_delete_anniversary"));
       
   855 			break;
       
   856 		}
       
   857 	}
       
   858 
       
   859 	popup.setText(text);
       
   860 	
       
   861 	popup.setPrimaryAction(new HbAction(
       
   862 								hbTrId("txt_calendar_button_delete"), &popup));
       
   863 	popup.setSecondaryAction(new HbAction(
       
   864 								hbTrId("txt_calendar_button_cancel"), &popup));
       
   865 	HbAction *selected = popup.exec();
       
   866 	if (selected == popup.primaryAction()) { 
       
   867 		retStatus = 1;
       
   868 	}
       
   869 
       
   870 	qDebug()
       
   871 	   << "AgendaEventViewer: AgendaEventView::showDeleteConfirmationQuery <--";
       
   872 	return retStatus;
       
   873 }
       
   874 
       
   875 /*!
       
   876 	Marks to-do entry as done or undone based on the completed value.
       
   877  */
       
   878 void AgendaEventView::markTodoStatus()
       
   879 {
       
   880 	qDebug() << "AgendaEventViewer: AgendaEventView::markTodoStatus -->";
       
   881 
       
   882 	QDateTime currentDateTime = QDateTime::currentDateTime();
       
   883 
       
   884 	// Set the to-do status using the agenda util.
       
   885 	if (AgendaEntry::TodoNeedsAction == mAgendaEntry.status()) {
       
   886 		
       
   887 		// Update the menu text to mark to-do as undone.
       
   888 		mMarkTodoAction->setText(hbTrId("txt_calendar_menu_mark_as_not_done"));
       
   889 		
       
   890 		mAgendaEntry.setStatus(AgendaEntry::TodoCompleted);
       
   891 		mAgendaEntry.setCompletedDateTime(currentDateTime);
       
   892 		mOwner->mAgendaUtil->setCompleted(mAgendaEntry, true, currentDateTime);
       
   893 		
       
   894 		
       
   895 
       
   896 	} else if (AgendaEntry::TodoCompleted == mAgendaEntry.status()) {
       
   897 		
       
   898 		// Update the menu text to mark to-do as done.
       
   899 		mMarkTodoAction->setText(hbTrId("txt_calendar_menu_mark_as_done"));
       
   900 				
       
   901 		mAgendaEntry.setStatus(AgendaEntry::TodoNeedsAction);
       
   902 		mOwner->mAgendaUtil->setCompleted(mAgendaEntry, false, currentDateTime);
       
   903 		
       
   904 		
       
   905 	}
       
   906 
       
   907 	updateCompletedReminderData();
       
   908 	
       
   909 	qDebug() << "AgendaEventViewer: AgendaEventView::markTodoStatus <--";
       
   910 }
       
   911 
       
   912 /*!
       
   913 	Edits the agenda entry by lanching the to-do viewer.
       
   914  */
       
   915 void AgendaEventView::edit()
       
   916 {
       
   917 	qDebug() << "AgendaEventViewer: AgendaEventView::edit -->";
       
   918 
       
   919 	mOwner->editingStarted();
       
   920 	
       
   921 	if (AgendaEntry::TypeTodo == mAgendaEntry.type()) {
       
   922 		// Launch the to-do editor using notes editor api
       
   923 		// Construct Note editor for launching the to-do editor
       
   924 		mNoteEditor = new NotesEditor(mOwner->mAgendaUtil, this);
       
   925 		mNoteEditor->edit(mAgendaEntry);
       
   926 
       
   927 		connect(
       
   928 				mNoteEditor, SIGNAL(editingCompleted(bool)),
       
   929 				this, SLOT(handleNoteEditorClosed(bool)));
       
   930 		
       
   931 
       
   932 	} else {
       
   933 		// Launch the calendar entry editor using calendar editor api
       
   934 		mCalenEditor = new CalenEditor(mOwner->mAgendaUtil, this);
       
   935 		mCalenEditor->edit(mAgendaEntry, false);
       
   936 		connect(mCalenEditor, SIGNAL(dialogClosed()),
       
   937 						this, SLOT(handleCalendarEditorClosed()));
       
   938 		
       
   939 	}
       
   940 	qDebug() << "AgendaEventViewer: AgendaEventView::edit <--";
       
   941 }
       
   942 
       
   943 /*!
       
   944 	Deletes the agenda entry.
       
   945  */
       
   946 void AgendaEventView::deleteAgendaEntry()
       
   947 {
       
   948 	qDebug() << "AgendaEventViewer: AgendaEventView::deleteAgendaEntry -->";
       
   949 
       
   950 	// Before we do anything, check in the entry is repeating
       
   951 	// OR its a child item
       
   952 	bool isChild = !(mAgendaEntry.recurrenceId().isNull());
       
   953 	bool isRepeating = mAgendaEntry.isRepeating();
       
   954 	if ((isChild || isRepeating) 
       
   955 			&& (mAgendaEntry.type() != AgendaEntry::TypeAnniversary) 
       
   956 			&& (mAgendaEntry.type() != AgendaEntry::TypeTodo)) {
       
   957 		// Query user if he wants to delete whole series or just this occurence
       
   958 		showDeleteOccurencePopup();
       
   959 	} else {
       
   960 		if (showDeleteConfirmationQuery()) {
       
   961 			
       
   962 			// To notify client that deleting Started
       
   963 			// Calendar Application changing state from viewing to deleting.
       
   964 			mOwner->deletingStarted();
       
   965 				
       
   966 			// Delete the entry.
       
   967 			mOwner->mAgendaUtil->deleteEntry(mAgendaEntry.id());
       
   968 		}
       
   969 	}
       
   970 
       
   971 	qDebug() << "AgendaEventViewer: AgendaEventView::deleteAgendaEntry <--";
       
   972 }
       
   973 
       
   974 /*!
       
   975 	Save the agenda entry to calendar db.
       
   976  */
       
   977 void AgendaEventView::saveAgendaEntry()
       
   978 {
       
   979 	qDebug() << "AgendaEventViewer: AgendaEventView::saveAgendaEntry -->";
       
   980 	
       
   981 	// Save entry to calendar.
       
   982 	mOwner->mAgendaUtil->addEntry(mAgendaEntry);
       
   983 	
       
   984 	// Close the agenda entry viewer
       
   985 	close();
       
   986 	qDebug() << "AgendaEventViewer: AgendaEventView::saveAgendaEntry <--";
       
   987 }
       
   988 /*!
       
   989 	Closes the event viewer
       
   990  */
       
   991 void AgendaEventView::close()
       
   992 {
       
   993 	qDebug() << "AgendaEventViewer: AgendaEventView::close -->";
       
   994 
       
   995 	// Remove the view from main window.
       
   996 	HbMainWindow *window = hbInstance->allMainWindows().first();
       
   997 
       
   998 	// Cleanup.
       
   999 	disconnect(
       
  1000 			mBackAction, SIGNAL(triggered()),
       
  1001 			this, SLOT(close()));
       
  1002 
       
  1003 	window->removeView(mViewer);
       
  1004 	mOwner->viewingCompleted();
       
  1005 
       
  1006 	qDebug() << "AgendaEventViewer: AgendaEventView::close <--";
       
  1007 }
       
  1008 
       
  1009 /*!
       
  1010 	Handles entry updation of the event entry.
       
  1011  */
       
  1012 void AgendaEventView::handleEntryUpdation(ulong id)
       
  1013 {
       
  1014 	qDebug() << "AgendaEventViewer: AgendaEventView::handleEntryUpdation -->";
       
  1015 
       
  1016 	AgendaEntry updatedEntry = mOwner->mAgendaUtil->fetchById(id);
       
  1017 
       
  1018 	// Agenda entry is not null then refresh the view else close event viewer
       
  1019 	if (!updatedEntry.isNull()) {
       
  1020 
       
  1021 		mAgendaEntry = updatedEntry;
       
  1022 
       
  1023 		if (updatedEntry.isRepeating() && mAgendaEntry.type()
       
  1024 		        != AgendaEntry::TypeTodo) {
       
  1025 			// if start date of original entry is between start date of updated 
       
  1026 			// entry and until date of updated entry then only update time.
       
  1027 			if (mOriginalAgendaEntry.startTime().date()
       
  1028 			        >= updatedEntry.startTime().date()
       
  1029 			        || mOriginalAgendaEntry.startTime().date()
       
  1030 			                <= updatedEntry.repeatRule().until()) {
       
  1031 				QDateTime
       
  1032 				        startDateTime(mOriginalAgendaEntry.startTime().date(),
       
  1033 				                      updatedEntry.startTime().time());
       
  1034 				QDateTime endDateTime(mOriginalAgendaEntry.endTime().date(),
       
  1035 				                      updatedEntry.endTime().time());
       
  1036 				mAgendaEntry.setStartAndEndTime(startDateTime, endDateTime);
       
  1037 			}
       
  1038 		}
       
  1039 
       
  1040 		if (mOriginalAgendaEntry.status() == updatedEntry.status()) {
       
  1041 			
       
  1042 			// Remove all widgets from layout.
       
  1043 			removeAllWidgets();
       
  1044 			
       
  1045 			// Add all widgets to layout.
       
  1046 			addAllWidgets();
       
  1047 			
       
  1048 			// Update the viewer's data using the modified entry from parent.
       
  1049 			addViewerData();
       
  1050 			
       
  1051 			// Remove unnecessary widget from event viewer.
       
  1052 			removeWidget();
       
  1053 		}
       
  1054 		mOriginalAgendaEntry = mAgendaEntry;
       
  1055 	} else {
       
  1056 		// Close the agenda entry viewer
       
  1057 		close();
       
  1058 	}
       
  1059 
       
  1060 	qDebug() << "AgendaEventViewer: AgendaEventView::handleEntryUpdation <--";
       
  1061 }
       
  1062 
       
  1063 /*!
       
  1064 	Handles the entry deletion of the agenda entry
       
  1065 */
       
  1066 void AgendaEventView::handleEntryDeletion(ulong id)
       
  1067 {
       
  1068 	qDebug() <<"AgendaEventViewer: AgendaEventView::handleEntryDeletion -->";
       
  1069 
       
  1070 	if (id == mAgendaEntry.id()) {
       
  1071 		// Close the agenda entry viewer
       
  1072 		close();
       
  1073 		mOwner->deletingCompleted();
       
  1074 	}
       
  1075 
       
  1076 	qDebug() <<"AgendaEventViewer: AgendaEventView::handleEntryDeletion <--";
       
  1077 }
       
  1078 
       
  1079 /*!
       
  1080 	Handles the Note Editor editing completion of the agenda entry
       
  1081  */
       
  1082 void AgendaEventView::handleNoteEditorClosed(bool status)
       
  1083 {
       
  1084 	Q_UNUSED(status);
       
  1085 	qDebug() <<"AgendaEventViewer: AgendaEventView::handleNoteEditorClosed -->";
       
  1086 
       
  1087 	// Cleanup.
       
  1088 	mNoteEditor->deleteLater();
       
  1089 	mOwner->editingCompleted();
       
  1090 
       
  1091 	qDebug() <<"AgendaEventViewer: AgendaEventView::handleNoteEditorClosed <--";
       
  1092 }
       
  1093 
       
  1094 /*!
       
  1095 	Handles the Note Editor editing completion of the agenda entry
       
  1096  */
       
  1097 void AgendaEventView::handleCalendarEditorClosed()
       
  1098 {
       
  1099 	qDebug() 
       
  1100 		<<"AgendaEventViewer: AgendaEventView::handleCalendarEditorClosed -->";
       
  1101 
       
  1102 	// Cleanup.
       
  1103 	mCalenEditor->deleteLater();
       
  1104 	mOwner->editingCompleted();
       
  1105 
       
  1106 	qDebug() 
       
  1107 		<<"AgendaEventViewer: AgendaEventView::handleCalendarEditorClosed <--";
       
  1108 }
       
  1109 
       
  1110 /*!
       
  1111 	Slot to handle User selection for series deleting or single occurence popup
       
  1112  */
       
  1113 void AgendaEventView::handleDeleteOccurence(int index)
       
  1114 {
       
  1115 	qDebug() << "AgendaEventViewer: AgendaEventView::handleDeleteOccurence -->";
       
  1116 	
       
  1117 	// To notify client that deleting Started
       
  1118 	// Calendar Application changing state from viewing to deleting.
       
  1119 	mOwner->deletingStarted();
       
  1120 	
       
  1121 	switch (index) {
       
  1122 		case 0:
       
  1123 			// User wants to delete only this occurence
       
  1124 			mOwner->mAgendaUtil->deleteRepeatedEntry(mAgendaEntry,
       
  1125 			                                         AgendaUtil::ThisOnly);
       
  1126 
       
  1127 			break;
       
  1128 		case 1:
       
  1129 			// User wants to delete all the occurences
       
  1130 			mOwner->mAgendaUtil->deleteRepeatedEntry(mAgendaEntry,
       
  1131 			                                         AgendaUtil::ThisAndAll);
       
  1132 			break;
       
  1133 	}
       
  1134 
       
  1135 	qDebug() << "AgendaEventViewer: AgendaEventView::handleDeleteOccurence <--";
       
  1136 }
       
  1137 
       
  1138 // End of file