calendarui/agendaeventviewer/src/agendaeventview.cpp
changeset 50 579cc610882e
parent 49 5de72ea7a065
child 58 ef813d54df51
equal deleted inserted replaced
49:5de72ea7a065 50:579cc610882e
    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>
    24 #include <QFile>
    22 #include <QFile>
    25 #include <QString>
    23 #include <QString>
    26 #include <QTimer>
    24 #include <QTimer>
    27 #include <QPluginLoader>
    25 #include <QPluginLoader>
    28 #include <QDir>
    26 #include <QDir>
    29 #include <HbInstance>
    27 #include <HbInstance>
    30 #include <hbapplication.h>
       
    31 #include <HbMainWindow>
    28 #include <HbMainWindow>
    32 #include <HbView>
    29 #include <HbView>
    33 #include <HbMenu>
    30 #include <HbMenu>
    34 #include <HbGroupBox>
    31 #include <HbGroupBox>
    35 #include <HbScrollArea>
    32 #include <HbScrollArea>
    40 #include <hbi18ndef.h>
    37 #include <hbi18ndef.h>
    41 #include <HbRadioButtonList>
    38 #include <HbRadioButtonList>
    42 #include <HbMessageBox>
    39 #include <HbMessageBox>
    43 #include <HbDialog>
    40 #include <HbDialog>
    44 #include <HbLabel>
    41 #include <HbLabel>
       
    42 #include <HbTranslator>
       
    43 
    45 // User includes
    44 // User includes
    46 #include <maptileservice.h>//maptile service
    45 #include <maptileservice.h>//maptile service
    47 #include <agendautil.h>
    46 #include <agendautil.h>
    48 #include <NotesEditorInterface>
    47 #include <NotesEditorInterface>
    49 #include <caleneditor.h>
    48 #include <caleneditor.h>
    56 // Constants
    55 // Constants
    57 #define CHARACTER_HYPHEN    "-"
    56 #define CHARACTER_HYPHEN    "-"
    58 #define CHARACTER_SPACE     " "
    57 #define CHARACTER_SPACE     " "
    59 #define CHARACTER_NEW_LINE  "\n"
    58 #define CHARACTER_NEW_LINE  "\n"
    60 
    59 
    61 // This is used to set the maptile image height and width ,
       
    62 //because HbLabel by default not displaying the actual size of image 
       
    63 const int height = 128;
       
    64 const int width =  330;
       
    65 
       
    66 //This Property is use for setting a primary left icon
    60 //This Property is use for setting a primary left icon
    67 static const char *primaryLeftIconItem("leftPrimaryIconItem");
    61 static const char *primaryLeftIconItem("leftPrimaryIconItem");
    68 
    62 
    69 /*!
    63 /*!
    70 	\class AgendaEventView.
    64 	\class AgendaEventView.
    81 	\param parent pointer to QGraphicsWidget.
    75 	\param parent pointer to QGraphicsWidget.
    82  */
    76  */
    83 AgendaEventView::AgendaEventView(
    77 AgendaEventView::AgendaEventView(
    84 		AgendaEventViewerPrivate *owner, QObject *parent):
    78 		AgendaEventViewerPrivate *owner, QObject *parent):
    85 		QObject(parent),
    79 		QObject(parent),
       
    80 		mMainWindow(NULL),
    86 		mOwner(owner),
    81 		mOwner(owner),
       
    82 		mTranslator(new HbTranslator("caleneventviewer")),
    87 		mReminderWidgetAdded(true),
    83 		mReminderWidgetAdded(true),
    88 		mMainWindow(NULL),
       
    89 		mMaptilePath(NULL),
    84 		mMaptilePath(NULL),
    90 		mMaptileService(NULL),
    85 		mMaptileService(NULL),
    91 		mProgressTimer(NULL),
    86 		mProgressTimer(NULL),
    92 		mProgressIconCount(0),
    87 		mProgressIconCount(0),
    93 		mMaptileStatusReceived(false),
    88 		mMaptileStatusReceived(false),
    94 		mMaptileStatus(-1),
    89 		mMaptileStatus(-1),
    95 		mNotesPluginLoaded(false)
    90 		mNotesPluginLoaded(false)
    96 {
    91 {
    97 	qDebug() << "AgendaEventViewer: AgendaEventView::AgendaEventView -->";
       
    98 
       
    99 	// Load the translator based on locale
       
   100 	mTranslator = new QTranslator;
       
   101 	QString lang = QLocale::system().name();
       
   102 	QString path = "Z:/resource/qt/translations/";
       
   103 	mTranslator->load("caleneventviewer_en_GB",":/translations");
       
   104 	// TODO: Load the appropriate .qm file based on locale
       
   105 	//bool loaded = mTranslator->load("caleneventviewer_" + lang, path);
       
   106 	HbApplication::instance()->installTranslator(mTranslator);
       
   107 	
    92 	
   108 	mDocLoader = new AgendaEventViewerDocLoader;
    93 	mDocLoader = new AgendaEventViewerDocLoader;
   109 
    94 
   110 	// Load to-do viewer's docml.
    95 	// Load to-do viewer's docml.
   111 	bool loadSuccess;
    96 	bool loadSuccess;
   159         //timer to run progress indicator icon.
   144         //timer to run progress indicator icon.
   160         mProgressTimer = new QTimer(this);
   145         mProgressTimer = new QTimer(this);
   161         mProgressTimer->setSingleShot(true);
   146         mProgressTimer->setSingleShot(true);
   162         connect(mProgressTimer, SIGNAL(timeout()), this, SLOT(updateProgressIndicator()));
   147         connect(mProgressTimer, SIGNAL(timeout()), this, SLOT(updateProgressIndicator()));
   163     }
   148     }
   164     qDebug() << "AgendaEventViewer: AgendaEventView::AgendaEventView <--";
   149         
   165 	
   150 	
   166 }
   151 }
   167 
   152 
   168 /*!
   153 /*!
   169 	Destructor.
   154 	Destructor.
   170  */
   155  */
   171 AgendaEventView::~AgendaEventView()
   156 AgendaEventView::~AgendaEventView()
   172 {
   157 {
   173 	qDebug() << "AgendaEventViewer: AgendaEventView::~AgendaEventView -->";
       
   174 
   158 
   175 	// Remove the translator
   159 	// Remove the translator
   176 	HbApplication::instance()->removeTranslator(mTranslator);
       
   177 	if (mTranslator) {
   160 	if (mTranslator) {
   178 		delete mTranslator;
   161 		delete mTranslator;
   179 		mTranslator = 0;
   162 		mTranslator = 0;
   180 	}
   163 	}
   181 	
   164 	
   203 	if (mProgressTimer) {
   186 	if (mProgressTimer) {
   204         delete mProgressTimer;
   187         delete mProgressTimer;
   205         mProgressTimer = NULL;
   188         mProgressTimer = NULL;
   206     }
   189     }
   207 	
   190 	
   208 	qDebug() << "AgendaEventViewer: AgendaEventView::~AgendaEventView <--";
       
   209 }
   191 }
   210 
   192 
   211 /*!
   193 /*!
   212 	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.
   213 
   195 
   214 	\param entry Agenda entry from which attributes have to be read.
   196 	\param entry Agenda entry from which attributes have to be read.
   215  */
   197  */
   216 void AgendaEventView::execute(AgendaEntry entry,
   198 void AgendaEventView::execute(AgendaEntry entry,
   217 											AgendaEventViewer::Actions action)
   199 											AgendaEventViewer::Actions action)
   218 {
   200 {
   219 	qDebug() << "AgendaEventViewer: AgendaEventView::execute -->";
       
   220 
   201 
   221 	mOriginalAgendaEntry = entry;
   202 	mOriginalAgendaEntry = entry;
   222 	mAgendaEntry = entry;
   203 	mAgendaEntry = entry;
   223 
   204 
   224 	// Add the viewer data reading from the agenda entry.
   205 	// Add the viewer data reading from the agenda entry.
   230 	// Add the menu items to event viewer.
   211 	// Add the menu items to event viewer.
   231 	addMenuItem();
   212 	addMenuItem();
   232 	
   213 	
   233 	// Add the toolbar items to event viewer
   214 	// Add the toolbar items to event viewer
   234 	addToolBarItem(action);
   215 	addToolBarItem(action);
   235 	
       
   236 	// Add the title to event viewer.
       
   237 	addGroupBoxData();
       
   238 
   216 
   239 	// 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
   240 	// when the same is edited in editor.
   218 	// when the same is edited in editor.
   241 	connect(mOwner->mAgendaUtil, SIGNAL(entryUpdated(ulong)),
   219 	connect(mOwner->mAgendaUtil, SIGNAL(entryUpdated(ulong)),
   242 				this, SLOT(handleEntryUpdation(ulong)));
   220 				this, SLOT(handleEntryUpdation(ulong)));
   254 		// Might be some non-ui based app called us
   232 		// Might be some non-ui based app called us
   255 		// so create mainwindow now
   233 		// so create mainwindow now
   256 		mMainWindow = new HbMainWindow();
   234 		mMainWindow = new HbMainWindow();
   257 		mMainWindow->addView(mViewer);
   235 		mMainWindow->addView(mViewer);
   258 		mMainWindow->setCurrentView(mViewer);
   236 		mMainWindow->setCurrentView(mViewer);
       
   237 	    connect(mMainWindow,SIGNAL(orientationChanged(Qt::Orientation)),this,SLOT(changedOrientation(Qt::Orientation)));		
   259 	} else {
   238 	} else {
   260 		window->addView(mViewer);
   239 		window->addView(mViewer);
   261 		window->setCurrentView(mViewer);
   240 		window->setCurrentView(mViewer);
       
   241 		connect(window,SIGNAL(orientationChanged(Qt::Orientation)),this,SLOT(changedOrientation(Qt::Orientation)));		
   262 	}
   242 	}
   263 	
   243 	
   264 	// Add softkey after adding view on window
   244 	// Add softkey after adding view on window
   265 	mBackAction = new HbAction(Hb::BackNaviAction);
   245 	mBackAction = new HbAction(Hb::BackNaviAction);
   266 	mViewer->setNavigationAction(mBackAction);
   246 	mViewer->setNavigationAction(mBackAction);
   267 		
   247 		
   268 	connect(mBackAction, SIGNAL(triggered()), this, SLOT(close()));
   248 	connect(mBackAction, SIGNAL(triggered()), this, SLOT(close()));
   269 
   249 
   270 	qDebug() << "AgendaEventViewer: AgendaEventView::execute <--";
       
   271 }
   250 }
   272 
   251 
   273 /*!
   252 /*!
   274 	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.
   275  */
   254  */
   276 void AgendaEventView::addViewerData()
   255 void AgendaEventView::addViewerData()
   277 {
   256 {
   278 	qDebug() << "AgendaEventViewer: AgendaEventView::addViewerData -->";
   257 	
       
   258 	// Add the title to event viewer.
       
   259 	addGroupBoxData();
   279 
   260 
   280 	// Set the summary & priority to viewer.
   261 	// Set the summary & priority to viewer.
   281 	addSubjectAndPriorityData();
   262 	addSubjectAndPriorityData();
   282 	
   263 	
   283 	// Set Date & Time to viewer.
   264 	// Set Date & Time to viewer.
   306 	}
   287 	}
   307 
   288 
   308 	// Set the description.
   289 	// Set the description.
   309 	addDescriptionData();
   290 	addDescriptionData();
   310 	
   291 	
   311 	qDebug() << "AgendaEventViewer: AgendaEventView::addViewerData <--";
       
   312 }
   292 }
   313 
   293 
   314 /*!
   294 /*!
   315 	Add the menu item depends up on entry type
   295 	Add the menu item depends up on entry type
   316  */
   296  */
   317 void AgendaEventView::addMenuItem()
   297 void AgendaEventView::addMenuItem()
   318 {
   298 {
   319 	qDebug() << "AgendaEventViewer: AgendaEventView::addMenuItem -->";
       
   320 
   299 
   321 	if (mAgendaEntry.type() == AgendaEntry::TypeTodo) {
   300 	if (mAgendaEntry.type() == AgendaEntry::TypeTodo) {
   322 
   301 
   323 		HbMenu *menu = qobject_cast<HbMenu *> (
   302 		HbMenu *menu = qobject_cast<HbMenu *> (
   324 				mDocLoader->findWidget(AGENDA_EVENT_VIEWER_MENU));
   303 				mDocLoader->findWidget(AGENDA_EVENT_VIEWER_MENU));
   332 		}
   311 		}
   333 		connect(mMarkTodoAction, SIGNAL(triggered()), this,
   312 		connect(mMarkTodoAction, SIGNAL(triggered()), this,
   334 		        SLOT(markTodoStatus()));
   313 		        SLOT(markTodoStatus()));
   335 		menu->addAction(mMarkTodoAction);
   314 		menu->addAction(mMarkTodoAction);
   336 	}
   315 	}
   337 	qDebug() << "AgendaEventViewer: AgendaEventView::addMenuItem <--";
       
   338 }
   316 }
   339 
   317 
   340 /*!
   318 /*!
   341 	Add the toolbar item
   319 	Add the toolbar item
   342  */
   320  */
   343 void AgendaEventView::addToolBarItem(AgendaEventViewer::Actions action)
   321 void AgendaEventView::addToolBarItem(AgendaEventViewer::Actions action)
   344 {
   322 {
   345 	qDebug() << "AgendaEventViewer: AgendaEventView::addToolBarItem -->";
       
   346 
   323 
   347 	HbToolBar *toolBar = qobject_cast<HbToolBar *> (
   324 	HbToolBar *toolBar = qobject_cast<HbToolBar *> (
   348 	                       mDocLoader->findWidget(AGENDA_EVENT_VIEWER_TOOLBAR));
   325 	                       mDocLoader->findWidget(AGENDA_EVENT_VIEWER_TOOLBAR));
   349 
   326 
   350 	// Load all the actions for event viewer
   327 	// Load all the actions for event viewer
   371 		saveAction->setIcon(HbIcon("qtg_mono_add_to_calendar"));
   348 		saveAction->setIcon(HbIcon("qtg_mono_add_to_calendar"));
   372 		connect(saveAction, SIGNAL(triggered()), this, SLOT(saveAgendaEntry()));
   349 		connect(saveAction, SIGNAL(triggered()), this, SLOT(saveAgendaEntry()));
   373 		toolBar->addAction(saveAction);
   350 		toolBar->addAction(saveAction);
   374 	}
   351 	}
   375 
   352 
   376 	qDebug() << "AgendaEventViewer: AgendaEventView::addToolBarItem <--";
       
   377 }
   353 }
   378 
   354 
   379 /*!
   355 /*!
   380 	Add the groupbox data depends up on entry type
   356 	Add the groupbox data depends up on entry type
   381  */
   357  */
   382 void AgendaEventView::addGroupBoxData()
   358 void AgendaEventView::addGroupBoxData()
   383 {
   359 {
   384 	qDebug() << "AgendaEventViewer: AgendaEventView::addGroupBoxData -->";
       
   385 	
   360 	
   386 	HbGroupBox *groupBox = qobject_cast<HbGroupBox *> (
   361 	HbGroupBox *groupBox = qobject_cast<HbGroupBox *> (
   387 			mDocLoader->findWidget(AGENDA_EVENT_VIEWER_GROUPBOX));
   362 			mDocLoader->findWidget(AGENDA_EVENT_VIEWER_GROUPBOX));
   388 
   363 
   389 	if (mAgendaEntry.type() == AgendaEntry::TypeTodo) {
   364 	AgendaEntry::Type entryType = mAgendaEntry.type();
       
   365 	if (entryType == AgendaEntry::TypeTodo) {
   390 		groupBox->setHeading(hbTrId("txt_calendar_subhead_to_do"));
   366 		groupBox->setHeading(hbTrId("txt_calendar_subhead_to_do"));
   391 	} else if (mAgendaEntry.type() == AgendaEntry::TypeNote) {
   367 	} else if (entryType == AgendaEntry::TypeAppoinment) {
   392 		groupBox->setHeading(tr("Note"));
   368 		groupBox->setHeading(hbTrId("txt_calendar_subhead_meeting"));
   393 	} else {
   369 	}else if (entryType == AgendaEntry::TypeEvent) {
   394 		// TODO: Add the text id based on the entry type Anniversary or meeting
   370 		//TODO: Add text id once available
   395 		groupBox->setHeading(hbTrId("txt_calendar_subhead_event"));
   371 		groupBox->setHeading(hbTrId("All day event"));
   396 	}
   372 	}
   397 
   373 		
   398 	qDebug() << "AgendaEventViewer: AgendaEventView::addGroupBoxData <--";
       
   399 }
   374 }
   400 
   375 
   401 /*!
   376 /*!
   402 	Add subject and priority data to Event viewer
   377 	Add subject and priority data to Event viewer
   403  */
   378  */
   404 void AgendaEventView::addSubjectAndPriorityData()
   379 void AgendaEventView::addSubjectAndPriorityData()
   405 {
   380 {
   406 	qDebug()
       
   407 	     << "AgendaEventViewer: AgendaEventView::addSubjectAndPriorityData -->";
       
   408 
   381 
   409 	QStringList itemList;
   382 	QStringList itemList;
   410 	itemList.append(hbTrId("txt_calendar_dblist_subject"));
   383 	itemList.append(hbTrId("txt_calendar_dblist_subject"));
   411 	if (mAgendaEntry.summary().isEmpty()) {
   384 	if (mAgendaEntry.summary().isEmpty()) {
   412 		itemList.append(hbTrId("txt_calendar_dblist_val_unnamed"));
   385 		itemList.append(hbTrId("txt_calendar_dblist_val_unnamed"));
   426     itemList.append(priorityIcon);
   399     itemList.append(priorityIcon);
   427     itemList.append(QString::null);
   400     itemList.append(QString::null);
   428 
   401 
   429 	mSubjectWidget->setEventViewerItemData(itemList, Qt::DecorationRole);
   402 	mSubjectWidget->setEventViewerItemData(itemList, Qt::DecorationRole);
   430 
   403 
   431 	qDebug()
       
   432 	     << "AgendaEventViewer: AgendaEventView::addSubjectAndPriorityData <--";
       
   433 }
   404 }
   434 
   405 
   435 /*!
   406 /*!
   436 	Add date & time data to Event viewer
   407 	Add date & time data to Event viewer
   437  */
   408  */
   438 void AgendaEventView::addDateTimeData()
   409 void AgendaEventView::addDateTimeData()
   439 {
   410 {
   440     qDebug()
       
   441          << "AgendaEventViewer: AgendaEventView::addDateTimeData -->";
       
   442     
       
   443     
   411     
   444     QStringList itemData;
   412     QStringList itemData;
   445     HbExtendedLocale systemLocale = HbExtendedLocale::system();
   413     HbExtendedLocale systemLocale = HbExtendedLocale::system();
   446     QDateTime startDateTime = mAgendaEntry.startTime();
   414     QDateTime startDateTime = mAgendaEntry.startTime();
   447     QDateTime endDateTime = mAgendaEntry.endTime();
   415     QDateTime endDateTime = mAgendaEntry.endTime();
   518     		break;
   486     		break;
   519     }
   487     }
   520 	itemData.append(data);
   488 	itemData.append(data);
   521     mDateTimeWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   489     mDateTimeWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   522     
   490     
   523     qDebug()
       
   524          << "AgendaEventViewer: AgendaEventView::addDateTimeData <--";
       
   525 }
   491 }
   526 
   492 
   527 /*!
   493 /*!
   528 	Add location data to Event viewer
   494 	Add location data to Event viewer
   529  */
   495  */
   530 void AgendaEventView::addLocationData()
   496 void AgendaEventView::addLocationData()
   531 {
   497 {
   532 	qDebug() << "AgendaEventViewer: AgendaEventView::addLocationData -->";
       
   533 	QStringList itemData;
   498 	QStringList itemData;
   534 	QString progressIcon(QString::null);	
   499 	QString progressIcon(QString::null);	
   535 	if ( mLocationFeatureEnabled ) {
   500 	if ( mLocationFeatureEnabled ) {
   536 	    getProgressIndicatorstatus(progressIcon);	   
   501 	    getProgressIndicatorstatus(progressIcon);	   
   537 	}
   502 	}
   550 	mLocationWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
   515 	mLocationWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
   551 	itemData.clear();
   516 	itemData.clear();
   552 	itemData.append(QString::null);
   517 	itemData.append(QString::null);
   553 	itemData.append(mAgendaEntry.location());
   518 	itemData.append(mAgendaEntry.location());
   554 	mLocationWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   519 	mLocationWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   555 	qDebug() << "AgendaEventViewer: AgendaEventView::addLocationData <--";
       
   556 }
   520 }
   557 
   521 
   558 /*!
   522 /*!
   559     Add maptile image to Event viewer
   523     Add maptile image to Event viewer
   560  */
   524  */
   562 {
   526 {
   563     if (mLocationFeatureEnabled && !mAgendaEntry.location().isEmpty() && !mMaptilePath.isEmpty()) {
   527     if (mLocationFeatureEnabled && !mAgendaEntry.location().isEmpty() && !mMaptilePath.isEmpty()) {
   564 
   528 
   565         HbIcon maptile(mMaptilePath);
   529         HbIcon maptile(mMaptilePath);
   566         mMaptileLabel->setIcon(maptile);
   530         mMaptileLabel->setIcon(maptile);
   567         mMaptileLabel->setPreferredSize(QSizeF(width, height));
   531         mMaptileLabel->setPreferredSize(QSizeF(maptile.width(), maptile.height()));
   568         mMaptileLabel->setMinimumSize(QSizeF(width, height));
       
   569         mMaptileLabel->setMaximumSize(QSizeF(width, height));
       
   570         mMaptileLabel->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
       
   571 
       
   572     }
   532     }
   573 }
   533 }
   574 /*!
   534 /*!
   575 	Add reminder data to Event viewer
   535 	Add reminder data to Event viewer
   576  */
   536  */
   577 void AgendaEventView::addReminderData()
   537 void AgendaEventView::addReminderData()
   578 {
   538 {
   579 	qDebug() << "AgendaEventViewer: AgendaEventView::addReminderData -->";
       
   580 	QStringList itemData;
   539 	QStringList itemData;
   581 	itemData.append(QString::null);
   540 	itemData.append(QString::null);
   582     itemData.append(QString::null);
   541     itemData.append(QString::null);
   583     itemData.append("qtg_small_reminder");
   542     itemData.append("qtg_small_reminder");
   584     mReminderWidget->setProperty(primaryLeftIconItem, false); 
   543     mReminderWidget->setProperty(primaryLeftIconItem, false); 
   585 	mReminderWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
   544 	mReminderWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
   586 	itemData.clear();
   545 	itemData.clear();
   587 	itemData.append(QString::null);
   546 	itemData.append(QString::null);
   588 	itemData.append(alarmTimeText());
   547 	itemData.append(alarmTimeText());
   589 	mReminderWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   548 	mReminderWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   590 	qDebug() << "AgendaEventViewer: AgendaEventView::addReminderData <--";
       
   591     }
   549     }
   592 
   550 
   593 /*!
   551 /*!
   594 	Add completed to-do data to Event viewer
   552 	Add completed to-do data to Event viewer
   595  */
   553  */
   596 void AgendaEventView::addCompletedTodoData()
   554 void AgendaEventView::addCompletedTodoData()
   597 {
   555 {
   598 	qDebug() << "AgendaEventViewer: AgendaEventView::addCompletedTodoData -->";
       
   599 	QStringList itemData;
   556 	QStringList itemData;
   600 	QString     completedText;
   557 	QString     completedText;
   601     HbExtendedLocale systemLocale = HbExtendedLocale::system();;
   558     HbExtendedLocale systemLocale = HbExtendedLocale::system();;
   602     itemData.append(QString::null);
   559     itemData.append(QString::null);
   603 	itemData.append(QString::null);
   560 	itemData.append(QString::null);
   608 	completedText = systemLocale.format(mAgendaEntry.completedDateTime().date(),
   565 	completedText = systemLocale.format(mAgendaEntry.completedDateTime().date(),
   609 					                    r_qtn_date_usual_with_zero);
   566 					                    r_qtn_date_usual_with_zero);
   610 	itemData.append(hbTrId("txt_calendar_dblist_completed_date"));
   567 	itemData.append(hbTrId("txt_calendar_dblist_completed_date"));
   611 	itemData.append(completedText);
   568 	itemData.append(completedText);
   612 	mReminderWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   569 	mReminderWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   613 	qDebug() << "AgendaEventViewer: AgendaEventView::addCompletedTodoData <--";
       
   614 }
   570 }
   615 
   571 
   616 /*!
   572 /*!
   617 	Add repeat data to Event viewer
   573 	Add repeat data to Event viewer
   618  */
   574  */
   619 void AgendaEventView::addRepeatData()
   575 void AgendaEventView::addRepeatData()
   620 {
   576 {
   621 	qDebug() << "AgendaEventViewer: AgendaEventView::addRepeatData -->";
       
   622 	QStringList itemData;
   577 	QStringList itemData;
   623 	itemData.append(QString::null);
   578 	itemData.append(QString::null);
   624     itemData.append(QString::null);
   579     itemData.append(QString::null);
   625     itemData.append("qtg_small_repeat");
   580     itemData.append("qtg_small_repeat");
   626     mRepeatWidget->setProperty(primaryLeftIconItem, false);
   581     mRepeatWidget->setProperty(primaryLeftIconItem, false);
   627 	mRepeatWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
   582 	mRepeatWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
   628 	itemData.clear();
   583 	itemData.clear();
   629 	itemData.append(QString::null);
   584 	itemData.append(QString::null);
   630 	itemData.append(repeatRule());
   585 	itemData.append(repeatRule());
   631 	mRepeatWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   586 	mRepeatWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   632 	qDebug() << "AgendaEventViewer: AgendaEventView::addRepeatData <--";
       
   633 }
   587 }
   634 
   588 
   635 /*!
   589 /*!
   636 	Add description data to Event viewer
   590 	Add description data to Event viewer
   637  */
   591  */
   638 void AgendaEventView::addDescriptionData()
   592 void AgendaEventView::addDescriptionData()
   639 {
   593 {
   640 	qDebug() << "AgendaEventViewer: AgendaEventView::addDiscriptionData -->";
       
   641 	QStringList itemData;
   594 	QStringList itemData;
   642 	itemData.append(QString::null);
   595 	itemData.append(QString::null);
   643 	itemData.append(QString::null);
   596 	itemData.append(QString::null);
   644     itemData.append(QString::null);
   597     itemData.append(QString::null);
   645     mDescriptionWidget->setProperty(primaryLeftIconItem, false);
   598     mDescriptionWidget->setProperty(primaryLeftIconItem, false);
   646 	mDescriptionWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
   599 	mDescriptionWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
   647 	itemData.clear();
   600 	itemData.clear();
   648 	itemData.append(hbTrId("txt_calendar_dblist_description"));
   601 	itemData.append(hbTrId("txt_calendar_dblist_description"));
   649 	itemData.append(mAgendaEntry.description());
   602 	itemData.append(mAgendaEntry.description());
   650 	mDescriptionWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   603 	mDescriptionWidget->setEventViewerItemData(itemData, Qt::DisplayRole);
   651 	qDebug() << "AgendaEventViewer: AgendaEventView::addDiscriptionData <--";
       
   652 }
   604 }
   653 
   605 
   654 /*!
   606 /*!
   655 	Returns priority icon
   607 	Returns priority icon
   656  */
   608  */
   657 void AgendaEventView::getPriorityIcon(int priority, QString &priorityIcon)
   609 void AgendaEventView::getPriorityIcon(int priority, QString &priorityIcon)
   658 {
   610 {
   659 	qDebug() << "AgendaEventViewer: AgendaEventView::getPriorityIcon -->";
       
   660 
   611 
   661 	switch(priority) {
   612 	switch(priority) {
   662 		case 1:priorityIcon.append("qtg_small_priority_high");
   613 		case 1:priorityIcon.append("qtg_small_priority_high");
   663 		break;
   614 		break;
   664 		case 3:priorityIcon.append("qtg_small_priority_low");
   615 		case 3:priorityIcon.append("qtg_small_priority_low");
   665 		break;
   616 		break;
   666 		default:
   617 		default:
   667 		break;
   618 		break;
   668 	}
   619 	}
   669 
   620 
   670 	qDebug() << "AgendaEventViewer: AgendaEventView::getPriorityIcon <--";
       
   671 }
   621 }
   672 
   622 
   673 /*!
   623 /*!
   674 	Returns repeat rule
   624 	Returns repeat rule
   675  */
   625  */
   676 QString AgendaEventView::repeatRule() const
   626 QString AgendaEventView::repeatRule() const
   677 {
   627 {
   678 	qDebug() << "AgendaEventViewer: AgendaEventView::repeatRule -->";
       
   679 	
   628 	
   680 	QString repeatRule;
   629 	QString repeatRule;
   681 	AgendaRepeatRule agendaRepeatRule = mAgendaEntry.repeatRule();
   630 	AgendaRepeatRule agendaRepeatRule = mAgendaEntry.repeatRule();
   682 	if (agendaRepeatRule.type() != AgendaRepeatRule::InvalidRule)
   631 	if (agendaRepeatRule.type() != AgendaRepeatRule::InvalidRule)
   683 	{
   632 	{
   685 			case AgendaRepeatRule::DailyRule:
   634 			case AgendaRepeatRule::DailyRule:
   686 				repeatRule.append(hbTrId("txt_calendar_dblist_repeats_daily"));
   635 				repeatRule.append(hbTrId("txt_calendar_dblist_repeats_daily"));
   687 			break;
   636 			break;
   688 			case AgendaRepeatRule::WeeklyRule:
   637 			case AgendaRepeatRule::WeeklyRule:
   689 				if (AgendaUtil::isWorkdaysRepeatingEntry(agendaRepeatRule)) {
   638 				if (AgendaUtil::isWorkdaysRepeatingEntry(agendaRepeatRule)) {
   690 					//TODO: Add text id for workdays
   639 					repeatRule.append(hbTrId("txt_calendar_dblist_repeats_workdays"));
   691 					repeatRule.append(hbTrId("Workdays"));
       
   692 				} else {
   640 				} else {
   693 					if (agendaRepeatRule.interval() == 2) {
   641 					if (agendaRepeatRule.interval() == 2) {
   694 						repeatRule.append(
   642 						repeatRule.append(
   695 							hbTrId("txt_calendar_dblist_repeats_fortnightly"));
   643 							hbTrId("txt_calendar_dblist_repeats_fortnightly"));
   696 					} else {
   644 					} else {
   717 				r_qtn_date_usual_with_zero);
   665 				r_qtn_date_usual_with_zero);
   718 		repeatRule.append(
   666 		repeatRule.append(
   719 			hbTrId("txt_calendar_dblist_repeats_daily_val_until_1").
   667 			hbTrId("txt_calendar_dblist_repeats_daily_val_until_1").
   720 			arg(untilDateString));
   668 			arg(untilDateString));
   721 	}
   669 	}
   722 	qDebug() << "AgendaEventViewer: AgendaEventView::repeatRule <--";
       
   723 	
   670 	
   724 	return repeatRule;
   671 	return repeatRule;
   725 }
   672 }
   726 
   673 
   727 /*!
   674 /*!
   729 
   676 
   730 	\return QString	Holds the alarm time text.
   677 	\return QString	Holds the alarm time text.
   731  */
   678  */
   732 QString AgendaEventView::alarmTimeText() const
   679 QString AgendaEventView::alarmTimeText() const
   733 {
   680 {
   734 	qDebug() << "AgendaEventViewer: AgendaEventView::alarmTimeText -->";
       
   735 
   681 
   736 	QString alarmDateTimeText;
   682 	QString alarmDateTimeText;
   737 	QDateTime startTime;
   683 	QDateTime startTime;
   738 	QDateTime alarmDateTime;
   684 	QDateTime alarmDateTime;
   739 	
   685 	
   754 						r_qtn_time_usual_with_zero)).arg(
   700 						r_qtn_time_usual_with_zero)).arg(
   755 						systemLocale.format(alarmDateTime.date(),
   701 						systemLocale.format(alarmDateTime.date(),
   756 						r_qtn_date_usual_with_zero)));
   702 						r_qtn_date_usual_with_zero)));
   757 	}
   703 	}
   758 	
   704 	
   759 	qDebug() << "AgendaEventViewer: AgendaEventView::alarmTimeText <--";
       
   760 	return alarmDateTimeText;
   705 	return alarmDateTimeText;
   761 }
   706 }
   762 
   707 
   763 /*!
   708 /*!
   764 	Remove unnecessary widget from layout.
   709 	Remove unnecessary widget from layout.
   765  */
   710  */
   766 void AgendaEventView::removeWidget()
   711 void AgendaEventView::removeWidget()
   767 {
   712 {
   768 	qDebug() << "AgendaEventViewer: AgendaEventView::removeWidget -->";
       
   769 	
   713 	
   770 	if (mAgendaEntry.location().isEmpty()) { 
   714 	if (mAgendaEntry.location().isEmpty()) { 
   771 		mLocationWidget->hide();
   715 		mLocationWidget->hide();
   772 		mLinearLayout->removeItem(mLocationWidget);
   716 		mLinearLayout->removeItem(mLocationWidget);
   773 	}
   717 	}
   781     }
   725     }
   782     file.close();
   726     file.close();
   783         
   727         
   784 	if (mAgendaEntry.alarm().isNull()) { 
   728 	if (mAgendaEntry.alarm().isNull()) { 
   785 		if (mAgendaEntry.type() == AgendaEntry::TypeTodo ) {
   729 		if (mAgendaEntry.type() == AgendaEntry::TypeTodo ) {
   786 				if (AgendaEntry::TodoNeedsAction == mAgendaEntry.status()) { 
   730 				if (AgendaEntry::TodoCompleted != mAgendaEntry.status()) { 
   787 					mReminderWidget->hide();
   731 					mReminderWidget->hide();
   788 					mLinearLayout->removeItem(mReminderWidget);
   732 					mLinearLayout->removeItem(mReminderWidget);
   789 					mReminderWidgetAdded = false;
   733 					mReminderWidgetAdded = false;
   790 				}
   734 				}
   791 		} else { 
   735 		} else { 
   806 	}
   750 	}
   807 	
   751 	
   808 	mLinearLayout->invalidate();
   752 	mLinearLayout->invalidate();
   809 	mLinearLayout->activate();
   753 	mLinearLayout->activate();
   810 	
   754 	
   811 	qDebug() << "AgendaEventViewer: AgendaEventView::removeWidget <--";
       
   812 }
   755 }
   813 
   756 
   814 /*!
   757 /*!
   815 	Update the completed to-do or reminder data to event viewer.
   758 	Update the completed to-do or reminder data to event viewer.
   816  */
   759  */
   817 void AgendaEventView::updateCompletedReminderData()
   760 void AgendaEventView::updateCompletedReminderData()
   818 {
   761 {
   819 	qDebug()
       
   820 	   << "AgendaEventViewer: AgendaEventView::updateCompletedReminderData -->";
       
   821 
   762 
   822 	if (AgendaEntry::TodoCompleted == mAgendaEntry.status()) {
   763 	if (AgendaEntry::TodoCompleted == mAgendaEntry.status()) {
   823 		addCompletedTodoData();
   764 		addCompletedTodoData();
   824 		if (!mReminderWidgetAdded) {
   765 		if (!mReminderWidgetAdded) {
   825 			mReminderWidget->show();
   766 			mReminderWidget->show();
   845 
   786 
   846 	}
   787 	}
   847 	
   788 	
   848 	mLinearLayout->invalidate();
   789 	mLinearLayout->invalidate();
   849 	mLinearLayout->activate();
   790 	mLinearLayout->activate();
   850 	qDebug()
       
   851 	   << "AgendaEventViewer: AgendaEventView::updateCompletedReminderData <--";
       
   852 }
   791 }
   853 
   792 
   854 /*!
   793 /*!
   855 	Remove all widgets from layout.
   794 	Remove all widgets from layout.
   856  */
   795  */
   857 void AgendaEventView::removeAllWidgets()
   796 void AgendaEventView::removeAllWidgets()
   858 {
   797 {
   859 	qDebug() << "AgendaEventViewer: AgendaEventView::removeAllWidgets -->";
       
   860 
   798 
   861 	for (int i = 2; i < mLinearLayout->count(); i++) {
   799 	for (int i = 2; i < mLinearLayout->count(); i++) {
   862 		mLinearLayout->removeAt(i);
   800 		mLinearLayout->removeAt(i);
   863 	}
   801 	}
   864 	mLinearLayout->invalidate();
   802 	mLinearLayout->invalidate();
   865 	mLinearLayout->activate();
   803 	mLinearLayout->activate();
   866 	
   804 	
   867 	qDebug() << "AgendaEventViewer: AgendaEventView::removeAllWidgets <--";
       
   868 }
   805 }
   869 
   806 
   870 /*!
   807 /*!
   871 	Add all widgets to layout.
   808 	Add all widgets to layout.
   872  */
   809  */
   873 void AgendaEventView::addAllWidgets()
   810 void AgendaEventView::addAllWidgets()
   874 {
   811 {
   875 	qDebug() << "AgendaEventViewer: AgendaEventView::addAllWidgets -->";
       
   876 	
   812 	
   877 	mLinearLayout->addItem(mLocationWidget);
   813 	mLinearLayout->addItem(mLocationWidget);
   878 	mLocationWidget->show();
   814 	mLocationWidget->show();
   879 	mLinearLayout->addItem(mMaptileLabel);
   815 	mLinearLayout->addItem(mMaptileLabel);
   880 	mMaptileLabel->show();		
   816 	mMaptileLabel->show();		
   886 	mDescriptionWidget->show();
   822 	mDescriptionWidget->show();
   887 	
   823 	
   888 	mLinearLayout->invalidate();
   824 	mLinearLayout->invalidate();
   889 	mLinearLayout->activate();
   825 	mLinearLayout->activate();
   890 	
   826 	
   891 	qDebug() << "AgendaEventViewer: AgendaEventView::addAllWidgets <--";
       
   892 }
   827 }
   893 
   828 
   894 /*!
   829 /*!
   895 	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
   896  */
   831  */
   897 void AgendaEventView::showDeleteOccurencePopup()
   832 void AgendaEventView::showDeleteOccurencePopup()
   898 {
   833 {
   899 	qDebug()
       
   900 		<< "AgendaEventViewer: AgendaEventView::showDeleteOccurencePopup -->";
       
   901 	HbDialog *popUp = new HbDialog();
   834 	HbDialog *popUp = new HbDialog();
   902 	popUp->setDismissPolicy(HbDialog::NoDismiss);
   835 	popUp->setDismissPolicy(HbDialog::NoDismiss);
   903 	popUp->setTimeout(HbDialog::NoTimeout);
   836 	popUp->setTimeout(HbDialog::NoTimeout);
   904 	popUp->setAttribute( Qt::WA_DeleteOnClose, true );
   837 	popUp->setAttribute( Qt::WA_DeleteOnClose, true );
   905 
   838 
   929 			hbTrId("txt_calendar_button_softkey1_cancel")));
   862 			hbTrId("txt_calendar_button_softkey1_cancel")));
   930 
   863 
   931 	// Show the popup
   864 	// Show the popup
   932 	popUp->open();
   865 	popUp->open();
   933 
   866 
   934 	qDebug()
       
   935 		<< "AgendaEventViewer: AgendaEventView::showDeleteOccurencePopup <--";
       
   936 }
   867 }
   937 
   868 
   938 /*!
   869 /*!
   939 	Show delete confirmation query
   870 	Show delete confirmation query
   940  */
   871  */
   941 void AgendaEventView::showDeleteConfirmationQuery()
   872 void AgendaEventView::showDeleteConfirmationQuery()
   942     {
   873     {
   943     qDebug()
       
   944 		<< "AgendaEventViewer: AgendaEventView::showDeleteConfirmationQuery -->";
       
   945     
   874     
   946     HbMessageBox *popup = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
   875     HbMessageBox *popup = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
   947     popup->setDismissPolicy(HbDialog::NoDismiss);
   876     popup->setDismissPolicy(HbDialog::NoDismiss);
   948     popup->setTimeout(HbDialog::NoTimeout);
   877     popup->setTimeout(HbDialog::NoTimeout);
   949     popup->setAttribute( Qt::WA_DeleteOnClose, true );
   878     popup->setAttribute( Qt::WA_DeleteOnClose, true );
   981     popup->addAction(deleteAction);
   910     popup->addAction(deleteAction);
   982     connect(deleteAction, SIGNAL(triggered()), this ,
   911     connect(deleteAction, SIGNAL(triggered()), this ,
   983 												SLOT(handleDeleteAction()));
   912 												SLOT(handleDeleteAction()));
   984     popup->addAction(new HbAction(hbTrId("txt_calendar_button_cancel"), popup));
   913     popup->addAction(new HbAction(hbTrId("txt_calendar_button_cancel"), popup));
   985     popup->open();
   914     popup->open();
   986     qDebug()
       
   987 		<< "AgendaEventViewer: AgendaEventView::showDeleteConfirmationQuery <--";
       
   988 }
   915 }
   989 
   916 
   990 /*!
   917 /*!
   991 	Handles the delete action
   918 	Handles the delete action
   992  */
   919  */
  1004 /*!
   931 /*!
  1005 	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.
  1006  */
   933  */
  1007 void AgendaEventView::markTodoStatus()
   934 void AgendaEventView::markTodoStatus()
  1008 {
   935 {
  1009 	qDebug() << "AgendaEventViewer: AgendaEventView::markTodoStatus -->";
       
  1010 
   936 
  1011 	QDateTime currentDateTime = QDateTime::currentDateTime();
   937 	QDateTime currentDateTime = QDateTime::currentDateTime();
  1012 
   938 
  1013 	// Set the to-do status using the agenda util.
   939 	// Set the to-do status using the agenda util.
  1014 	if (AgendaEntry::TodoNeedsAction == mAgendaEntry.status()) {
   940 	if (AgendaEntry::TodoCompleted != mAgendaEntry.status()) {
  1015 		
       
  1016 		// Update the menu text to mark to-do as undone.
   941 		// Update the menu text to mark to-do as undone.
  1017 		mMarkTodoAction->setText(hbTrId("txt_calendar_menu_mark_as_not_done"));
   942 		mMarkTodoAction->setText(hbTrId("txt_calendar_menu_mark_as_not_done"));
  1018 		
       
  1019 		mAgendaEntry.setStatus(AgendaEntry::TodoCompleted);
   943 		mAgendaEntry.setStatus(AgendaEntry::TodoCompleted);
  1020 		mAgendaEntry.setCompletedDateTime(currentDateTime);
   944 		mAgendaEntry.setCompletedDateTime(currentDateTime);
  1021 		mOwner->mAgendaUtil->setCompleted(mAgendaEntry, true, currentDateTime);
   945 		mOwner->mAgendaUtil->setCompleted(mAgendaEntry, true, currentDateTime);
  1022 		
   946 	} else {
  1023 		
       
  1024 
       
  1025 	} else if (AgendaEntry::TodoCompleted == mAgendaEntry.status()) {
       
  1026 		
   947 		
  1027 		// Update the menu text to mark to-do as done.
   948 		// Update the menu text to mark to-do as done.
  1028 		mMarkTodoAction->setText(hbTrId("txt_calendar_menu_mark_as_done"));
   949 		mMarkTodoAction->setText(hbTrId("txt_calendar_menu_mark_as_done"));
  1029 				
       
  1030 		mAgendaEntry.setStatus(AgendaEntry::TodoNeedsAction);
   950 		mAgendaEntry.setStatus(AgendaEntry::TodoNeedsAction);
  1031 		mOwner->mAgendaUtil->setCompleted(mAgendaEntry, false, currentDateTime);
   951 		mOwner->mAgendaUtil->setCompleted(mAgendaEntry, false, currentDateTime);
  1032 		
       
  1033 		
       
  1034 	}
   952 	}
  1035 
   953 
  1036 	updateCompletedReminderData();
   954 	updateCompletedReminderData();
  1037 	
   955 	
  1038 	qDebug() << "AgendaEventViewer: AgendaEventView::markTodoStatus <--";
       
  1039 }
   956 }
  1040 
   957 
  1041 /*!
   958 /*!
  1042 	Edits the agenda entry by lanching the to-do viewer.
   959 	Edits the agenda entry by lanching the to-do viewer.
  1043  */
   960  */
  1044 void AgendaEventView::edit()
   961 void AgendaEventView::edit()
  1045 {
   962 {
  1046 	qDebug() << "AgendaEventViewer: AgendaEventView::edit -->";
       
  1047 
   963 
  1048 	mOwner->editingStarted();
   964 	mOwner->editingStarted();
  1049 	
   965 	
  1050 	if (AgendaEntry::TypeTodo == mAgendaEntry.type()) {
   966 	if (AgendaEntry::TypeTodo == mAgendaEntry.type()) {
  1051 		// Load notes editor plugin if not loaded.
   967 		// Load notes editor plugin if not loaded.
  1080 		                        this, SLOT(handleCalendarEditorClosed()));
   996 		                        this, SLOT(handleCalendarEditorClosed()));
  1081 		mCalenEditor->edit(mAgendaEntry, false);
   997 		mCalenEditor->edit(mAgendaEntry, false);
  1082 	
   998 	
  1083 		
   999 		
  1084 	}
  1000 	}
  1085 	qDebug() << "AgendaEventViewer: AgendaEventView::edit <--";
       
  1086 }
  1001 }
  1087 
  1002 
  1088 /*!
  1003 /*!
  1089 	Deletes the agenda entry.
  1004 	Deletes the agenda entry.
  1090  */
  1005  */
  1091 void AgendaEventView::deleteAgendaEntry()
  1006 void AgendaEventView::deleteAgendaEntry()
  1092 {
  1007 {
  1093 	qDebug() << "AgendaEventViewer: AgendaEventView::deleteAgendaEntry -->";
       
  1094 
  1008 
  1095 	// Before we do anything, check in the entry is repeating
  1009 	// Before we do anything, check in the entry is repeating
  1096 	// OR its a child item
  1010 	// OR its a child item
  1097 	bool isChild = !(mAgendaEntry.recurrenceId().isNull());
  1011 	bool isChild = !(mAgendaEntry.recurrenceId().isNull());
  1098 	bool isRepeating = mAgendaEntry.isRepeating();
  1012 	bool isRepeating = mAgendaEntry.isRepeating();
  1103 		showDeleteOccurencePopup();
  1017 		showDeleteOccurencePopup();
  1104 	} else {
  1018 	} else {
  1105         showDeleteConfirmationQuery();
  1019         showDeleteConfirmationQuery();
  1106 	}
  1020 	}
  1107 
  1021 
  1108 	qDebug() << "AgendaEventViewer: AgendaEventView::deleteAgendaEntry <--";
       
  1109 }
  1022 }
  1110 
  1023 
  1111 /*!
  1024 /*!
  1112 	Save the agenda entry to calendar db.
  1025 	Save the agenda entry to calendar db.
  1113  */
  1026  */
  1114 void AgendaEventView::saveAgendaEntry()
  1027 void AgendaEventView::saveAgendaEntry()
  1115 {
  1028 {
  1116 	qDebug() << "AgendaEventViewer: AgendaEventView::saveAgendaEntry -->";
       
  1117 	
  1029 	
  1118 	// Save entry to calendar.
  1030 	// Save entry to calendar.
  1119 	mOwner->mAgendaUtil->addEntry(mAgendaEntry);
  1031 	mOwner->mAgendaUtil->addEntry(mAgendaEntry);
  1120 	
  1032 	
  1121 	// Close the agenda entry viewer
  1033 	// Close the agenda entry viewer
  1122 	close();
  1034 	close();
  1123 	qDebug() << "AgendaEventViewer: AgendaEventView::saveAgendaEntry <--";
       
  1124 }
  1035 }
  1125 /*!
  1036 /*!
  1126 	Closes the event viewer
  1037 	Closes the event viewer
  1127  */
  1038  */
  1128 void AgendaEventView::close()
  1039 void AgendaEventView::close()
  1129 {
  1040 {
  1130 	qDebug() << "AgendaEventViewer: AgendaEventView::close -->";
       
  1131 
  1041 
  1132 	// Remove the view from main window.
  1042 	// Remove the view from main window.
  1133 	HbMainWindow *window = hbInstance->allMainWindows().first();
  1043 	HbMainWindow *window = hbInstance->allMainWindows().first();
  1134 
  1044 
  1135 	// Cleanup.
  1045 	// Cleanup.
  1138 			this, SLOT(close()));
  1048 			this, SLOT(close()));
  1139 
  1049 
  1140 	window->removeView(mViewer);
  1050 	window->removeView(mViewer);
  1141 	mOwner->viewingCompleted(mAgendaEntry.startTime().date());
  1051 	mOwner->viewingCompleted(mAgendaEntry.startTime().date());
  1142 
  1052 
  1143 	qDebug() << "AgendaEventViewer: AgendaEventView::close <--";
       
  1144 }
  1053 }
  1145 
  1054 
  1146 /*!
  1055 /*!
  1147 	Handles entry updation of the event entry.
  1056 	Handles entry updation of the event entry.
  1148  */
  1057  */
  1149 void AgendaEventView::handleEntryUpdation(ulong id)
  1058 void AgendaEventView::handleEntryUpdation(ulong id)
  1150 {
  1059 {
  1151 	qDebug() << "AgendaEventViewer: AgendaEventView::handleEntryUpdation -->";
       
  1152 
  1060 
  1153 	AgendaEntry updatedEntry = mOwner->mAgendaUtil->fetchById(id);
  1061 	AgendaEntry updatedEntry = mOwner->mAgendaUtil->fetchById(id);
  1154 
  1062 
  1155 	// 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
  1156 	if (!updatedEntry.isNull()) {
  1064 	if (!updatedEntry.isNull()) {
  1192 	} else {
  1100 	} else {
  1193 		// Close the agenda entry viewer
  1101 		// Close the agenda entry viewer
  1194 		close();
  1102 		close();
  1195 	}
  1103 	}
  1196 
  1104 
  1197 	qDebug() << "AgendaEventViewer: AgendaEventView::handleEntryUpdation <--";
       
  1198 }
  1105 }
  1199 
  1106 
  1200 /*!
  1107 /*!
  1201 	Handles the entry deletion of the agenda entry
  1108 	Handles the entry deletion of the agenda entry
  1202 */
  1109 */
  1203 void AgendaEventView::handleEntryDeletion(ulong id)
  1110 void AgendaEventView::handleEntryDeletion(ulong id)
  1204 {
  1111 {
  1205 	qDebug() <<"AgendaEventViewer: AgendaEventView::handleEntryDeletion -->";
       
  1206 
  1112 
  1207 	if (id == mAgendaEntry.id()) {
  1113 	if (id == mAgendaEntry.id()) {
  1208 		// Close the agenda entry viewer
  1114 		// Close the agenda entry viewer
  1209 		close();
  1115 		close();
  1210 		mOwner->deletingCompleted();
  1116 		mOwner->deletingCompleted();
  1211 	}
  1117 	}
  1212 
  1118 
  1213 	qDebug() <<"AgendaEventViewer: AgendaEventView::handleEntryDeletion <--";
       
  1214 }
  1119 }
  1215 
  1120 
  1216 /*!
  1121 /*!
  1217 	Handles the Note Editor editing completion of the agenda entry
  1122 	Handles the Note Editor editing completion of the agenda entry
  1218  */
  1123  */
  1219 void AgendaEventView::handleNoteEditorClosed(bool status)
  1124 void AgendaEventView::handleNoteEditorClosed(bool status)
  1220 {
  1125 {
  1221 	Q_UNUSED(status);
  1126 	Q_UNUSED(status);
  1222 	qDebug() <<"AgendaEventViewer: AgendaEventView::handleNoteEditorClosed -->";
       
  1223 
  1127 
  1224 	// To avoid loading the plugin again for editing,
  1128 	// To avoid loading the plugin again for editing,
  1225 	// Unload the plug-in while destruction.
  1129 	// Unload the plug-in while destruction.
  1226 
  1130 
  1227 	mOwner->editingCompleted();
  1131 	mOwner->editingCompleted();
  1228 
  1132 
  1229 	qDebug() <<"AgendaEventViewer: AgendaEventView::handleNoteEditorClosed <--";
       
  1230 }
  1133 }
  1231 
  1134 
  1232 /*!
  1135 /*!
  1233 	Handles the Note Editor editing completion of the agenda entry
  1136 	Handles the Note Editor editing completion of the agenda entry
  1234  */
  1137  */
  1235 void AgendaEventView::handleCalendarEditorClosed()
  1138 void AgendaEventView::handleCalendarEditorClosed()
  1236 {
  1139 {
  1237 	qDebug() 
       
  1238 		<<"AgendaEventViewer: AgendaEventView::handleCalendarEditorClosed -->";
       
  1239 
  1140 
  1240 	// Cleanup.
  1141 	// Cleanup.
  1241 	mCalenEditor->deleteLater();
  1142 	mCalenEditor->deleteLater();
  1242 	mOwner->editingCompleted();
  1143 	mOwner->editingCompleted();
  1243 
  1144 
  1244 	qDebug() 
       
  1245 		<<"AgendaEventViewer: AgendaEventView::handleCalendarEditorClosed <--";
       
  1246 }
  1145 }
  1247 
  1146 
  1248 /*!
  1147 /*!
  1249 	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
  1250  */
  1149  */
  1251 void AgendaEventView::handleDeleteOccurence(int index)
  1150 void AgendaEventView::handleDeleteOccurence(int index)
  1252 {
  1151 {
  1253 	qDebug() << "AgendaEventViewer: AgendaEventView::handleDeleteOccurence -->";
       
  1254 	
  1152 	
  1255 	// To notify client that deleting Started
  1153 	// To notify client that deleting Started
  1256 	// Calendar Application changing state from viewing to deleting.
  1154 	// Calendar Application changing state from viewing to deleting.
  1257 	mOwner->deletingStarted();
  1155 	mOwner->deletingStarted();
  1258 	
  1156 	
  1268 			mOwner->mAgendaUtil->deleteRepeatedEntry(mAgendaEntry,
  1166 			mOwner->mAgendaUtil->deleteRepeatedEntry(mAgendaEntry,
  1269 			                                         AgendaUtil::ThisAndAll);
  1167 			                                         AgendaUtil::ThisAndAll);
  1270 			break;
  1168 			break;
  1271 	}
  1169 	}
  1272 
  1170 
  1273 	qDebug() << "AgendaEventViewer: AgendaEventView::handleDeleteOccurence <--";
       
  1274 }
  1171 }
  1275 
  1172 
  1276 /*!
  1173 /*!
  1277     Returns subject icon
  1174     Returns subject icon
  1278  */
  1175  */
  1279 void AgendaEventView::getSubjectIcon(AgendaEntry::Type type, QString &subjectIcon)
  1176 void AgendaEventView::getSubjectIcon(AgendaEntry::Type type, QString &subjectIcon)
  1280     {
  1177     {
  1281     qDebug() << "AgendaEventViewer: AgendaEventView::getSubjectIcon -->";
       
  1282     switch(type) {
  1178     switch(type) {
  1283         case AgendaEntry::TypeAppoinment:
  1179         case AgendaEntry::TypeAppoinment:
  1284             {
  1180             {
  1285             subjectIcon.append("qtg_small_favorite");//@to do add proper icon
  1181             subjectIcon.append("qtg_small_meeting");
  1286             }
  1182             }
  1287             break;
  1183             break;
  1288         case AgendaEntry::TypeTodo:
  1184         case AgendaEntry::TypeTodo:
  1289             {
  1185             {
  1290             subjectIcon.append("qtg_small_todo");
  1186             subjectIcon.append("qtg_small_todo");
  1302             break;
  1198             break;
  1303         default:
  1199         default:
  1304             break;
  1200             break;
  1305     }
  1201     }
  1306 
  1202 
  1307     qDebug() << "AgendaEventViewer: AgendaEventView::getSubjectIcon <--";
       
  1308     }
  1203     }
  1309 
  1204 
  1310 /*!
  1205 /*!
  1311     According to maptile fetching status , update the viewer screen.
  1206     According to maptile fetching status , update the viewer screen.
  1312  */
  1207  */
  1333             itemData.append(QString::null);
  1228             itemData.append(QString::null);
  1334             itemData.append(QString::null);
  1229             itemData.append(QString::null);
  1335             itemData.append("qtg_small_location");
  1230             itemData.append("qtg_small_location");
  1336             mLocationWidget->setProperty(primaryLeftIconItem, false);
  1231             mLocationWidget->setProperty(primaryLeftIconItem, false);
  1337             mLocationWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
  1232             mLocationWidget->setEventViewerItemData(itemData, Qt::DecorationRole);
  1338             MapTileService::AddressType addressType;
  1233             Qt::Orientations orientation=hbInstance->allMainWindows().first()->orientation();
  1339             addressType = MapTileService::AddressPlain;
  1234             mMaptilePath.clear();
  1340             int eventId = mAgendaEntry.id();
  1235             mMaptileStatus = mMaptileService->getMapTileImage(mAgendaEntry.id(), MapTileService::AddressPlain, mMaptilePath ,orientation);
  1341             mMaptileService->getMapTileImage(eventId, addressType, mMaptilePath);
       
  1342             addMapTileImage();
  1236             addMapTileImage();
  1343             QFile file(mMaptilePath);
  1237             QFile file(mMaptilePath);
  1344             if (file.exists()) {
  1238             if (file.exists()) {
  1345                 //add to linear layout  
  1239                 //add to linear layout  
  1346                 int indexMaptileLabel = 3;
  1240                 int indexMaptileLabel = 3;// index of maptile widget position
  1347                 mLinearLayout->insertItem(indexMaptileLabel, mMaptileLabel);
  1241                 mLinearLayout->insertItem(indexMaptileLabel, mMaptileLabel);
  1348                 mMaptileLabel->show();
  1242                 mMaptileLabel->show();
  1349             }
  1243             }
  1350             file.close();
  1244             file.close();
  1351 
  1245 
  1383 {
  1277 {
  1384     MapTileService::AddressType addressType;
  1278     MapTileService::AddressType addressType;
  1385     addressType = MapTileService::AddressPlain;
  1279     addressType = MapTileService::AddressPlain;
  1386     int eventId = mAgendaEntry.id();
  1280     int eventId = mAgendaEntry.id();
  1387     mMaptilePath.clear();
  1281     mMaptilePath.clear();
  1388     int status = 0;
  1282     mMaptileStatus = -1;
  1389     connect(mMaptileService, SIGNAL(maptileFetchingStatusUpdate(int,
  1283     connect(mMaptileService, SIGNAL(maptileFetchingStatusUpdate(int,
  1390             int ,int)), this, SLOT(receiveMapTileStatus(int,int,int)));
  1284             int ,int)), this, SLOT(receiveMapTileStatus(int,int,int)));
  1391     status = mMaptileService->getMapTileImage(eventId, addressType, mMaptilePath);
  1285     Qt::Orientations orientation=hbInstance->allMainWindows().first()->orientation();
  1392     if (status == MapTileService::MapTileFetchingNetworkError || status
  1286     mMaptileStatus = mMaptileService->getMapTileImage(eventId, addressType, mMaptilePath ,orientation);    
       
  1287     if (mMaptileStatus == MapTileService::MapTileFetchingNetworkError || mMaptileStatus
  1393         == MapTileService::MapTileFetchingInProgress) {
  1288         == MapTileService::MapTileFetchingInProgress) {
  1394         mMaptilePath.clear();
  1289         mMaptilePath.clear();
  1395         mMaptileStatusReceived = false; //reseting receiving status value
  1290         mMaptileStatusReceived = false; //reseting receiving status value       
  1396         mMaptileStatus = -1;// reseting status value;
       
  1397         progressIcon.append(QString("qtg_anim_small_loading_1"));
  1291         progressIcon.append(QString("qtg_anim_small_loading_1"));
  1398         mProgressTimer->start(100);
  1292         mProgressTimer->start(100);
  1399     }
  1293     }
  1400     else if (status == MapTileService::MapTileFetchingInvalidAddress || status
  1294     else if (mMaptileStatus == MapTileService::MapTileFetchingInvalidAddress || mMaptileStatus
  1401         == MapTileService::MapTileFetchingUnknownError) {
  1295         == MapTileService::MapTileFetchingUnknownError) {
  1402         mMaptilePath.clear();
  1296         mMaptilePath.clear();
  1403         //no further need of this coonnection 
  1297         //no further need of this coonnection 
  1404         disconnect(mMaptileService, SIGNAL(maptileFetchingStatusUpdate(int,
  1298         disconnect(mMaptileService, SIGNAL(maptileFetchingStatusUpdate(int,
  1405                 int ,int)), this, SLOT(receiveMapTileStatus(int,int,int)));
  1299                 int ,int)), this, SLOT(receiveMapTileStatus(int,int,int)));
  1410         disconnect(mMaptileService, SIGNAL(maptileFetchingStatusUpdate(int,
  1304         disconnect(mMaptileService, SIGNAL(maptileFetchingStatusUpdate(int,
  1411                 int ,int)), this, SLOT(receiveMapTileStatus(int,int,int)));
  1305                 int ,int)), this, SLOT(receiveMapTileStatus(int,int,int)));
  1412         progressIcon.append(QString::null);
  1306         progressIcon.append(QString::null);
  1413     }
  1307     }
  1414 }
  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     }
       
  1319 }
       
  1320 
  1415 // End of file
  1321 // End of file