author | hgs |
Tue, 05 Oct 2010 13:57:00 +0530 | |
changeset 81 | ce92091cbd61 |
parent 75 | 7ac58b2aae6f |
child 83 | 5aadd1120515 |
permissions | -rw-r--r-- |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
* All rights reserved. |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
8 |
* |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
9 |
* Initial Contributors: |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
11 |
* |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
12 |
* Contributors: |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
13 |
* |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
14 |
* Description: Definition file for class CalenMonthGrid. |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
16 |
*/ |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
18 |
// System includes |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
19 |
#include <hbgridview.h> |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
20 |
#include <hbabstractviewitem.h> |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
21 |
#include <hbstyleloader.h> |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
22 |
#include <hbcolorscheme.h> |
45 | 23 |
#include <hbpangesture.h> |
24 |
#include <hbswipegesture.h> |
|
51 | 25 |
#include <hbtapgesture.h> |
45 | 26 |
#include <hbdeviceprofile.h> |
55 | 27 |
#include <hbinstance.h> |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
29 |
// User includes |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
30 |
#include "calenmonthgrid.h" |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
31 |
#include "calengriditemprototype.h" |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
32 |
#include "calenmonthdata.h" |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
33 |
#include "calenmonthview.h" |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
34 |
#include "calendateutils.h" |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
35 |
#include "calencommon.h" |
45 | 36 |
#include "calenconstants.h" |
51 | 37 |
#include "OstTraceDefinitions.h" |
38 |
#ifdef OST_TRACE_COMPILER_IN_USE |
|
39 |
#include "calenmonthgridTraces.h" |
|
40 |
#endif |
|
41 |
||
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
42 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
43 |
// Constants |
45 | 44 |
#define SCROLL_SPEEED 3000 |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
45 |
#define GRIDLINE_WIDTH 0.075 //units |
45 | 46 |
#define MAX_PAN_DIRECTION_THRESHOLD 50 |
47 |
#define MIN_PAN_DIRECTION_THRESHOLD 20 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
48 |
|
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
49 |
/*! |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
50 |
\class CalenMonthGrid |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
51 |
|
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
52 |
Implements the month grid |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
53 |
*/ |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
54 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
55 |
/*! |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
56 |
Default constructor. |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
57 |
*/ |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
58 |
CalenMonthGrid::CalenMonthGrid(QGraphicsItem *parent): |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
59 |
HbGridView(parent), |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
60 |
mModel(0), |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
61 |
mDirection(invalid), |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
62 |
mIsPanGesture(false), |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
63 |
mIsAtomicScroll(true), |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
64 |
mView(NULL), |
45 | 65 |
mCurrentRow(-100), |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
66 |
mIsNonActiveDayFocused(false), |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
67 |
mIgnoreItemActivated(false), |
63 | 68 |
mGridLineColor(HbColorScheme::color("qtc_cal_grid_line")), |
70 | 69 |
mActiveDatesSet(false), |
75 | 70 |
mIsGridAdjusting(false), |
71 |
mEventIndicatorNotSet(false) |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
72 |
{ |
51 | 73 |
OstTraceFunctionEntry0( CALENMONTHGRID_CALENMONTHGRID_ENTRY ); |
74 |
||
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
75 |
setScrollDirections(Qt::Vertical); |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
76 |
setRowCount(KNumOfVisibleRows); |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
77 |
setColumnCount(KCalenDaysInWeek); |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
78 |
setItemRecycling(false); |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
79 |
setSelectionMode(HbGridView::NoSelection); |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
80 |
setUniformItemSizes(true); |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
81 |
setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff); |
45 | 82 |
setClampingStyle(HbScrollArea::StrictClamping); |
83 |
setEnabledAnimations(HbAbstractItemView::None); |
|
84 |
setFrictionEnabled(false); |
|
85 |
setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
63 | 86 |
|
75 | 87 |
// Enable the pixmap cache for better scrolling performance |
88 |
setItemPixmapCacheEnabled(true); |
|
89 |
||
63 | 90 |
// Disable the rows and columns swapping on orientation change |
91 |
setSwapDimensionsOnOrientationChange(false); |
|
92 |
||
45 | 93 |
resetTransform(); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
94 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
95 |
// Get the content widget of the scroll area to draw the grid lines |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
96 |
mContentWidget = contentWidget(); |
63 | 97 |
|
45 | 98 |
// Get the localised dates well before |
99 |
// TODO: Need to update the mLocalisedDates when user changes the |
|
100 |
// phone language keeping calendar application in background |
|
101 |
HbExtendedLocale locale = HbExtendedLocale::system(); |
|
102 |
for (int i = 1; i <= 31; i++) { |
|
103 |
mLocalisedDates.append(locale.toString(i)); |
|
104 |
} |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
105 |
|
45 | 106 |
// Connect to scrolling finished signal |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
107 |
connect(this, SIGNAL(scrollingEnded()), this, |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
108 |
SLOT(scrollingFinished())); |
63 | 109 |
|
110 |
connect( |
|
111 |
HbTheme::instance(), SIGNAL(changed()), |
|
112 |
this, SLOT(handleThemeChange())); |
|
113 |
||
114 |
// Disable the haptic feedback for the month grid during scrolling |
|
115 |
setAttribute(Hb::InteractionDisabled); |
|
51 | 116 |
|
117 |
OstTraceFunctionExit0( CALENMONTHGRID_CALENMONTHGRID_EXIT ); |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
118 |
} |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
119 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
120 |
/*! |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
121 |
Destructor |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
122 |
*/ |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
123 |
CalenMonthGrid::~CalenMonthGrid() |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
124 |
{ |
51 | 125 |
OstTraceFunctionEntry0( DUP1_CALENMONTHGRID_CALENMONTHGRID_ENTRY ); |
126 |
||
45 | 127 |
// Nothing Yet |
51 | 128 |
|
129 |
OstTraceFunctionExit0( DUP1_CALENMONTHGRID_CALENMONTHGRID_EXIT ); |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
130 |
} |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
131 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
132 |
/*! |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
133 |
Stores the view pointer |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
134 |
*/ |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
135 |
void CalenMonthGrid::setView(CalenMonthView *view) |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
136 |
{ |
51 | 137 |
OstTraceFunctionEntry0( CALENMONTHGRID_SETVIEW_ENTRY ); |
138 |
||
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
139 |
mView = view; |
51 | 140 |
|
141 |
OstTraceFunctionExit0( CALENMONTHGRID_SETVIEW_EXIT ); |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
142 |
} |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
143 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
144 |
/*! |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
145 |
Updates the model with the proper dates and sets the required user roles |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
146 |
*/ |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
147 |
void CalenMonthGrid::updateMonthGridModel(QList<CalenMonthData> &monthDataArray, |
45 | 148 |
int indexToBeScrolled, bool isFirstTime) |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
149 |
{ |
51 | 150 |
OstTraceFunctionEntry0( CALENMONTHGRID_UPDATEMONTHGRIDMODEL_ENTRY ); |
151 |
||
45 | 152 |
int loopStart = 0; |
153 |
int loopEnd = monthDataArray.count(); |
|
154 |
if (isFirstTime) { |
|
155 |
// Create the model with only 42 items as visible to the user |
|
156 |
mModel = new QStandardItemModel(KCalenDaysInWeek * KNumOfVisibleRows, |
|
157 |
1, this); |
|
158 |
loopStart = (mView->rowsInPrevMonth()) * KCalenDaysInWeek; |
|
159 |
loopEnd = loopStart + (KCalenDaysInWeek * KNumOfVisibleRows); |
|
160 |
} else { |
|
161 |
// Block the signals generated by model, this is being done as |
|
162 |
// we want to avoid the overload of view listening to signals |
|
163 |
mModel->blockSignals(true); |
|
164 |
||
165 |
// Check the counts |
|
166 |
int dataCount = monthDataArray.count(); |
|
167 |
int rowCount = mModel->rowCount(); |
|
168 |
int countDiff = dataCount - rowCount; |
|
169 |
if (countDiff < 0) { |
|
170 |
// Delete extra rows in the model |
|
171 |
mModel->removeRows(dataCount,abs(countDiff)); |
|
172 |
} else if (countDiff > 0) { |
|
173 |
// Add the necessary number of rows |
|
174 |
mModel->insertRows(rowCount,countDiff); |
|
175 |
} |
|
176 |
loopEnd = dataCount; |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
177 |
} |
45 | 178 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
179 |
QDateTime activeDay = mView->getActiveDay(); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
180 |
QDateTime activeDateTime = CalenDateUtils::beginningOfDay(activeDay); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
181 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
182 |
QModelIndex currentIndex; |
45 | 183 |
int modelIndex = 0; |
184 |
for (int i = loopStart; i < loopEnd; i++) { |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
185 |
QDateTime dateTime = monthDataArray[i].Day(); |
45 | 186 |
currentIndex = mModel->index(modelIndex++, 0); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
187 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
188 |
// Create the variant list to contain the date to depict a grid item |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
189 |
QVariantList itemData; |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
190 |
|
45 | 191 |
// !!!NOTE!!!: Add the data in the order mentioned in the |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
192 |
// CalendarNamespace::DataRole enum. Dont change the order. |
45 | 193 |
itemData << mLocalisedDates.at(dateTime.date().day()-1); |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
194 |
|
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
195 |
// Check for active day |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
196 |
if (activeDateTime == CalenDateUtils::beginningOfDay(dateTime)) { |
45 | 197 |
mCurrentRow = i; |
198 |
// Set the focus attribute to true |
|
199 |
itemData << true; |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
200 |
} else { |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
201 |
// reset the highlight |
45 | 202 |
itemData << false; |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
203 |
} |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
204 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
205 |
// Check for current day |
81 | 206 |
if (QDate::currentDate() == dateTime.date()) { |
45 | 207 |
// Set the underline attribute to true |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
208 |
itemData << true; |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
209 |
} else { |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
210 |
itemData << false; |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
211 |
} |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
212 |
|
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
213 |
// Check for events |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
214 |
if (monthDataArray[i].HasEvents()) { |
45 | 215 |
// Set the event indicator attribute |
216 |
itemData << true; |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
217 |
} else { |
45 | 218 |
itemData << false; |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
219 |
} |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
220 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
221 |
// Add default text color |
45 | 222 |
if (monthDataArray[i].isActive()) { |
223 |
itemData << true; |
|
224 |
} else { |
|
225 |
itemData << false; |
|
226 |
} |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
227 |
mModel->itemFromIndex(currentIndex)->setData(itemData); |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
228 |
} |
45 | 229 |
|
230 |
if (isFirstTime) { |
|
231 |
||
232 |
// Create the prototype |
|
63 | 233 |
CalenGridItemPrototype* gridItemPrototype = new CalenGridItemPrototype(this); |
45 | 234 |
|
63 | 235 |
connect( |
236 |
HbTheme::instance(), SIGNAL(changed()), |
|
237 |
gridItemPrototype, SLOT(handleThemeChange())); |
|
45 | 238 |
|
239 |
// Register the widgetml and css files |
|
240 |
HbStyleLoader::registerFilePath(":/"); |
|
241 |
||
242 |
// Set the layout name |
|
243 |
setLayoutName("calendarCustomGridItem"); |
|
75 | 244 |
|
245 |
// Set the mode and the prototypec --> set it after setting layout name and |
|
246 |
// other things as it will avoid unnecessary polish calls |
|
247 |
setModel(mModel,gridItemPrototype); |
|
45 | 248 |
} else { |
249 |
// Since, we have finished setData, Now unblock the signals |
|
250 |
mModel->blockSignals(false); |
|
251 |
||
252 |
// Since till now, we had blocked signals being generated frm the mode |
|
253 |
// view will be unaware of the items that we added. Hence, inform the view |
|
254 |
// explicitly in one shot |
|
255 |
QModelIndex leftIndex = mModel->index(0, 0); |
|
256 |
QModelIndex rightIndex = mModel->index(loopEnd-1, 0); |
|
257 |
dataChanged(leftIndex, rightIndex); |
|
258 |
||
259 |
// NOTE: To make sure that we always display proper month, |
|
260 |
// two calls have been made to scrollTo(), one with top |
|
261 |
// visible item and other with bottom visible item |
|
262 |
// Calculate the first visible item in the grid |
|
263 |
||
264 |
// Calculate the last visible item in the grid |
|
265 |
QModelIndex lastVisibleIndex = mModel->index(indexToBeScrolled, 0); |
|
81 | 266 |
scrollTo(lastVisibleIndex, HbAbstractItemView::PositionAtBottom); |
45 | 267 |
} |
51 | 268 |
|
269 |
OstTraceFunctionExit0( CALENMONTHGRID_UPDATEMONTHGRIDMODEL_EXIT ); |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
270 |
} |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
271 |
|
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
272 |
/*! |
45 | 273 |
Updates the view with jprevious month dates when calendar is opened for the |
274 |
first time to improve the opening time |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
275 |
*/ |
45 | 276 |
void CalenMonthGrid::updateMonthGridWithInActiveMonths( |
277 |
QList<CalenMonthData> &monthDataArray) |
|
278 |
{ |
|
51 | 279 |
OstTraceFunctionEntry0( CALENMONTHGRID_UPDATEMONTHGRIDWITHINACTIVEMONTHS_ENTRY ); |
45 | 280 |
|
281 |
// Prepend the required rows |
|
282 |
handlePrependingRows(monthDataArray); |
|
283 |
||
284 |
// Append the required rows |
|
285 |
handleAppendingRows(monthDataArray); |
|
286 |
||
287 |
int rowsInPrevMonth = mView->rowsInPrevMonth(); |
|
288 |
||
289 |
// Calculate the proper index to be scrolled to |
|
81 | 290 |
|
291 |
int itemToBeScrolled = ((rowsInPrevMonth + KNumOfVisibleRows) * |
|
292 |
KCalenDaysInWeek) - 1; |
|
45 | 293 |
QModelIndex indexToBeScrolled = mModel->index(itemToBeScrolled, 0); |
294 |
mIsAtomicScroll = true; |
|
81 | 295 |
scrollTo(indexToBeScrolled, HbAbstractItemView::PositionAtBottom); |
45 | 296 |
|
297 |
// Update the sart position of the content widget |
|
298 |
mStartPos = mContentWidget->pos(); |
|
299 |
||
300 |
// Now connect to the signal which gets emitted when any item on the grid |
|
301 |
// is tapped. |
|
302 |
connect(this, SIGNAL(activated(const QModelIndex &)), this, |
|
303 |
SLOT(itemActivated(const QModelIndex &))); |
|
51 | 304 |
|
75 | 305 |
// Check if we need to set the event indicators |
306 |
if(mEventIndicatorNotSet) { |
|
307 |
mEventIndicatorNotSet = false; |
|
308 |
updateMonthGridWithEventIndicators(monthDataArray); |
|
309 |
} |
|
51 | 310 |
OstTraceFunctionExit0( CALENMONTHGRID_UPDATEMONTHGRIDWITHINACTIVEMONTHS_EXIT ); |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
311 |
} |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
312 |
|
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
313 |
/*! |
45 | 314 |
Updates the view with just event indicators |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
315 |
*/ |
45 | 316 |
void CalenMonthGrid::updateMonthGridWithEventIndicators( |
317 |
QList<CalenMonthData> &monthDataArray) |
|
318 |
{ |
|
51 | 319 |
OstTraceFunctionEntry0( CALENMONTHGRID_UPDATEMONTHGRIDWITHEVENTINDICATORS_ENTRY ); |
320 |
||
321 |
int count(monthDataArray.count()); |
|
75 | 322 |
|
323 |
// Check if model is updated with all the dates |
|
324 |
// If not, return false for later updation |
|
325 |
if(count == mModel->rowCount()) { |
|
326 |
for(int i = 0; i < count; i++) { |
|
327 |
// Check if the day has events |
|
328 |
if (monthDataArray[i].HasEvents()) { |
|
329 |
QModelIndex itemIndex = mModel->index(i,0); |
|
330 |
QVariant itemData = itemIndex.data(Qt::UserRole + 1); |
|
331 |
QVariantList list = itemData.toList(); |
|
81 | 332 |
if (list.count() > CalendarNamespace::CalendarMonthEventRole ) { |
333 |
list.replace(CalendarNamespace::CalendarMonthEventRole, true); |
|
334 |
mModel->itemFromIndex(itemIndex)->setData(list); |
|
335 |
} |
|
75 | 336 |
} |
337 |
} |
|
338 |
} else { |
|
339 |
mEventIndicatorNotSet = true; |
|
45 | 340 |
} |
51 | 341 |
|
342 |
OstTraceFunctionExit0( CALENMONTHGRID_UPDATEMONTHGRIDWITHEVENTINDICATORS_EXIT ); |
|
45 | 343 |
} |
344 |
||
345 |
/*! |
|
346 |
Scrolls the content dowmwards |
|
347 |
*/ |
|
348 |
void CalenMonthGrid::downGesture() |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
349 |
{ |
51 | 350 |
OstTraceFunctionEntry0( CALENMONTHGRID_DOWNGESTURE_ENTRY ); |
70 | 351 |
mIsGridAdjusting = true; |
45 | 352 |
// Make sure that content widget is properly placed |
63 | 353 |
// We are doing this as tapping on inactive date of previous month is leading to |
354 |
// position the grid at wrong place after scrolling down. Hence, set the grid |
|
355 |
// at proper position before we start actual scrolling |
|
45 | 356 |
if (mIsNonActiveDayFocused) { |
357 |
mIsAtomicScroll = true; |
|
358 |
int itemToBeScrolled = mView->rowsInPrevMonth() * KCalenDaysInWeek; |
|
359 |
QModelIndex indexToBeScrolled = mModel->index(itemToBeScrolled, 0); |
|
360 |
scrollTo(indexToBeScrolled); |
|
361 |
} |
|
63 | 362 |
|
363 |
// Set the required flags |
|
45 | 364 |
mDirection = down; |
365 |
mIsAtomicScroll = false; |
|
63 | 366 |
|
367 |
// Set the active and inactive dates |
|
368 |
QDateTime activeMonth = mView->getActiveDay(); |
|
369 |
// For previous month, substract one month to the current month |
|
370 |
setActiveDates(activeMonth.addMonths(-1).date()); |
|
371 |
mActiveDatesSet = true; |
|
372 |
// Set the focus to proper date before scrolling to avoid somekind of |
|
373 |
// jerkiness |
|
374 |
if (!mIsNonActiveDayFocused) { |
|
375 |
setFocusToProperDay(); |
|
376 |
} |
|
377 |
||
378 |
// Start the scrolling |
|
45 | 379 |
QPointF targetPos(0.0, 0.0); |
380 |
scrollContentsTo(targetPos,500); |
|
51 | 381 |
|
382 |
OstTraceFunctionExit0( CALENMONTHGRID_DOWNGESTURE_EXIT ); |
|
45 | 383 |
} |
384 |
||
385 |
/*! |
|
386 |
Scrolls the content upwards |
|
387 |
*/ |
|
388 |
void CalenMonthGrid::upGesture() |
|
389 |
{ |
|
51 | 390 |
OstTraceFunctionEntry0( CALENMONTHGRID_UPGESTURE_ENTRY ); |
70 | 391 |
|
392 |
mIsGridAdjusting = true; |
|
393 |
||
63 | 394 |
// Set the required flags |
45 | 395 |
mDirection = up; |
396 |
mIsAtomicScroll = false; |
|
63 | 397 |
|
398 |
// Set the active and inactive dates |
|
399 |
QDateTime activeMonth = mView->getActiveDay(); |
|
400 |
// For next month, add one month to the current month |
|
401 |
setActiveDates(activeMonth.addMonths(1).date()); |
|
402 |
mActiveDatesSet = true; |
|
403 |
// Set the focus to proper date before scrolling to avoid somekind of |
|
404 |
// jerkiness |
|
405 |
if (!mIsNonActiveDayFocused) { |
|
406 |
setFocusToProperDay(); |
|
407 |
} |
|
408 |
||
409 |
// Start the scrolling |
|
45 | 410 |
QPointF targetPos(0.0, mStartPos.y() - size().height()); |
411 |
scrollContentsTo(-targetPos,500); |
|
412 |
||
51 | 413 |
OstTraceFunctionExit0( CALENMONTHGRID_UPGESTURE_EXIT ); |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
414 |
} |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
415 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
416 |
/*! |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
417 |
Function to listen mouse press events |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
418 |
*/ |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
419 |
void CalenMonthGrid::mousePressEvent(QGraphicsSceneMouseEvent* event) |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
420 |
{ |
51 | 421 |
OstTraceFunctionEntry0( CALENMONTHGRID_MOUSEPRESSEVENT_ENTRY ); |
422 |
||
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
423 |
// Pass it to parent |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
424 |
HbGridView::mousePressEvent(event); |
51 | 425 |
|
426 |
OstTraceFunctionExit0( CALENMONTHGRID_MOUSEPRESSEVENT_EXIT ); |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
427 |
} |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
428 |
|
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
429 |
/*! |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
430 |
Function to listen mouse release events |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
431 |
*/ |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
432 |
void CalenMonthGrid::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
433 |
{ |
51 | 434 |
OstTraceFunctionEntry0( CALENMONTHGRID_MOUSERELEASEEVENT_ENTRY ); |
435 |
||
45 | 436 |
// Pass it grid view if pan gesture is not in progress else pass it to |
437 |
// scrollarea. Problem here is, if we pass to gridview when panning, then |
|
438 |
// its emitting item activated signal simply becasue of which focus item |
|
439 |
// is getting changed when you finish the pan / shake |
|
440 |
if (!mIsPanGesture) { |
|
441 |
HbGridView::mouseReleaseEvent(event); |
|
442 |
} else { |
|
443 |
HbScrollArea::mouseReleaseEvent(event); |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
444 |
} |
51 | 445 |
|
446 |
OstTraceFunctionExit0( CALENMONTHGRID_MOUSERELEASEEVENT_EXIT ); |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
447 |
} |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
448 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
449 |
/*! |
45 | 450 |
Function to list for all the gesture events |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
451 |
*/ |
45 | 452 |
void CalenMonthGrid::gestureEvent(QGestureEvent *event) |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
453 |
{ |
51 | 454 |
OstTraceFunctionEntry0( CALENMONTHGRID_GESTUREEVENT_ENTRY ); |
455 |
||
75 | 456 |
// Dont listen for any gesture when grid is getting adjusted as listening to those was causing |
70 | 457 |
// grid to stop abruptly i between |
458 |
if (mIsGridAdjusting) { |
|
459 |
// consume the event and return |
|
460 |
qDebug()<<"RETURNING BACK"; |
|
461 |
event->ignore(); |
|
462 |
return; |
|
463 |
} |
|
464 |
||
45 | 465 |
if(HbPanGesture *gesture = qobject_cast<HbPanGesture *>(event->gesture(Qt::PanGesture))) { |
466 |
if (gesture->state() == Qt::GestureStarted) { |
|
467 |
mIsAtomicScroll = false; |
|
468 |
if (!mIsPanGesture) { |
|
469 |
mDirection = invalid; |
|
470 |
mStartPos = mContentWidget->pos(); |
|
63 | 471 |
// TODO: This work around till framework provides an api |
45 | 472 |
// to know the direciton of the pan, until then we need |
473 |
// calculate the direction explicitly |
|
474 |
// Get to know the direction of the gesture |
|
475 |
// Use our defined threshold temporarily till scrollarea |
|
476 |
// frm orbit side is made clever enough not to scroll in other direction |
|
477 |
// apart frm the registered scroll direction |
|
75 | 478 |
QPointF delta = gesture->sceneOffset(); |
479 |
qreal horizontalDiff = delta.x(); |
|
480 |
qreal verticalDiff = delta.y(); |
|
55 | 481 |
if (abs(horizontalDiff) > MAX_PAN_DIRECTION_THRESHOLD) { |
45 | 482 |
// Now see if y coord diff has crossed threshold |
55 | 483 |
if (verticalDiff > MAX_PAN_DIRECTION_THRESHOLD) { |
45 | 484 |
mIsPanGesture = true; |
485 |
mIgnoreItemActivated = true; |
|
486 |
mDirection = down; |
|
55 | 487 |
} else if (verticalDiff < -MAX_PAN_DIRECTION_THRESHOLD){ |
45 | 488 |
mIsPanGesture = true; |
489 |
mIgnoreItemActivated = true; |
|
490 |
mDirection = up; |
|
491 |
} else { |
|
492 |
event->accept(Qt::PanGesture); |
|
51 | 493 |
OstTraceFunctionExit0( CALENMONTHGRID_GESTUREEVENT_EXIT ); |
45 | 494 |
return; |
495 |
} |
|
55 | 496 |
} else if (abs(horizontalDiff) < MAX_PAN_DIRECTION_THRESHOLD) { |
497 |
if (verticalDiff > MIN_PAN_DIRECTION_THRESHOLD) { |
|
45 | 498 |
mIsPanGesture = true; |
499 |
mIgnoreItemActivated = true; |
|
500 |
mDirection = down; |
|
55 | 501 |
} else if (verticalDiff < -MIN_PAN_DIRECTION_THRESHOLD){ |
45 | 502 |
mIsPanGesture = true; |
503 |
mIgnoreItemActivated = true; |
|
504 |
mDirection = up; |
|
505 |
}else { |
|
506 |
event->accept(Qt::PanGesture); |
|
51 | 507 |
OstTraceFunctionExit0( DUP1_CALENMONTHGRID_GESTUREEVENT_EXIT ); |
45 | 508 |
return; |
509 |
} |
|
510 |
} |
|
511 |
} |
|
512 |
} |
|
513 |
} else if(HbSwipeGesture *gesture = qobject_cast<HbSwipeGesture *>(event->gesture(Qt::SwipeGesture))) { |
|
514 |
if (gesture->state() == Qt::GestureStarted) { |
|
515 |
mIsAtomicScroll = false; |
|
516 |
mDirection = invalid; |
|
517 |
if (gesture->sceneVerticalDirection() == QSwipeGesture::Down) { |
|
518 |
mDirection = down; |
|
519 |
} else if (gesture->sceneVerticalDirection() == QSwipeGesture::Up) { |
|
520 |
mDirection = up; |
|
521 |
} else { |
|
522 |
event->accept(Qt::SwipeGesture); |
|
51 | 523 |
OstTraceFunctionExit0( DUP2_CALENMONTHGRID_GESTUREEVENT_EXIT ); |
45 | 524 |
return; |
525 |
} |
|
526 |
} |
|
51 | 527 |
} else if (HbTapGesture *gesture = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) { |
528 |
if(gesture->state() == Qt::GestureFinished) { |
|
529 |
// Check if scrolling is in progress |
|
530 |
if (mDirection != invalid) { |
|
531 |
// Set the pan flag to true so that grid adjusts to nearest |
|
532 |
// month after tapping |
|
533 |
mIsPanGesture = true; |
|
534 |
handlePanGestureFinished(); |
|
535 |
} |
|
536 |
} |
|
45 | 537 |
} |
538 |
||
75 | 539 |
// Check if we can scroll |
540 |
if (!checkIfWeCanScroll(mDirection)) { |
|
541 |
// We cannot scroll, return back |
|
542 |
mIsPanGesture = false; |
|
543 |
mIgnoreItemActivated = false; |
|
544 |
mDirection = invalid; |
|
545 |
event->accept(Qt::PanGesture); |
|
546 |
} |
|
547 |
||
45 | 548 |
if (mDirection!= invalid) { |
549 |
// Call the parent class to perform the pan gesture |
|
550 |
// When scrolling finished, month grid will adjust to show the proper month |
|
551 |
HbScrollArea::gestureEvent(event); |
|
552 |
} |
|
51 | 553 |
|
554 |
OstTraceFunctionExit0( DUP3_CALENMONTHGRID_GESTUREEVENT_EXIT ); |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
555 |
} |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
556 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
557 |
/*! |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
558 |
Gets called when scrolling finishes to update the model |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
559 |
*/ |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
560 |
void CalenMonthGrid::scrollingFinished() |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
561 |
{ |
51 | 562 |
OstTraceFunctionEntry0( CALENMONTHGRID_SCROLLINGFINISHED_ENTRY ); |
70 | 563 |
|
564 |
mIsGridAdjusting = false; |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
565 |
if (mIsPanGesture) { |
45 | 566 |
handlePanGestureFinished(); |
70 | 567 |
// Check if still request has been made for scrolling |
568 |
// if yes, then simply return |
|
569 |
if (mDirection != invalid) { |
|
570 |
mIgnoreItemActivated = false; |
|
571 |
return; |
|
572 |
} |
|
573 |
} |
|
574 |
||
575 |
if(!mIsAtomicScroll) { |
|
45 | 576 |
QDateTime activeDate = mView->getActiveDay(); |
577 |
if(mDirection == down) { // down gesture |
|
63 | 578 |
if (!mActiveDatesSet) { |
45 | 579 |
setActiveDates(activeDate.addMonths(-1).date()); |
63 | 580 |
setFocusToProperDay(); |
45 | 581 |
} |
582 |
prependRows(); |
|
583 |
} else if (mDirection == up) { //up gesture |
|
63 | 584 |
if (!mActiveDatesSet) { |
45 | 585 |
setActiveDates(activeDate.addMonths(1).date()); |
63 | 586 |
setFocusToProperDay(); |
45 | 587 |
} |
588 |
appendRows(); |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
589 |
} |
45 | 590 |
mDirection = invalid; |
63 | 591 |
mActiveDatesSet = false; |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
592 |
} else { |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
593 |
mIsAtomicScroll = false; |
45 | 594 |
mDirection = invalid; |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
595 |
} |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
596 |
mIgnoreItemActivated = false; |
51 | 597 |
|
598 |
OstTraceFunctionExit0( CALENMONTHGRID_SCROLLINGFINISHED_EXIT ); |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
599 |
} |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
600 |
|
45 | 601 |
/*! |
602 |
Function to handle completion of pan gesture |
|
603 |
*/ |
|
604 |
void CalenMonthGrid::handlePanGestureFinished() |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
605 |
{ |
51 | 606 |
OstTraceFunctionEntry0( CALENMONTHGRID_HANDLEPANGESTUREFINISHED_ENTRY ); |
607 |
||
45 | 608 |
mIsPanGesture = false; |
70 | 609 |
// Reset the mDirection flag |
610 |
mDirection = invalid; |
|
45 | 611 |
// Get the first item that is visible |
612 |
QList<HbAbstractViewItem *> list = visibleItems(); |
|
613 |
HbAbstractViewItem* item = list[0]; |
|
614 |
QModelIndex modelIndex = item->modelIndex(); |
|
615 |
||
616 |
// Get the date which is visible at the above row |
|
55 | 617 |
QList<CalenMonthData>& monthDataArray = mView->monthDataList(); |
618 |
QDateTime date = monthDataArray[modelIndex.row()].Day(); |
|
45 | 619 |
|
620 |
// Check if this date belong to current active month or |
|
621 |
// previous month else future month |
|
622 |
QDateTime activeMonth = mView->getActiveDay(); |
|
623 |
QDateTime prevMonth = activeMonth.addMonths(-1); |
|
624 |
QDateTime nextMonth = activeMonth.addMonths(1); |
|
625 |
int month = date.date().month(); |
|
626 |
if (month == activeMonth.date().month()) { |
|
627 |
// Then pan is completed on current month |
|
628 |
// Check if the date is more than half of the current month or it is |
|
629 |
// more than or equal to half of the future month |
|
630 |
if (date.date().day() > (activeMonth.date().daysInMonth()) / 2 || |
|
631 |
date.addDays(KNumOfVisibleRows*KCalenDaysInWeek).date().day() >= |
|
632 |
(prevMonth.date().daysInMonth()) / 2) { |
|
633 |
// up gesture to bring the next month |
|
634 |
upGesture(); |
|
635 |
} else { |
|
636 |
// we should again show the current month by scrolling downwards |
|
637 |
mDirection = down; |
|
638 |
mIsAtomicScroll = true; |
|
639 |
scrollContentsTo(-mStartPos,500); |
|
640 |
} |
|
641 |
} else if (month == prevMonth.date().month()) { |
|
642 |
// first visible item belongs to previous month |
|
643 |
// Check if the date is more than half of the previous month |
|
644 |
if (date.date().day() > (prevMonth.date().daysInMonth()) / 2) { |
|
70 | 645 |
// we should again show the current month by scrolling downwards |
646 |
mDirection = down; |
|
45 | 647 |
mIsAtomicScroll = true; |
648 |
scrollContentsTo(-mStartPos,500); |
|
649 |
} else { |
|
650 |
// down gesture to show the previous month |
|
651 |
downGesture(); |
|
652 |
} |
|
653 |
} else if (month == prevMonth.addMonths(-1).date().month()) { |
|
654 |
// first visible date belong to previous to previous month |
|
655 |
// hence, scroll down to bring the previous month |
|
656 |
downGesture(); |
|
657 |
} else if (month == nextMonth.date().month()) { |
|
658 |
// first visible item belongs to next month |
|
659 |
// Check if the date is more than half of the next month |
|
660 |
if (date.date().day() > (nextMonth.date().daysInMonth()) / 2) { |
|
661 |
// up gesture to bring the next month |
|
662 |
upGesture(); |
|
663 |
} else { |
|
664 |
// we should again show the current month by scrolling upwards |
|
63 | 665 |
mDirection = up; |
70 | 666 |
mIsAtomicScroll = true; |
45 | 667 |
scrollContentsTo(-mStartPos,500); |
668 |
} |
|
669 |
} else if (month == nextMonth.addMonths(1).date().month()) { |
|
670 |
// first visible date belongs to next to next month |
|
671 |
// hence, scroll up to show the next month |
|
672 |
upGesture(); |
|
70 | 673 |
} else { |
674 |
// User has panned so that exact month has been scrolled |
|
675 |
// no need for any adjustment here, just append/prepend the rows |
|
676 |
mIsAtomicScroll = false; |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
677 |
} |
51 | 678 |
|
679 |
OstTraceFunctionExit0( CALENMONTHGRID_HANDLEPANGESTUREFINISHED_EXIT ); |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
680 |
} |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
681 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
682 |
/*! |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
683 |
Called when down gesture is performed. Adds the new previous month details |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
684 |
to the model |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
685 |
*/ |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
686 |
void CalenMonthGrid::prependRows() |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
687 |
{ |
51 | 688 |
OstTraceFunctionEntry0( CALENMONTHGRID_PREPENDROWS_ENTRY ); |
45 | 689 |
|
690 |
// Block the signals generated by model, this is being done as |
|
691 |
// we want to avoid the overload of view listening to signals |
|
692 |
mModel->blockSignals(true); |
|
693 |
||
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
694 |
mIsNonActiveDayFocused = false; |
45 | 695 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
696 |
int rowsInFutMonthEarlier = mView->rowsInFutMonth(); |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
697 |
int rowsInPrevMonthEarlier = mView->rowsInPrevMonth(); |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
698 |
|
45 | 699 |
// remove the cells in the future month |
700 |
int deleteFromIndex = (rowsInPrevMonthEarlier + KNumOfVisibleRows) * KCalenDaysInWeek; |
|
701 |
int numOfIndices = rowsInFutMonthEarlier * KCalenDaysInWeek; |
|
702 |
||
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
703 |
// Get the updated dates from the view |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
704 |
mView->updateModelWithPrevMonth(); |
55 | 705 |
QList<CalenMonthData >& monthDataList = mView->monthDataList(); |
45 | 706 |
|
707 |
// Prepend the required rows |
|
708 |
handlePrependingRows(monthDataList); |
|
709 |
||
710 |
// Since, we have finished setData, Now unblock the signals |
|
711 |
mModel->blockSignals(false); |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
712 |
|
45 | 713 |
int rowsInPrevMonth = mView->rowsInPrevMonth(); |
714 |
int countToBeAdded = rowsInPrevMonth * KCalenDaysInWeek; |
|
715 |
||
716 |
// Since till now, we had blocked signals being generated frm the model |
|
717 |
// view will be unaware of the items that we added. Hence, inform the view |
|
718 |
// explicitly in one shot |
|
719 |
QModelIndex leftIndex = mModel->index(0, 0); |
|
720 |
QModelIndex rightIndex = mModel->index(countToBeAdded-1, 0); |
|
721 |
dataChanged(leftIndex, rightIndex); |
|
722 |
||
723 |
// Now remove the necessary items frm the model |
|
724 |
mModel->removeRows(deleteFromIndex+countToBeAdded, numOfIndices); |
|
725 |
mIsAtomicScroll = true; |
|
726 |
int itemToBeScrolled = rowsInPrevMonth * KCalenDaysInWeek; |
|
727 |
QModelIndex indexToBeScrolled = mModel->index(itemToBeScrolled, 0); |
|
728 |
scrollTo(indexToBeScrolled); |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
729 |
|
45 | 730 |
// Scroll to proper index |
731 |
itemToBeScrolled = ((rowsInPrevMonth + KNumOfVisibleRows) * |
|
732 |
KCalenDaysInWeek) - 1; |
|
733 |
indexToBeScrolled = mModel->index(itemToBeScrolled, 0); |
|
734 |
mIsAtomicScroll = true; |
|
735 |
scrollTo(indexToBeScrolled); |
|
736 |
// Update the mCurrentRow |
|
737 |
mCurrentRow += countToBeAdded; |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
738 |
|
45 | 739 |
// Update the sart position of the content widget |
740 |
mStartPos = mContentWidget->pos(); |
|
51 | 741 |
|
742 |
OstTraceFunctionExit0( CALENMONTHGRID_PREPENDROWS_EXIT ); |
|
45 | 743 |
} |
744 |
||
745 |
/*! |
|
746 |
Helper function that prepends the required rows to the model |
|
747 |
*/ |
|
748 |
void CalenMonthGrid::handlePrependingRows(QList<CalenMonthData > &monthDataList) |
|
749 |
{ |
|
51 | 750 |
OstTraceFunctionEntry0( CALENMONTHGRID_HANDLEPREPENDINGROWS_ENTRY ); |
751 |
||
45 | 752 |
int rowsInPrevMonth = mView->rowsInPrevMonth(); |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
753 |
// Add the new days |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
754 |
int countToBeAdded = rowsInPrevMonth * KCalenDaysInWeek; |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
755 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
756 |
mModel->insertRows(0, countToBeAdded); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
757 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
758 |
for (int i = 0; i < countToBeAdded; i++) { |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
759 |
QDateTime dateTime = monthDataList[i].Day(); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
760 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
761 |
// Get the localised string for the day |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
762 |
QModelIndex currentIndex = mModel->index(i, 0); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
763 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
764 |
// Create the variant list to contain the date to depict a grid item |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
765 |
QVariantList itemData; |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
766 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
767 |
// NOTE: Add the data in the order mentioned in the |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
768 |
// CalendarNamespace::DataRole enum. Dont change the order. |
45 | 769 |
itemData << mLocalisedDates.at(dateTime.date().day()-1);; |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
770 |
|
45 | 771 |
// Disable the focus role |
772 |
itemData << false; |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
773 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
774 |
// Check for current day |
81 | 775 |
if (QDate::currentDate() == dateTime.date()) { |
45 | 776 |
// Set the underline icon attribute |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
777 |
itemData << true; |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
778 |
} else { |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
779 |
itemData << false; |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
780 |
} |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
781 |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
782 |
// Update the event indicators |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
783 |
if (monthDataList[i].HasEvents()) { |
45 | 784 |
// Set the event indicator attribute |
785 |
itemData << true; |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
786 |
} else { |
45 | 787 |
itemData << false; |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
788 |
} |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
789 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
790 |
// Add default text color |
45 | 791 |
itemData << false; |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
792 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
793 |
// Set the data to model |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
794 |
mModel->itemFromIndex(currentIndex)->setData(itemData); |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
795 |
} |
51 | 796 |
|
797 |
OstTraceFunctionExit0( CALENMONTHGRID_HANDLEPREPENDINGROWS_EXIT ); |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
798 |
} |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
799 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
800 |
/*! |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
801 |
Called when Up gwsture is performed. Adds the new future month details |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
802 |
to the model |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
803 |
*/ |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
804 |
void CalenMonthGrid::appendRows() |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
805 |
{ |
51 | 806 |
OstTraceFunctionEntry0( CALENMONTHGRID_APPENDROWS_ENTRY ); |
45 | 807 |
|
808 |
// Block the signals generated by model, this is being done as |
|
809 |
// we want to avoid the overload of view listening to signals |
|
810 |
mModel->blockSignals(true); |
|
811 |
||
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
812 |
mIsNonActiveDayFocused = false; |
45 | 813 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
814 |
int rowsInFutMonth = mView->rowsInFutMonth(); |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
815 |
int rowsInPrevMonth = mView->rowsInPrevMonth(); |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
816 |
// remove the cells in the previous month |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
817 |
int countToBeDeleted = rowsInPrevMonth * KCalenDaysInWeek; |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
818 |
|
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
819 |
// Get the updated dates from the view |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
820 |
mView->updateModelWithFutureMonth(); |
55 | 821 |
QList<CalenMonthData >& monthDataList = mView->monthDataList(); |
45 | 822 |
|
823 |
// Get the model count before we add any rows into the mode |
|
824 |
int rowCount = mModel->rowCount(); |
|
825 |
// Append the required rows |
|
826 |
handleAppendingRows(monthDataList); |
|
827 |
||
828 |
// Since, we have finished setData, Now unblock the signals |
|
829 |
mModel->blockSignals(false); |
|
830 |
||
831 |
// Since till now, we had blocked signals being generated frm the mode |
|
832 |
// view will be unaware of the items that we added. Hence, inform the view |
|
833 |
// explicitly in one shot |
|
834 |
QModelIndex leftIndex = mModel->index(rowCount-1, 0); |
|
835 |
QModelIndex rightIndex = mModel->index(mModel->rowCount()-1, 0); |
|
836 |
dataChanged(leftIndex, rightIndex); |
|
837 |
||
838 |
// Update the mCurrentRow |
|
839 |
mCurrentRow -= (countToBeDeleted); |
|
840 |
for (int i = 0; i < countToBeDeleted; i++) { |
|
841 |
mModel->removeRow(0); |
|
842 |
} |
|
843 |
||
844 |
mIsAtomicScroll = true; |
|
845 |
||
846 |
rowsInFutMonth = mView->rowsInFutMonth(); |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
847 |
rowsInPrevMonth = mView->rowsInPrevMonth(); |
45 | 848 |
|
849 |
// Calculate the proper index to be scrolled to |
|
850 |
int itemToBeScrolled = rowsInPrevMonth * KCalenDaysInWeek; |
|
851 |
QModelIndex indexToBeScrolled = mModel->index(itemToBeScrolled, 0); |
|
852 |
scrollTo(indexToBeScrolled); |
|
853 |
||
854 |
itemToBeScrolled = ((rowsInPrevMonth + KNumOfVisibleRows) * |
|
855 |
KCalenDaysInWeek) - 1; |
|
856 |
indexToBeScrolled = mModel->index(itemToBeScrolled, 0); |
|
857 |
mIsAtomicScroll = true; |
|
858 |
scrollTo(indexToBeScrolled); |
|
859 |
||
860 |
// Update the sart position of the content widget |
|
861 |
mStartPos = mContentWidget->pos(); |
|
51 | 862 |
|
863 |
OstTraceFunctionExit0( CALENMONTHGRID_APPENDROWS_EXIT ); |
|
45 | 864 |
} |
865 |
||
866 |
/*! |
|
867 |
Helper function that appends the required rows to the model |
|
868 |
*/ |
|
869 |
void CalenMonthGrid::handleAppendingRows(QList<CalenMonthData > &monthDataList) |
|
870 |
{ |
|
51 | 871 |
OstTraceFunctionEntry0( CALENMONTHGRID_HANDLEAPPENDINGROWS_ENTRY ); |
872 |
||
45 | 873 |
int rowsInFutMonth = mView->rowsInFutMonth(); |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
874 |
int countToBeAdded = rowsInFutMonth * KCalenDaysInWeek; |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
875 |
int lastVisibleIndex = monthDataList.count() - countToBeAdded; |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
876 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
877 |
int rowCount = mModel->rowCount(); |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
878 |
mModel->insertRows(rowCount, countToBeAdded); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
879 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
880 |
for (int i = 0; i < countToBeAdded; i++) { |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
881 |
QModelIndex currentIndex = mModel->index(rowCount + i, 0); |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
882 |
|
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
883 |
QDateTime dateTime = monthDataList[lastVisibleIndex + i].Day(); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
884 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
885 |
// Create the variant list to contain the date to depict a grid item |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
886 |
QVariantList itemData; |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
887 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
888 |
// NOTE: Add the data in the order mentioned in the |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
889 |
// CalendarNamespace::DataRole enum. Dont change the order. |
45 | 890 |
itemData << mLocalisedDates.at(dateTime.date().day()-1);; |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
891 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
892 |
// Disable the focus role |
45 | 893 |
itemData << false; |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
894 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
895 |
// Check for current day |
81 | 896 |
if (QDate::currentDate() == dateTime.date()) { |
45 | 897 |
// Set the underline icon attribute |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
898 |
itemData << true; |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
899 |
} else { |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
900 |
itemData << false; |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
901 |
} |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
902 |
|
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
903 |
// Update the event indicators |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
904 |
if (monthDataList[lastVisibleIndex + i].HasEvents()) { |
45 | 905 |
// Set the event indicator attribute |
906 |
itemData << true; |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
907 |
} else { |
45 | 908 |
itemData << false; |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
909 |
} |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
910 |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
911 |
// Add default text color |
45 | 912 |
itemData << false; |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
913 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
914 |
// Set the data to model |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
915 |
mModel->itemFromIndex(currentIndex)->setData(itemData); |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
916 |
} |
51 | 917 |
|
918 |
OstTraceFunctionExit0( CALENMONTHGRID_HANDLEAPPENDINGROWS_EXIT ); |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
919 |
} |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
920 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
921 |
/*! |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
922 |
Slot to handle when a particular grid item is tapped |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
923 |
*/ |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
924 |
void CalenMonthGrid::itemActivated(const QModelIndex &index) |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
925 |
{ |
51 | 926 |
OstTraceFunctionEntry0( CALENMONTHGRID_ITEMACTIVATED_ENTRY ); |
927 |
||
75 | 928 |
QList<CalenMonthData >& monthDataList = mView->monthDataList(); |
929 |
// Chekc if we need to ignore the event or the newly tapped date is |
|
930 |
// not valid date |
|
931 |
if (mIgnoreItemActivated || !(CalenDateUtils::isValidDay(monthDataList[index.row()].Day()))) { |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
932 |
mIgnoreItemActivated = false; |
51 | 933 |
OstTraceFunctionExit0( CALENMONTHGRID_ITEMACTIVATED_EXIT ); |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
934 |
return; |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
935 |
} |
75 | 936 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
937 |
mIsNonActiveDayFocused = false; |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
938 |
// Check if the same item has been tapped twice |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
939 |
if (mCurrentRow == index.row()) { |
45 | 940 |
// Launch the Day view |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
941 |
mView->launchDayView(); |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
942 |
} else { |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
943 |
// Reset the focus attribute to this item |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
944 |
QModelIndex itemIndex = mModel->index(mCurrentRow,0); |
45 | 945 |
if(itemIndex.row() < 0 || itemIndex.row() >= mModel->rowCount() || |
946 |
itemIndex.column() < 0 || itemIndex.column() > mModel->columnCount()) { |
|
51 | 947 |
OstTraceFunctionExit0( DUP1_CALENMONTHGRID_ITEMACTIVATED_EXIT ); |
45 | 948 |
return; |
949 |
} |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
950 |
QVariant itemData = itemIndex.data(Qt::UserRole + 1); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
951 |
QVariantList list = itemData.toList(); |
45 | 952 |
list.replace(CalendarNamespace::CalendarMonthFocusRole, false); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
953 |
mModel->itemFromIndex(itemIndex)->setData(list); |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
954 |
|
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
955 |
// Inform view to update the context and preview panes |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
956 |
mCurrentRow = index.row(); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
957 |
itemIndex = mModel->index(mCurrentRow,0); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
958 |
itemData = itemIndex.data(Qt::UserRole + 1); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
959 |
list = itemData.toList(); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
960 |
list.replace(CalendarNamespace::CalendarMonthFocusRole, |
45 | 961 |
true); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
962 |
mModel->itemFromIndex(itemIndex)->setData(list); |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
963 |
// Check if inactive date is tapped |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
964 |
QDateTime activeMonth = mView->getActiveDay(); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
965 |
int month = activeMonth.date().month(); |
55 | 966 |
if(month != monthDataList[mCurrentRow].Day().date().month()){ |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
967 |
// Set the flag |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
968 |
mIsNonActiveDayFocused = true; |
63 | 969 |
QDateTime nonActiveFocusedDay = monthDataList[mCurrentRow].Day(); |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
970 |
|
45 | 971 |
// Add one month to active month |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
972 |
activeMonth = activeMonth.addMonths(1); |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
973 |
if (activeMonth.date().month() == |
63 | 974 |
nonActiveFocusedDay.date().month()) { |
45 | 975 |
mDirection = up; |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
976 |
// up gesture |
45 | 977 |
upGesture(); |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
978 |
} else { |
45 | 979 |
mDirection = down; |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
980 |
// down gesture |
45 | 981 |
downGesture(); |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
982 |
} |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
983 |
} |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
984 |
mView->setContextForActiveDay(index.row()); |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
985 |
} |
51 | 986 |
|
987 |
OstTraceFunctionExit0( DUP2_CALENMONTHGRID_ITEMACTIVATED_EXIT ); |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
988 |
} |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
989 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
990 |
/*! |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
991 |
Sets the focus to proper day after the flick scrollng |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
992 |
*/ |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
993 |
void CalenMonthGrid::setFocusToProperDay() |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
994 |
{ |
51 | 995 |
OstTraceFunctionEntry0( CALENMONTHGRID_SETFOCUSTOPROPERDAY_ENTRY ); |
996 |
||
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
997 |
// Calculate the new item to be focussed |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
998 |
QDateTime oldFocussedDate = mView->getActiveDay(); |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
999 |
QList<CalenMonthData> monthDataList = mView->monthDataList(); |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1000 |
int listCount = monthDataList.count(); |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1001 |
int rowsInPrevMonth = mView->rowsInPrevMonth(); |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1002 |
QDateTime dateToBeFocussed; |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1003 |
int indexStart = 0; |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1004 |
int indexEnd = listCount - 1; |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1005 |
if (mDirection == up) { |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1006 |
dateToBeFocussed = oldFocussedDate.addMonths(1); // add the month |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1007 |
indexStart = (rowsInPrevMonth + 4) * KCalenDaysInWeek; |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1008 |
} else if (mDirection == down) { |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1009 |
dateToBeFocussed = oldFocussedDate.addMonths(-1); // substract the month |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1010 |
indexEnd = (rowsInPrevMonth + 1) * KCalenDaysInWeek; |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1011 |
} |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1012 |
// Reset the focus attribute to earlier current item |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1013 |
QModelIndex index = mModel->index(mCurrentRow,0); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1014 |
QVariant itemData = index.data(Qt::UserRole + 1); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1015 |
QVariantList list = itemData.toList(); |
45 | 1016 |
list.replace(CalendarNamespace::CalendarMonthFocusRole, false); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1017 |
mModel->itemFromIndex(index)->setData(list); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1018 |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1019 |
// Search for this date in the model |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1020 |
for (int i = indexStart; i <= indexEnd; i++) { |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1021 |
if (monthDataList[i].Day().date() == dateToBeFocussed.date()) { |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1022 |
index = mModel->index(i,0); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1023 |
itemData = index.data(Qt::UserRole + 1); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1024 |
list = itemData.toList(); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1025 |
list.replace(CalendarNamespace::CalendarMonthFocusRole, |
45 | 1026 |
true); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1027 |
mModel->itemFromIndex(index)->setData(list); |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1028 |
mCurrentRow = i; |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1029 |
mView->setContextForActiveDay(i); |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1030 |
break; |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1031 |
} |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1032 |
} |
51 | 1033 |
|
1034 |
OstTraceFunctionExit0( CALENMONTHGRID_SETFOCUSTOPROPERDAY_EXIT ); |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1035 |
} |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1036 |
|
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1037 |
/*! |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1038 |
Sets the appropriate text color depending upon the active dates |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1039 |
*/ |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1040 |
void CalenMonthGrid::setActiveDates(QDate activeDate) |
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1041 |
{ |
51 | 1042 |
OstTraceFunctionEntry0( CALENMONTHGRID_SETACTIVEDATES_ENTRY ); |
1043 |
||
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1044 |
// By default, text color will be set as inactive date color |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1045 |
// set active date color only for the dates that fall in current month |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1046 |
// So, in the whole data array, start from where the current month starts |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1047 |
// and stop the loop where it the current month ends |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1048 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1049 |
int start = 0; |
55 | 1050 |
QList<CalenMonthData >& monthDataList = mView->monthDataList(); |
1051 |
int end = monthDataList.count(); |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1052 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1053 |
// Calculate the start and end values |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1054 |
QDate firstDateInGrid = mView->firstDayOfGrid().date(); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1055 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1056 |
// Get the date where active month starts |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1057 |
QDate startOfActiveMonth(activeDate.year(), activeDate.month(),1); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1058 |
// Number of days frm start of the grid to start of the month |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1059 |
start = firstDateInGrid.daysTo(startOfActiveMonth); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1060 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1061 |
// Get the date where active month ends |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1062 |
QDate endOfActiveMonth = startOfActiveMonth.addDays( |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1063 |
activeDate.daysInMonth()); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1064 |
// Number of days frm start of the grid to end of the month |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1065 |
end = firstDateInGrid.daysTo(endOfActiveMonth); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1066 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1067 |
// Set the active text color |
63 | 1068 |
if (start >= 0 && end < monthDataList.count()) { |
1069 |
for (int i = start; i < end; i++) { |
|
1070 |
QModelIndex index = mModel->index(i,0); |
|
1071 |
QVariant itemData = index.data(Qt::UserRole + 1); |
|
1072 |
QVariantList list = itemData.toList(); |
|
1073 |
list.replace(CalendarNamespace::CalendarMonthTextColorRole, true); |
|
1074 |
mModel->itemFromIndex(index)->setData(list); |
|
1075 |
} |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1076 |
} |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1077 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1078 |
// Now set the inactive text color to those which were active before the swipe |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1079 |
if (mDirection == invalid) { |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1080 |
// no need to do anything as other dates will be in inactive dates color |
51 | 1081 |
OstTraceFunctionExit0( CALENMONTHGRID_SETACTIVEDATES_EXIT ); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1082 |
return; |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1083 |
} |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1084 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1085 |
if (mDirection == up) { |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1086 |
// Came here as user did up gesture |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1087 |
// Get the activeDate that was set before the swipe |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1088 |
activeDate = activeDate.addMonths(-1); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1089 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1090 |
// Get the date where active month starts |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1091 |
startOfActiveMonth = QDate(activeDate.year(), activeDate.month(),1); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1092 |
// Number of days frm start of the grid to start of the month |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1093 |
start = firstDateInGrid.daysTo(startOfActiveMonth); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1094 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1095 |
// Get the date where active month ends |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1096 |
QDate endOfActiveMonth = startOfActiveMonth.addDays(activeDate.daysInMonth()); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1097 |
// Number of days frm start of the grid to end of the month |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1098 |
end = firstDateInGrid.daysTo(endOfActiveMonth); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1099 |
} else if (mDirection == down) { |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1100 |
// Came here as user did down gesture |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1101 |
// Get the activeDate that was set before the swipe |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1102 |
activeDate = activeDate.addMonths(1); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1103 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1104 |
// Get the activeDate that was set before the swipe |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1105 |
startOfActiveMonth = QDate(activeDate.year(), activeDate.month(),1); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1106 |
// Number of days frm start of the grid to start of the month |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1107 |
start = firstDateInGrid.daysTo(startOfActiveMonth); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1108 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1109 |
// Get the date where active month ends |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1110 |
QDate endOfActiveMonth = startOfActiveMonth.addDays(activeDate.daysInMonth()); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1111 |
// Number of days frm start of the grid to end of the month |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1112 |
end = firstDateInGrid.daysTo(endOfActiveMonth); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1113 |
} |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1114 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1115 |
// Set the inactive text color |
63 | 1116 |
if (start >= 0 && end < monthDataList.count()) { |
1117 |
for (int i = start; i < end; i++) { |
|
1118 |
QModelIndex index = mModel->index(i,0); |
|
1119 |
QVariant itemData = index.data(Qt::UserRole + 1); |
|
1120 |
QVariantList list = itemData.toList(); |
|
1121 |
list.replace(CalendarNamespace::CalendarMonthTextColorRole, false); |
|
1122 |
mModel->itemFromIndex(index)->setData(list); |
|
1123 |
} |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1124 |
} |
51 | 1125 |
|
1126 |
OstTraceFunctionExit0( DUP1_CALENMONTHGRID_SETACTIVEDATES_EXIT ); |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1127 |
} |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1128 |
|
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1129 |
/*! |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1130 |
To get current foucsed index of monthGrid |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1131 |
*/ |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1132 |
int CalenMonthGrid::getCurrentIndex() |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1133 |
{ |
51 | 1134 |
OstTraceFunctionEntry0( CALENMONTHGRID_GETCURRENTINDEX_ENTRY ); |
1135 |
||
1136 |
OstTraceFunctionExit0( CALENMONTHGRID_GETCURRENTINDEX_EXIT ); |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1137 |
return mCurrentRow; |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1138 |
} |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1139 |
|
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1140 |
/*! |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1141 |
To set the focus to Index |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1142 |
*/ |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1143 |
void CalenMonthGrid::setCurrentIdex(int index) |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1144 |
{ |
51 | 1145 |
OstTraceFunctionEntry0( CALENMONTHGRID_SETCURRENTIDEX_ENTRY ); |
1146 |
||
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1147 |
itemActivated(mModel->index(index, 0)); |
51 | 1148 |
|
1149 |
OstTraceFunctionExit0( CALENMONTHGRID_SETCURRENTIDEX_EXIT ); |
|
18
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1150 |
} |
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1151 |
|
c198609911f9
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1152 |
/*! |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1153 |
Paint function to draw grid lines |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1154 |
*/ |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1155 |
void CalenMonthGrid::paint(QPainter* painter, |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1156 |
const QStyleOptionGraphicsItem* option, |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1157 |
QWidget* widget) |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1158 |
{ |
51 | 1159 |
OstTraceFunctionEntry0( CALENMONTHGRID_PAINT_ENTRY ); |
1160 |
||
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1161 |
Q_UNUSED(option); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1162 |
Q_UNUSED(widget); |
45 | 1163 |
painter->setRenderHint(QPainter::NonCosmeticDefaultPen); |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1164 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1165 |
// Set the required attributes to the pen |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1166 |
QPen pen; |
45 | 1167 |
HbDeviceProfile deviceProf; |
1168 |
qreal unitValue = deviceProf.unitValue(); |
|
1169 |
qreal widthInPixels = GRIDLINE_WIDTH * unitValue; |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1170 |
pen.setStyle(Qt::SolidLine); |
45 | 1171 |
pen.setWidth(widthInPixels); |
63 | 1172 |
pen.setBrush(mGridLineColor); |
1173 |
||
51 | 1174 |
// Store the old pen |
1175 |
QPen oldPen = painter->pen(); |
|
1176 |
||
45 | 1177 |
// Set the new pen to the painter |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1178 |
painter->setPen(pen); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1179 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1180 |
// Get the sizes of content widget |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1181 |
qreal contentHeight = mContentWidget->size().height(); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1182 |
qreal contentWidth = mContentWidget->size().width(); |
45 | 1183 |
qreal rowWidth = 0.0; |
1184 |
int numOfRows = 0; |
|
1185 |
QPointF startPoint = mContentWidget->pos(); |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1186 |
|
45 | 1187 |
// NOTE!!!: There is a filcker when we blindly draw equally spaced lines |
1188 |
// on complete content widget when scrolling is finished. This happens only |
|
1189 |
// when content widget size is changed due to the change in total number |
|
1190 |
// of rows when we append or prepend rows. Hence, to avoid this, we draw |
|
1191 |
// lines on complete content widget only when it is scrolling. |
|
1192 |
// That means, as soon as scrolling is finished, we will end up drawing |
|
1193 |
// only 6 lines that are visible to the user. |
|
1194 |
if (mDirection == invalid) { |
|
1195 |
// Start point is left most point on the screen |
|
1196 |
startPoint = QPointF(0,0); |
|
1197 |
rowWidth = size().height() / KNumOfVisibleRows; |
|
1198 |
numOfRows = KNumOfVisibleRows; |
|
1199 |
} else { |
|
1200 |
// Get the num of rows |
|
1201 |
numOfRows = mModel->rowCount() / KCalenDaysInWeek; |
|
1202 |
// Draw horizontal lines |
|
1203 |
rowWidth = contentHeight / numOfRows; |
|
1204 |
} |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1205 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1206 |
QPointF endPoint(startPoint.x() + contentWidth, |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1207 |
startPoint.y()); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1208 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1209 |
// Create the list of points for which lines have to be drawn |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1210 |
// List should have even number of points so that it draws all the lines |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1211 |
// Painter draws the line for first two points in the list and then second |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1212 |
// line for next two points in the list like that. Hence, list should |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1213 |
// contain even number of points |
57 | 1214 |
// Dont draw the first horizontal line as we have thick line seperator |
1215 |
// coming between day names and the month grid |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1216 |
QVector<QPointF> pointList; |
57 | 1217 |
for (int i = 1; i < numOfRows; i++) { |
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1218 |
pointList.append(QPointF(startPoint.x(), |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1219 |
startPoint.y() + (i * rowWidth))); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1220 |
pointList.append(QPointF(endPoint.x(), endPoint.y() + (i * rowWidth))); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1221 |
} |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1222 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1223 |
// Draw vertical lines |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1224 |
qreal colWidth = contentWidth / KCalenDaysInWeek; |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1225 |
endPoint = QPointF(startPoint.x(), |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1226 |
startPoint.y() + contentHeight); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1227 |
for (int i = 1; i < KCalenDaysInWeek; i++) { |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1228 |
pointList.append(QPointF(startPoint.x() + (i * colWidth), |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1229 |
startPoint.y())); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1230 |
pointList.append(QPointF(endPoint.x() + (i * colWidth), endPoint.y())); |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1231 |
} |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1232 |
|
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1233 |
// Draw the lines for the points in the vector list |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1234 |
painter->drawLines(pointList); |
51 | 1235 |
|
45 | 1236 |
// Set the old pen back |
1237 |
painter->setPen(oldPen); |
|
51 | 1238 |
|
1239 |
OstTraceFunctionExit0( CALENMONTHGRID_PAINT_EXIT ); |
|
23
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1240 |
} |
fd30d51f876b
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1241 |
|
63 | 1242 |
/*! |
75 | 1243 |
Function to check if scrolling is allowed. This function will make an effect |
1244 |
only when you are going to month that is not supported by us. |
|
1245 |
*/ |
|
1246 |
bool CalenMonthGrid::checkIfWeCanScroll(scrollDirection direction) |
|
1247 |
{ |
|
1248 |
OstTraceFunctionEntry0( CALENMONTHGRID_CHECKIFWECANSCROLL_ENTRY ); |
|
1249 |
||
1250 |
bool value = true; |
|
1251 |
||
1252 |
// Get the current active Date |
|
1253 |
QDateTime activeDate = mView->getActiveDay(); |
|
1254 |
// if direction is up, then check if the next month is |
|
1255 |
// not January, 2101 |
|
1256 |
if (direction == up) { |
|
1257 |
QDateTime nextMonth = activeDate.addMonths(1); |
|
1258 |
value = CalenDateUtils::isValidDay(nextMonth); |
|
1259 |
} else if (direction == down) { // if direction is up, then check if the next month is |
|
1260 |
// not December, 1899 |
|
1261 |
QDateTime prevMonth = activeDate.addMonths(-1); |
|
1262 |
value = CalenDateUtils::isValidDay(prevMonth); |
|
1263 |
} |
|
1264 |
||
1265 |
OstTraceFunctionExit0( CALENMONTHGRID_CHECKIFWECANSCROLL_EXIT ); |
|
1266 |
||
1267 |
return value; |
|
1268 |
} |
|
1269 |
||
1270 |
/*! |
|
63 | 1271 |
Slot to handle the change in theme |
1272 |
*/ |
|
1273 |
void CalenMonthGrid::handleThemeChange() |
|
1274 |
{ |
|
1275 |
OstTraceFunctionEntry0(CALENMONTHGRID_HANDLETHEMECHANGE_ENTRY); |
|
1276 |
||
1277 |
mGridLineColor = HbColorScheme::color("qtc_cal_grid_line"); |
|
1278 |
||
1279 |
OstTraceFunctionExit0(CALENMONTHGRID_HANDLETHEMECHANGE_EXIT); |
|
1280 |
} |
|
1281 |
||
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1282 |
// End of File |