calendarui/calenplugins/agendaeventviewerplugin/src/agendaeventviewerplugin.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: 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(bool status = true)
       
    31 
       
    32 	Signal is emitted when viewing of the agenda entry is complete
       
    33 	After receiving this signal use deleteLater() to detele this class object.
       
    34 
       
    35  */
       
    36 
       
    37 /*!
       
    38 	\fn void AgendaEventViewerPlugin::editingStarted()
       
    39 
       
    40 	Signal is emitted when editing of the agenda entry is start
       
    41 
       
    42  */
       
    43 
       
    44 /*!
       
    45 	\fn void AgendaEventViewerPlugin::editingCompleted()
       
    46 
       
    47 	Signal is emitted when editing of the agenda entry is complete
       
    48 
       
    49  */
       
    50 
       
    51 /*!
       
    52 	\fn void AgendaEventViewerPlugin::deletingStarted()
       
    53 
       
    54 	Signal is emitted when deleting of the agenda entry is start
       
    55 
       
    56  */
       
    57 
       
    58 /*!
       
    59 	\fn void AgendaEventViewerPlugin::deletingCompleted()
       
    60 
       
    61 	Signal is emitted when deleting of the agenda entry is complete
       
    62 
       
    63  */
       
    64 
       
    65 /*!
       
    66 	Constructor.
       
    67 
       
    68 	\param parent Pointer to QObject.
       
    69  */
       
    70 AgendaEventViewerPlugin::AgendaEventViewerPlugin(QObject *parent)
       
    71 :mEventViewer(NULL)
       
    72 {
       
    73 Q_UNUSED(parent)
       
    74 }
       
    75 
       
    76 /*!
       
    77 	Destructor.
       
    78  */
       
    79 AgendaEventViewerPlugin::~AgendaEventViewerPlugin()
       
    80 {
       
    81 }
       
    82 
       
    83 /*!
       
    84 	Launches the event viewer.Id is used for fetching
       
    85 	the calendar entry information.
       
    86 
       
    87 	\param id Local Uid of the calendar entry to be viewed
       
    88  */
       
    89 void AgendaEventViewerPlugin::viewEvent(const ulong id,
       
    90                                         Actions action,
       
    91                                         AgendaUtil *agendaUtil)
       
    92 {
       
    93 	CreateAgendaEventViewer(agendaUtil);
       
    94 
       
    95 	AgendaEventViewer::Actions eventviewerAction =
       
    96 	        CreateAgendaEventViewerAction(action);
       
    97 	if (mEventViewer) {
       
    98 		mEventViewer->view(id, eventviewerAction);
       
    99 	}
       
   100 }
       
   101 
       
   102 /*!
       
   103 	Launches the event viewer.File handle of any vcs/ics file can be given as 
       
   104 	input to view the calendar entry information.
       
   105 
       
   106 	\param fileHandle reference to the file handle of vcs/ics file
       
   107  */
       
   108 void AgendaEventViewerPlugin::viewEvent(const QFile &fileHandle,
       
   109                                         Actions action,
       
   110                                         AgendaUtil *agendaUtil)
       
   111 {
       
   112 	CreateAgendaEventViewer(agendaUtil);
       
   113 	AgendaEventViewer::Actions eventviewerAction =
       
   114 	        CreateAgendaEventViewerAction(action);
       
   115 	if (mEventViewer) {
       
   116 		mEventViewer->view(fileHandle, eventviewerAction);
       
   117 	}
       
   118 }
       
   119 
       
   120 /*!
       
   121 	Launches the event viewer.
       
   122 	AgendaEntry can be given as input to view the calendar entry information.
       
   123 	
       
   124 	\param entry Object of calendar entry to be viewed
       
   125  */
       
   126 void AgendaEventViewerPlugin::viewEvent(AgendaEntry entry,
       
   127                                         Actions action,
       
   128                                         AgendaUtil *agendaUtil)
       
   129 {
       
   130 	CreateAgendaEventViewer(agendaUtil);
       
   131 	AgendaEventViewer::Actions eventviewerAction =
       
   132 	        CreateAgendaEventViewerAction(action);
       
   133 	if (mEventViewer) {
       
   134 		mEventViewer->view(entry, eventviewerAction);
       
   135 	}
       
   136 }
       
   137 
       
   138 /*!
       
   139 	Create a Agenda Interface pointer
       
   140 	\param agendaUtil Pointer of AgendaUtil
       
   141 	\return Return Pointer of AgendaEventViewer
       
   142  */
       
   143 void AgendaEventViewerPlugin::CreateAgendaEventViewer(
       
   144 														AgendaUtil *agendaUtil)
       
   145 {
       
   146 	if (agendaUtil) {
       
   147 		mEventViewer = new AgendaEventViewer(agendaUtil, this);
       
   148 	} else {
       
   149 		mEventViewer = new AgendaEventViewer(this);
       
   150 	}
       
   151 
       
   152 	if (mEventViewer) {
       
   153 		connect(mEventViewer, SIGNAL(viewingCompleted(bool)), this,
       
   154 		        SLOT(handleViewingCompleted(bool)));
       
   155 		connect(mEventViewer, SIGNAL(editingStarted()), this,
       
   156 		        SLOT(handleEditingStarted()));
       
   157 		connect(mEventViewer, SIGNAL(editingCompleted()), this,
       
   158 		        SLOT(handleEditingCompleted()));
       
   159 		connect(mEventViewer, SIGNAL(deletingStarted()), this,
       
   160 		        SLOT(handleDeletingStarted()));
       
   161 		connect(mEventViewer, SIGNAL(deletingCompleted()), this,
       
   162 		        SLOT(handleDeletingCompleted()));
       
   163 	}
       
   164 }
       
   165 
       
   166 /*!
       
   167 	Create AgendaEventViewer Action enum from EventViewerPluginInterface Action enum
       
   168 	\param action EventViewerPluginInterface Action enum
       
   169 	\return Return AgendaEventViewer Action enum
       
   170  */
       
   171 AgendaEventViewer::Actions AgendaEventViewerPlugin::
       
   172 								CreateAgendaEventViewerAction(Actions action)
       
   173 {
       
   174 	switch (action) {
       
   175 		case EventViewerPluginInterface::ActionEdit:
       
   176 			return AgendaEventViewer::ActionEdit;
       
   177 		case EventViewerPluginInterface::ActionDelete:
       
   178 			return AgendaEventViewer::ActionDelete;
       
   179 		case EventViewerPluginInterface::ActionEditDelete:
       
   180 			return AgendaEventViewer::ActionEditDelete;
       
   181 		case EventViewerPluginInterface::ActionSave:
       
   182 			return AgendaEventViewer::ActionSave;
       
   183 	}
       
   184 	
       
   185 	return AgendaEventViewer::ActionEditDelete;
       
   186 }
       
   187 
       
   188 /*!
       
   189     Emits the signal viewing completed to the clients
       
   190 
       
   191     \param status true if viewing completed otherwise false.
       
   192  */
       
   193 void AgendaEventViewerPlugin::handleViewingCompleted(bool status)
       
   194 {
       
   195 	Q_UNUSED(status)
       
   196 	emit viewingCompleted();
       
   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