1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
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: For Month view of calendar application. |
8 * |
15 * |
9 * Initial Contributors: |
16 */ |
10 * Nokia Corporation - initial contribution. |
17 |
11 * |
18 |
12 * Contributors: |
19 #include <aknnavide.h> |
13 * |
20 #include <bldvariant.hrh> // For FeatureIds (lint warns without) |
14 * Description: CalenMonthView implementation. |
21 #include <eikmenup.h> |
15 * |
22 #include <eikspane.h> //CEikStatusPane |
16 */ |
23 #include <StringLoader.h> |
17 |
24 #include <aknappui.h> |
18 //system includes |
25 #include <featmgr.h> |
19 #include <QtGui> |
26 #include <calinstance.h> |
20 #include <xqsettingsmanager.h> |
27 #include <calinstanceview.h> |
21 #include <xqsettingskey.h> |
28 #include <calcommon.h> |
22 #include <hbapplication.h> |
29 #include <caliterator.h> |
23 #include <hbmainwindow.h> |
30 #include <Calendar.rsg> |
24 #include <hbmenu.h> |
31 #include <calencommonui.rsg> |
25 #include <hbaction.h> |
32 #include <calencommands.hrh> // Calendar commands |
26 #include <hbview.h> |
33 #include <calencontext.h> |
27 #include <hblabel.h> |
34 #include <CalenStatusPaneUtils.h> |
28 #include <hbframeitem.h> |
35 #include <calenservices.h> |
29 #include <hbcolorscheme.h> |
36 #include <caleninstanceid.h> |
30 #include <hbtheme.h> |
37 #include <calenviewutils.h> |
31 #include <agendautil.h> |
38 #include <calcalendarinfo.h> |
32 #include <agendaentry.h> |
39 |
33 #include <hbapplication.h> // hbapplication |
40 #include "calendarui_debug.h" |
34 |
|
35 |
|
36 //user includes |
|
37 #include "calenmonthview.h" |
41 #include "calenmonthview.h" |
38 #include "calenservices.h" |
42 #include "calenmonthcontainer.h" |
39 #include "calennativeview.h" |
43 #include <CalenInterimUtils2.h> |
40 #include "calenview.h" |
44 #include "calentitlepane.h" |
41 #include "calenmonthdata.h" |
45 #include "calensend.h" |
42 #include "calencontext.h" |
46 #include "ToDo.hrh" |
43 #include "calenagendautils.h" |
47 #include "calendar.hrh" |
44 #include "CalenUid.h" |
48 #include "CalenUid.h" |
45 #include "hb_calencommands.hrh" |
49 |
46 #include "calendateutils.h" |
50 // ================= MEMBER FUNCTIONS ========================================= |
47 #include "calenmonthgrid.h" |
51 |
48 #include "calenpreviewpane.h" |
52 // ---------------------------------------------------------------------------- |
49 #include "calendocloader.h" |
53 // CCalenMonthView::NewLC |
50 #include "calenthicklinesdrawer.h" |
54 // First stage construction |
51 #include "calencommon.h" |
55 // (other items were commented in a header). |
52 #include "calendarprivatecrkeys.h" |
56 // ---------------------------------------------------------------------------- |
53 #include "calenpluginlabel.h" |
57 // |
54 #include "calenconstants.h" |
58 EXPORT_C CCalenMonthView* CCalenMonthView::NewL( MCalenServices& aServices ) |
55 #include "OstTraceDefinitions.h" |
59 { |
56 #ifdef OST_TRACE_COMPILER_IN_USE |
60 TRACE_ENTRY_POINT; |
57 #include "calenmonthviewTraces.h" |
61 |
58 #endif |
62 CCalenMonthView* self = new( ELeave ) CCalenMonthView( aServices ); |
59 |
63 CleanupStack::PushL( self ); |
60 // CONSTANTS |
64 self->ConstructL(); |
61 #define WEEKNUMWIDTH 6.41604 // in units, need to update this value if it |
65 CleanupStack::Pop( self ); |
62 // is changed in the docml |
66 |
63 /*! |
67 TRACE_EXIT_POINT; |
64 \class CalenMonthView |
68 return self; |
65 |
69 } |
66 Class implementing calendar month view |
70 |
67 */ |
71 // ---------------------------------------------------------------------------- |
68 |
72 // CCalenMonthView::~CCalenMonthView |
69 /*! |
73 // Destructor |
70 Default constructor. |
74 // (other items were commented in a header). |
71 */ |
75 // ---------------------------------------------------------------------------- |
72 CalenMonthView::CalenMonthView(MCalenServices &services) : |
76 // |
73 CalenNativeView(services), mAgendaUtil(services.agendaInterface()), |
77 CCalenMonthView::~CCalenMonthView() |
74 mGoToTodayAction(0), |
78 { |
75 mPrevRegionalInfo(0), |
79 TRACE_ENTRY_POINT; |
76 mCurrRegionalInfo(0), |
80 TRACE_EXIT_POINT; |
77 mNextRegionalInfo(0), |
81 } |
78 mIsAboutToQuitEventConnected(false) |
82 |
79 { |
83 // ---------------------------------------------------------------------------- |
80 OstTraceFunctionEntry0( CALENMONTHVIEW_CALENMONTHVIEW_ENTRY ); |
84 // CCalenMonthView::CCalenMonthView |
|
85 // C++ default constructor can NOT contain any code, that might leave. |
|
86 // (other items were commented in a header). |
|
87 // ---------------------------------------------------------------------------- |
|
88 // |
|
89 CCalenMonthView::CCalenMonthView( MCalenServices& aServices ) |
|
90 : CCalenNativeView( aServices ), |
|
91 iPopulationStep( ENothingDone ) |
|
92 { |
|
93 TRACE_ENTRY_POINT; |
|
94 TRACE_EXIT_POINT; |
|
95 } |
|
96 |
|
97 // ---------------------------------------------------------------------------- |
|
98 // CCalenMonthView::ConstructL |
|
99 // Symbian OS constructor can leave. |
|
100 // (other items were commented in a header). |
|
101 // ---------------------------------------------------------------------------- |
|
102 // |
|
103 void CCalenMonthView::ConstructL() |
|
104 { |
|
105 TRACE_ENTRY_POINT; |
|
106 |
|
107 CommonConstructL( R_CALEN_MONTHVIEW_INFO ); |
|
108 //iLocalisedViewName = StringLoader::LoadL( R_CALEN_VIEW_MONTH, iCoeEnv ); |
|
109 |
|
110 TRACE_EXIT_POINT; |
|
111 } |
|
112 |
|
113 // ---------------------------------------------------------------------------- |
|
114 // CCalenMonthView::SetStatusPaneFromActiveContextL |
|
115 // Set active date to Status pane |
|
116 // (other items were commented in a header). |
|
117 // ---------------------------------------------------------------------------- |
|
118 // |
|
119 void CCalenMonthView::SetStatusPaneFromActiveContextL() |
|
120 { |
|
121 TRACE_ENTRY_POINT; |
81 |
122 |
82 mIsWeekNumbersShown = 0; |
123 // title pane |
83 mOrientation = mServices.MainWindow().orientation(); |
124 TBuf<KMaxMonthName> title; |
84 // Read the date from the context |
125 TTime activeDay = CCalenContainer::DateFromContextL( iServices.Context() ); |
85 mDate = mServices.Context().focusDateAndTime(); |
126 TDateTime activeDayTime = activeDay.DateTime(); |
86 |
127 iSPUtils->MonthNameByActiveTime( title, activeDay ); |
87 // Create the settings manager instance and settings key for week number |
128 iSPUtils->UnderLineTitleText( EFalse ); |
88 mSettingsManager = new XQSettingsManager(this); |
129 iSPUtils->SetTitleTextL( title ); |
89 mWeekNumberCenrepKey |
130 |
90 = new XQSettingsKey(XQSettingsKey::TargetCentralRepository, |
131 |
91 KCRUidCalendar, KCalendarShowWeekNum); |
132 // navi pane |
92 |
133 CAknNavigationDecorator* naviLabel = iSPUtils->ShowNaviPaneL( activeDay ); |
93 mLocale = HbExtendedLocale::system(); |
134 ShowValidScrollButtons( *naviLabel, |
94 mFirstWeekLabel = NULL; |
135 activeDay - TTimeIntervalMonths(1), |
95 mIsPrevPaneGesture = false; |
136 activeDay + TTimeIntervalMonths(1) ); |
96 // Get the week day and preview heading color from the theme |
137 |
97 mWeekDaysColor = HbColorScheme::color("qtc_cal_week_day"); |
138 iSPUtils->RefreshStatusPane(); |
|
139 TRACE_EXIT_POINT; |
|
140 } |
|
141 |
|
142 // ---------------------------------------------------------------------------- |
|
143 // CCalenMonthView::DoActivateImplL |
|
144 // CCalenNativeView::DoActivateL() calls DoActivateImplL() |
|
145 // (other items were commented in a header). |
|
146 // ---------------------------------------------------------------------------- |
|
147 // |
|
148 void CCalenMonthView::DoActivateImplL( const TVwsViewId& /*aPrevViewId*/, |
|
149 TUid /*aCustomMessageId*/, |
|
150 const TDesC8& /*aCustomMessage*/ ) |
|
151 { |
|
152 TRACE_ENTRY_POINT; |
|
153 |
|
154 static_cast<CCalenMonthContainer*>(iContainer)->InitDataForMonthL(); |
|
155 |
|
156 TRACE_EXIT_POINT; |
|
157 } |
|
158 |
|
159 // ---------------------------------------------------------------------------- |
|
160 // CCalenMonthView::DoDeactivateImpl |
|
161 // CCalenNativeView::DoDeactivateL() calls DoDeactivateImplL() |
|
162 // (other items were commented in a header). |
|
163 // ---------------------------------------------------------------------------- |
|
164 // |
|
165 void CCalenMonthView::DoDeactivateImpl() |
|
166 { |
|
167 TRACE_ENTRY_POINT; |
|
168 |
|
169 if (!iAvkonAppUi->IsDisplayingMenuOrDialog()) |
|
170 { |
|
171 iSPUtils->HideNaviPane(); |
|
172 //iNaviContainer->Pop(iNaviLabel); |
|
173 //delete iNaviLabel; |
|
174 //iNaviLabel = NULL; |
|
175 } |
|
176 |
|
177 TRACE_EXIT_POINT; |
|
178 } |
|
179 |
|
180 // ---------------------------------------------------------------------------- |
|
181 // CCalenMonthView::CreateContainerImplL |
|
182 // making CCalendarContainer. In this class, it is CCalenMonthContainer. |
|
183 // (other items were commented in a header). |
|
184 // ---------------------------------------------------------------------------- |
|
185 // |
|
186 CCalenContainer* CCalenMonthView::CreateContainerImplL() |
|
187 { |
|
188 TRACE_ENTRY_POINT; |
|
189 |
|
190 TRACE_EXIT_POINT; |
|
191 return new( ELeave )CCalenMonthContainer( this, iDate, iServices ); |
|
192 } |
|
193 |
|
194 // ---------------------------------------------------------------------------- |
|
195 // CCalenMonthView::OnLocaleChangedL |
|
196 // Locale or Today was changed when this function is called. |
|
197 // (other items were commented in a header). |
|
198 // ---------------------------------------------------------------------------- |
|
199 // |
|
200 void CCalenMonthView::OnLocaleChangedL(TInt aReason) |
|
201 { |
|
202 TRACE_ENTRY_POINT; |
|
203 |
|
204 if (iContainer) |
|
205 { |
|
206 if (iContainer->IsVisible()) |
|
207 { |
|
208 if (aReason & EChangesLocale) |
|
209 { |
|
210 if (IsContainerFocused()) |
|
211 { |
|
212 SetStatusPaneFromActiveContextL(); |
|
213 } |
|
214 else |
|
215 { |
|
216 iLocChangeReason = aReason; |
|
217 } |
|
218 } |
|
219 if ((aReason & EChangesSystemTime ) || (aReason & EChangesMidnightCrossover )) |
|
220 { |
|
221 static_cast<CCalenMonthContainer*>(iContainer)->ChangesMidnightCrossover(); |
|
222 } |
|
223 } |
|
224 else |
|
225 { // Not visible |
|
226 iLocChangeReason = aReason; |
|
227 } |
|
228 } |
|
229 |
|
230 TRACE_EXIT_POINT; |
|
231 } |
|
232 |
|
233 // ---------------------------------------------------------------------------- |
|
234 // CCalenMonthView::RedrawStatusPaneL |
|
235 // Redraw status pane when Form is closed |
|
236 // (other items were commented in a header). |
|
237 // ---------------------------------------------------------------------------- |
|
238 // |
|
239 void CCalenMonthView::RedrawStatusPaneL() |
|
240 { |
|
241 TRACE_ENTRY_POINT; |
|
242 |
|
243 SetStatusPaneFromActiveContextL(); |
|
244 |
|
245 static_cast<CCalenMonthContainer*>( |
|
246 iContainer)->ChangesMidnightCrossover(); |
98 |
247 |
99 mPreviewHeadingColor = HbColorScheme::color("qtc_cal_day_preview_heading"); |
248 static_cast<CCalenMonthContainer*>( |
|
249 iContainer)->RedrawPreviewPane(); |
100 |
250 |
101 connect(HbTheme::instance(), SIGNAL(changed()), |
251 TRACE_EXIT_POINT; |
102 this, SLOT(handleThemeChange())); |
252 } |
|
253 |
|
254 // ---------------------------------------------------------------------------- |
|
255 // CCalenMonthView::DynInitMenuPaneL |
|
256 // Changes MenuPane dynamically |
|
257 // (other items were commented in a header). |
|
258 // ---------------------------------------------------------------------------- |
|
259 // |
|
260 void CCalenMonthView::DynInitMenuPaneL(TInt aResourceId, |
|
261 CEikMenuPane* aMenuPane) |
|
262 { |
|
263 TRACE_ENTRY_POINT; |
|
264 |
|
265 TBool isEntry = EFalse; |
|
266 static_cast<CCalenMonthContainer*>(iContainer)->HidePopup(); |
|
267 |
|
268 |
|
269 CCalenNativeView::DynInitMenuPaneL(aResourceId, aMenuPane); |
|
270 switch (aResourceId) |
|
271 { |
|
272 case R_CALENDAR_MONTH_MENUPANE: |
|
273 { |
|
274 |
|
275 #ifdef RD_CALEN_EXTERNAL_CAL |
|
276 TBool isit=ExtCalendarAvailableL(); |
|
277 if (!isit) |
|
278 { |
|
279 ReleaseServiceHandler(); |
|
280 TInt dummy; |
|
281 if (aMenuPane->MenuItemExists(ECalenExtAiwCommandId,dummy)) |
|
282 { |
|
283 aMenuPane->DeleteMenuItem(ECalenExtAiwCommandId); |
|
284 } |
|
285 } |
|
286 #endif //RD_CALEN_EXTERNAL_CAL |
|
287 |
|
288 if ( ! FeatureManager::FeatureSupported(KFeatureIdHelp) ) |
|
289 { |
|
290 aMenuPane->DeleteMenuItem(EAknCmdHelp); |
|
291 } |
|
292 |
|
293 RPointerArray<CCalCalendarInfo> calendarInfoList; |
|
294 iServices.GetAllCalendarInfoL(calendarInfoList); |
|
295 CleanupClosePushL(calendarInfoList); |
|
296 |
|
297 for(TInt index=0 ; index < calendarInfoList.Count();index++ ) |
|
298 { |
|
299 if(calendarInfoList[index]->Enabled() ) |
|
300 { |
|
301 CCalIter* iterator = CCalIter::NewL( |
|
302 iServices.SessionL(calendarInfoList[index]->FileNameL()) ); |
|
303 CleanupStack::PushL( iterator ); |
|
304 if( iterator->FirstL() != KNullDesC8() ) |
|
305 { |
|
306 isEntry = ETrue; |
|
307 } |
|
308 CleanupStack::PopAndDestroy( iterator ); |
|
309 } |
|
310 |
|
311 } |
|
312 CleanupStack::PopAndDestroy(&calendarInfoList); |
|
313 |
|
314 if( !isEntry ) |
|
315 { |
|
316 aMenuPane->DeleteMenuItem( ECalenDeleteAllEntries ); |
|
317 } |
|
318 if( !iServices.InterimUtilsL().MRViewersEnabledL( ETrue ) ) |
|
319 { |
|
320 aMenuPane->DeleteMenuItem( ECalenNewMeetingRequest ); |
|
321 } |
|
322 // Offer the menu pane to the services for customisation by the |
|
323 // the view manager/plugins |
|
324 iServices.OfferMenuPaneL( aResourceId, aMenuPane ); |
|
325 } |
|
326 break; |
|
327 |
|
328 default: |
|
329 break; |
|
330 } |
|
331 |
|
332 TRACE_EXIT_POINT; |
|
333 } |
|
334 |
|
335 // ---------------------------------------------------------------------------- |
|
336 // CMonthCalenView::HandleCommandL |
|
337 // Command handling for month view. |
|
338 // (other items were commented in a header). |
|
339 // ---------------------------------------------------------------------------- |
|
340 // |
|
341 void CCalenMonthView::HandleCommandL(TInt aCommand) |
|
342 { |
|
343 TRACE_ENTRY_POINT; |
|
344 |
|
345 switch (aCommand) |
|
346 { |
|
347 // if MSK Open was selected then switch into Day view. |
|
348 case EAknSoftkeyOpen: |
|
349 CCalenNativeView::HandleCommandL( ECalenForwardsToDayView ); |
|
350 break; |
|
351 // otherwise let CCalenNativeView handle the command. |
|
352 default: |
|
353 CCalenNativeView::HandleCommandL(aCommand); |
|
354 break; |
|
355 } |
|
356 |
|
357 TRACE_EXIT_POINT; |
|
358 } |
|
359 |
|
360 // ---------------------------------------------------------------------------- |
|
361 // CCalenMonthView::Id |
|
362 // From CAknView |
|
363 // Return the UID of the month view |
|
364 // (other items were commented in a header) |
|
365 // ---------------------------------------------------------------------------- |
|
366 // |
|
367 TUid CCalenMonthView::Id() const |
|
368 { |
|
369 TRACE_ENTRY_POINT; |
|
370 |
|
371 TRACE_EXIT_POINT; |
|
372 return KUidCalenMonthView; |
|
373 } |
|
374 |
|
375 // ---------------------------------------------------------------------------- |
|
376 // CCalenMonthView::ClearViewSpecificDataL |
|
377 // Clears any cached data for the specific view, e.g. currently |
|
378 // highlighted row, column, etc. |
|
379 // (other items were commented in a header) |
|
380 // ---------------------------------------------------------------------------- |
|
381 // |
|
382 void CCalenMonthView::ClearViewSpecificDataL() |
|
383 { |
|
384 TRACE_ENTRY_POINT; |
|
385 |
|
386 iDate = Time::NullTTime(); |
|
387 |
|
388 TRACE_EXIT_POINT; |
|
389 } |
|
390 |
|
391 // ---------------------------------------------------------------------------- |
|
392 // CCalenMonthView::IsViewSpecificDataNullL |
|
393 // From CCalenNativeView |
|
394 // Returns ETrue if the view specific data is null, EFalse otherwise. |
|
395 // (other items were commented in a header) |
|
396 // ---------------------------------------------------------------------------- |
|
397 // |
|
398 TBool CCalenMonthView::IsViewSpecificDataNullL() |
|
399 { |
|
400 TRACE_ENTRY_POINT; |
|
401 TRACE_EXIT_POINT; |
|
402 return ( iDate == Time::NullTTime() ); |
|
403 } |
|
404 |
|
405 // ---------------------------------------------------------------------------- |
|
406 // CCalenMonthView::ActiveStepL |
|
407 // From CCalenView |
|
408 // (other items were commented in a header) |
|
409 // ---------------------------------------------------------------------------- |
|
410 // |
|
411 CCalenView::TNextPopulationStep CCalenMonthView::ActiveStepL() |
|
412 { |
|
413 TRACE_ENTRY_POINT; |
|
414 |
|
415 CCalenMonthContainer* cnt = static_cast<CCalenMonthContainer*>( iContainer ); |
|
416 if(!cnt) |
|
417 { |
|
418 TRACE_EXIT_POINT; |
|
419 iPopulationStep = EPopulationDone; |
|
420 return CCalenView::EDone; |
|
421 } |
|
422 |
|
423 switch( iPopulationStep ) |
|
424 { |
|
425 case ENothingDone: |
|
426 { |
|
427 cnt->PrepareForPopulationL(); |
|
428 iPopulationStep = ERequestedInstanceView; |
|
429 |
|
430 CCalenView::TNextPopulationStep nextStep = CCalenView::EDone; |
|
431 |
|
432 // Get the active collection ids. |
|
433 RArray<TInt> colIdArray; |
|
434 CCalenNativeView::GetActiveCollectionidsL( iServices, colIdArray ); |
|
435 |
|
436 if(colIdArray.Count() > 0) |
|
437 { |
|
438 if( !iServices.InstanceViewL(colIdArray) ) |
|
439 { |
|
440 TRACE_EXIT_POINT; |
|
441 nextStep = CCalenView::EWaitForInstanceView; |
|
442 } |
|
443 else |
|
444 { |
|
445 TRACE_EXIT_POINT; |
|
446 nextStep = CCalenView::EKeepGoing; |
|
447 } |
|
448 } |
|
449 else |
|
450 { |
|
451 if( !iServices.InstanceViewL() ) |
|
452 { |
|
453 TRACE_EXIT_POINT; |
|
454 nextStep = CCalenView::EWaitForInstanceView; |
|
455 } |
|
456 else |
|
457 { |
|
458 TRACE_EXIT_POINT; |
|
459 nextStep = CCalenView::EKeepGoing; |
|
460 } |
|
461 } |
|
462 colIdArray.Reset(); |
|
463 return nextStep; |
|
464 } |
|
465 |
|
466 case ERequestedInstanceView: |
|
467 { |
|
468 cnt->PopulateWithInstanceViewL(); |
|
469 iPopulationStep = ESetIndicatorNext; |
|
470 TRACE_EXIT_POINT; |
|
471 return CCalenView::EKeepGoing; |
|
472 } |
|
473 case ESetIndicatorNext: |
|
474 { |
|
475 cnt->SetIndicatorL(); |
|
476 iPopulationStep = ESetFocusNext; |
|
477 TRACE_EXIT_POINT; |
|
478 return CCalenView::EKeepGoing; |
|
479 } |
|
480 case ESetFocusNext: |
|
481 { |
|
482 cnt->SetFocusL(); |
|
483 iPopulationStep = EPopulationDone; |
|
484 TRACE_EXIT_POINT; |
|
485 return CCalenView::EKeepGoing; |
|
486 } |
|
487 case EPopulationDone: /* fall through... */ |
|
488 default: |
|
489 { |
|
490 cnt->CompletePopulationL(); |
|
491 |
|
492 TRACE_EXIT_POINT; |
|
493 return CCalenView::EDone; |
|
494 } |
|
495 } |
|
496 } |
|
497 |
|
498 // ---------------------------------------------------------------------------- |
|
499 // CCalenMonthView::CancelPopulation |
|
500 // From CCalenView |
|
501 // (other items were commented in a header) |
|
502 // ---------------------------------------------------------------------------- |
|
503 // |
|
504 void CCalenMonthView::CancelPopulation() |
|
505 { |
|
506 TRACE_ENTRY_POINT; |
|
507 |
|
508 iPopulationStep = ENothingDone; |
|
509 |
|
510 TRACE_EXIT_POINT; |
|
511 } |
|
512 |
|
513 // ---------------------------------------------------------------------------- |
|
514 // CCalenMonthView::CyclePosition |
|
515 // From CCalenView |
|
516 // (other items were commented in a header) |
|
517 // ---------------------------------------------------------------------------- |
|
518 // |
|
519 CCalenView::TCyclePosition CCalenMonthView::CyclePosition() const |
|
520 { |
|
521 TRACE_ENTRY_POINT; |
|
522 TRACE_EXIT_POINT; |
|
523 return CCalenView::EReplaceMonthView; |
|
524 } |
|
525 |
|
526 // ---------------------------------------------------------------------------- |
|
527 // CCalenMonthView::LocalisedViewNameL |
|
528 // From CCalenView |
|
529 // (other items were commented in a header) |
|
530 // ---------------------------------------------------------------------------- |
|
531 // |
|
532 const TDesC& CCalenMonthView::LocalisedViewNameL( CCalenView::TViewName aViewName ) |
|
533 { |
|
534 TRACE_ENTRY_POINT; |
103 |
535 |
104 OstTraceFunctionExit0( CALENMONTHVIEW_CALENMONTHVIEW_EXIT ); |
536 HBufC* ret = NULL; |
105 } |
537 |
106 |
538 switch ( aViewName ) |
107 /*! |
539 { |
108 Destructor. |
540 case CCalenView::EMenuName: |
109 */ |
541 if ( !iMenuName ) |
110 CalenMonthView::~CalenMonthView() |
542 { |
111 { |
543 iMenuName = StringLoader::LoadL( R_CALEN_VIEW_MONTH, iCoeEnv ); |
112 OstTraceFunctionEntry0( DUP1_CALENMONTHVIEW_CALENMONTHVIEW_ENTRY ); |
544 } |
|
545 ret = iMenuName; |
|
546 break; |
|
547 case CCalenView::ESettingsName: |
|
548 if ( !iSettingsName ) |
|
549 { |
|
550 iSettingsName = StringLoader::LoadL( R_CALEN_QTN_DEFAULT_MONTH_VIEW, |
|
551 iCoeEnv ); |
|
552 } |
|
553 ret = iSettingsName; |
|
554 break; |
|
555 default: |
|
556 ASSERT( EFalse ); |
|
557 break; |
|
558 } |
|
559 |
|
560 TRACE_EXIT_POINT; |
|
561 return *ret; |
|
562 } |
|
563 |
|
564 // ---------------------------------------------------------------------------- |
|
565 // CCalenMonthView::ViewIconL |
|
566 // From CCalenView |
|
567 // (other items were commented in a header) |
|
568 // ---------------------------------------------------------------------------- |
|
569 // |
|
570 CGulIcon* CCalenMonthView::ViewIconL() const |
|
571 { |
|
572 TRACE_ENTRY_POINT; |
|
573 TRACE_EXIT_POINT; |
|
574 return iServices.GetIconL( MCalenServices::ECalenMonthViewIcon ); |
|
575 } |
|
576 |
|
577 // ---------------------------------------------------------------------------- |
|
578 // CCalenMonthView::UpdatePreviewPaneL |
|
579 // Updates preview pane/preview popup |
|
580 // (other items were commented in a header) |
|
581 // ---------------------------------------------------------------------------- |
|
582 // |
|
583 void CCalenMonthView::UpdatePreviewPaneL() |
|
584 { |
|
585 TRACE_ENTRY_POINT; |
113 |
586 |
114 OstTraceFunctionExit0( DUP1_CALENMONTHVIEW_CALENMONTHVIEW_EXIT ); |
587 CCalenMonthContainer* cnt = static_cast<CCalenMonthContainer*>( iContainer ); |
115 } |
588 if(cnt) |
116 |
589 { |
117 /*! |
590 cnt->RedrawPreviewPane(); |
118 Called by the CalenViewManager after loading the view from the docml. |
591 } |
119 The initializaion/setup of the view is done here. |
592 |
120 */ |
593 TRACE_EXIT_POINT; |
121 void CalenMonthView::setupView(CalenDocLoader *docLoader) |
594 } |
122 { |
595 |
123 OstTraceFunctionEntry0( CALENMONTHVIEW_SETUPVIEW_ENTRY ); |
596 // ---------------------------------------------------------------------------- |
|
597 // CCalenMonthView::HidePreviewPane |
|
598 // Hides preview pane/preview popup |
|
599 // (other items were commented in a header) |
|
600 // ---------------------------------------------------------------------------- |
|
601 // |
|
602 void CCalenMonthView::HidePreviewPane() |
|
603 { |
|
604 TRACE_ENTRY_POINT; |
124 |
605 |
125 mDocLoader = docLoader; |
606 CCalenMonthContainer* cnt = static_cast<CCalenMonthContainer*>( iContainer ); |
126 mTitleLabel |
607 if(cnt) |
127 = qobject_cast<HbLabel *> ( |
608 { |
128 mDocLoader->findWidget(CALEN_MONTH_TITLE)); |
609 cnt->HidePopup(); |
129 // Set the title text color |
610 } |
130 QColor monthTitleColor = HbColorScheme::color("qtc_cal_monthgrid_title"); |
|
131 if (mTitleLabel && monthTitleColor.isValid()) { |
|
132 mTitleLabel->setTextColor(monthTitleColor); |
|
133 } |
|
134 |
|
135 mDayNameWidget |
|
136 = qobject_cast<CalenThickLinesDrawer *> ( |
|
137 mDocLoader->findWidget( |
|
138 CALEN_DAYNAMES_WIDGET)); |
|
139 |
|
140 // Get all the seven day labels |
|
141 mFirstDayLabel |
|
142 = qobject_cast<HbLabel *> ( |
|
143 mDocLoader->findWidget(CALEN_MONTVIEW_FIRST_DAY_LABEL)); |
|
144 mSecondDayLabel |
|
145 = qobject_cast<HbLabel *> ( |
|
146 mDocLoader->findWidget(CALEN_MONTVIEW_SECOND_DAY_LABEL)); |
|
147 mThirdDayLabel |
|
148 = qobject_cast<HbLabel *> ( |
|
149 mDocLoader->findWidget(CALEN_MONTVIEW_THIRD_DAY_LABEL)); |
|
150 mFourthDayLabel |
|
151 = qobject_cast<HbLabel *> ( |
|
152 mDocLoader->findWidget(CALEN_MONTVIEW_FOURTH_DAY_LABEL)); |
|
153 mFifthDayLabel |
|
154 = qobject_cast<HbLabel *> ( |
|
155 mDocLoader->findWidget(CALEN_MONTVIEW_FIFTH_DAY_LABEL)); |
|
156 mSixthDayLabel |
|
157 = qobject_cast<HbLabel *> ( |
|
158 mDocLoader->findWidget(CALEN_MONTVIEW_SIXTH_DAY_LABEL)); |
|
159 mSeventhDayLabel |
|
160 = qobject_cast<HbLabel *> ( |
|
161 mDocLoader->findWidget(CALEN_MONTVIEW_SEVENTH_DAY_LABEL)); |
|
162 |
|
163 // Get the weeknumber widget |
|
164 mWeekNumberWidget |
|
165 = qobject_cast<CalenThickLinesDrawer *> ( |
|
166 mDocLoader->findWidget(CALEN_WEEKNUMBERS_WIDGET)); |
|
167 // Disable the item so that line seperator doesnt gets drawn by default |
|
168 mWeekNumberWidget->setEnabled(false); |
|
169 |
|
170 // Get the month grid |
|
171 mMonthGrid |
|
172 = qobject_cast<CalenMonthGrid *> ( |
|
173 mDocLoader->findWidget(CALEN_MONTHGRID)); |
|
174 mCurrPaneParent = qobject_cast<HbWidget *> ( |
|
175 mDocLoader->findWidget(CALEN_CURRPREVIEWPARENT)); |
|
176 // Get current day preview pane widget |
|
177 mCurrPreviewPane |
|
178 = static_cast<CalenPreviewPane *> ( |
|
179 docLoader->findWidget(CALEN_CURRPREVIEWPANE)); |
|
180 //mCurrPreviewPane->setParent(mCurrPaneParent); |
|
181 mCurrPaneParent->setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); |
|
182 HbLabel* currPaneNoEntriesLabel = static_cast<HbLabel *> ( |
|
183 docLoader->findWidget(CALEN_NOENTRIES_LABEL_CURR)); |
|
184 mCurrPreviewPane->setView(this); |
|
185 mCurrPreviewPane->setNoEntriesLabel(currPaneNoEntriesLabel); |
|
186 |
|
187 connect( |
|
188 HbTheme::instance(), SIGNAL(changed()), |
|
189 mCurrPreviewPane, SLOT(handleThemeChange())); |
|
190 |
|
191 mCurrPaneLayoutWidget = qobject_cast<HbWidget*>(docLoader->findWidget(CALEN_CURRPANELAYOUT)); |
|
192 mCurrPaneLayout = static_cast<QGraphicsLinearLayout*>(mCurrPaneLayoutWidget->layout()); |
|
193 |
|
194 mPrevPaneParent = qobject_cast<HbWidget *> ( |
|
195 mDocLoader->findWidget(CALEN_PREVPREVIEWPARENT)); |
|
196 // Get previous day preview pane widget |
|
197 mPrevPreviewPane |
|
198 = static_cast<CalenPreviewPane *> ( |
|
199 docLoader->findWidget(CALEN_PREVPREVIEWPANE)); |
|
200 //mPrevPreviewPane->setParent(mPrevPaneParent); |
|
201 mPrevPaneParent->setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); |
|
202 HbLabel* prevPaneNoEntriesLabel = static_cast<HbLabel *> ( |
|
203 docLoader->findWidget(CALEN_NOENTRIES_LABEL_PREV)); |
|
204 mPrevPreviewPane->setView(this); |
|
205 mPrevPreviewPane->setNoEntriesLabel(prevPaneNoEntriesLabel); |
|
206 connect( |
|
207 HbTheme::instance(), SIGNAL(changed()), |
|
208 mPrevPreviewPane, SLOT(handleThemeChange())); |
|
209 mPrevPaneParent->setVisible(false); |
|
210 |
|
211 mPrevPaneLayoutWidget = qobject_cast<HbWidget*>(docLoader->findWidget(CALEN_PREVPANELAYOUT)); |
|
212 mPrevPaneLayout = static_cast<QGraphicsLinearLayout*>(mPrevPaneLayoutWidget->layout()); |
|
213 mNextPaneParent = qobject_cast<HbWidget *> ( |
|
214 mDocLoader->findWidget(CALEN_NEXTPREVIEWPARENT)); |
|
215 // Get next day preview pane widget |
|
216 mNextPreviewPane |
|
217 = static_cast<CalenPreviewPane *> ( |
|
218 docLoader->findWidget(CALEN_NEXTPREVIEWPANE)); |
|
219 //mNextPreviewPane->setParent(mNextPaneParent); |
|
220 mNextPaneParent->setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); |
|
221 HbLabel* nextPaneNoEntriesLabel = static_cast<HbLabel *> ( |
|
222 docLoader->findWidget(CALEN_NOENTRIES_LABEL_NEXT)); |
|
223 mNextPreviewPane->setView(this); |
|
224 mNextPreviewPane->setNoEntriesLabel(nextPaneNoEntriesLabel); |
|
225 connect( |
|
226 HbTheme::instance(), SIGNAL(changed()), |
|
227 mNextPreviewPane, SLOT(handleThemeChange())); |
|
228 |
611 |
229 mNextPaneParent->setVisible(false); |
612 TRACE_EXIT_POINT; |
230 mNextPaneLayoutWidget = qobject_cast<HbWidget*>(docLoader->findWidget(CALEN_NEXTPANELAYOUT)); |
613 } |
231 mNextPaneLayout = static_cast<QGraphicsLinearLayout*>(mNextPaneLayoutWidget->layout()); |
614 |
232 |
615 // End of File |
233 mMonthGridPlusWeekNumWidget |
|
234 = qobject_cast<HbWidget *> ( |
|
235 mDocLoader->findWidget(CALEN_MONTHGRID_WEEKNUMBERS_WIDGET)); |
|
236 |
|
237 mMonthGrid->setView(this); |
|
238 |
|
239 |
|
240 |
|
241 mIsFirstTimeLoad = true; |
|
242 |
|
243 // clean up any previous versions of this activity, if any, i.e. activityName |
|
244 // Ignore return value, first boot would always return False. bool declared |
|
245 // only for debugging purpose. |
|
246 bool ok = removeActivity(); |
|
247 |
|
248 OstTraceFunctionExit0( CALENMONTHVIEW_SETUPVIEW_EXIT ); |
|
249 } |
|
250 |
|
251 /*! |
|
252 Constructs the remaining part of the month view that was kept as |
|
253 part if lazy loading |
|
254 */ |
|
255 void CalenMonthView::doLazyLoading() |
|
256 { |
|
257 OstTraceFunctionEntry0( CALENMONTHVIEW_DOLAZYLOADING_ENTRY ); |
|
258 // Add background items to all the widgets |
|
259 addBackgroundFrame(); |
|
260 |
|
261 // Construct and add the previous month and next month items to the view |
|
262 mMonthGrid->updateMonthGridWithInActiveMonths(mMonthDataArray); |
|
263 |
|
264 // Check if regional information needs to be shown |
|
265 // and add it or remove it |
|
266 showHideRegionalInformation(); |
|
267 |
|
268 // Connect to the menu actions |
|
269 HbAction |
|
270 *newEventAction = |
|
271 qobject_cast<HbAction *> ( |
|
272 mDocLoader->findObject(CALEN_MONTVIEW_MENU_NEWEVENT)); |
|
273 |
|
274 connect(newEventAction, SIGNAL(triggered()), this, SLOT(createEditor())); |
|
275 |
|
276 mGoToTodayAction = |
|
277 qobject_cast<HbAction *> ( |
|
278 mDocLoader->findObject(CALEN_MONTVIEW_MENU_GOTOTODAY)); |
|
279 connect(mGoToTodayAction, SIGNAL(triggered()), this, SLOT(goToToday())); |
|
280 |
|
281 HbAction |
|
282 *goToDateAction = |
|
283 qobject_cast<HbAction *> ( |
|
284 mDocLoader->findObject(CALEN_MONTVIEW_MENU_GOTODATE)); |
|
285 |
|
286 connect(goToDateAction, SIGNAL(triggered()), this, SLOT(goToDate())); |
|
287 |
|
288 // TODO: Need to move this to docml |
|
289 // Set the title to the submenu |
|
290 mDeleteSubMenu = |
|
291 qobject_cast<HbMenu *> ( |
|
292 mDocLoader->findObject(CALEN_MONTVIEW_DELETE_SUBMENU)); |
|
293 mDeleteSubMenu->setTitle(hbTrId("txt_calendar_opt_delete_entries")); |
|
294 |
|
295 HbAction |
|
296 *beforeDateAction = |
|
297 qobject_cast<HbAction *> ( |
|
298 mDocLoader->findObject(CALEN_MONTVIEW_MENU_BEFOREDATE)); |
|
299 |
|
300 connect(beforeDateAction, SIGNAL(triggered()), this, |
|
301 SLOT(deleteBeforeDate())); |
|
302 |
|
303 HbAction |
|
304 *allEntriesAction = |
|
305 qobject_cast<HbAction *> ( |
|
306 mDocLoader->findObject(CALEN_MONTVIEW_MENU_ALLENTRIES)); |
|
307 |
|
308 connect(allEntriesAction, SIGNAL(triggered()), this, |
|
309 SLOT(deleteAllEntries())); |
|
310 |
|
311 HbAction |
|
312 *settingsAction = |
|
313 qobject_cast<HbAction *> ( |
|
314 mDocLoader->findObject(CALEN_MONTVIEW_MENU_SETTINGS)); |
|
315 |
|
316 connect(settingsAction, SIGNAL(triggered()), this, |
|
317 SLOT(launchSettingsView())); |
|
318 |
|
319 |
|
320 // Connect to the signal of change orientation. |
|
321 connect(&(mServices.MainWindow()), |
|
322 SIGNAL(orientationChanged(Qt::Orientation)), this, |
|
323 SLOT(changeOrientation(Qt::Orientation))); |
|
324 |
|
325 // Connect to the signal when options menu is shown |
|
326 // This is required to add/remove dynamically some options |
|
327 connect(menu(), SIGNAL(aboutToShow ()), this, |
|
328 SLOT(addRemoveActionsInMenu())); |
|
329 // Close the menu once closeDialogs() is received |
|
330 connect(this, SIGNAL(closeDialogs()), menu(), SLOT(close())); |
|
331 |
|
332 //add "show lunar data" action item ,if regional plugin is present |
|
333 //regional plugin will add the option itself and handles it accordingly |
|
334 //use this api after adding all action item to the menu |
|
335 //so that plugin add the "Show lunar data" item as a second last option |
|
336 // in all views |
|
337 mServices.OfferMenu(menu()); |
|
338 |
|
339 OstTraceFunctionExit0( CALENMONTHVIEW_DOLAZYLOADING_EXIT ); |
|
340 } |
|
341 |
|
342 /*! |
|
343 Adds the week numbers to the weeknumber widget |
|
344 */ |
|
345 void CalenMonthView::addWeekNumbers() |
|
346 { |
|
347 OstTraceFunctionEntry0( CALENMONTHVIEW_ADDWEEKNUMBERS_ENTRY ); |
|
348 |
|
349 if (!mFirstWeekLabel) { |
|
350 // Get all the six week labels |
|
351 mFirstWeekLabel |
|
352 = qobject_cast<HbLabel *> ( |
|
353 mDocLoader->findWidget(CALEN_MONTVIEW_FIRST_WEEK_LABEL)); |
|
354 mSecondWeekLabel |
|
355 = qobject_cast<HbLabel *> ( |
|
356 mDocLoader->findWidget(CALEN_MONTVIEW_SECOND_WEEK_LABEL)); |
|
357 mThirdWeekLabel |
|
358 = qobject_cast<HbLabel *> ( |
|
359 mDocLoader->findWidget(CALEN_MONTVIEW_THIRD_WEEK_LABEL)); |
|
360 mFourthWeekLabel |
|
361 = qobject_cast<HbLabel *> ( |
|
362 mDocLoader->findWidget(CALEN_MONTVIEW_FOURTH_WEEK_LABEL)); |
|
363 mFifthWeekLabel |
|
364 = qobject_cast<HbLabel *> ( |
|
365 mDocLoader->findWidget(CALEN_MONTVIEW_FIFTH_WEEK_LABEL)); |
|
366 mSixthWeekLabel |
|
367 = qobject_cast<HbLabel *> ( |
|
368 mDocLoader->findWidget(CALEN_MONTVIEW_SIXTH_WEEK_LABEL)); |
|
369 } |
|
370 |
|
371 // Set the text colors well before instead of setting it again and again |
|
372 mFirstWeekLabel->setTextColor(mWeekDaysColor); |
|
373 mSecondWeekLabel->setTextColor(mWeekDaysColor); |
|
374 mThirdWeekLabel->setTextColor(mWeekDaysColor); |
|
375 mFourthWeekLabel->setTextColor(mWeekDaysColor); |
|
376 mFifthWeekLabel->setTextColor(mWeekDaysColor); |
|
377 mSixthWeekLabel->setTextColor(mWeekDaysColor); |
|
378 |
|
379 // Calculate the week numbers and set them to the week labels |
|
380 updateWeekNumGridModel(); |
|
381 |
|
382 // Get the day names layout |
|
383 QGraphicsLinearLayout *dayNamesLayout = |
|
384 static_cast<QGraphicsLinearLayout *> (mDayNameWidget->layout()); |
|
385 |
|
386 if (KCalenDaysInWeek == dayNamesLayout->count()) { |
|
387 // Add one empty label in the day name grid |
|
388 HbLabel *label = new HbLabel(mDayNameWidget); |
|
389 |
|
390 // Set the attributes same as that of other day names to make it |
|
391 // look similar to the day names |
|
392 label->setPlainText(""); |
|
393 label->setFont(mFirstDayLabel->font()); |
|
394 label->setFontSpec(mFirstDayLabel->fontSpec()); |
|
395 label->setAlignment(mFirstDayLabel->alignment()); |
|
396 label->setElideMode(mFirstDayLabel->elideMode()); |
|
397 label->setZValue(mFirstDayLabel->zValue()); |
|
398 // Set the proper width to this empty label so that |
|
399 // day names are dislayed against the correct columns |
|
400 HbDeviceProfile deviceProf; |
|
401 qreal unitValue = deviceProf.unitValue(); |
|
402 qreal widthInPixels = WEEKNUMWIDTH * unitValue; |
|
403 label->setPreferredWidth(widthInPixels); |
|
404 label->setMinimumWidth(widthInPixels); |
|
405 label->setMaximumWidth(widthInPixels); |
|
406 label->setContentsMargins(0,0,0,0); |
|
407 |
|
408 // Add this label into layout |
|
409 dayNamesLayout->insertItem(0, label); |
|
410 dayNamesLayout->invalidate(); |
|
411 dayNamesLayout->activate(); |
|
412 } |
|
413 |
|
414 // Now insert the weekNumber Grid |
|
415 QGraphicsLinearLayout *layout = static_cast<QGraphicsLinearLayout *> |
|
416 (mMonthGridPlusWeekNumWidget->layout()); |
|
417 |
|
418 if (1 == layout->count()) { |
|
419 layout->insertItem(0, mWeekNumberWidget); |
|
420 // Enable the item so that line seperator gets drawn |
|
421 mWeekNumberWidget->setEnabled(true); |
|
422 layout->invalidate(); |
|
423 layout->activate(); |
|
424 } |
|
425 |
|
426 OstTraceFunctionExit0( CALENMONTHVIEW_ADDWEEKNUMBERS_EXIT ); |
|
427 } |
|
428 |
|
429 /*! |
|
430 Removes the week numbers from the view |
|
431 */ |
|
432 void CalenMonthView::removeWeekNumbers() |
|
433 |
|
434 { |
|
435 OstTraceFunctionEntry0( CALENMONTHVIEW_REMOVEWEEKNUMBERS_ENTRY ); |
|
436 |
|
437 // Remove the week number grid if setting is off |
|
438 QGraphicsLinearLayout *layout = static_cast<QGraphicsLinearLayout *> |
|
439 (mMonthGridPlusWeekNumWidget->layout()); |
|
440 if (2 == layout->count()) { |
|
441 layout->removeItem(mWeekNumberWidget); |
|
442 |
|
443 // Disable the item as we are removing it from the layout |
|
444 mWeekNumberWidget->setEnabled(false); |
|
445 layout->invalidate(); |
|
446 layout->activate(); |
|
447 |
|
448 // Clear the week labels |
|
449 mFirstWeekLabel->clear(); |
|
450 mSecondWeekLabel->clear(); |
|
451 mThirdWeekLabel->clear(); |
|
452 mFourthWeekLabel->clear(); |
|
453 mFifthWeekLabel->clear(); |
|
454 mSixthWeekLabel->clear(); |
|
455 |
|
456 // Get the day names layout |
|
457 QGraphicsLinearLayout *dayNamesLayout = |
|
458 static_cast<QGraphicsLinearLayout *> (mDayNameWidget->layout()); |
|
459 if (dayNamesLayout->count() == KCalenDaysInWeek + 1) { |
|
460 // Remove the empty item in the day name grid |
|
461 QGraphicsLayoutItem *item = dayNamesLayout->itemAt(0); |
|
462 dayNamesLayout->removeAt(0); |
|
463 delete item; |
|
464 dayNamesLayout->invalidate(); |
|
465 dayNamesLayout->activate(); |
|
466 } |
|
467 } |
|
468 |
|
469 OstTraceFunctionExit0( CALENMONTHVIEW_REMOVEWEEKNUMBERS_EXIT ); |
|
470 } |
|
471 |
|
472 /*! |
|
473 Sets the background frame for the month view |
|
474 */ |
|
475 void CalenMonthView::addBackgroundFrame() |
|
476 { |
|
477 OstTraceFunctionEntry0( CALENMONTHVIEW_ADDBACKGROUNDFRAME_ENTRY ); |
|
478 |
|
479 // Set the background items for all the widgets |
|
480 HbFrameItem* frame = NULL; |
|
481 HbFrameDrawer *drawer = NULL; |
|
482 HbWidget* monthViewExceptPreviewPane = qobject_cast<HbWidget *> ( |
|
483 mDocLoader->findWidget(CALEN_MONTHVIEW_EXCEPT_PANE)); |
|
484 if (monthViewExceptPreviewPane) { |
|
485 drawer = new HbFrameDrawer("qtg_fr_cal_monthgrid_bg", HbFrameDrawer::NinePieces); |
|
486 // The grid background |
|
487 frame = new HbFrameItem(drawer, this); |
|
488 monthViewExceptPreviewPane->setBackgroundItem(frame->graphicsItem(), -2); |
|
489 } |
|
490 if (mTitleLabel) { |
|
491 // The month title |
|
492 drawer = new HbFrameDrawer("qtg_fr_cal_monthgrid_title_bg", HbFrameDrawer::ThreePiecesHorizontal); |
|
493 if (drawer) |
|
494 frame = new HbFrameItem(drawer, this); |
|
495 if(frame) |
|
496 mTitleLabel->setBackgroundItem(frame->graphicsItem(), -2); |
|
497 } |
|
498 |
|
499 // Set the frame to the preview pane |
|
500 drawer = new HbFrameDrawer("qtg_fr_cal_preview_bg", HbFrameDrawer::NinePieces); |
|
501 if (drawer) |
|
502 frame = new HbFrameItem(drawer, this); |
|
503 if(frame) |
|
504 mPrevPaneLayoutWidget->setBackgroundItem(frame->graphicsItem(), -5); |
|
505 |
|
506 // Set the frame to the preview pane |
|
507 drawer = new HbFrameDrawer("qtg_fr_cal_preview_bg", HbFrameDrawer::NinePieces); |
|
508 if(drawer) |
|
509 frame = new HbFrameItem(drawer, this); |
|
510 if(frame) |
|
511 mCurrPaneLayoutWidget->setBackgroundItem(frame->graphicsItem(), -5); |
|
512 |
|
513 // Set the frame to the preview pane |
|
514 drawer = new HbFrameDrawer("qtg_fr_cal_preview_bg", HbFrameDrawer::NinePieces); |
|
515 if(drawer) |
|
516 frame = new HbFrameItem(drawer, this); |
|
517 if(frame) |
|
518 mNextPaneLayoutWidget->setBackgroundItem(frame->graphicsItem(), -5); |
|
519 |
|
520 OstTraceFunctionExit0( CALENMONTHVIEW_ADDBACKGROUNDFRAME_EXIT ); |
|
521 } |
|
522 |
|
523 void CalenMonthView::showHideRegionalInformation() |
|
524 { |
|
525 OstTraceFunctionEntry0( CALENMONTHVIEW_SHOWHIDEREGIONALINFORMATION_ENTRY ); |
|
526 |
|
527 if (pluginEnabled()) { |
|
528 XQSettingsKey regionalInfo(XQSettingsKey::TargetCentralRepository, |
|
529 KCRUidCalendar, KCalendarShowRegionalInfo); |
|
530 |
|
531 int showRegionalInfo = |
|
532 mSettingsManager->readItemValue(regionalInfo).toUInt(); |
|
533 if (showRegionalInfo) { |
|
534 |
|
535 // Add the regional information to the preview panes |
|
536 if (!mPrevRegionalInfo) { |
|
537 mPrevRegionalInfo = qobject_cast<CalenPluginLabel *> |
|
538 (mDocLoader->findWidget(CALEN_PREVREGIONALINFO)); |
|
539 mPrevRegionalInfo->show(); |
|
540 mPrevPaneLayout->insertItem(0, mPrevRegionalInfo); |
|
541 |
|
542 HbFrameItem *frameCurr = new HbFrameItem(this); |
|
543 frameCurr->frameDrawer().setFrameType( |
|
544 HbFrameDrawer::ThreePiecesHorizontal); |
|
545 frameCurr->frameDrawer().setFrameGraphicsName( |
|
546 "qtg_fr_cal_preview_title_bg"); |
|
547 mPrevRegionalInfo->setBackgroundItem( |
|
548 frameCurr->graphicsItem(), -2); |
|
549 } |
|
550 if (!mCurrRegionalInfo) { |
|
551 mCurrRegionalInfo = qobject_cast<CalenPluginLabel *> |
|
552 (mDocLoader->findWidget(CALEN_CURRREGIONALINFO)); |
|
553 mCurrRegionalInfo->show(); |
|
554 mCurrPaneLayout->insertItem(0, mCurrRegionalInfo); |
|
555 |
|
556 HbFrameItem *frameCurr = new HbFrameItem(this); |
|
557 frameCurr->frameDrawer().setFrameType( |
|
558 HbFrameDrawer::ThreePiecesHorizontal); |
|
559 frameCurr->frameDrawer().setFrameGraphicsName( |
|
560 "qtg_fr_cal_preview_title_bg"); |
|
561 mCurrRegionalInfo->setBackgroundItem( |
|
562 frameCurr->graphicsItem(), -2); |
|
563 } |
|
564 if (!mNextRegionalInfo) { |
|
565 mNextRegionalInfo = qobject_cast<CalenPluginLabel *> |
|
566 (mDocLoader->findWidget(CALEN_NEXTREGIONALINFO)); |
|
567 mNextRegionalInfo->show(); |
|
568 mNextPaneLayout->insertItem(0, mNextRegionalInfo); |
|
569 |
|
570 HbFrameItem *frameCurr = new HbFrameItem(this); |
|
571 frameCurr->frameDrawer().setFrameType( |
|
572 HbFrameDrawer::ThreePiecesHorizontal); |
|
573 frameCurr->frameDrawer().setFrameGraphicsName( |
|
574 "qtg_fr_cal_preview_title_bg"); |
|
575 mNextRegionalInfo->setBackgroundItem( |
|
576 frameCurr->graphicsItem(), -2); |
|
577 } |
|
578 QString *pluginString = pluginText(); |
|
579 mPrevRegionalInfo->setPlainText(*pluginString); |
|
580 mPrevRegionalInfo->setTextColor(mPreviewHeadingColor); |
|
581 mPrevRegionalInfo->setTextWrapping(Hb::TextNoWrap); |
|
582 mPrevRegionalInfo->setElideMode(Qt::ElideRight); |
|
583 |
|
584 mCurrRegionalInfo->setPlainText(*pluginString); |
|
585 mCurrRegionalInfo->setTextColor(mPreviewHeadingColor); |
|
586 mCurrRegionalInfo->setTextWrapping(Hb::TextNoWrap); |
|
587 mCurrRegionalInfo->setElideMode(Qt::ElideRight); |
|
588 |
|
589 |
|
590 mNextRegionalInfo->setPlainText(*pluginString); |
|
591 mNextRegionalInfo->setTextColor(mPreviewHeadingColor); |
|
592 mNextRegionalInfo->setTextWrapping(Hb::TextNoWrap); |
|
593 mNextRegionalInfo->setElideMode(Qt::ElideRight); |
|
594 |
|
595 } else { |
|
596 if (mPrevRegionalInfo) { |
|
597 mPrevPaneLayout->removeItem(mPrevRegionalInfo); |
|
598 mPrevRegionalInfo->hide(); |
|
599 mPrevRegionalInfo = NULL; |
|
600 } |
|
601 if (mCurrRegionalInfo) { |
|
602 mCurrPaneLayout->removeItem(mCurrRegionalInfo); |
|
603 mCurrRegionalInfo->hide(); |
|
604 mCurrRegionalInfo = NULL; |
|
605 } |
|
606 if (mNextRegionalInfo) { |
|
607 mNextPaneLayout->removeItem(mNextRegionalInfo); |
|
608 mNextRegionalInfo->hide(); |
|
609 mNextRegionalInfo = NULL; |
|
610 } |
|
611 } |
|
612 } |
|
613 |
|
614 OstTraceFunctionExit0( CALENMONTHVIEW_SHOWHIDEREGIONALINFORMATION_EXIT ); |
|
615 } |
|
616 |
|
617 /*! |
|
618 Handles the context changed notification |
|
619 */ |
|
620 void CalenMonthView::onContextChanged() |
|
621 { |
|
622 OstTraceFunctionEntry0( CALENMONTHVIEW_ONCONTEXTCHANGED_ENTRY ); |
|
623 //Update plugin label after setting context |
|
624 if (mCurrRegionalInfo && mPrevRegionalInfo && mNextPaneLayout |
|
625 && pluginEnabled()) { |
|
626 QString *pluginString = pluginText(); |
|
627 mPrevRegionalInfo->setPlainText(*pluginString); |
|
628 mCurrRegionalInfo->setPlainText(*pluginString); |
|
629 mNextRegionalInfo->setPlainText(*pluginString); |
|
630 } |
|
631 OstTraceFunctionExit0( CALENMONTHVIEW_ONCONTEXTCHANGED_EXIT ); |
|
632 } |
|
633 |
|
634 /*! |
|
635 Calculates the week numbers and sets them to the week labels |
|
636 */ |
|
637 void CalenMonthView::updateWeekNumGridModel() |
|
638 |
|
639 { |
|
640 OstTraceFunctionEntry0( CALENMONTHVIEW_UPDATEWEEKNUMGRIDMODEL_ENTRY ); |
|
641 |
|
642 // Get the visible date |
|
643 QDateTime firstVisibleDate = mFirstDayOfGrid.addDays(KCalenDaysInWeek |
|
644 * mNumOfRowsInPrevMonth); |
|
645 // Go to the last day so that we get the proper week number for the first |
|
646 // week of January |
|
647 mWeekNumbers.clear(); |
|
648 // get the proper week numbers |
|
649 for (int i = 0; i < KNumOfVisibleRows; i++) { |
|
650 // Get the week number |
|
651 QDateTime day = firstVisibleDate.addDays((KCalenDaysInWeek * i)); |
|
652 long weekNumber(day.date().weekNumber()); |
|
653 mWeekNumbers.append(weekNumber); |
|
654 } |
|
655 |
|
656 // Update the week labels text |
|
657 QString text = QString::number(mWeekNumbers.at(0)); |
|
658 mFirstWeekLabel->setPlainText(text); |
|
659 text = QString::number(mWeekNumbers.at(1)); |
|
660 mSecondWeekLabel->setPlainText(text); |
|
661 text = QString::number(mWeekNumbers.at(2)); |
|
662 mThirdWeekLabel->setPlainText(text); |
|
663 text = QString::number(mWeekNumbers.at(3)); |
|
664 mFourthWeekLabel->setPlainText(text); |
|
665 text = QString::number(mWeekNumbers.at(4)); |
|
666 mFifthWeekLabel->setPlainText(text); |
|
667 text = QString::number(mWeekNumbers.at(5)); |
|
668 mSixthWeekLabel->setPlainText(text); |
|
669 |
|
670 OstTraceFunctionExit0( CALENMONTHVIEW_UPDATEWEEKNUMGRIDMODEL_EXIT ); |
|
671 } |
|
672 |
|
673 /*! |
|
674 Populates the month view with today as focussed item |
|
675 */ |
|
676 void CalenMonthView::goToToday() |
|
677 { |
|
678 OstTraceFunctionEntry0( CALENMONTHVIEW_GOTOTODAY_ENTRY ); |
|
679 |
|
680 QDateTime today = CalenDateUtils::today(); |
|
681 // Set the context and repopulate the view |
|
682 MCalenContext &context = mServices.Context(); |
|
683 context.setFocusDateAndTime(today); |
|
684 |
|
685 // First check if we are not alread |
|
686 // showing today's month view |
|
687 if (mDate == today) { |
|
688 OstTraceFunctionExit0( CALENMONTHVIEW_GOTOTODAY_EXIT ); |
|
689 return; |
|
690 } else if (mActiveMonth.date().year() == today.date().year() && |
|
691 mActiveMonth.date().month() == today.date().month()) { |
|
692 mDate = today; |
|
693 // User is in current month only, so just set the focus to current |
|
694 // date grid item and refresh the preview pane |
|
695 int currIndex = mFirstDayOfGrid.daysTo(today); |
|
696 setCurrGridIndex(currIndex); |
|
697 // Populate the preview panes |
|
698 populatePreviewPane(mDate); |
|
699 } else { |
|
700 refreshViewOnGoToDate(); |
|
701 } |
|
702 |
|
703 OstTraceFunctionExit0( DUP1_CALENMONTHVIEW_GOTOTODAY_EXIT ); |
|
704 } |
|
705 |
|
706 /* |
|
707 Slot to handle adding / removing actions frm the menu when menu is about to |
|
708 shown to the user |
|
709 */ |
|
710 void CalenMonthView::addRemoveActionsInMenu() |
|
711 { |
|
712 OstTraceFunctionEntry0( CALENMONTHVIEW_ADDREMOVEACTIONSINMENU_ENTRY ); |
|
713 HbAction* menuAction = mDeleteSubMenu->menuAction(); |
|
714 if (menuAction) { |
|
715 if (!mEntriesInDataBase && mAgendaUtil->areNoEntriesInCalendar()) { |
|
716 // hide the delete entries option |
|
717 menuAction->setVisible(false); |
|
718 } else { |
|
719 mEntriesInDataBase = true; |
|
720 // Show the option to delete |
|
721 menuAction->setVisible(true); |
|
722 } |
|
723 } |
|
724 |
|
725 // Check if we are population for current day, if yes then disable the |
|
726 // gototoday action |
|
727 if ((CalenDateUtils::today().date() == mDate.date()) && mGoToTodayAction) { |
|
728 mGoToTodayAction->setVisible(false); |
|
729 } else if (mGoToTodayAction){ |
|
730 mGoToTodayAction->setVisible(true); |
|
731 } |
|
732 OstTraceFunctionExit0( CALENMONTHVIEW_ADDREMOVEACTIONSINMENU_EXIT ); |
|
733 } |
|
734 |
|
735 /*! |
|
736 Populates the view |
|
737 */ |
|
738 void CalenMonthView::doPopulation() |
|
739 { |
|
740 OstTraceFunctionEntry0( CALENMONTHVIEW_DOPOPULATION_ENTRY ); |
|
741 |
|
742 // Get the layout and add the preview pane layout. |
|
743 QGraphicsLinearLayout* viewLayout = static_cast<QGraphicsLinearLayout *> |
|
744 (widget()->layout()); |
|
745 if (viewLayout->count() == 1) { |
|
746 // Count is 1 implies view has only month grid. |
|
747 // Add the preview pane at corresponding position. |
|
748 viewLayout->addItem(mCurrPaneParent); |
|
749 } |
|
750 |
|
751 // prepare for the population like reading the date frm the context |
|
752 // calculating the start of the grid etc., |
|
753 prepareForPopulation(); |
|
754 |
|
755 // Populate the view and preview panes only if we are not opening the calendar |
|
756 if (!mIsFirstTimeLoad) { |
|
757 // fetch list of required calendar instances |
|
758 populateWithInstanceView(); |
|
759 // Populate the preview panes |
|
760 populatePreviewPane(mDate); |
|
761 } |
|
762 |
|
763 |
|
764 //update the day label |
|
765 //if changes in locale setting |
|
766 updateDayLabel(); |
|
767 |
|
768 // Create the grid items with proper dates |
|
769 createGrid(); |
|
770 |
|
771 |
|
772 // Complete the population |
|
773 completePopulation(); |
|
774 |
|
775 //set Currect Activity to month view |
|
776 mActivityId = ECalenMonthView; |
|
777 |
|
778 // connect to receive a call back on Month View exit. Call back would result in saveActivity |
|
779 // to be called in Native View. |
|
780 if (!mIsAboutToQuitEventConnected) // check if not already connected |
|
781 { |
|
782 connect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity())); |
|
783 mIsAboutToQuitEventConnected = true; |
|
784 } |
|
785 |
|
786 |
|
787 // Population is complete, inform it |
|
788 populationComplete(); |
|
789 |
|
790 // Handle regional data here if we are not populating the month view for |
|
791 // the first time |
|
792 if (!mIsFirstTimeLoad) { |
|
793 showHideRegionalInformation(); |
|
794 } |
|
795 // Reset the first time load flag |
|
796 mIsFirstTimeLoad = false; |
|
797 |
|
798 OstTraceFunctionExit0( CALENMONTHVIEW_DOPOPULATION_EXIT ); |
|
799 } |
|
800 |
|
801 /*! |
|
802 Reads the date from the context and calculates the grid item dates |
|
803 */ |
|
804 void CalenMonthView::prepareForPopulation() |
|
805 { |
|
806 OstTraceFunctionEntry0( CALENMONTHVIEW_PREPAREFORPOPULATION_ENTRY ); |
|
807 |
|
808 setActiveDay(dateFromContext(mServices.Context())); |
|
809 setDate(); |
|
810 updateMonthDataArrayWithActiveDates(); |
|
811 |
|
812 OstTraceFunctionExit0( CALENMONTHVIEW_PREPAREFORPOPULATION_EXIT ); |
|
813 } |
|
814 |
|
815 /*! |
|
816 Slot to handle gotodate action |
|
817 */ |
|
818 void CalenMonthView::refreshViewOnGoToDate() |
|
819 { |
|
820 OstTraceFunctionEntry0( CALENMONTHVIEW_REFRESHVIEWONGOTODATE_ENTRY ); |
|
821 |
|
822 prepareForPopulation(); |
|
823 setDateToLabel(); |
|
824 // fetch list of required calendar instances |
|
825 populateWithInstanceView(); |
|
826 |
|
827 populatePreviewPane(mDate); |
|
828 |
|
829 mMonthGrid->updateMonthGridModel(mMonthDataArray, mIndexToBeScrolled, |
|
830 mIsFirstTimeLoad); |
|
831 // Update the week Numbers model |
|
832 if (mIsWeekNumbersShown) { |
|
833 updateWeekNumGridModel(); |
|
834 } |
|
835 |
|
836 OstTraceFunctionExit0( CALENMONTHVIEW_REFRESHVIEWONGOTODATE_EXIT ); |
|
837 } |
|
838 |
|
839 /*! |
|
840 Reads the date from the context and stores into mDate |
|
841 */ |
|
842 QDateTime CalenMonthView::dateFromContext(const MCalenContext &context) |
|
843 { |
|
844 OstTraceFunctionEntry0( CALENMONTHVIEW_DATEFROMCONTEXT_ENTRY ); |
|
845 QDateTime ret; |
|
846 if (AgendaEntry::TypeTodo == context.instanceId().mType) { |
|
847 QDateTime today = CalenDateUtils::today(); |
|
848 if (context.focusDateAndTime() < today) { |
|
849 ret = today; |
|
850 } else { |
|
851 ret = context.focusDateAndTime(); |
|
852 } |
|
853 } else { |
|
854 ret = context.focusDateAndTime(); |
|
855 } |
|
856 OstTraceFunctionExit0( CALENMONTHVIEW_DATEFROMCONTEXT_EXIT ); |
|
857 return ret; |
|
858 } |
|
859 |
|
860 /*! |
|
861 Calculates the necesary parameters of the month view w.r.t mDate |
|
862 */ |
|
863 void CalenMonthView::setActiveDay(QDateTime day) |
|
864 { |
|
865 OstTraceFunctionEntry0( CALENMONTHVIEW_SETACTIVEDAY_ENTRY ); |
|
866 |
|
867 mDate = day; |
|
868 |
|
869 mActiveMonth = mDate; |
|
870 // Get the first day of the previous month |
|
871 QDateTime prevMonthDate = mDate.addMonths(-1); |
|
872 int prevMonth = prevMonthDate.date().month(); |
|
873 |
|
874 // Get the first day of the month |
|
875 QDate date = prevMonthDate.date(); |
|
876 date.setDate(date.year(), date.month(), 1); |
|
877 QDateTime firstDayOfPrevMonth(date, day.time()); |
|
878 |
|
879 int offset(firstDayOfPrevMonth.date().dayOfWeek() - (mLocale.startOfWeek() |
|
880 + 1)); |
|
881 if (offset < 0) { |
|
882 offset += KCalenDaysInWeek; |
|
883 } |
|
884 |
|
885 // Substract the offset days |
|
886 mFirstDayOfGrid = firstDayOfPrevMonth.addDays(-offset); |
|
887 |
|
888 // Calculate the number of weeks in the previous month that will be hidden |
|
889 mNumOfRowsInPrevMonth = offset + prevMonthDate.date().daysInMonth(); |
|
890 mNumOfRowsInPrevMonth = (mNumOfRowsInPrevMonth / KCalenDaysInWeek); |
|
891 |
|
892 // Index to be scrolled is the last day of the visible grid item |
|
893 mIndexToBeScrolled = ((mNumOfRowsInPrevMonth + KNumOfVisibleRows) |
|
894 * KCalenDaysInWeek) - 1; |
|
895 |
|
896 // Now add the future month days to the count. While doing that, we need to |
|
897 // calcualte the count till the end of the week in which the month ends |
|
898 QDateTime futureMonthDate = mDate.addMonths(1); |
|
899 // Get the first day of the future month |
|
900 date = futureMonthDate.date(); |
|
901 date.setDate(date.year(), date.month(), 1); |
|
902 QDateTime firstDayOfFutMonth(date, day.time()); |
|
903 offset = firstDayOfFutMonth.date().dayOfWeek() - (mLocale.startOfWeek() + 1); |
|
904 if (offset < 0) { |
|
905 offset += KCalenDaysInWeek; |
|
906 } |
|
907 // Substract the firstDayNoInWeek days |
|
908 QDateTime dateTime = firstDayOfFutMonth.addDays(-offset); |
|
909 |
|
910 // Need to add 42 days for dateTime so that it fits into the visible grid |
|
911 mLastDayOfGrid = dateTime.addDays(KNumOfVisibleRows * KCalenDaysInWeek - 1); |
|
912 |
|
913 // calculate the total numbers of dates that needs to be populated from |
|
914 // previous month to future month |
|
915 mTotalNumOfGridItems = mFirstDayOfGrid.daysTo(mLastDayOfGrid) + 1; |
|
916 |
|
917 // Calculate the last visible day |
|
918 int index = (mNumOfRowsInPrevMonth + KNumOfVisibleRows) * KCalenDaysInWeek; |
|
919 QDateTime lastVisibleDate = mFirstDayOfGrid.addDays(index - 1); |
|
920 QDateTime dateTimeToCalc = mLastDayOfGrid; |
|
921 mNumOfRowsInFutureMonth = 0; |
|
922 while (dateTimeToCalc > lastVisibleDate) { |
|
923 mNumOfRowsInFutureMonth++; |
|
924 dateTimeToCalc = dateTimeToCalc.addDays(-KCalenDaysInWeek); |
|
925 } |
|
926 |
|
927 OstTraceFunctionExit0( CALENMONTHVIEW_SETACTIVEDAY_EXIT ); |
|
928 } |
|
929 |
|
930 /*! |
|
931 Calculates the dates that needs to be set to mMonthDataArray |
|
932 */ |
|
933 void CalenMonthView::setDate() |
|
934 { |
|
935 OstTraceFunctionEntry0( CALENMONTHVIEW_SETDATE_ENTRY ); |
|
936 |
|
937 mMonthDataArray.clear(); |
|
938 // Calculate the actual number of dates to be populated from previous month |
|
939 // to future month |
|
940 for (int i(0); i < mTotalNumOfGridItems; ++i) { |
|
941 QDateTime currentDay = CalenDateUtils::futureOf(mFirstDayOfGrid, i); |
|
942 CalenMonthData element(currentDay); |
|
943 mMonthDataArray.append(element); |
|
944 } |
|
945 |
|
946 OstTraceFunctionExit0( CALENMONTHVIEW_SETDATE_EXIT ); |
|
947 } |
|
948 |
|
949 /*! |
|
950 Returns the active day(currently focussed day) |
|
951 */ |
|
952 QDateTime CalenMonthView::getActiveDay() |
|
953 { |
|
954 OstTraceFunctionEntry0( CALENMONTHVIEW_GETACTIVEDAY_ENTRY ); |
|
955 |
|
956 OstTraceFunctionExit0( CALENMONTHVIEW_GETACTIVEDAY_EXIT ); |
|
957 return mDate; |
|
958 } |
|
959 |
|
960 /*! |
|
961 Returns the array of CalenMonthData items |
|
962 */ |
|
963 QList<CalenMonthData>& CalenMonthView::monthDataList() |
|
964 { |
|
965 OstTraceFunctionEntry0( CALENMONTHVIEW_MONTHDATALIST_ENTRY ); |
|
966 |
|
967 OstTraceFunctionExit0( CALENMONTHVIEW_MONTHDATALIST_EXIT ); |
|
968 return mMonthDataArray; |
|
969 } |
|
970 |
|
971 /*! |
|
972 Creates the grid and adds the week numbers depending on the week number setting |
|
973 */ |
|
974 void CalenMonthView::createGrid() |
|
975 { |
|
976 OstTraceFunctionEntry0( CALENMONTHVIEW_CREATEGRID_ENTRY ); |
|
977 // Update the month grid |
|
978 mMonthGrid->updateMonthGridModel(mMonthDataArray, mIndexToBeScrolled, |
|
979 mIsFirstTimeLoad); |
|
980 // Get start of week from the locale. |
|
981 HbExtendedLocale locale = HbExtendedLocale::system(); |
|
982 int startOfWeek = locale.startOfWeek(); |
|
983 if(startOfWeek != HbExtendedLocale::Monday) |
|
984 { |
|
985 //if the start of week is other than Monday, don't show the week number |
|
986 mIsWeekNumbersShown = 0; |
|
987 } |
|
988 else |
|
989 { |
|
990 // Read the week number setting from cenrep |
|
991 QVariant value = mSettingsManager->readItemValue(*mWeekNumberCenrepKey); |
|
992 mIsWeekNumbersShown = value.toUInt(); |
|
993 } |
|
994 if (mIsWeekNumbersShown) { |
|
995 // Add week numbers to week grid |
|
996 addWeekNumbers(); |
|
997 } else { |
|
998 // remove the weeknumbergrid from the layout |
|
999 removeWeekNumbers(); |
|
1000 } |
|
1001 OstTraceFunctionExit0( CALENMONTHVIEW_CREATEGRID_EXIT ); |
|
1002 } |
|
1003 |
|
1004 /*! |
|
1005 Called when down gesture is performed |
|
1006 Caluclates the necessary dates for the new previous month |
|
1007 */ |
|
1008 void CalenMonthView::updateModelWithPrevMonth() |
|
1009 { |
|
1010 OstTraceFunctionEntry0( CALENMONTHVIEW_UPDATEMODELWITHPREVMONTH_ENTRY ); |
|
1011 |
|
1012 // Get the new previous month |
|
1013 QDateTime prevMonthDateTime = mActiveMonth.addMonths(-1); |
|
1014 QDateTime dateTime = mFirstDayOfGrid; |
|
1015 if (prevMonthDateTime.date().month() == mFirstDayOfGrid.date().month()) { |
|
1016 // Month starts right on Monday(Start of the week), |
|
1017 //hence go back to previous month |
|
1018 dateTime = mFirstDayOfGrid.addMonths(-1); |
|
1019 } |
|
1020 |
|
1021 int prevMonth = dateTime.date().month(); |
|
1022 QDateTime prevFirstDayOfGrid = mFirstDayOfGrid; |
|
1023 for (int i = 0; i < KNumOfVisibleRows; i++) { |
|
1024 mFirstDayOfGrid = mFirstDayOfGrid.addDays(-KCalenDaysInWeek); |
|
1025 if (mFirstDayOfGrid.date().month() == prevMonth) { |
|
1026 continue; |
|
1027 } else { |
|
1028 // Entered to another month, stop here |
|
1029 break; |
|
1030 } |
|
1031 } |
|
1032 // Readjust the mFirstDayOfGrid |
|
1033 if (mFirstDayOfGrid.addDays(KCalenDaysInWeek - 1).date().month() |
|
1034 != prevMonth) { |
|
1035 mFirstDayOfGrid = mFirstDayOfGrid.addDays(KCalenDaysInWeek); |
|
1036 } |
|
1037 |
|
1038 // Calculate the new days to be added |
|
1039 int countToBeAdded = mFirstDayOfGrid.daysTo(prevFirstDayOfGrid); |
|
1040 |
|
1041 // Remove the bottom month entries in mMonthDataArray |
|
1042 int countToBeDeleted = mNumOfRowsInFutureMonth * KCalenDaysInWeek; |
|
1043 int count = mMonthDataArray.count() - 1; |
|
1044 for (int i = 0; i < countToBeDeleted; i++) { |
|
1045 mMonthDataArray.removeAt(count--); |
|
1046 } |
|
1047 |
|
1048 // Update the total number of grid items as we will be removing the month |
|
1049 // at the below |
|
1050 mTotalNumOfGridItems -= countToBeDeleted; |
|
1051 |
|
1052 // Prepend countToBeAdded new items to mMonthDataArray |
|
1053 for (int i = 0; i < countToBeAdded; i++) { |
|
1054 QDateTime currentDay = mFirstDayOfGrid.addDays(i); |
|
1055 CalenMonthData element(currentDay); |
|
1056 mMonthDataArray.insert(i, element); |
|
1057 } |
|
1058 mTotalNumOfGridItems += countToBeAdded; |
|
1059 |
|
1060 // Update the mMonthDataArray with instances if any |
|
1061 populatePrevMonth(); |
|
1062 |
|
1063 // Update the necessary globals |
|
1064 mActiveMonth = mActiveMonth.addMonths(-1); |
|
1065 mNumOfRowsInPrevMonth = (countToBeAdded / KCalenDaysInWeek); |
|
1066 mLastDayOfGrid = mFirstDayOfGrid.addDays(mTotalNumOfGridItems - 1); |
|
1067 // Calculate the last visible day |
|
1068 int index = (mNumOfRowsInPrevMonth + KNumOfVisibleRows) * KCalenDaysInWeek; |
|
1069 QDateTime lastVisibleDate = mFirstDayOfGrid.addDays(index - 1); |
|
1070 QDateTime date = mLastDayOfGrid; |
|
1071 mNumOfRowsInFutureMonth = 0; |
|
1072 while (date > lastVisibleDate) { |
|
1073 mNumOfRowsInFutureMonth++; |
|
1074 date = date.addDays(-KCalenDaysInWeek); |
|
1075 } |
|
1076 // Update the week Numbers model |
|
1077 if (mIsWeekNumbersShown) { |
|
1078 updateWeekNumGridModel(); |
|
1079 } |
|
1080 |
|
1081 OstTraceFunctionExit0( CALENMONTHVIEW_UPDATEMODELWITHPREVMONTH_EXIT ); |
|
1082 } |
|
1083 /*! |
|
1084 Called when up gesture is performed |
|
1085 */ |
|
1086 void CalenMonthView::updateModelWithFutureMonth() |
|
1087 { |
|
1088 OstTraceFunctionEntry0( CALENMONTHVIEW_UPDATEMODELWITHFUTUREMONTH_ENTRY ); |
|
1089 |
|
1090 // Get the new future month |
|
1091 QDateTime previousLastDayOfGrid = mLastDayOfGrid; |
|
1092 QDateTime futureMonthDateTime = mActiveMonth.addMonths(2); |
|
1093 QDate date = futureMonthDateTime.date(); |
|
1094 date.setDate(date.year(), date.month(), 1); |
|
1095 // Get the first day of the future month |
|
1096 QDateTime firstDayOfFutMonth(date, futureMonthDateTime.time()); |
|
1097 |
|
1098 int offset = firstDayOfFutMonth.date().dayOfWeek() - (mLocale.startOfWeek() |
|
1099 + 1); |
|
1100 if (offset < 0) { |
|
1101 offset += KCalenDaysInWeek; |
|
1102 } |
|
1103 // Substract the firstDayNoInWeek days |
|
1104 QDateTime dateTime = firstDayOfFutMonth.addDays(-offset); |
|
1105 // Need to add 42 days for dateTime |
|
1106 mLastDayOfGrid = dateTime.addDays(KNumOfVisibleRows * KCalenDaysInWeek - 1); |
|
1107 |
|
1108 // Remove the first mNumOfRowsInPrevMonth rows in mMonthDataArray |
|
1109 int countToBeDeleted = mNumOfRowsInPrevMonth * KCalenDaysInWeek; |
|
1110 for (int i = 0; i < countToBeDeleted; i++) { |
|
1111 mMonthDataArray.removeAt(0); |
|
1112 } |
|
1113 |
|
1114 // Update the total number of grid items as we will be removing the month |
|
1115 // at the top |
|
1116 mTotalNumOfGridItems -= countToBeDeleted; |
|
1117 |
|
1118 // Calcualate the num fo days to be added |
|
1119 int countToBeAdded = previousLastDayOfGrid.daysTo(mLastDayOfGrid); |
|
1120 // Append countToBeAdded new items to mMonthDataArray |
|
1121 for (int i = 1; i <= countToBeAdded; i++) { |
|
1122 QDateTime currentDay = previousLastDayOfGrid.addDays(i); |
|
1123 CalenMonthData element(currentDay); |
|
1124 mMonthDataArray.append(element); |
|
1125 } |
|
1126 |
|
1127 |
|
1128 |
|
1129 // Update the necessary globals |
|
1130 mTotalNumOfGridItems += countToBeAdded; |
|
1131 mActiveMonth = mActiveMonth.addMonths(1); |
|
1132 mNumOfRowsInFutureMonth = (countToBeAdded / KCalenDaysInWeek); |
|
1133 mFirstDayOfGrid = mLastDayOfGrid.addDays(-(mTotalNumOfGridItems - 1)); |
|
1134 // Calculate the first visible date |
|
1135 int index = mTotalNumOfGridItems - ((mNumOfRowsInFutureMonth |
|
1136 + KNumOfVisibleRows) * KCalenDaysInWeek); |
|
1137 QDateTime firstVisibleDate = mFirstDayOfGrid.addDays(index - 1); |
|
1138 QDateTime dateTimeToCalc = mFirstDayOfGrid; |
|
1139 mNumOfRowsInPrevMonth = 0; |
|
1140 while (dateTimeToCalc < firstVisibleDate) { |
|
1141 mNumOfRowsInPrevMonth++; |
|
1142 dateTimeToCalc = dateTimeToCalc.addDays(KCalenDaysInWeek); |
|
1143 } |
|
1144 |
|
1145 // Update the week Numbers model |
|
1146 if (mIsWeekNumbersShown) { |
|
1147 updateWeekNumGridModel(); |
|
1148 } |
|
1149 |
|
1150 // Update the mMonthDataArray with instances if any |
|
1151 populateNextMonth(); |
|
1152 |
|
1153 OstTraceFunctionExit0( CALENMONTHVIEW_UPDATEMODELWITHFUTUREMONTH_EXIT ); |
|
1154 } |
|
1155 |
|
1156 /*! |
|
1157 Returns the numner of rows in previous month |
|
1158 */ |
|
1159 int CalenMonthView::rowsInPrevMonth() |
|
1160 { |
|
1161 OstTraceFunctionEntry0( CALENMONTHVIEW_ROWSINPREVMONTH_ENTRY ); |
|
1162 |
|
1163 OstTraceFunctionExit0( CALENMONTHVIEW_ROWSINPREVMONTH_EXIT ); |
|
1164 return mNumOfRowsInPrevMonth; |
|
1165 } |
|
1166 |
|
1167 /*! |
|
1168 Returns the number of rows in future month |
|
1169 */ |
|
1170 int CalenMonthView::rowsInFutMonth() |
|
1171 { |
|
1172 OstTraceFunctionEntry0( CALENMONTHVIEW_ROWSINFUTMONTH_ENTRY ); |
|
1173 |
|
1174 OstTraceFunctionExit0( CALENMONTHVIEW_ROWSINFUTMONTH_EXIT ); |
|
1175 return mNumOfRowsInFutureMonth; |
|
1176 } |
|
1177 |
|
1178 /*! |
|
1179 Returns current Grid index |
|
1180 */ |
|
1181 int CalenMonthView::getCurrGridIndex() |
|
1182 { |
|
1183 OstTraceFunctionEntry0( CALENMONTHVIEW_GETCURRGRIDINDEX_ENTRY ); |
|
1184 |
|
1185 OstTraceFunctionExit0( CALENMONTHVIEW_GETCURRGRIDINDEX_EXIT ); |
|
1186 return mMonthGrid->getCurrentIndex(); |
|
1187 } |
|
1188 |
|
1189 /*! |
|
1190 Set the currend Index of the Grid |
|
1191 */ |
|
1192 void CalenMonthView::setCurrGridIndex(int index) |
|
1193 { |
|
1194 OstTraceFunctionEntry0( CALENMONTHVIEW_SETCURRGRIDINDEX_ENTRY ); |
|
1195 mIsPrevPaneGesture = true; |
|
1196 mMonthGrid->setCurrentIdex(index); |
|
1197 OstTraceFunctionExit0( CALENMONTHVIEW_SETCURRGRIDINDEX_EXIT ); |
|
1198 } |
|
1199 |
|
1200 /*! |
|
1201 Sets the active flag to the required dates in the array |
|
1202 */ |
|
1203 void CalenMonthView::updateMonthDataArrayWithActiveDates() |
|
1204 { |
|
1205 OstTraceFunctionEntry0( CALENMONTHVIEW_UPDATEMONTHDATAARRAYWITHACTIVEDATES_ENTRY ); |
|
1206 |
|
1207 int activeMonth = mActiveMonth.date().month(); |
|
1208 int monthDataCount = mMonthDataArray.count(); |
|
1209 for (int i = 0; i < monthDataCount; i++) { |
|
1210 if (mMonthDataArray[i].Day().date().month() == activeMonth) { |
|
1211 // Set the active flag |
|
1212 mMonthDataArray[i].setActive(true); |
|
1213 } else { |
|
1214 // Disable the active flag |
|
1215 mMonthDataArray[i].setActive(false); |
|
1216 } |
|
1217 } |
|
1218 |
|
1219 OstTraceFunctionExit0( CALENMONTHVIEW_UPDATEMONTHDATAARRAYWITHACTIVEDATES_EXIT ); |
|
1220 } |
|
1221 |
|
1222 /*! |
|
1223 Fetches the calenda entries for a given range |
|
1224 */ |
|
1225 void CalenMonthView::getInstanceList(QList<QDate> &list, |
|
1226 QDateTime rangeStart, QDateTime rangeEnd) |
|
1227 { |
|
1228 OstTraceFunctionEntry0( CALENMONTHVIEW_GETINSTANCELIST_ENTRY ); |
|
1229 |
|
1230 AgendaUtil::FilterFlags filter = |
|
1231 AgendaUtil::FilterFlags(AgendaUtil::IncludeAnniversaries |
|
1232 | AgendaUtil::IncludeAppointments |
|
1233 | AgendaUtil::IncludeEvents |
|
1234 | AgendaUtil::IncludeReminders |
|
1235 | AgendaUtil::IncludeIncompletedTodos); |
|
1236 mAgendaUtil->markDatesWithEvents(rangeStart, rangeEnd, filter, list); |
|
1237 |
|
1238 OstTraceFunctionExit0( CALENMONTHVIEW_GETINSTANCELIST_EXIT ); |
|
1239 } |
|
1240 |
|
1241 /*! |
|
1242 Parses the fetched entries and sets hasEvent attribute for necessary days |
|
1243 */ |
|
1244 void CalenMonthView::populateWithInstanceView() |
|
1245 { |
|
1246 OstTraceFunctionEntry0( CALENMONTHVIEW_POPULATEWITHINSTANCEVIEW_ENTRY ); |
|
1247 |
|
1248 const QDateTime today(CalenDateUtils::today()); |
|
1249 const QDateTime gridStart(CalenDateUtils::beginningOfDay(mFirstDayOfGrid)); |
|
1250 |
|
1251 // grid index for "today" |
|
1252 const int todayIndex(gridStart.daysTo(today)); |
|
1253 |
|
1254 QDateTime gridEnd(mLastDayOfGrid.date(), QTime(23, 59, 59, 0)); |
|
1255 |
|
1256 // Get the list of dates which have events |
|
1257 QList<QDate> datesWithEvents; |
|
1258 getInstanceList(datesWithEvents,gridStart,gridEnd); |
|
1259 |
|
1260 // Parse thru the list of dates and set the required flags |
|
1261 int datesEventsCount = datesWithEvents.count(); |
|
1262 for(int i(0); i < datesEventsCount; i++) { |
|
1263 int offset = mFirstDayOfGrid.date().daysTo(datesWithEvents.at(i)); |
|
1264 mMonthDataArray[offset].SetHasEvents(true); |
|
1265 } |
|
1266 datesWithEvents.clear(); |
|
1267 |
|
1268 if (datesEventsCount) { |
|
1269 mEntriesInDataBase = true; |
|
1270 } |
|
1271 |
|
1272 OstTraceFunctionExit0( CALENMONTHVIEW_POPULATEWITHINSTANCEVIEW_EXIT ); |
|
1273 } |
|
1274 |
|
1275 /*! |
|
1276 Parses the fetched entries for previous month and |
|
1277 sets hasEvent attribute for necessary days |
|
1278 */ |
|
1279 void CalenMonthView::populatePrevMonth() |
|
1280 { |
|
1281 OstTraceFunctionEntry0( CALENMONTHVIEW_POPULATEPREVMONTH_ENTRY ); |
|
1282 |
|
1283 const QDateTime gridStart(CalenDateUtils::beginningOfDay(mFirstDayOfGrid)); |
|
1284 const QDateTime today(CalenDateUtils::today()); |
|
1285 |
|
1286 const int todayIndex(gridStart.daysTo(today)); // grid index for "today" |
|
1287 QDateTime end = gridStart.addDays(mNumOfRowsInPrevMonth * KCalenDaysInWeek); |
|
1288 QDateTime gridEnd(end.date(), QTime(23, 59, 59, 0)); |
|
1289 |
|
1290 |
|
1291 // Get the list of dates which have events |
|
1292 QList<QDate> datesWithEvents; |
|
1293 getInstanceList(datesWithEvents,gridStart,gridEnd); |
|
1294 |
|
1295 // Parse thru the list of dates and set the required flags |
|
1296 int datesEventsCount = datesWithEvents.count(); |
|
1297 for(int i(0); i < datesEventsCount; i++) { |
|
1298 int offset = mFirstDayOfGrid.date().daysTo(datesWithEvents.at(i)); |
|
1299 mMonthDataArray[offset].SetHasEvents(true); |
|
1300 } |
|
1301 datesWithEvents.clear(); |
|
1302 |
|
1303 if (datesEventsCount) { |
|
1304 mEntriesInDataBase = true; |
|
1305 } |
|
1306 |
|
1307 OstTraceFunctionExit0( CALENMONTHVIEW_POPULATEPREVMONTH_EXIT ); |
|
1308 } |
|
1309 |
|
1310 /*! |
|
1311 Parses the fetched entries for future month and |
|
1312 sets hasEvent attribute for necessary days |
|
1313 */ |
|
1314 void CalenMonthView::populateNextMonth() |
|
1315 { |
|
1316 OstTraceFunctionEntry0( CALENMONTHVIEW_POPULATENEXTMONTH_ENTRY ); |
|
1317 QList<AgendaEntry> list; |
|
1318 int actualIndex = mNumOfRowsInFutureMonth * KCalenDaysInWeek; |
|
1319 const QDateTime gridStart(mLastDayOfGrid.addDays(-actualIndex)); |
|
1320 actualIndex = mMonthDataArray.count() - actualIndex -1; |
|
1321 |
|
1322 const QDateTime today(CalenDateUtils::today()); |
|
1323 const int todayIndex(gridStart.daysTo(today)); // grid index for "today" |
|
1324 QDateTime gridEnd(mLastDayOfGrid.date(), QTime(23, 59, 59, 0)); |
|
1325 |
|
1326 // Get the list of dates which have events |
|
1327 QList<QDate> datesWithEvents; |
|
1328 getInstanceList(datesWithEvents,gridStart,gridEnd); |
|
1329 |
|
1330 // Parse thru the list of dates and set the required flags |
|
1331 int datesEventsCount = datesWithEvents.count(); |
|
1332 for(int i(0); i < datesEventsCount; i++) { |
|
1333 int offset = mFirstDayOfGrid.date().daysTo(datesWithEvents.at(i)); |
|
1334 mMonthDataArray[offset].SetHasEvents(true); |
|
1335 } |
|
1336 datesWithEvents.clear(); |
|
1337 |
|
1338 if (datesEventsCount) { |
|
1339 mEntriesInDataBase = true; |
|
1340 } |
|
1341 OstTraceFunctionExit0( CALENMONTHVIEW_POPULATENEXTMONTH_EXIT ); |
|
1342 } |
|
1343 |
|
1344 /*! |
|
1345 Function that gets called when instacne view is created, so that it can |
|
1346 query agenda server for any entries |
|
1347 */ |
|
1348 void CalenMonthView::fetchEntriesAndUpdateModel() |
|
1349 { |
|
1350 OstTraceFunctionEntry0( CALENMONTHVIEW_FETCHENTRIESANDUPDATEMODEL_ENTRY ); |
|
1351 |
|
1352 // Get to know if entries are there from the agenda server |
|
1353 populateWithInstanceView(); |
|
1354 // Update the month grid model |
|
1355 mMonthGrid->updateMonthGridWithEventIndicators(mMonthDataArray); |
|
1356 // Populate the preview panes |
|
1357 populatePreviewPane(mDate); |
|
1358 |
|
1359 OstTraceFunctionExit0( CALENMONTHVIEW_FETCHENTRIESANDUPDATEMODEL_EXIT ); |
|
1360 } |
|
1361 |
|
1362 /*! |
|
1363 Populates the preview pane |
|
1364 */ |
|
1365 void CalenMonthView::populatePreviewPane(QDateTime &dateTime) |
|
1366 { |
|
1367 OstTraceFunctionEntry0( CALENMONTHVIEW_POPULATEPREVIEWPANE_ENTRY ); |
|
1368 |
|
1369 mPrevPreviewPane->populateLabel(dateTime.addDays(-1)); |
|
1370 mCurrPreviewPane->populateLabel(dateTime); |
|
1371 mNextPreviewPane->populateLabel(dateTime.addDays(1)); |
|
1372 |
|
1373 // Start the auto scroll on current preview pane |
|
1374 mCurrPreviewPane->startAutoScroll(); |
|
1375 |
|
1376 OstTraceFunctionExit0( CALENMONTHVIEW_POPULATEPREVIEWPANE_EXIT ); |
|
1377 } |
|
1378 |
|
1379 /*! |
|
1380 Completes the population after setting the view as |
|
1381 current view to the main window |
|
1382 */ |
|
1383 void CalenMonthView::completePopulation() |
|
1384 { |
|
1385 OstTraceFunctionEntry0( CALENMONTHVIEW_COMPLETEPOPULATION_ENTRY ); |
|
1386 |
|
1387 setDateToLabel(); |
|
1388 |
|
1389 OstTraceFunctionExit0( CALENMONTHVIEW_COMPLETEPOPULATION_EXIT ); |
|
1390 } |
|
1391 |
|
1392 /*! |
|
1393 Launches the day view on tapping of the grid item |
|
1394 */ |
|
1395 void CalenMonthView::handleGridItemActivated() |
|
1396 { |
|
1397 OstTraceFunctionEntry0( CALENMONTHVIEW_HANDLEGRIDITEMACTIVATED_ENTRY ); |
|
1398 |
|
1399 mServices.IssueCommandL(ECalenDayView); |
|
1400 |
|
1401 OstTraceFunctionExit0( CALENMONTHVIEW_HANDLEGRIDITEMACTIVATED_EXIT ); |
|
1402 } |
|
1403 |
|
1404 /*! |
|
1405 Sets the context w.r.t to the active day |
|
1406 */ |
|
1407 void CalenMonthView::setContextForActiveDay(int index) |
|
1408 { |
|
1409 OstTraceFunctionEntry0( CALENMONTHVIEW_SETCONTEXTFORACTIVEDAY_ENTRY ); |
|
1410 QDateTime newActiveDay = mFirstDayOfGrid.addDays(index); |
|
1411 // Set the context |
|
1412 mServices.Context().setFocusDate(newActiveDay); |
|
1413 mDate = newActiveDay; |
|
1414 setDateToLabel(); |
|
1415 |
|
1416 if(!mIsPrevPaneGesture) { |
|
1417 populatePreviewPane(mDate); |
|
1418 } else { |
|
1419 // reset flag |
|
1420 mIsPrevPaneGesture = false; |
|
1421 } |
|
1422 |
|
1423 OstTraceFunctionExit0( CALENMONTHVIEW_SETCONTEXTFORACTIVEDAY_EXIT ); |
|
1424 } |
|
1425 |
|
1426 /*! |
|
1427 Slot to launch the event editor |
|
1428 */ |
|
1429 void CalenMonthView::createEditor() |
|
1430 { |
|
1431 OstTraceFunctionEntry0( CALENMONTHVIEW_CREATEEDITOR_ENTRY ); |
|
1432 |
|
1433 captureScreenshot(true); |
|
1434 mServices.IssueCommandL(ECalenNewMeeting); |
|
1435 |
|
1436 OstTraceFunctionExit0( CALENMONTHVIEW_CREATEEDITOR_EXIT ); |
|
1437 } |
|
1438 |
|
1439 /*! |
|
1440 Slot to launch the Day view |
|
1441 */ |
|
1442 void CalenMonthView::launchDayView() |
|
1443 { |
|
1444 OstTraceFunctionEntry0( CALENMONTHVIEW_LAUNCHDAYVIEW_ENTRY ); |
|
1445 |
|
1446 mServices.IssueCommandL(ECalenDayView); |
|
1447 // day view launched now, captre the screen shot of month view |
|
1448 captureScreenshot(true); |
|
1449 |
|
1450 OstTraceFunctionExit0( CALENMONTHVIEW_LAUNCHDAYVIEW_EXIT ); |
|
1451 } |
|
1452 |
|
1453 /*! |
|
1454 disconnects for the aboutToQuit events |
|
1455 */ |
|
1456 void CalenMonthView::disconnectAboutToQuitEvent() |
|
1457 { |
|
1458 OstTraceFunctionEntry0( CALENMONTHVIEW_DISCONNECTABOUTTOQUITEVENT_ENTRY ); |
|
1459 |
|
1460 if (mIsAboutToQuitEventConnected) { |
|
1461 disconnect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity())); |
|
1462 mIsAboutToQuitEventConnected = false; |
|
1463 } |
|
1464 |
|
1465 OstTraceFunctionExit0( CALENMONTHVIEW_DISCONNECTABOUTTOQUITEVENT_EXIT ); |
|
1466 } |
|
1467 |
|
1468 /*! |
|
1469 Slot to handle the change in orientation |
|
1470 */ |
|
1471 void CalenMonthView::changeOrientation(Qt::Orientation orientation) |
|
1472 { |
|
1473 OstTraceFunctionEntry0( CALENMONTHVIEW_CHANGEORIENTATION_ENTRY ); |
|
1474 |
|
1475 if (mOrientation != orientation) { |
|
1476 // change the orientation here |
|
1477 mOrientation = orientation; |
|
1478 handleChangeOrientation(); |
|
1479 } |
|
1480 |
|
1481 OstTraceFunctionExit0( CALENMONTHVIEW_CHANGEORIENTATION_EXIT ); |
|
1482 } |
|
1483 |
|
1484 /*! |
|
1485 Slot to handle the change in theme |
|
1486 */ |
|
1487 void CalenMonthView::handleThemeChange() |
|
1488 { |
|
1489 OstTraceFunctionEntry0( CALENMONTHVIEW_HANDLETHEMECHANGE_ENTRY ); |
|
1490 |
|
1491 // Refresh the month view when the theme change happens |
|
1492 mWeekDaysColor = HbColorScheme::color("qtc_cal_week_day"); |
|
1493 QColor monthTitleColor = HbColorScheme::color("qtc_cal_monthgrid_title"); |
|
1494 |
|
1495 if (mTitleLabel && monthTitleColor.isValid()) { |
|
1496 mTitleLabel->setTextColor(monthTitleColor); |
|
1497 } |
|
1498 |
|
1499 mPreviewHeadingColor = HbColorScheme::color("qtc_cal_day_preview_heading"); |
|
1500 |
|
1501 mServices.IssueCommandL(ECalenStartActiveStep); |
|
1502 |
|
1503 OstTraceFunctionExit0( CALENMONTHVIEW_HANDLETHEMECHANGE_EXIT ); |
|
1504 } |
|
1505 |
|
1506 /*! |
|
1507 Loads appropriate section from the docml dsepending on the current orientation |
|
1508 of the device |
|
1509 */ |
|
1510 void CalenMonthView::handleChangeOrientation() |
|
1511 { |
|
1512 OstTraceFunctionEntry0( CALENMONTHVIEW_HANDLECHANGEORIENTATION_ENTRY ); |
|
1513 |
|
1514 bool loadSuccess = false; |
|
1515 if (mOrientation == Qt::Horizontal) { |
|
1516 mDocLoader->load(CALEN_MONTHVIEW_XML_FILE, CALEN_LANDSCAPE, |
|
1517 &loadSuccess); |
|
1518 |
|
1519 } else if (mOrientation == Qt::Vertical) { |
|
1520 mDocLoader->load(CALEN_MONTHVIEW_XML_FILE, CALEN_PORTRAIT, |
|
1521 &loadSuccess); |
|
1522 } |
|
1523 |
|
1524 Q_ASSERT_X(loadSuccess, "calenmonthview.cpp", "Unable to load XML"); |
|
1525 |
|
1526 // Remove the current pane read from the docml from the layout |
|
1527 // and add actual current pane to the layout |
|
1528 QGraphicsLinearLayout* viewLayout = static_cast<QGraphicsLinearLayout *> |
|
1529 (widget()->layout()); |
|
1530 viewLayout->removeAt(1); |
|
1531 // Add this item only when orientaion is changed on month view |
|
1532 // if it is changed in other views, adding the preview pane here was |
|
1533 // overlapping with the month grid, hence, its been added in dopopulation() |
|
1534 if (this == mServices.MainWindow().currentView()) { |
|
1535 viewLayout->addItem(mCurrPaneParent); |
|
1536 } |
|
1537 |
|
1538 OstTraceFunctionExit0( CALENMONTHVIEW_HANDLECHANGEORIENTATION_EXIT ); |
|
1539 } |
|
1540 |
|
1541 /*! |
|
1542 Sets the appropriate date to the month title |
|
1543 */ |
|
1544 void CalenMonthView::setDateToLabel() |
|
1545 { |
|
1546 OstTraceFunctionEntry0( CALENMONTHVIEW_SETDATETOLABEL_ENTRY ); |
|
1547 |
|
1548 // Get the localised string for month name from system locale |
|
1549 QString dateString = mLocale.monthName(mDate.date().month(), HbExtendedLocale::LongFormat); |
|
1550 // Append a single space |
|
1551 dateString.append(" "); |
|
1552 mLocale.setNumberOptions(QLocale::OmitGroupSeparator); |
|
1553 // Append the year string also |
|
1554 dateString.append(mLocale.toString(mDate.date().year())); |
|
1555 mTitleLabel->setPlainText(dateString); |
|
1556 |
|
1557 OstTraceFunctionExit0( CALENMONTHVIEW_SETDATETOLABEL_EXIT ); |
|
1558 } |
|
1559 |
|
1560 /*! |
|
1561 To handle previewpane swipe |
|
1562 */ |
|
1563 void CalenMonthView::handlePreviewPaneGesture(bool rightGesture) |
|
1564 { |
|
1565 OstTraceFunctionEntry0( CALENMONTHVIEW_HANDLEPREVIEWPANEGESTURE_ENTRY ); |
|
1566 |
|
1567 // Check if we can swipe, if yes, then proceed, else, do nothing |
|
1568 if (checkIfWeCanSwipe(mDate, rightGesture)) { |
|
1569 |
|
1570 QGraphicsLinearLayout* viewLayout = static_cast<QGraphicsLinearLayout *> |
|
1571 (widget()->layout()); |
|
1572 |
|
1573 // Set the effect in progress flags for next and previous panes |
|
1574 // For current pane, we would have set it in gestureEvent() function |
|
1575 mPrevPreviewPane->effectStarted(); |
|
1576 mNextPreviewPane->effectStarted(); |
|
1577 |
|
1578 if(rightGesture) { |
|
1579 // Need to bring up the previous day preview pane |
|
1580 // Create the effect on mCurrPreviewPane to slide to right side |
|
1581 mPrevPaneParent->setVisible(true); |
|
1582 if (mOrientation == Qt::Vertical) { |
|
1583 HbEffect::add(mCurrPaneLayoutWidget, |
|
1584 ":/fxml/portrait_preview_pane_hide_on_right_gesture", |
|
1585 "hide"); |
|
1586 HbEffect::add(mPrevPaneLayoutWidget, |
|
1587 ":/fxml/portrait_preview_pane_show_on_right_gesture", |
|
1588 "show"); |
|
1589 } else { |
|
1590 HbEffect::add(mCurrPaneLayoutWidget, |
|
1591 ":/fxml/landscape_preview_pane_hide_on_right_gesture", |
|
1592 "hide"); |
|
1593 HbEffect::add(mPrevPaneLayoutWidget, |
|
1594 ":/fxml/landscape_preview_pane_show_on_right_gesture", |
|
1595 "show"); |
|
1596 } |
|
1597 // Start the effects |
|
1598 HbEffect::start(mCurrPaneLayoutWidget, "hide"); |
|
1599 HbEffect::start(mPrevPaneLayoutWidget, "show", |
|
1600 this, "handleRightEffectCompleted"); |
|
1601 |
|
1602 //Remove the mCurrPreviewPane from the layout and add mPrevPreviewPane |
|
1603 // to the layout |
|
1604 viewLayout->removeAt(1); |
|
1605 viewLayout->addItem(mPrevPaneParent); |
|
1606 } else { |
|
1607 // Need to bring up the previous day preview pane |
|
1608 // Create the effect on mCurrPreviewPane to slide to left side |
|
1609 mNextPaneParent->setVisible(true); |
|
1610 if (mOrientation == Qt::Vertical) { |
|
1611 HbEffect::add(mCurrPaneLayoutWidget, |
|
1612 ":/fxml/portrait_preview_pane_hide_on_left_gesture", |
|
1613 "hide"); |
|
1614 HbEffect::add(mNextPaneLayoutWidget, |
|
1615 ":/fxml/portrait_preview_pane_show_on_left_gesture", |
|
1616 "show"); |
|
1617 } else { |
|
1618 HbEffect::add(mCurrPaneLayoutWidget, |
|
1619 ":/fxml/landscape_preview_pane_hide_on_left_gesture", |
|
1620 "hide"); |
|
1621 HbEffect::add(mNextPaneLayoutWidget, |
|
1622 ":/fxml/landscape_preview_pane_show_on_left_gesture", |
|
1623 "show"); |
|
1624 } |
|
1625 |
|
1626 // Start the effects |
|
1627 HbEffect::start(mCurrPaneLayoutWidget, "hide"); |
|
1628 HbEffect::start(mNextPaneLayoutWidget, "show", |
|
1629 this, "handleLeftEffectCompleted"); |
|
1630 |
|
1631 //Remove the mCurrPreviewPane from the layout and add mNextPreviewPane |
|
1632 // to the layout |
|
1633 viewLayout->removeAt(1); |
|
1634 viewLayout->addItem(mNextPaneParent); |
|
1635 } |
|
1636 } |
|
1637 |
|
1638 OstTraceFunctionExit0( CALENMONTHVIEW_HANDLEPREVIEWPANEGESTURE_EXIT ); |
|
1639 } |
|
1640 |
|
1641 /*! |
|
1642 Returns the first date in the month grid |
|
1643 */ |
|
1644 QDateTime CalenMonthView::firstDayOfGrid() |
|
1645 { |
|
1646 OstTraceFunctionEntry0( CALENMONTHVIEW_FIRSTDAYOFGRID_ENTRY ); |
|
1647 |
|
1648 OstTraceFunctionExit0( CALENMONTHVIEW_FIRSTDAYOFGRID_EXIT ); |
|
1649 return mFirstDayOfGrid; |
|
1650 } |
|
1651 |
|
1652 /*! |
|
1653 Function to handle any locale related changes |
|
1654 */ |
|
1655 void CalenMonthView::onLocaleChanged(int reason) |
|
1656 { |
|
1657 OstTraceFunctionEntry0( CALENMONTHVIEW_ONLOCALECHANGED_ENTRY ); |
|
1658 Q_UNUSED(reason); |
|
1659 OstTraceFunctionExit0( CALENMONTHVIEW_ONLOCALECHANGED_EXIT ); |
|
1660 } |
|
1661 |
|
1662 /*! |
|
1663 Slot to handle left gesture effects completion |
|
1664 */ |
|
1665 void CalenMonthView::handleLeftEffectCompleted( |
|
1666 const HbEffect::EffectStatus &status) |
|
1667 { |
|
1668 OstTraceFunctionEntry0( CALENMONTHVIEW_HANDLELEFTEFFECTCOMPLETED_ENTRY ); |
|
1669 Q_UNUSED(status); |
|
1670 |
|
1671 int index = getCurrGridIndex(); |
|
1672 index++; |
|
1673 |
|
1674 // Stop the scrolling on current preview pane |
|
1675 mCurrPreviewPane->stopScrolling(); |
|
1676 |
|
1677 // Swap the preview panes properly |
|
1678 CalenPreviewPane* pane = mCurrPreviewPane; |
|
1679 HbWidget* paneParent = mCurrPaneParent; |
|
1680 HbWidget* paneLayoutWidget = mCurrPaneLayoutWidget; |
|
1681 mCurrPreviewPane = mNextPreviewPane; |
|
1682 mCurrPaneParent = mNextPaneParent; |
|
1683 mCurrPaneLayoutWidget = mNextPaneLayoutWidget; |
|
1684 mNextPreviewPane = mPrevPreviewPane; |
|
1685 mNextPaneParent = mPrevPaneParent; |
|
1686 mNextPaneLayoutWidget = mPrevPaneLayoutWidget; |
|
1687 mPrevPreviewPane = pane; |
|
1688 mPrevPaneParent = paneParent; |
|
1689 mPrevPaneLayoutWidget = paneLayoutWidget; |
|
1690 |
|
1691 // Reset the effect in progress flag |
|
1692 mCurrPreviewPane->effectFinished(); |
|
1693 mPrevPreviewPane->effectFinished(); |
|
1694 mNextPreviewPane->effectFinished(); |
|
1695 |
|
1696 // Set the focus to proper date |
|
1697 setCurrGridIndex(index); |
|
1698 // Start the auto scroll on current preview pane |
|
1699 mCurrPreviewPane->startAutoScroll(); |
|
1700 mNextPreviewPane->populateLabel(mDate.addDays(1)); |
|
1701 OstTraceFunctionExit0( CALENMONTHVIEW_HANDLELEFTEFFECTCOMPLETED_EXIT ); |
|
1702 } |
|
1703 |
|
1704 /*! |
|
1705 Slot to handle right gesture effects completion |
|
1706 */ |
|
1707 void CalenMonthView::handleRightEffectCompleted( |
|
1708 const HbEffect::EffectStatus &status) |
|
1709 { |
|
1710 OstTraceFunctionEntry0( CALENMONTHVIEW_HANDLERIGHTEFFECTCOMPLETED_ENTRY ); |
|
1711 |
|
1712 Q_UNUSED(status); |
|
1713 |
|
1714 int index = getCurrGridIndex(); |
|
1715 index--; |
|
1716 |
|
1717 // Stop the scrolling on current preview pane |
|
1718 mCurrPreviewPane->stopScrolling(); |
|
1719 |
|
1720 // Swap the preview panes properly |
|
1721 CalenPreviewPane* pane = mCurrPreviewPane; |
|
1722 HbWidget* paneParent = mCurrPaneParent; |
|
1723 HbWidget* paneLayoutWidget = mCurrPaneLayoutWidget; |
|
1724 mCurrPreviewPane = mPrevPreviewPane; |
|
1725 mCurrPaneParent = mPrevPaneParent; |
|
1726 mCurrPaneLayoutWidget = mPrevPaneLayoutWidget; |
|
1727 mPrevPreviewPane = mNextPreviewPane; |
|
1728 mPrevPaneParent = mNextPaneParent; |
|
1729 mPrevPaneLayoutWidget = mNextPaneLayoutWidget; |
|
1730 mNextPreviewPane = pane; |
|
1731 mNextPaneParent = paneParent; |
|
1732 mNextPaneLayoutWidget = paneLayoutWidget; |
|
1733 |
|
1734 // Reset the effect in progress flag |
|
1735 mCurrPreviewPane->effectFinished(); |
|
1736 mNextPreviewPane->effectFinished(); |
|
1737 mPrevPreviewPane->effectFinished(); |
|
1738 |
|
1739 // Set the focus to proper date |
|
1740 setCurrGridIndex(index); |
|
1741 // Start the auto scroll on current preview pane |
|
1742 mCurrPreviewPane->startAutoScroll(); |
|
1743 mPrevPreviewPane->populateLabel(mDate.addDays(-1)); |
|
1744 |
|
1745 OstTraceFunctionExit0( CALENMONTHVIEW_HANDLERIGHTEFFECTCOMPLETED_EXIT ); |
|
1746 } |
|
1747 /*! |
|
1748 update the Day labels |
|
1749 */ |
|
1750 void CalenMonthView::updateDayLabel() |
|
1751 { |
|
1752 OstTraceFunctionEntry0( CALENMONTHVIEW_UPDATEDAYLABEL_ENTRY ); |
|
1753 |
|
1754 // Set the short day names to these labels |
|
1755 int startOfWeek = mLocale.startOfWeek(); |
|
1756 int weekDayIndex = startOfWeek; |
|
1757 QStringList weekDayArray ; |
|
1758 weekDayArray <<hbTrId("txt_calendar_grid_day_mo") |
|
1759 <<hbTrId("txt_calendar_grid_day_tu") |
|
1760 <<hbTrId("txt_calendar_grid_day_we") |
|
1761 <<hbTrId("txt_calendar_grid_day_th") |
|
1762 <<hbTrId("txt_calendar_grid_day_fr") |
|
1763 <<hbTrId("txt_calendar_grid_day_sa") |
|
1764 <<hbTrId("txt_calendar_grid_day_su"); |
|
1765 |
|
1766 QList<HbLabel*> labels; |
|
1767 // append seven day labels |
|
1768 labels.append(mFirstDayLabel); |
|
1769 labels.append(mSecondDayLabel); |
|
1770 labels.append(mThirdDayLabel); |
|
1771 labels.append(mFourthDayLabel); |
|
1772 labels.append(mFifthDayLabel); |
|
1773 labels.append(mSixthDayLabel); |
|
1774 labels.append(mSeventhDayLabel); |
|
1775 QGraphicsLinearLayout* layout = static_cast<QGraphicsLinearLayout*> (mDayNameWidget->layout()); |
|
1776 for(int i=0;i < KCalenDaysInWeek; i++ ) |
|
1777 { |
|
1778 labels.at(i)->setPlainText(weekDayArray[weekDayIndex]); |
|
1779 // Set the stretch factor as 1 so that each label occupies equal space |
|
1780 layout->setStretchFactor(labels.at(i), 1); |
|
1781 if(weekDayIndex == KCalenDaysInWeek - 1 )//Sunday |
|
1782 { |
|
1783 weekDayIndex = 0;//reset to monday |
|
1784 continue; |
|
1785 } |
|
1786 weekDayIndex++;//increase the index for next value |
|
1787 } |
|
1788 labels.clear(); |
|
1789 weekDayArray.clear(); |
|
1790 |
|
1791 OstTraceFunctionExit0( CALENMONTHVIEW_UPDATEDAYLABEL_EXIT ); |
|
1792 } |
|
1793 |
|
1794 // End of file --Don't remove this. |
|