calendarui/calenplugins/agendaeventviewerplugin/src/agendaeventviewerplugin.cpp
branchRCL_3
changeset 65 12af337248b1
equal deleted inserted replaced
60:96907930389d 65:12af337248b1
       
     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: Definition of AgendaEventViewerPlugin class
       
    15 *
       
    16 */
       
    17 
       
    18 // User Includes.
       
    19 #include "agendaeventviewerplugin.h"
       
    20 #include <agendaentry.h>
       
    21 
       
    22 /*!
       
    23 	\class AgendaEventViewerPlugin
       
    24 
       
    25 	To view entry in agenda event viewer plugin.
       
    26 	To delete this class object use deleteLater().
       
    27  */
       
    28 
       
    29 /*!
       
    30 	\fn void AgendaEventViewerPlugin::viewingCompleted(const QDate date = QDate())
       
    31 
       
    32 	Signal is emitted when viewing of the agenda entry is complete
       
    33 	Returns QDate for calendar application so it has proper context to set.
       
    34 	After receiving this signal use deleteLater() to detele this class object.
       
    35 
       
    36  */
       
    37 
       
    38 /*!
       
    39 	\fn void AgendaEventViewerPlugin::editingStarted()
       
    40 
       
    41 	Signal is emitted when editing of the agenda entry is start
       
    42 
       
    43  */
       
    44 
       
    45 /*!
       
    46 	\fn void AgendaEventViewerPlugin::editingCompleted()
       
    47 
       
    48 	Signal is emitted when editing of the agenda entry is complete
       
    49 
       
    50  */
       
    51 
       
    52 /*!
       
    53 	\fn void AgendaEventViewerPlugin::deletingStarted()
       
    54 
       
    55 	Signal is emitted when deleting of the agenda entry is start
       
    56 
       
    57  */
       
    58 
       
    59 /*!
       
    60 	\fn void AgendaEventViewerPlugin::deletingCompleted()
       
    61 
       
    62 	Signal is emitted when deleting of the agenda entry is complete
       
    63 
       
    64  */
       
    65 
       
    66 /*!
       
    67 	Constructor.
       
    68 
       
    69 	\param parent Pointer to QObject.
       
    70  */
       
    71 AgendaEventViewerPlugin::AgendaEventViewerPlugin(QObject *parent)
       
    72 :mEventViewer(NULL)
       
    73 {
       
    74 Q_UNUSED(parent)
       
    75 }
       
    76 
       
    77 /*!
       
    78 	Destructor.
       
    79  */
       
    80 AgendaEventViewerPlugin::~AgendaEventViewerPlugin()
       
    81 {
       
    82 }
       
    83 
       
    84 /*!
       
    85 	Launches the event viewer.Id is used for fetching
       
    86 	the calendar entry information.
       
    87 
       
    88 	\param id Local Uid of the calendar entry to be viewed
       
    89  */
       
    90 void AgendaEventViewerPlugin::viewEvent(const ulong id,
       
    91                                         Actions action,
       
    92                                         AgendaUtil *agendaUtil)
       
    93 {
       
    94 	CreateAgendaEventViewer(agendaUtil);
       
    95 
       
    96 	AgendaEventViewer::Actions eventviewerAction =
       
    97 	        CreateAgendaEventViewerAction(action);
       
    98 	if (mEventViewer) {
       
    99 		mEventViewer->view(id, eventviewerAction);
       
   100 	}
       
   101 }
       
   102 
       
   103 /*!
       
   104 	Launches the event viewer.File handle of any vcs/ics file can be given as 
       
   105 	input to view the calendar entry information.
       
   106 
       
   107 	\param fileHandle reference to the file handle of vcs/ics file
       
   108  */
       
   109 void AgendaEventViewerPlugin::viewEvent(const QFile &fileHandle,
       
   110                                         Actions action,
       
   111                                         AgendaUtil *agendaUtil)
       
   112 {
       
   113 	CreateAgendaEventViewer(agendaUtil);
       
   114 	AgendaEventViewer::Actions eventviewerAction =
       
   115 	        CreateAgendaEventViewerAction(action);
       
   116 	if (mEventViewer) {
       
   117 		mEventViewer->view(fileHandle, eventviewerAction);
       
   118 	}
       
   119 }
       
   120 
       
   121 /*!
       
   122 	Launches the event viewer.
       
   123 	AgendaEntry can be given as input to view the calendar entry information.
       
   124 	
       
   125 	\param entry Object of calendar entry to be viewed
       
   126  */
       
   127 void AgendaEventViewerPlugin::viewEvent(AgendaEntry entry,
       
   128                                         Actions action,
       
   129                                         AgendaUtil *agendaUtil)
       
   130 {
       
   131 	CreateAgendaEventViewer(agendaUtil);
       
   132 	AgendaEventViewer::Actions eventviewerAction =
       
   133 	        CreateAgendaEventViewerAction(action);
       
   134 	if (mEventViewer) {
       
   135 		mEventViewer->view(entry, eventviewerAction);
       
   136 	}
       
   137 }
       
   138 
       
   139 /*!
       
   140 	Create a Agenda Interface pointer
       
   141 	\param agendaUtil Pointer of AgendaUtil
       
   142 	\return Return Pointer of AgendaEventViewer
       
   143  */
       
   144 void AgendaEventViewerPlugin::CreateAgendaEventViewer(
       
   145 														AgendaUtil *agendaUtil)
       
   146 {
       
   147 	if (agendaUtil) {
       
   148 		mEventViewer = new AgendaEventViewer(agendaUtil, this);
       
   149 	} else {
       
   150 		mEventViewer = new AgendaEventViewer(this);
       
   151 	}
       
   152 
       
   153 	if (mEventViewer) {
       
   154 		connect(mEventViewer, SIGNAL(viewingCompleted(const QDate)), this,
       
   155 		        SLOT(handleViewingCompleted(const QDate)));
       
   156 		connect(mEventViewer, SIGNAL(editingStarted()), this,
       
   157 		        SLOT(handleEditingStarted()));
       
   158 		connect(mEventViewer, SIGNAL(editingCompleted()), this,
       
   159 		        SLOT(handleEditingCompleted()));
       
   160 		connect(mEventViewer, SIGNAL(deletingStarted()), this,
       
   161 		        SLOT(handleDeletingStarted()));
       
   162 		connect(mEventViewer, SIGNAL(deletingCompleted()), this,
       
   163 		        SLOT(handleDeletingCompleted()));
       
   164 	}
       
   165 }
       
   166 
       
   167 /*!
       
   168 	Create AgendaEventViewer Action enum from EventViewerPluginInterface Action enum
       
   169 	\param action EventViewerPluginInterface Action enum
       
   170 	\return Return AgendaEventViewer Action enum
       
   171  */
       
   172 AgendaEventViewer::Actions AgendaEventViewerPlugin::
       
   173 								CreateAgendaEventViewerAction(Actions action)
       
   174 {
       
   175 	switch (action) {
       
   176 		case EventViewerPluginInterface::ActionEdit:
       
   177 			return AgendaEventViewer::ActionEdit;
       
   178 		case EventViewerPluginInterface::ActionDelete:
       
   179 			return AgendaEventViewer::ActionDelete;
       
   180 		case EventViewerPluginInterface::ActionEditDelete:
       
   181 			return AgendaEventViewer::ActionEditDelete;
       
   182 		case EventViewerPluginInterface::ActionSave:
       
   183 			return AgendaEventViewer::ActionSave;
       
   184 	}
       
   185 	
       
   186 	return AgendaEventViewer::ActionNothing;
       
   187 }
       
   188 
       
   189 /*!
       
   190     Emits the signal viewing completed to the clients
       
   191 
       
   192     \param status true if viewing completed otherwise false.
       
   193  */
       
   194 void AgendaEventViewerPlugin::handleViewingCompleted(const QDate date)
       
   195 {
       
   196 	emit viewingCompleted(date);
       
   197 
       
   198 	// Cleanup viewer.
       
   199 	if (mEventViewer) {
       
   200 		mEventViewer->deleteLater();
       
   201 	}
       
   202 
       
   203 }
       
   204 
       
   205 /*!
       
   206     Emits the signal editing started to the clients
       
   207  */
       
   208 void AgendaEventViewerPlugin::handleEditingStarted()
       
   209 {
       
   210 	emit editingStarted();
       
   211 }
       
   212 
       
   213 /*!
       
   214     Emits the signal editing completed to the clients
       
   215  */
       
   216 void AgendaEventViewerPlugin::handleEditingCompleted()
       
   217 {
       
   218 	emit editingCompleted();
       
   219 }
       
   220 
       
   221 /*!
       
   222     Emits the signal deleting started to the clients
       
   223  */
       
   224 void AgendaEventViewerPlugin::handleDeletingStarted()
       
   225 {
       
   226 	emit deletingStarted();
       
   227 }
       
   228 
       
   229 /*!
       
   230     Emits the signal deleting completed to the clients
       
   231  */
       
   232 void AgendaEventViewerPlugin::handleDeletingCompleted()
       
   233 {
       
   234 	emit deletingCompleted();
       
   235 }
       
   236 
       
   237 Q_EXPORT_PLUGIN2(agendaeventviewerplugin, AgendaEventViewerPlugin)
       
   238 
       
   239 // End of file