|
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 AgendaEventViewerPrivate class |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes. |
|
19 #include <QFile> |
|
20 #include <QDir> |
|
21 |
|
22 // User includes. |
|
23 #include <agendautil.h> |
|
24 #include <agendaentry.h> |
|
25 #include "agendaeventviewer_p.h" |
|
26 #include "agendaeventviewer.h" |
|
27 #include "agendaeventview.h" |
|
28 #include "OstTraceDefinitions.h" |
|
29 #ifdef OST_TRACE_COMPILER_IN_USE |
|
30 #include "agendaeventviewer_pTraces.h" |
|
31 #endif |
|
32 |
|
33 |
|
34 /*! |
|
35 \class AgendaEventViewerPrivate |
|
36 |
|
37 Private class implementation of AgendaEventViewer.It is responsible for |
|
38 launching the agenda event viewer. |
|
39 */ |
|
40 |
|
41 |
|
42 /*! |
|
43 Constructor |
|
44 |
|
45 \param agendaUtil Pointer to AgendaUtil. |
|
46 \param parent Pointer to QObject. |
|
47 */ |
|
48 AgendaEventViewerPrivate::AgendaEventViewerPrivate( |
|
49 AgendaUtil *agendaUtil, QObject *parent) |
|
50 : QObject(parent),mAction(AgendaEventViewer::ActionNothing),mShowEventViewById(false),mShowEventViewByFileHandle(false),mFileName(NULL) |
|
51 { |
|
52 OstTraceFunctionEntry0( AGENDAEVENTVIEWERPRIVATE_AGENDAEVENTVIEWERPRIVATE_ENTRY ); |
|
53 |
|
54 // Get the q-pointer.from parent |
|
55 q_ptr = static_cast<AgendaEventViewer *> (parent); |
|
56 |
|
57 // Check for agendaUtil sent by client. If null agendaUtil will be |
|
58 // created and owned by AgendaEventViewerPrivate |
|
59 if (!agendaUtil) { |
|
60 mAgendaUtil = new AgendaUtil(parent); |
|
61 mViewerOwnsAgendaUtil = true; |
|
62 } else { |
|
63 mAgendaUtil = agendaUtil; |
|
64 mViewerOwnsAgendaUtil = false; |
|
65 } |
|
66 |
|
67 // Register for the entry change signal when the same entry is updated |
|
68 // by other application.This is to handle the db conflict changes. |
|
69 connect( |
|
70 mAgendaUtil, SIGNAL(entriesChanged(QList<ulong> )), |
|
71 this, SLOT(handleEntriesChanged(QList<ulong> ))); |
|
72 |
|
73 // Register for the calenInstance view creation sucessfully |
|
74 connect( |
|
75 mAgendaUtil, SIGNAL(entryViewCreationCompleted(int)), |
|
76 this, SLOT(viewCreationCompleted(int))); |
|
77 |
|
78 OstTraceFunctionExit0( AGENDAEVENTVIEWERPRIVATE_AGENDAEVENTVIEWERPRIVATE_EXIT ); |
|
79 } |
|
80 |
|
81 /*! |
|
82 Destructor. |
|
83 */ |
|
84 AgendaEventViewerPrivate::~AgendaEventViewerPrivate() |
|
85 { |
|
86 OstTraceFunctionEntry0( DUP1_AGENDAEVENTVIEWERPRIVATE_AGENDAEVENTVIEWERPRIVATE_ENTRY ); |
|
87 |
|
88 if (mViewerOwnsAgendaUtil) { |
|
89 delete mAgendaUtil; |
|
90 mAgendaUtil = 0; |
|
91 } |
|
92 |
|
93 OstTraceFunctionExit0( DUP1_AGENDAEVENTVIEWERPRIVATE_AGENDAEVENTVIEWERPRIVATE_EXIT ); |
|
94 } |
|
95 |
|
96 /*! |
|
97 Launches the event viewer.Id is used for fetching |
|
98 the calendar entry information. |
|
99 |
|
100 \param id Local Uid of the calendar entry to be viewed |
|
101 */ |
|
102 void AgendaEventViewerPrivate::view(const ulong id, |
|
103 AgendaEventViewer::Actions action) |
|
104 { |
|
105 OstTraceFunctionEntry0( AGENDAEVENTVIEWERPRIVATE_VIEW_ENTRY ); |
|
106 |
|
107 AgendaEntry entry = mAgendaUtil->fetchById(id); |
|
108 |
|
109 if (entry.isNull()) { |
|
110 // save the entries , to show the entry once instances are created |
|
111 // if entry is null exit ,later call back comes in viewCreationCompleted |
|
112 mAction = action; |
|
113 mId =id; |
|
114 //to avoid view creation multiple times |
|
115 mShowEventViewById = true; |
|
116 OstTraceFunctionExit0( AGENDAEVENTVIEWERPRIVATE_VIEW_EXIT ); |
|
117 return; |
|
118 } |
|
119 // Construct the agenda event view |
|
120 mAgendaEventView = new AgendaEventView(this); |
|
121 mAgendaEventView->execute(entry, action); |
|
122 |
|
123 OstTraceFunctionExit0( DUP1_AGENDAEVENTVIEWERPRIVATE_VIEW_EXIT ); |
|
124 } |
|
125 |
|
126 /*! |
|
127 Launches the event viewer.File handle of any vcs/ics |
|
128 file can be given as input to view the calendar entry information. |
|
129 |
|
130 \param fileHandle reference to the file handle of vcs/ics file |
|
131 */ |
|
132 void AgendaEventViewerPrivate::view(const QFile &fileHandle, |
|
133 AgendaEventViewer::Actions action) |
|
134 { |
|
135 OstTraceFunctionEntry0( DUP1_AGENDAEVENTVIEWERPRIVATE_VIEW_ENTRY ); |
|
136 |
|
137 // Using calendar importer read the filehandle and generate agenda entry |
|
138 QString filePath = fileHandle.fileName(); |
|
139 QString nativeFilePath = QDir::toNativeSeparators(filePath); |
|
140 AgendaEntry entry; |
|
141 mAgendaUtil->importvCalendar(nativeFilePath, entry); |
|
142 if (!entry.isNull()) { |
|
143 mAgendaEventView = new AgendaEventView(this); |
|
144 mAgendaEventView->execute(entry, action); |
|
145 } else { |
|
146 //store the file name |
|
147 mFileName = filePath ; |
|
148 mAction = action ; |
|
149 mShowEventViewByFileHandle = true; |
|
150 q_ptr->viewingCompleted(QDateTime::currentDateTime().date()); |
|
151 } |
|
152 OstTraceFunctionExit0( DUP2_AGENDAEVENTVIEWERPRIVATE_VIEW_EXIT ); |
|
153 } |
|
154 |
|
155 /*! |
|
156 Launches the event viewer.AgendaEntry can be given as input to view the |
|
157 calendar entry information |
|
158 */ |
|
159 void AgendaEventViewerPrivate::view(AgendaEntry entry, |
|
160 AgendaEventViewer::Actions action) |
|
161 { |
|
162 OstTraceFunctionEntry0( DUP2_AGENDAEVENTVIEWERPRIVATE_VIEW_ENTRY ); |
|
163 |
|
164 if (entry.isNull()) { |
|
165 OstTraceFunctionExit0( DUP3_AGENDAEVENTVIEWERPRIVATE_VIEW_EXIT ); |
|
166 return; |
|
167 } |
|
168 // Construct the agenda event view |
|
169 mAgendaEventView = new AgendaEventView(this); |
|
170 mAgendaEventView->execute(entry, action); |
|
171 |
|
172 OstTraceFunctionExit0( DUP4_AGENDAEVENTVIEWERPRIVATE_VIEW_EXIT ); |
|
173 } |
|
174 |
|
175 /*! |
|
176 Emits the signal viewing completed to the clients |
|
177 |
|
178 \param status true if viewing completed otherwise false. |
|
179 */ |
|
180 void AgendaEventViewerPrivate::viewingCompleted(const QDate date) |
|
181 { |
|
182 OstTraceFunctionEntry0( AGENDAEVENTVIEWERPRIVATE_VIEWINGCOMPLETED_ENTRY ); |
|
183 |
|
184 emit q_ptr->viewingCompleted(date); |
|
185 |
|
186 // Cleanup viewer. |
|
187 if (mAgendaEventView) { |
|
188 mAgendaEventView->deleteLater(); |
|
189 } |
|
190 |
|
191 OstTraceFunctionExit0( AGENDAEVENTVIEWERPRIVATE_VIEWINGCOMPLETED_EXIT ); |
|
192 } |
|
193 |
|
194 /*! |
|
195 Emits the signal editing started to the clients |
|
196 */ |
|
197 void AgendaEventViewerPrivate::editingStarted() |
|
198 { |
|
199 OstTraceFunctionEntry0( AGENDAEVENTVIEWERPRIVATE_EDITINGSTARTED_ENTRY ); |
|
200 |
|
201 emit q_ptr->editingStarted(); |
|
202 |
|
203 OstTraceFunctionExit0( AGENDAEVENTVIEWERPRIVATE_EDITINGSTARTED_EXIT ); |
|
204 } |
|
205 |
|
206 /*! |
|
207 Emits the signal editing completed to the clients |
|
208 */ |
|
209 void AgendaEventViewerPrivate::editingCompleted() |
|
210 { |
|
211 OstTraceFunctionEntry0( AGENDAEVENTVIEWERPRIVATE_EDITINGCOMPLETED_ENTRY ); |
|
212 |
|
213 emit q_ptr->editingCompleted(); |
|
214 |
|
215 OstTraceFunctionExit0( AGENDAEVENTVIEWERPRIVATE_EDITINGCOMPLETED_EXIT ); |
|
216 } |
|
217 |
|
218 /*! |
|
219 Emits the signal deleting started to the clients |
|
220 */ |
|
221 void AgendaEventViewerPrivate::deletingStarted() |
|
222 { |
|
223 OstTraceFunctionEntry0( AGENDAEVENTVIEWERPRIVATE_DELETINGSTARTED_ENTRY ); |
|
224 |
|
225 emit q_ptr->deletingStarted(); |
|
226 |
|
227 OstTraceFunctionExit0( AGENDAEVENTVIEWERPRIVATE_DELETINGSTARTED_EXIT ); |
|
228 } |
|
229 |
|
230 /*! |
|
231 Emits the signal deleting completed to the clients |
|
232 */ |
|
233 void AgendaEventViewerPrivate::deletingCompleted() |
|
234 { |
|
235 OstTraceFunctionEntry0( AGENDAEVENTVIEWERPRIVATE_DELETINGCOMPLETED_ENTRY ); |
|
236 |
|
237 emit q_ptr->deletingCompleted(); |
|
238 |
|
239 OstTraceFunctionExit0( AGENDAEVENTVIEWERPRIVATE_DELETINGCOMPLETED_EXIT ); |
|
240 } |
|
241 |
|
242 |
|
243 /*! |
|
244 calls when instances of calenInstanceview and |
|
245 entryInstanceview is created successfully |
|
246 */ |
|
247 void AgendaEventViewerPrivate::viewCreationCompleted(int error) |
|
248 { |
|
249 OstTraceFunctionEntry0( AGENDAEVENTVIEWERPRIVATE_VIEWCREATIONCOMPLETED_ENTRY ); |
|
250 |
|
251 if((KErrNone == error)) |
|
252 { |
|
253 AgendaEntry entry; |
|
254 if (mShowEventViewById) |
|
255 { |
|
256 entry = mAgendaUtil->fetchById(mId); |
|
257 } |
|
258 else if(mShowEventViewByFileHandle) |
|
259 { |
|
260 QString nativeFilePath = QDir::toNativeSeparators(mFileName); |
|
261 mAgendaUtil->importvCalendar(nativeFilePath, entry); |
|
262 } |
|
263 //if entry is there , then show the view |
|
264 if (!entry.isNull()) |
|
265 { |
|
266 mAgendaEventView = new AgendaEventView(this); |
|
267 mAgendaEventView->execute(entry, mAction); |
|
268 } |
|
269 } |
|
270 //reset the variables |
|
271 mId = 0; |
|
272 mFileName.clear(); |
|
273 mShowEventViewById = false; |
|
274 mShowEventViewByFileHandle = false; |
|
275 mAction = AgendaEventViewer::ActionNothing; |
|
276 OstTraceFunctionExit0( AGENDAEVENTVIEWERPRIVATE_VIEWCREATIONCOMPLETED_EXIT ); |
|
277 } |
|
278 |
|
279 // ---------------------------------------------------------------------------- |
|
280 // AgendaEventViewerPrivate::saveAndCloseEditor |
|
281 // save the entry and close the editor |
|
282 // ---------------------------------------------------------------------------- |
|
283 // |
|
284 void AgendaEventViewerPrivate::saveAndCloseEditor() |
|
285 { |
|
286 mAgendaEventView->saveAndCloseEditor(); |
|
287 } |
|
288 |
|
289 |
|
290 // ---------------------------------------------------------------------------- |
|
291 // AgendaEventViewerPrivate::closeAgendaEventView |
|
292 // close the agenda event view |
|
293 // ---------------------------------------------------------------------------- |
|
294 // |
|
295 void AgendaEventViewerPrivate::closeAgendaEventView() |
|
296 { |
|
297 mAgendaEventView->closeAgendaEventView(); |
|
298 } |
|
299 // End of file |