15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 //system includes |
19 //system includes |
20 #include <QDebug> |
|
21 #include <hbmainwindow.h> |
20 #include <hbmainwindow.h> |
|
21 #include <hbinstance.h> |
|
22 #include <hbapplication.h> // hbapplication |
|
23 #include <xqserviceutil.h> // service utils |
22 |
24 |
23 //user includes |
25 //user includes |
24 #include "calenviewmanager.h" |
26 #include "calenviewmanager.h" |
25 #include "calencontroller.h" |
27 #include "calencontroller.h" |
26 #include "hb_calencommands.hrh" |
28 #include "hb_calencommands.hrh" |
27 #include "calenservicesimpl.h" |
29 #include "calenservicesimpl.h" |
28 #include "calenmonthview.h" |
30 #include "calenmonthview.h" |
29 #include "calendayview.h" |
31 #include "calenagendaview.h" |
30 #include "calenmonthview.h" |
32 #include "calenmonthview.h" |
31 #include "agendaeventviewer.h" |
33 #include "agendaeventviewer.h" |
32 #include "calennotificationhandler.h" |
34 #include "calennotificationhandler.h" |
33 #include "CalenUid.h" |
35 #include "CalenUid.h" |
34 #include "calenactionuiutils.h" |
36 #include "calenactionuiutils.h" |
35 #include "calensettingsview.h" |
37 #include "calensettingsview.h" |
36 #include "calendocloader.h" |
38 #include "calendocloader.h" |
37 #include "calendarui_debug.h" |
39 #include "calendarui_debug.h" |
38 #include "calencommon.h" |
40 #include "calencommon.h" |
|
41 #include "calendayview.h" |
39 |
42 |
40 // ---------------------------------------------------------------------------- |
43 // ---------------------------------------------------------------------------- |
41 // CalenViewManager::CalenViewManager |
44 // CalenViewManager::CalenViewManager |
42 // 2nd phase of construction. |
45 // 2nd phase of construction. |
43 // (other items were commented in a header). |
46 // (other items were commented in a header). |
44 // ---------------------------------------------------------------------------- |
47 // ---------------------------------------------------------------------------- |
45 // |
48 // |
46 CalenViewManager::CalenViewManager( CCalenController& aController, |
49 CalenViewManager::CalenViewManager( CCalenController& aController) |
47 bool isFromServiceFrmwrk) |
|
48 : mController(aController) |
50 : mController(aController) |
49 { |
51 { |
50 TRACE_ENTRY_POINT; |
52 TRACE_ENTRY_POINT; |
51 |
53 |
|
54 // Following block intializes member variables |
52 mCalenEventViewer = NULL; |
55 mCalenEventViewer = NULL; |
53 mMonthViewDocLoader = NULL; |
56 mMonthViewDocLoader = NULL; |
54 mDayViewDocLoader = NULL; |
57 mAgendaViewDocLoader = NULL; |
55 mDayViewAltDocLoader = NULL; |
58 mAgendaViewAltDocLoader = NULL; |
56 |
59 mCalenAgendaView = NULL; |
57 mController.MainWindow().setItemVisible(Hb::NaviPaneItem, false); |
60 mCalenMonthView = NULL; |
58 |
61 mCalenAgendaViewAlt = NULL; |
59 if (isFromServiceFrmwrk) { |
62 mSettingsView = NULL; |
60 // Dont load any views until our remote slot gets called in |
63 mCalenDayView = NULL; |
61 // calenserviceprovider.cpp |
64 |
62 // Just have an empty mainwindow |
65 // Connect to instance view and entry view creation signals from agenda |
63 } else { |
66 // interface |
64 // Do the normal startup |
67 connect(mController.agendaInterface(), SIGNAL(instanceViewCreationCompleted(int)), |
65 // Load the month view and active it and add it to main window |
68 this, SLOT(handleInstanceViewCreation(int))); |
66 mFirstView = ECalenMonthView; |
69 connect(mController.agendaInterface(), SIGNAL(entryViewCreationCompleted(int)), |
67 loadMonthView(); |
70 this, SLOT(handleEntryViewCreation(int))); |
68 ActivateDefaultViewL(ECalenMonthView); |
|
69 // Connect to the view ready signal so that we construct other view |
|
70 // once this view is shown |
|
71 connect(&mController.MainWindow(), SIGNAL(viewReady()), |
|
72 this, SLOT(constructOtherViews())); |
|
73 |
|
74 mController.MainWindow().addView(mCalenMonthView); |
|
75 mController.MainWindow().setCurrentView(mCalenMonthView); |
|
76 } |
|
77 |
71 |
78 TRACE_EXIT_POINT; |
72 TRACE_EXIT_POINT; |
|
73 } |
|
74 |
|
75 void CalenViewManager::SecondPhaseConstruction() |
|
76 { |
|
77 |
|
78 TRACE_ENTRY_POINT; |
|
79 |
|
80 // Check the Application Startup reason from Activity Manager |
|
81 int activityReason = qobject_cast<HbApplication*>(qApp)->activateReason(); |
|
82 |
|
83 // Check if calendar is launched thru XQService framework |
|
84 bool isFromServiceFrmWrk = XQServiceUtil::isService(); // Since activateReason |
|
85 //of hbapplication is not returning right value if the activity is started |
|
86 //as services so using the above line temporarily untill a fix is available in |
|
87 // hbappliacation. Need to remove this line after the fix is available for hbapplcation |
|
88 |
|
89 |
|
90 if (Hb::ActivationReasonActivity == activityReason) // Check if application is started |
|
91 // as an activity |
|
92 { |
|
93 // Application is started from an activity |
|
94 // Extract activity data |
|
95 QVariant data = qobject_cast<HbApplication*>(qApp)->activateData(); |
|
96 // Restore state from activity data |
|
97 QByteArray serializedModel = data.toByteArray(); |
|
98 QDataStream stream(&serializedModel, QIODevice::ReadOnly); |
|
99 int viewId; // int declared for debugging purpose |
|
100 stream >> viewId; // read stream into an int |
|
101 |
|
102 mFirstView = viewId; |
|
103 if (ECalenMonthView == viewId) // Check if Activity was stored for month view |
|
104 { |
|
105 loadMonthView(); // Load month view |
|
106 } |
|
107 else if (ECalenAgendaView == viewId) // Check if Activity was stored for agenda view |
|
108 { |
|
109 loadAgendaView(); // Load agenda view |
|
110 } |
|
111 |
|
112 ActivateDefaultViewL(viewId); |
|
113 // Connect to the view ready signal so that we can construct other views |
|
114 // once this view is ready |
|
115 connect(&mController.MainWindow(), SIGNAL(viewReady()), |
|
116 this, SLOT(handleMainViewReady())); |
|
117 |
|
118 if (ECalenMonthView == viewId) // Check if Activity was stored for month view |
|
119 { |
|
120 mController.MainWindow().addView(mCalenMonthView); // Add month view to main window |
|
121 mController.MainWindow().setCurrentView(mCalenMonthView); // Set month view as current view |
|
122 } |
|
123 else if (ECalenAgendaView == viewId) // Check if Activity was stored for agenda view |
|
124 { |
|
125 mController.MainWindow().addView(mCalenAgendaView); // Add agenda view to main window |
|
126 mController.MainWindow().setCurrentView(mCalenAgendaView); // Set agenda view as current view |
|
127 } |
|
128 } else if (isFromServiceFrmWrk/*Hb::ActivationReasonService == activityReason*/) { |
|
129 // Dont load any views until our remote slot gets called in |
|
130 // calenserviceprovider.cpp |
|
131 // Just have an empty mainwindow |
|
132 } else { |
|
133 // Do the normal startup |
|
134 // Load the month view and active it and add it to main window |
|
135 mFirstView = ECalenMonthView; |
|
136 loadMonthView(); |
|
137 ActivateDefaultViewL(ECalenMonthView); |
|
138 // Connect to the view ready signal so that we construct other view |
|
139 // once this view is shown |
|
140 connect(&mController.MainWindow(), SIGNAL(viewReady()), |
|
141 this, SLOT(handleMainViewReady())); |
|
142 |
|
143 mController.MainWindow().addView(mCalenMonthView); |
|
144 mController.MainWindow().setCurrentView(mCalenMonthView); |
|
145 } |
|
146 |
|
147 TRACE_EXIT_POINT; |
|
148 |
79 } |
149 } |
80 |
150 |
81 // ---------------------------------------------------------------------------- |
151 // ---------------------------------------------------------------------------- |
82 // CalenViewManager::~CalenViewManager |
152 // CalenViewManager::~CalenViewManager |
83 // Destructor. |
153 // Destructor. |
104 // ---------------------------------------------------------------------------- |
184 // ---------------------------------------------------------------------------- |
105 // |
185 // |
106 void CalenViewManager::constructAndActivateView(int view) |
186 void CalenViewManager::constructAndActivateView(int view) |
107 { |
187 { |
108 TRACE_ENTRY_POINT; |
188 TRACE_ENTRY_POINT; |
|
189 // We are here because, some other application is launching calendar with |
|
190 // the view, hence connect to viewReady() signal to do any lazy loading |
|
191 // in the slot |
|
192 |
|
193 // Connect to the view ready signal so that we construct other view |
|
194 // once this view is shown |
|
195 connect(&mController.MainWindow(), SIGNAL(viewReady()), |
|
196 this, SLOT(handleMainViewReady())); |
109 if (view == ECalenMonthView) { |
197 if (view == ECalenMonthView) { |
110 mFirstView = ECalenMonthView; |
198 mFirstView = ECalenMonthView; |
111 loadMonthView(); |
199 loadMonthView(); |
112 ActivateDefaultViewL(ECalenMonthView); |
200 ActivateDefaultViewL(ECalenMonthView); |
113 // Add month view to mainwindow. |
201 // Add month view to mainwindow. |
114 mController.MainWindow().addView(mCalenMonthView); |
202 mController.MainWindow().addView(mCalenMonthView); |
115 } else if (view == ECalenDayView) { |
203 mController.MainWindow().setCurrentView(mCalenMonthView); |
116 mFirstView = ECalenDayView; |
204 } else if (view == ECalenAgendaView) { |
117 loadDayView(); |
205 mFirstView = ECalenAgendaView; |
118 ActivateDefaultViewL(ECalenDayView); |
206 loadAgendaView(); |
119 // Add day view to mainwindow. |
207 ActivateDefaultViewL(ECalenAgendaView); |
120 mController.MainWindow().addView(mCalenDayView); |
208 // Add agenda view to mainwindow. |
|
209 mController.MainWindow().addView(mCalenAgendaView); |
|
210 mController.MainWindow().setCurrentView(mCalenAgendaView); |
121 } |
211 } |
122 TRACE_EXIT_POINT; |
212 TRACE_EXIT_POINT; |
123 } |
213 } |
124 |
214 |
125 // ---------------------------------------------------------------------------- |
215 // ---------------------------------------------------------------------------- |
148 Q_ASSERT_X(loadSuccess, "calenviewmanager.cpp", "Unable to load XML"); |
238 Q_ASSERT_X(loadSuccess, "calenviewmanager.cpp", "Unable to load XML"); |
149 |
239 |
150 // Get the calenmonth view from the loader. |
240 // Get the calenmonth view from the loader. |
151 mCalenMonthView = static_cast<CalenMonthView *> |
241 mCalenMonthView = static_cast<CalenMonthView *> |
152 (mMonthViewDocLoader->findWidget(CALEN_MONTHVIEW)); |
242 (mMonthViewDocLoader->findWidget(CALEN_MONTHVIEW)); |
153 Q_ASSERT_X(mCalenDayView, "calenviewmanager.cpp", |
243 Q_ASSERT_X(mCalenMonthView, "calenviewmanager.cpp", |
154 "Unable to load calenMonth view"); |
244 "Unable to load calenMonth view"); |
155 |
245 |
156 // Setup the month view. |
246 // Setup the month view. |
157 mCalenMonthView->setupView(mMonthViewDocLoader); |
247 mCalenMonthView->setupView(mMonthViewDocLoader); |
158 } |
248 } |
159 |
249 |
160 // ---------------------------------------------------------------------------- |
250 // ---------------------------------------------------------------------------- |
161 // CalenViewManager::loadDayView |
251 // CalenViewManager::loadAgendaView |
162 // Loads the day view frm the docml |
252 // Loads the agenda view frm the docml |
163 // (other items were commented in a header). |
253 // (other items were commented in a header). |
164 // ---------------------------------------------------------------------------- |
254 // ---------------------------------------------------------------------------- |
165 // |
255 // |
166 void CalenViewManager::loadDayView() |
256 void CalenViewManager::loadAgendaView() |
167 { |
257 { |
168 bool loadSuccess = false; |
258 bool loadSuccess = false; |
169 // Create the day view docloader object. |
259 // Create the agenda view docloader object. |
170 mDayViewDocLoader = new CalenDocLoader(mController); |
260 mAgendaViewDocLoader = new CalenDocLoader(mController); |
171 |
261 |
172 // Load default section |
262 // Load default section |
173 mDayViewDocLoader->load(CALEN_DAYVIEW_XML_FILE, &loadSuccess); |
263 mAgendaViewDocLoader->load(CALEN_AGENDAVIEW_XML_FILE, &loadSuccess); |
174 if (!loadSuccess) { |
264 if (!loadSuccess) { |
175 qFatal("calenviewmanager.cpp : Unable to load XML"); |
265 qFatal("calenviewmanager.cpp : Unable to load XML"); |
176 } |
266 } |
177 |
267 |
178 // Get the calenday view from the loader |
268 // Get the calenagenda view from the loader |
179 mCalenDayView = static_cast<CalenDayView *> (mDayViewDocLoader->findWidget(CALEN_DAYVIEW)); |
269 mCalenAgendaView = static_cast<CalenAgendaView *> (mAgendaViewDocLoader->findWidget(CALEN_AGENDAVIEW)); |
180 if (!mCalenDayView) { |
270 if (!mCalenAgendaView) { |
181 qFatal("calenviewmanager.cpp : Unable to find day view"); |
271 qFatal("calenviewmanager.cpp : Unable to find agenda view"); |
182 } |
272 } |
183 |
273 |
184 // Setup the day view |
274 // Setup the agenda view |
185 mCalenDayView->setupView(mDayViewDocLoader); |
275 mCalenAgendaView->setupView(mAgendaViewDocLoader); |
186 |
276 |
187 // The following code is done to provide swipe support |
277 // The following code is done to provide swipe support |
188 // in day view. Idea is to create two views and keep |
278 // in agenda view. Idea is to create two views and keep |
189 // switiching between these two using view switch effects |
279 // switiching between these two using view switch effects |
190 // to provide an illusion of flow to the user |
280 // to provide an illusion of flow to the user |
191 loadAlternateDayView(); |
281 loadAlternateAgendaView(); |
|
282 |
|
283 } |
|
284 |
|
285 // ---------------------------------------------------------------------------- |
|
286 // CalenViewManager::handleMainViewReady |
|
287 // Slot to handle viewReady() signal from mainwindow |
|
288 // (other items were commented in a header). |
|
289 // ---------------------------------------------------------------------------- |
|
290 // |
|
291 void CalenViewManager::handleMainViewReady() |
|
292 { |
|
293 // Construct the month view part that is kept for lazy loading |
|
294 if (mCalenMonthView) { |
|
295 mCalenMonthView->doLazyLoading(); |
|
296 } |
|
297 |
|
298 // Construct other views |
|
299 constructOtherViews(); |
|
300 |
|
301 // Install the event filter for the controller once the view is ready |
|
302 // so that system language/locale changes can be handled |
|
303 //hbInstance->allMainWindows().first()->installEventFilter(&mController); |
|
304 |
|
305 // disconnect the view ready signal as we dont need it anymore |
|
306 disconnect(&mController.MainWindow(), SIGNAL(viewReady()), |
|
307 this, SLOT(handleMainViewReady())); |
192 } |
308 } |
193 |
309 |
194 // ---------------------------------------------------------------------------- |
310 // ---------------------------------------------------------------------------- |
195 // CalenViewManager::constructOtherViews |
311 // CalenViewManager::constructOtherViews |
196 // Constructs the other views apart frm firstview and adds them to main window |
312 // Constructs the other views apart frm firstview and adds them to main window |
200 void CalenViewManager::constructOtherViews() |
316 void CalenViewManager::constructOtherViews() |
201 { |
317 { |
202 // Load all other views except mFirstView |
318 // Load all other views except mFirstView |
203 |
319 |
204 // NOTE: Right now, since Calendar has only two views, month view |
320 // NOTE: Right now, since Calendar has only two views, month view |
205 // and day view, when client launches day view, then there is no need |
321 // and agenda view, when client launches agenda view, then there is no need |
206 // to construct the month view as per UI REQ., but tomorrow if new views |
322 // to construct the month view as per UI REQ., but tomorrow if new views |
207 // come after day view, then we need to construct those views if they are |
323 // come after agenda view, then we need to construct those views if they are |
208 // native views. Right now, there is a event viewer but its not a native |
324 // native views. Right now, there is a event viewer but its not a native |
209 // view. Hence, if day view is launched, dont construct month view |
325 // view. Hence, if agenda view is launched, dont construct month view |
210 if (mFirstView == ECalenDayView) { |
326 if (mFirstView != ECalenAgendaView) // check if agenda view is not already loaded |
211 // Construct other views as mentioned above |
327 { |
212 return; |
|
213 } else { |
|
214 // Load all other views |
328 // Load all other views |
215 loadDayView(); |
329 loadAgendaView(); |
216 } |
330 |
|
331 if (!mCalenDayView) { |
|
332 mCalenDayView = new CalenDayView(mController.Services()); |
|
333 } |
|
334 } |
|
335 else //agenda view was launched as first view |
|
336 { |
|
337 // No implementation yet. UI specs not clear |
|
338 // to be commented in with some more code once UI specs is frozen |
|
339 // for agenda view launching as first view after it was saved as activity |
|
340 // when it was launched from month view |
|
341 // loadMonthView(); |
|
342 // mCalenMonthView->doLazyLoading(); |
|
343 } |
217 |
344 |
218 // Setup the settings view |
345 // Setup the settings view |
219 mSettingsView = new CalenSettingsView(mController.Services()); |
346 mSettingsView = new CalenSettingsView(mController.Services()); |
220 |
|
221 // disconnect the view ready signal as we dont need it anymore |
|
222 disconnect(&mController.MainWindow(), SIGNAL(viewReady()), |
|
223 this, SLOT(constructOtherViews())); |
|
224 } |
347 } |
225 |
348 |
226 // ---------------------------------------------------------------------------- |
349 // ---------------------------------------------------------------------------- |
227 // CalenViewManager::getFirstView |
350 // CalenViewManager::getFirstView |
228 // Returns the first view |
351 // Returns the first view |
240 // ---------------------------------------------------------------------------- |
363 // ---------------------------------------------------------------------------- |
241 // |
364 // |
242 void CalenViewManager::showNextDay() |
365 void CalenViewManager::showNextDay() |
243 { |
366 { |
244 // Set the context for the next day |
367 // Set the context for the next day |
245 QDateTime currentDay = mController.Services().Context().focusDateAndTimeL(); |
368 QDateTime currentDay = mController.Services().Context().focusDateAndTime(); |
246 currentDay = currentDay.addDays(1); |
369 currentDay = currentDay.addDays(1); |
247 mController.Services().Context().setFocusDateL(currentDay, ECalenDayView); |
370 mController.Services().Context().setFocusDate(currentDay); |
248 mCurrentViewId = ECalenDayView; |
371 mCurrentViewId = ECalenAgendaView; |
249 // Check which is the currently activated view |
372 // Check which is the currently activated view |
250 if (mController.MainWindow().currentView() == mCalenDayView) { |
373 if (mController.MainWindow().currentView() == mCalenAgendaView) { |
251 HbEffect::add(mCalenDayView, |
374 mCalenAgendaView->disconnectAboutToQuitEvent(); // disconnect mCalenAgendaView to get aboutToQuit Events |
|
375 HbEffect::add(mCalenAgendaView, |
252 ":/fxml/view_hide", |
376 ":/fxml/view_hide", |
253 "hide"); |
377 "hide"); |
254 HbEffect::add(mCalenDayViewAlt, |
378 HbEffect::add(mCalenAgendaViewAlt, |
255 ":/fxml/view_show", |
379 ":/fxml/view_show", |
256 "show"); |
380 "show"); |
257 // Set the other day view as the current view |
381 // Set the other agenda view as the current view |
258 // and animate to provide illusion of swipe |
382 // and animate to provide illusion of swipe |
259 mCalenDayViewAlt->doPopulation(); |
383 // It would also connect for aboutToQuit events |
260 mController.MainWindow().setCurrentView(mCalenDayViewAlt, true, Hb::ViewSwitchUseNormalAnim); |
384 mCalenAgendaViewAlt->doPopulation(); |
|
385 mController.MainWindow().setCurrentView(mCalenAgendaViewAlt, true, Hb::ViewSwitchUseNormalAnim); |
261 } else { |
386 } else { |
262 HbEffect::add(mCalenDayViewAlt, |
387 mCalenAgendaViewAlt->disconnectAboutToQuitEvent(); // disconnect mCalenAgendaViewAlt to get aboutToQuit Events |
|
388 HbEffect::add(mCalenAgendaViewAlt, |
263 ":/fxml/view_hide", |
389 ":/fxml/view_hide", |
264 "hide"); |
390 "hide"); |
265 HbEffect::add(mCalenDayView, |
391 HbEffect::add(mCalenAgendaView, |
266 ":/fxml/view_show", |
392 ":/fxml/view_show", |
267 "show"); |
393 "show"); |
268 mCalenDayView->doPopulation(); |
394 // It would also connect for aboutToQuit events |
269 mController.MainWindow().setCurrentView(mCalenDayView, true, Hb::ViewSwitchUseNormalAnim); |
395 mCalenAgendaView->doPopulation(); |
|
396 mController.MainWindow().setCurrentView(mCalenAgendaView, true, Hb::ViewSwitchUseNormalAnim); |
270 } |
397 } |
271 } |
398 } |
272 |
399 |
273 // ---------------------------------------------------------------------------- |
400 // ---------------------------------------------------------------------------- |
274 // CalenViewManager::showPrevDay |
401 // CalenViewManager::showPrevDay |
275 // other items were commented in a header |
402 // other items were commented in a header |
276 // ---------------------------------------------------------------------------- |
403 // ---------------------------------------------------------------------------- |
277 // |
404 // |
278 void CalenViewManager::showPrevDay() |
405 void CalenViewManager::showPrevDay() |
279 { |
406 { |
280 QDateTime currentDay = mController.Services().Context().focusDateAndTimeL(); |
407 QDateTime currentDay = mController.Services().Context().focusDateAndTime(); |
281 currentDay = currentDay.addDays(-1); |
408 currentDay = currentDay.addDays(-1); |
282 mController.Services().Context().setFocusDateL(currentDay, ECalenDayView); |
409 mController.Services().Context().setFocusDate(currentDay); |
283 mCurrentViewId = ECalenDayView; |
410 mCurrentViewId = ECalenAgendaView; |
284 if (mController.MainWindow().currentView() == mCalenDayView) { |
411 if (mController.MainWindow().currentView() == mCalenAgendaView) { |
285 HbEffect::add(mCalenDayView, |
412 mCalenAgendaView->disconnectAboutToQuitEvent(); // disconnect mCalenAgendaView to get aboutToQuit Events |
286 ":/fxml/view_show", |
413 HbEffect::add(mCalenAgendaView, |
|
414 ":/fxml/view_hide_back", |
287 "hide"); |
415 "hide"); |
288 HbEffect::add(mCalenDayViewAlt, |
416 HbEffect::add(mCalenAgendaViewAlt, |
289 ":/fxml/view_hide", |
417 ":/fxml/view_show_back", |
290 "show"); |
418 "show"); |
291 mCalenDayViewAlt->doPopulation(); |
419 // It would also connect for aboutToQuit events |
292 mController.MainWindow().setCurrentView(mCalenDayViewAlt, true, Hb::ViewSwitchUseBackAnim); |
420 mCalenAgendaViewAlt->doPopulation(); |
|
421 mController.MainWindow().setCurrentView(mCalenAgendaViewAlt, true, Hb::ViewSwitchUseNormalAnim); |
293 } else { |
422 } else { |
294 HbEffect::add(mCalenDayViewAlt, |
423 mCalenAgendaViewAlt->disconnectAboutToQuitEvent(); // disconnect mCalenAgendaViewAlt to get aboutToQuit Events |
295 ":/fxml/view_show", |
424 HbEffect::add(mCalenAgendaViewAlt, |
|
425 ":/fxml/view_hide_back", |
296 "hide"); |
426 "hide"); |
297 HbEffect::add(mCalenDayView, |
427 HbEffect::add(mCalenAgendaView, |
298 ":/fxml/view_hide", |
428 ":/fxml/view_show_back", |
299 "show"); |
429 "show"); |
300 mCalenDayView->doPopulation(); |
430 // It would also connect for aboutToQuit events |
301 mController.MainWindow().setCurrentView(mCalenDayView, true, Hb::ViewSwitchUseBackAnim); |
431 mCalenAgendaView->doPopulation(); |
|
432 mController.MainWindow().setCurrentView(mCalenAgendaView, true, Hb::ViewSwitchUseNormalAnim); |
302 } |
433 } |
303 } |
434 } |
304 |
435 |
305 // ---------------------------------------------------------------------------- |
436 // ---------------------------------------------------------------------------- |
306 // CalenViewManager::removeDayViews |
437 // CalenViewManager::removePreviousView |
307 // other items were commented in a header |
438 // Remove the previous view from main window |
308 // ---------------------------------------------------------------------------- |
439 // ---------------------------------------------------------------------------- |
309 // |
440 // |
310 void CalenViewManager::removeDayViews() |
441 void CalenViewManager::removePreviousView() |
311 { |
442 { |
312 mController.MainWindow().removeView(mCalenDayView); |
443 if (ECalenAgendaView == mCurrentViewId) { |
313 mController.MainWindow().removeView(mCalenDayViewAlt); |
444 mCalenAgendaView->clearListModel(); |
|
445 mCalenAgendaViewAlt->clearListModel(); |
|
446 mController.MainWindow().removeView(mCalenAgendaView); |
|
447 mController.MainWindow().removeView(mCalenAgendaViewAlt); |
|
448 } else if (ECalenDayView == mCurrentViewId) { |
|
449 mController.MainWindow().removeView(mCalenDayView); |
|
450 } else { |
|
451 if (ECalenMonthView == mCurrentViewId) { |
|
452 mController.MainWindow().removeView(mCalenMonthView); |
|
453 } |
|
454 } |
|
455 |
314 } |
456 } |
315 |
457 |
316 // ---------------------------------------------------------------------------- |
458 // ---------------------------------------------------------------------------- |
317 // CalenViewManager::~ActivateDefaultViewL |
459 // CalenViewManager::~ActivateDefaultViewL |
318 // Activates the default view, as retrieved from settings. |
460 // Activates the default view, as retrieved from settings. |
352 switch (mCurrentViewId) { |
494 switch (mCurrentViewId) { |
353 case ECalenMonthView: |
495 case ECalenMonthView: |
354 mCalenMonthView->doPopulation(); |
496 mCalenMonthView->doPopulation(); |
355 mController.MainWindow().setCurrentView(mCalenMonthView); |
497 mController.MainWindow().setCurrentView(mCalenMonthView); |
356 break; |
498 break; |
357 case ECalenDayView: |
499 case ECalenAgendaView: |
358 if (mController.MainWindow().currentView() == mCalenDayView) { |
500 if (mController.MainWindow().currentView() == mCalenAgendaView) { |
359 // This happens when settings view or event viewer is opened |
501 // This happens when settings view or event viewer is opened |
360 // from the agenda view. Simply repopulate the view |
502 // from the agenda view. Simply repopulate the view |
361 mCalenDayView->doPopulation(); |
503 if (mCalenAgendaView) { |
362 mController.MainWindow().setCurrentView(mCalenDayView); |
504 mCalenAgendaView->doPopulation(); |
363 } else if (mController.MainWindow().currentView() == mCalenDayViewAlt){ |
505 mController.MainWindow().setCurrentView(mCalenAgendaView); |
|
506 } |
|
507 } else if (mController.MainWindow().currentView() == mCalenAgendaViewAlt){ |
364 // This happens when settings view or event viewer is opened |
508 // This happens when settings view or event viewer is opened |
365 // from the agenda view. Simply repopulate the view |
509 // from the agenda view. Simply repopulate the view |
366 mCalenDayViewAlt->doPopulation(); |
510 if (mCalenAgendaViewAlt) { |
367 mController.MainWindow().setCurrentView(mCalenDayViewAlt); |
511 mCalenAgendaViewAlt->doPopulation(); |
|
512 mController.MainWindow().setCurrentView(mCalenAgendaViewAlt); |
|
513 } |
368 } else { |
514 } else { |
369 // This is called whenever the day view is opened from the month |
515 // This is called whenever the agenda view is opened from the month |
370 // view. Since the day view is not added to the mainwindow, |
516 // view. Since the agenda view is not added to the mainwindow, |
371 // add the day views to mainwindow and set any one of them as |
517 // add the agenda views to mainwindow and set any one of them as |
372 // current view |
518 // current view |
373 mCalenDayView->doPopulation(); |
519 if (mCalenAgendaView) { |
374 mController.MainWindow().addView(mCalenDayView); |
520 mCalenAgendaView->doPopulation(); |
375 mController.MainWindow().setCurrentView(mCalenDayView); |
521 mController.MainWindow().addView(mCalenAgendaView); |
376 mController.MainWindow().addView(mCalenDayViewAlt); |
522 mController.MainWindow().setCurrentView(mCalenAgendaView); |
|
523 mController.MainWindow().addView(mCalenAgendaViewAlt); |
|
524 } |
377 } |
525 } |
378 break; |
526 break; |
379 case ECalenLandscapeDayView: |
527 case ECalenShowSettings: |
380 // For later implementation |
528 mSettingsView->refreshView(); |
|
529 break; |
|
530 case ECalenDayView: |
|
531 mCalenDayView->doPopulation(); |
|
532 mController.MainWindow().setCurrentView(mCalenDayView); |
381 break; |
533 break; |
382 } |
534 } |
383 TRACE_EXIT_POINT; |
535 TRACE_EXIT_POINT; |
384 } |
536 } |
385 |
537 |
389 // (other items were commented in a header). |
541 // (other items were commented in a header). |
390 // ---------------------------------------------------------------------------- |
542 // ---------------------------------------------------------------------------- |
391 // |
543 // |
392 void CalenViewManager::launchEventView() |
544 void CalenViewManager::launchEventView() |
393 { |
545 { |
|
546 // capture cureent view in case app closed/quits from AgendaEventViewer |
|
547 if (mCalenMonthView) { |
|
548 mCalenMonthView->captureScreenshot(true); |
|
549 } |
|
550 else if (mCalenAgendaView) { |
|
551 mCalenAgendaView->captureScreenshot(true); |
|
552 } |
394 MCalenContext& context = mController.Services().Context(); |
553 MCalenContext& context = mController.Services().Context(); |
395 AgendaEntry viewEntry= mController.Services().agendaInterface()->fetchById( |
554 AgendaEntry viewEntry= mController.Services().agendaInterface()->fetchById( |
396 context.instanceId().mEntryLocalUid ); |
555 context.instanceId().mEntryLocalUid ); |
397 if (viewEntry.isRepeating() |
556 if (viewEntry.isRepeating() |
398 && viewEntry.type() != AgendaEntry::TypeTodo) { |
557 && viewEntry.type() != AgendaEntry::TypeTodo) { |
399 QDateTime startDateTime = context.focusDateAndTimeL(); |
558 QDateTime startDateTime = context.focusDateAndTime(); |
400 viewEntry.setStartAndEndTime(startDateTime, |
559 viewEntry.setStartAndEndTime(startDateTime, |
401 startDateTime.addSecs(viewEntry.durationInSecs())); |
560 startDateTime.addSecs(viewEntry.durationInSecs())); |
402 } |
561 } |
403 mCalenEventViewer = new AgendaEventViewer( |
562 mCalenEventViewer = new AgendaEventViewer( |
404 mController.Services().agendaInterface(), this); |
563 mController.Services().agendaInterface(), this); |
417 // Launch agenda event viewer |
576 // Launch agenda event viewer |
418 mCalenEventViewer->view(viewEntry, AgendaEventViewer::ActionEditDelete); |
577 mCalenEventViewer->view(viewEntry, AgendaEventViewer::ActionEditDelete); |
419 } |
578 } |
420 |
579 |
421 // ---------------------------------------------------------------------------- |
580 // ---------------------------------------------------------------------------- |
422 // CalenViewManager::loadAlternateDayView |
581 // CalenViewManager::loadAlternateAgendaView |
423 // other items were commented in a header |
582 // other items were commented in a header |
424 // ---------------------------------------------------------------------------- |
583 // ---------------------------------------------------------------------------- |
425 // |
584 // |
426 void CalenViewManager::loadAlternateDayView() |
585 void CalenViewManager::loadAlternateAgendaView() |
427 { |
586 { |
428 bool loadSuccess = false; |
587 bool loadSuccess = false; |
429 // Create the day view docloader object. |
588 // Create the agenda view docloader object. |
430 mDayViewAltDocLoader = new CalenDocLoader(mController); |
589 mAgendaViewAltDocLoader = new CalenDocLoader(mController); |
431 |
590 |
432 // Load default section |
591 // Load default section |
433 mDayViewAltDocLoader->load(CALEN_DAYVIEW_XML_FILE, &loadSuccess); |
592 mAgendaViewAltDocLoader->load(CALEN_AGENDAVIEW_XML_FILE, &loadSuccess); |
434 if (!loadSuccess) { |
593 if (!loadSuccess) { |
435 qFatal("calenviewmanager.cpp : Unable to load XML"); |
594 qFatal("calenviewmanager.cpp : Unable to load XML"); |
436 } |
595 } |
437 |
596 |
438 // Get the calenday view from the loader |
597 // Get the calenagenda view from the loader |
439 mCalenDayViewAlt = static_cast<CalenDayView *> (mDayViewAltDocLoader->findWidget(CALEN_DAYVIEW)); |
598 mCalenAgendaViewAlt = static_cast<CalenAgendaView *> (mAgendaViewAltDocLoader->findWidget(CALEN_AGENDAVIEW)); |
440 if (!mCalenDayViewAlt) { |
599 if (!mCalenAgendaViewAlt) { |
441 qFatal("calenviewmanager.cpp : Unable to find alternate day view"); |
600 qFatal("calenviewmanager.cpp : Unable to find alternate agenda view"); |
442 } |
601 } |
443 |
602 |
444 // Setup the day view |
603 // Setup the agenda view |
445 mCalenDayViewAlt->setupView(mDayViewAltDocLoader); |
604 mCalenAgendaViewAlt->setupView(mAgendaViewAltDocLoader); |
446 } |
605 } |
447 |
606 |
448 // ---------------------------------------------------------------------------- |
607 // ---------------------------------------------------------------------------- |
449 // CalenViewManager::HandleCommandL |
608 // CalenViewManager::HandleCommandL |
450 // Handles view manager commands. |
609 // Handles view manager commands. |
456 TRACE_ENTRY_POINT; |
615 TRACE_ENTRY_POINT; |
457 TBool commandUsed(EFalse); |
616 TBool commandUsed(EFalse); |
458 |
617 |
459 switch (command.Command()) { |
618 switch (command.Command()) { |
460 case ECalenMonthView: |
619 case ECalenMonthView: |
461 removeDayViews(); |
620 // First remove the previous native view before |
|
621 // we set the mCurrentViewId with the current view |
|
622 removePreviousView(); |
462 // Add month view to mainwindow. |
623 // Add month view to mainwindow. |
463 mController.MainWindow().addView(mCalenMonthView); |
624 mController.MainWindow().addView(mCalenMonthView); |
464 mCurrentViewId = ECalenMonthView; |
625 mCurrentViewId = ECalenMonthView; |
465 activateCurrentView(); |
626 activateCurrentView(); |
466 break; |
627 break; |
|
628 case ECalenAgendaView: |
|
629 // First remove the previous native view before |
|
630 // we set the mCurrentViewId with the current view |
|
631 removePreviousView(); |
|
632 mCurrentViewId = ECalenAgendaView; |
|
633 activateCurrentView(); |
|
634 break; |
467 case ECalenDayView: |
635 case ECalenDayView: |
468 // Remove month view from mainwindow. |
636 { |
469 mController.MainWindow().removeView(mCalenMonthView); |
637 // First add new view and use QueuedConnection to assure that |
470 mCurrentViewId = ECalenDayView; |
638 // view is ready before setting it as the current view |
471 activateCurrentView(); |
639 mController.MainWindow().addView(mCalenDayView); |
|
640 QMetaObject::invokeMethod(this, "handleDayViewReady", |
|
641 Qt::QueuedConnection); |
|
642 } |
472 break; |
643 break; |
473 case ECalenEventView: |
644 case ECalenEventView: |
474 launchEventView(); |
645 launchEventView(); |
475 break; |
|
476 case ECalenLandscapeDayView: |
|
477 mCurrentViewId = ECalenLandscapeDayView; |
|
478 activateCurrentView(); |
|
479 break; |
646 break; |
480 case ECalenStartActiveStep: |
647 case ECalenStartActiveStep: |
481 activateCurrentView(); |
648 activateCurrentView(); |
482 break; |
649 break; |
483 case ECalenShowNextDay: |
650 case ECalenShowNextDay: |
500 void CalenViewManager::HandleNotification( |
667 void CalenViewManager::HandleNotification( |
501 const TCalenNotification notification) |
668 const TCalenNotification notification) |
502 { |
669 { |
503 TRACE_ENTRY_POINT; |
670 TRACE_ENTRY_POINT; |
504 switch (notification) { |
671 switch (notification) { |
505 case ECalenNotifySystemLocaleChanged: |
|
506 case ECalenNotifyExternalDatabaseChanged: |
672 case ECalenNotifyExternalDatabaseChanged: |
507 case ECalenNotifyDialogClosed: |
673 case ECalenNotifyDialogClosed: |
508 case ECalenNotifyMultipleEntriesDeleted: |
674 case ECalenNotifyMultipleEntriesDeleted: |
509 case ECalenNotifyEntrySaved: |
675 case ECalenNotifyEntrySaved: |
510 case ECalenNotifyEntryDeleted: |
676 case ECalenNotifyEntryDeleted: |
511 case ECalenNotifyInstanceDeleted: |
677 case ECalenNotifyInstanceDeleted: |
512 case ECalenNotifyEntryClosed: |
678 case ECalenNotifyEntryClosed: |
|
679 case ECalenNotifySystemLocaleChanged: |
|
680 case ECalenNotifySystemLanguageChanged: |
|
681 { |
|
682 activateCurrentView(); |
|
683 } |
|
684 break; |
513 case ECalenNotifySettingsClosed: |
685 case ECalenNotifySettingsClosed: |
|
686 { |
|
687 //when setting view closed , switch to the previous view |
|
688 mCurrentViewId = mPreviousViewsId ; |
514 mController.Services().IssueCommandL(ECalenStartActiveStep); |
689 mController.Services().IssueCommandL(ECalenStartActiveStep); |
|
690 |
|
691 // invalidate captured screenshots as either agenda view is activated now |
|
692 if (mCalenMonthView) { |
|
693 mCalenMonthView->captureScreenshot(); |
|
694 } else if (mCalenAgendaView) { |
|
695 mCalenAgendaView->captureScreenshot(); |
|
696 } |
|
697 |
|
698 } |
515 break; |
699 break; |
516 default: |
700 default: |
517 break; |
701 break; |
518 } |
702 } |
519 TRACE_EXIT_POINT; |
703 TRACE_EXIT_POINT; |
536 // (other items were commented in a header). |
720 // (other items were commented in a header). |
537 // ---------------------------------------------------------------------------- |
721 // ---------------------------------------------------------------------------- |
538 // |
722 // |
539 void CalenViewManager::handleViewingCompleted(const QDate date) |
723 void CalenViewManager::handleViewingCompleted(const QDate date) |
540 { |
724 { |
541 qDebug() <<"calendar: CalenViewManager::handleEditingCompleted -->"; |
|
542 |
725 |
543 // Cleanup. |
726 // Cleanup. |
544 mCalenEventViewer->deleteLater(); |
727 mCalenEventViewer->deleteLater(); |
545 if (!date.isNull() && date.isValid()) { |
728 if (!date.isNull() && date.isValid()) { |
546 mController.Services().Context().setFocusDateL(QDateTime(date), |
729 mController.Services().Context().setFocusDate(QDateTime(date)); |
547 ECalenDayView); |
|
548 } |
730 } |
549 mController.Services().IssueNotificationL(ECalenNotifyEntryClosed); |
731 mController.Services().IssueNotificationL(ECalenNotifyEntryClosed); |
550 |
732 |
551 qDebug() <<"calendar: CalenViewManager::handleEditingCompleted <--"; |
733 // invalidate captured screenshots as either agenda view is activated now |
|
734 if (mCalenMonthView) { |
|
735 mCalenMonthView->captureScreenshot(); |
|
736 } else if (mCalenAgendaView) { |
|
737 mCalenAgendaView->captureScreenshot(); |
|
738 } |
552 } |
739 } |
553 |
740 |
554 // ---------------------------------------------------------------------------- |
741 // ---------------------------------------------------------------------------- |
555 // CalenViewManager::handleEditingStarted |
742 // CalenViewManager::handleEditingStarted |
556 // Slot to handle signal editingStarted by the agenda event viewer |
743 // Slot to handle signal editingStarted by the agenda event viewer |
557 // (other items were commented in a header). |
744 // (other items were commented in a header). |
558 // ---------------------------------------------------------------------------- |
745 // ---------------------------------------------------------------------------- |
559 // |
746 // |
560 void CalenViewManager::handleEditingStarted() |
747 void CalenViewManager::handleEditingStarted() |
561 { |
748 { |
562 qDebug() <<"calendar: CalenViewManager::handleEditingStarted -->"; |
|
563 |
749 |
564 mController.IssueCommandL(ECalenEditEntryFromViewer); |
750 mController.IssueCommandL(ECalenEditEntryFromViewer); |
565 |
751 |
566 qDebug() <<"calendar: CalenViewManager::handleEditingStarted <--"; |
|
567 } |
752 } |
568 |
753 |
569 // ---------------------------------------------------------------------------- |
754 // ---------------------------------------------------------------------------- |
570 // CalenViewManager::handleEditingCompleted |
755 // CalenViewManager::handleEditingCompleted |
571 // Slot to handle signal editingCompleted by the agenda event viewer |
756 // Slot to handle signal editingCompleted by the agenda event viewer |
572 // (other items were commented in a header). |
757 // (other items were commented in a header). |
573 // ---------------------------------------------------------------------------- |
758 // ---------------------------------------------------------------------------- |
574 // |
759 // |
575 void CalenViewManager::handleEditingCompleted() |
760 void CalenViewManager::handleEditingCompleted() |
576 { |
761 { |
577 qDebug() <<"calendar: CalenViewManager::handleEditingStarted -->"; |
|
578 |
762 |
579 mController.Services().IssueNotificationL(ECalenNotifyEditorClosedFromViewer); |
763 mController.Services().IssueNotificationL(ECalenNotifyEditorClosedFromViewer); |
580 |
764 |
581 qDebug() <<"calendar: CalenViewManager::handleEditingStarted <--"; |
|
582 } |
765 } |
583 |
766 |
584 // ---------------------------------------------------------------------------- |
767 // ---------------------------------------------------------------------------- |
585 // CalenViewManager::handleDeletingStarted |
768 // CalenViewManager::handleDeletingStarted |
586 // Slot to handle signal deletingStarted by the agenda event viewer |
769 // Slot to handle signal deletingStarted by the agenda event viewer |
587 // (other items were commented in a header). |
770 // (other items were commented in a header). |
588 // ---------------------------------------------------------------------------- |
771 // ---------------------------------------------------------------------------- |
589 // |
772 // |
590 void CalenViewManager::handleDeletingStarted() |
773 void CalenViewManager::handleDeletingStarted() |
591 { |
774 { |
592 qDebug() <<"calendar: CalenViewManager::handleEditingStarted -->"; |
|
593 |
775 |
594 mController.IssueCommandL(ECalenDeleteEntryFromViewer); |
776 mController.IssueCommandL(ECalenDeleteEntryFromViewer); |
595 |
777 |
596 qDebug() <<"calendar: CalenViewManager::handleEditingStarted <--"; |
|
597 } |
778 } |
598 |
779 |
599 // ---------------------------------------------------------------------------- |
780 // ---------------------------------------------------------------------------- |
600 // CalenViewManager::handleDeletingCompleted |
781 // CalenViewManager::handleDeletingCompleted |
601 // Slot to handle signal deletingCompleted by the agenda event viewer |
782 // Slot to handle signal deletingCompleted by the agenda event viewer |
602 // (other items were commented in a header). |
783 // (other items were commented in a header). |
603 // ---------------------------------------------------------------------------- |
784 // ---------------------------------------------------------------------------- |
604 // |
785 // |
605 void CalenViewManager::handleDeletingCompleted() |
786 void CalenViewManager::handleDeletingCompleted() |
606 { |
787 { |
607 qDebug() <<"calendar: CalenViewManager::handleEditingStarted -->"; |
|
608 |
788 |
609 mController.Services().IssueNotificationL(ECalenNotifyEntryDeleted); |
789 mController.Services().IssueNotificationL(ECalenNotifyEntryDeleted); |
610 |
790 |
611 qDebug() <<"calendar: CalenViewManager::handleEditingStarted <--"; |
791 // invalidate captured screenshots as either month view or agenda view is activated now |
|
792 if (mCalenMonthView) { |
|
793 mCalenMonthView->captureScreenshot(); |
|
794 } else if (mCalenAgendaView) { |
|
795 mCalenAgendaView->captureScreenshot(); |
|
796 } |
|
797 |
|
798 |
|
799 } |
|
800 |
|
801 // ---------------------------------------------------------------------------- |
|
802 // CalenViewManager::handleInstanceViewCreation |
|
803 // Slot to handle completion of instance view creation |
|
804 // (other items were commented in a header). |
|
805 // ---------------------------------------------------------------------------- |
|
806 // |
|
807 void CalenViewManager::handleInstanceViewCreation(int status) |
|
808 { |
|
809 Q_UNUSED(status); |
|
810 // handleInstanceViewCreation function is called only once. Now that the instance |
|
811 // view creation is successfull. Events need to be populated on screen |
|
812 // Ideal colution should be to call a uniform function, e.g. PopulateEvents |
|
813 // where PopulateEvents should be implemeted by all views. Since the current |
|
814 // solution for the month view implements the construction in two phases so |
|
815 // it needs to be refactored and a common solution needs to be put here. So |
|
816 // that code doesn't break if another view is added tomorow |
|
817 if (mCalenMonthView) { |
|
818 mCalenMonthView->fetchEntriesAndUpdateModel(); |
|
819 } |
|
820 else if (mCalenAgendaView) { |
|
821 mCalenAgendaView->doPopulation(); |
|
822 } |
|
823 } |
|
824 |
|
825 // ---------------------------------------------------------------------------- |
|
826 // CalenViewManager::handleDeletingCompleted |
|
827 // Slot to handle completion of entry view creation |
|
828 // (other items were commented in a header). |
|
829 // ---------------------------------------------------------------------------- |
|
830 // |
|
831 void CalenViewManager::handleEntryViewCreation(int status) |
|
832 { |
|
833 // Nothing Yet |
|
834 Q_UNUSED(status); |
|
835 } |
|
836 |
|
837 // ---------------------------------------------------------------------------- |
|
838 // CalenViewManager::handleDayViewReady |
|
839 // Launches day view when it is added to MainWindow and ready to be displayed |
|
840 // ---------------------------------------------------------------------------- |
|
841 // |
|
842 void CalenViewManager::handleDayViewReady() |
|
843 { |
|
844 // Removes current view |
|
845 // Notice: removing view should be done after new view is set as current to |
|
846 // avoid situation that there is no current view in application |
|
847 removePreviousView(); |
|
848 |
|
849 // Sets and activates day view |
|
850 mCurrentViewId = ECalenDayView; |
|
851 activateCurrentView(); |
|
852 } |
|
853 |
|
854 // ---------------------------------------------------------------------------- |
|
855 // CalenViewManager::launchSettingsView |
|
856 // Launches settings view |
|
857 // (other items were commented in a header). |
|
858 // ---------------------------------------------------------------------------- |
|
859 // |
|
860 void CalenViewManager::launchSettingsView() |
|
861 { |
|
862 mPreviousViewsId = mCurrentViewId ; |
|
863 mCurrentViewId = ECalenShowSettings; |
|
864 mSettingsView->initializeForm(); |
|
865 mController.Services().MainWindow().setCurrentView(mSettingsView); |
|
866 |
|
867 // capture cureent view in case app closed/quits from settings view |
|
868 if (mCalenMonthView){ |
|
869 mCalenMonthView->captureScreenshot(true); |
|
870 } else if(mCalenAgendaView){ |
|
871 mCalenAgendaView->captureScreenshot(true); |
|
872 } |
612 } |
873 } |
613 |
874 |
614 // End of file --Don't remove this. |
875 // End of file --Don't remove this. |