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