|
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 <QDebug> |
|
20 #include <QFile> |
|
21 #include <QDir> |
|
22 |
|
23 // User includes. |
|
24 #include <agendautil.h> |
|
25 #include <agendaentry.h> |
|
26 #include "agendaeventviewer_p.h" |
|
27 #include "agendaeventviewer.h" |
|
28 #include "agendaeventview.h" |
|
29 |
|
30 /*! |
|
31 \class AgendaEventViewerPrivate |
|
32 |
|
33 Private class implementation of AgendaEventViewer.It is responsible for |
|
34 launching the agenda event viewer. |
|
35 */ |
|
36 |
|
37 |
|
38 /*! |
|
39 Constructor |
|
40 |
|
41 \param agendaUtil Pointer to AgendaUtil. |
|
42 \param parent Pointer to QObject. |
|
43 */ |
|
44 AgendaEventViewerPrivate::AgendaEventViewerPrivate( |
|
45 AgendaUtil *agendaUtil, QObject *parent) |
|
46 : QObject(parent) |
|
47 { |
|
48 qDebug() <<"AgendaEventViewerPrivate::AgendaEventViewerPrivate -->"; |
|
49 |
|
50 // Get the q-pointer.from parent |
|
51 q_ptr = static_cast<AgendaEventViewer *> (parent); |
|
52 |
|
53 // Check for agendaUtil sent by client. If null agendaUtil will be |
|
54 // created and owned by AgendaEventViewerPrivate |
|
55 if (!agendaUtil) { |
|
56 mAgendaUtil = new AgendaUtil(parent); |
|
57 mViewerOwnsAgendaUtil = true; |
|
58 } else { |
|
59 mAgendaUtil = agendaUtil; |
|
60 mViewerOwnsAgendaUtil = false; |
|
61 } |
|
62 |
|
63 // Register for the entry change signal when the same entry is updated |
|
64 // by other application.This is to handle the db conflict changes. |
|
65 connect( |
|
66 mAgendaUtil, SIGNAL(entriesChanged(QList<ulong> )), |
|
67 this, SLOT(handleEntriesChanged(QList<ulong> ))); |
|
68 |
|
69 qDebug() <<"AgendaEventViewerPrivate::AgendaEventViewerPrivate <--"; |
|
70 } |
|
71 |
|
72 /*! |
|
73 Destructor. |
|
74 */ |
|
75 AgendaEventViewerPrivate::~AgendaEventViewerPrivate() |
|
76 { |
|
77 qDebug() <<"AgendaEventViewerPrivate::~AgendaEventViewerPrivate -->"; |
|
78 |
|
79 if (mViewerOwnsAgendaUtil) { |
|
80 delete mAgendaUtil; |
|
81 mAgendaUtil = 0; |
|
82 } |
|
83 |
|
84 qDebug() <<"AgendaEventViewerPrivate::~AgendaEventViewerPrivate <--"; |
|
85 } |
|
86 |
|
87 /*! |
|
88 Launches the event viewer.Id is used for fetching |
|
89 the calendar entry information. |
|
90 |
|
91 \param id Local Uid of the calendar entry to be viewed |
|
92 */ |
|
93 void AgendaEventViewerPrivate::view(const ulong id, |
|
94 AgendaEventViewer::Actions action) |
|
95 { |
|
96 qDebug() <<"AgendaEventViewerPrivate::view(id) -->"; |
|
97 |
|
98 AgendaEntry entry = mAgendaUtil->fetchById(id); |
|
99 |
|
100 if (entry.isNull()) { |
|
101 return; |
|
102 } |
|
103 // Construct the agenda event view |
|
104 mAgendaEventView = new AgendaEventView(this); |
|
105 mAgendaEventView->execute(entry, action); |
|
106 |
|
107 qDebug() <<"AgendaEventViewerPrivate::view(id) <--"; |
|
108 } |
|
109 |
|
110 /*! |
|
111 Launches the event viewer.File handle of any vcs/ics |
|
112 file can be given as input to view the calendar entry information. |
|
113 |
|
114 \param fileHandle reference to the file handle of vcs/ics file |
|
115 */ |
|
116 void AgendaEventViewerPrivate::view(const QFile &fileHandle, |
|
117 AgendaEventViewer::Actions action) |
|
118 { |
|
119 qDebug() <<"AgendaEventViewerPrivate::view(fileHandle) -->"; |
|
120 |
|
121 // Using calendar importer read the filehandle and generate agenda entry |
|
122 QString filePath = fileHandle.fileName(); |
|
123 QString nativeFilePath = QDir::toNativeSeparators(filePath); |
|
124 AgendaEntry entry; |
|
125 mAgendaUtil->importvCalendar(nativeFilePath, entry); |
|
126 if (!entry.isNull()) { |
|
127 mAgendaEventView = new AgendaEventView(this); |
|
128 mAgendaEventView->execute(entry, action); |
|
129 } |
|
130 qDebug() <<"AgendaEventViewerPrivate::view(fileHandle) <--"; |
|
131 } |
|
132 |
|
133 /*! |
|
134 Launches the event viewer.AgendaEntry can be given as input to view the |
|
135 calendar entry information |
|
136 */ |
|
137 void AgendaEventViewerPrivate::view(AgendaEntry entry, |
|
138 AgendaEventViewer::Actions action) |
|
139 { |
|
140 qDebug() <<"AgendaEventViewerPrivate::view(entry) -->"; |
|
141 |
|
142 if (entry.isNull()) { |
|
143 return; |
|
144 } |
|
145 // Construct the agenda event view |
|
146 mAgendaEventView = new AgendaEventView(this); |
|
147 mAgendaEventView->execute(entry, action); |
|
148 |
|
149 qDebug() <<"AgendaEventViewerPrivate::view(entry) <--"; |
|
150 } |
|
151 |
|
152 /*! |
|
153 Emits the signal viewing completed to the clients |
|
154 |
|
155 \param status true if viewing completed otherwise false. |
|
156 */ |
|
157 void AgendaEventViewerPrivate::viewingCompleted(bool status) |
|
158 { |
|
159 qDebug() <<"AgendaEventViewerPrivate::viewingCompleted -->"; |
|
160 |
|
161 emit q_ptr->viewingCompleted(status); |
|
162 |
|
163 // Cleanup viewer. |
|
164 if (mAgendaEventView) { |
|
165 mAgendaEventView->deleteLater(); |
|
166 } |
|
167 |
|
168 qDebug() <<"AgendaEventViewerPrivate::viewingCompleted -->"; |
|
169 } |
|
170 |
|
171 /*! |
|
172 Emits the signal editing started to the clients |
|
173 */ |
|
174 void AgendaEventViewerPrivate::editingStarted() |
|
175 { |
|
176 qDebug() <<"AgendaEventViewerPrivate::editingStarted -->"; |
|
177 |
|
178 emit q_ptr->editingStarted(); |
|
179 |
|
180 qDebug() <<"AgendaEventViewerPrivate::editingStarted -->"; |
|
181 } |
|
182 |
|
183 /*! |
|
184 Emits the signal editing completed to the clients |
|
185 */ |
|
186 void AgendaEventViewerPrivate::editingCompleted() |
|
187 { |
|
188 qDebug() <<"AgendaEventViewerPrivate::editingCompleted -->"; |
|
189 |
|
190 emit q_ptr->editingCompleted(); |
|
191 |
|
192 qDebug() <<"AgendaEventViewerPrivate::editingCompleted -->"; |
|
193 } |
|
194 |
|
195 /*! |
|
196 Emits the signal deleting started to the clients |
|
197 */ |
|
198 void AgendaEventViewerPrivate::deletingStarted() |
|
199 { |
|
200 qDebug() <<"AgendaEventViewerPrivate::deletingStarted -->"; |
|
201 |
|
202 emit q_ptr->deletingStarted(); |
|
203 |
|
204 qDebug() <<"AgendaEventViewerPrivate::deletingStarted -->"; |
|
205 } |
|
206 |
|
207 /*! |
|
208 Emits the signal deleting completed to the clients |
|
209 */ |
|
210 void AgendaEventViewerPrivate::deletingCompleted() |
|
211 { |
|
212 qDebug() <<"AgendaEventViewerPrivate::deletingCompleted -->"; |
|
213 |
|
214 emit q_ptr->deletingCompleted(); |
|
215 |
|
216 qDebug() <<"AgendaEventViewerPrivate::deletingCompleted -->"; |
|
217 } |
|
218 |
|
219 // End of file |