|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Day view control of calendar |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CALENDAYCONTAINER_H |
|
19 #define CALENDAYCONTAINER_H |
|
20 |
|
21 //System includes |
|
22 #include <QDateTime> |
|
23 |
|
24 #include "../../../../../mw/hb/src/hbwidgets/itemviews/hbabstractitemcontainer_p.h" |
|
25 |
|
26 //User includes |
|
27 |
|
28 //Forward declarations |
|
29 class CalenDayInfo; |
|
30 class TouchEventAbsorber; |
|
31 |
|
32 class CalenDayContainer : public HbAbstractItemContainer |
|
33 { |
|
34 Q_OBJECT |
|
35 |
|
36 public: |
|
37 |
|
38 /** |
|
39 * Constructor. |
|
40 */ |
|
41 CalenDayContainer(QGraphicsItem *parent = 0); |
|
42 |
|
43 /** |
|
44 * Destructor. |
|
45 */ |
|
46 ~CalenDayContainer(); |
|
47 |
|
48 /** |
|
49 * |
|
50 */ |
|
51 void itemAdded (int index, HbAbstractViewItem *item, bool animate); |
|
52 |
|
53 /** |
|
54 * |
|
55 */ |
|
56 void itemRemoved (HbAbstractViewItem *item, bool animate); |
|
57 |
|
58 /** |
|
59 * |
|
60 */ |
|
61 void reset(); |
|
62 |
|
63 /** |
|
64 * |
|
65 */ |
|
66 void viewResized (const QSizeF &size); |
|
67 |
|
68 /** |
|
69 * Sets day's info structer to the container. |
|
70 * |
|
71 * @param dayInfo Day info. |
|
72 */ |
|
73 void setDayInfo( CalenDayInfo* dayInfo ); |
|
74 |
|
75 public slots: |
|
76 |
|
77 /** |
|
78 * Slot handles layout switch. |
|
79 * @param orientation Current device orientation |
|
80 */ |
|
81 void orientationChanged(Qt::Orientation orientation); |
|
82 |
|
83 protected: |
|
84 |
|
85 /** |
|
86 * |
|
87 */ |
|
88 HbAbstractViewItem * createDefaultPrototype() const; |
|
89 |
|
90 /** |
|
91 * |
|
92 */ |
|
93 void setItemModelIndex(HbAbstractViewItem *item, const QModelIndex &index); |
|
94 |
|
95 /** |
|
96 * Updates geometry of a timed event. |
|
97 */ |
|
98 void updateTimedEventGeometry(HbAbstractViewItem *item, |
|
99 const QModelIndex &index); |
|
100 |
|
101 /** |
|
102 * Updates geometry of a all-day events |
|
103 */ |
|
104 void updateAllDayEventGeometry(HbAbstractViewItem *item, |
|
105 const QModelIndex &index); |
|
106 |
|
107 /** |
|
108 * Structure with event layout values. |
|
109 * |
|
110 * eventAreaX X value for event area start. |
|
111 * eventAreaWidth The width of event area. |
|
112 * eventMargin Margins between the multiple events. |
|
113 * slotHeight Half hour slot's height. |
|
114 * unitInPixels no. of pixels in 1un |
|
115 */ |
|
116 |
|
117 struct LayoutValues { |
|
118 LayoutValues() |
|
119 :eventAreaX(0), |
|
120 eventAreaWidth(0), |
|
121 eventMargin(0), |
|
122 slotHeight(0), |
|
123 unitInPixels(0), |
|
124 maxColumns(0) |
|
125 {} |
|
126 |
|
127 qreal eventAreaX; |
|
128 qreal eventAreaWidth; |
|
129 qreal eventMargin; |
|
130 qreal slotHeight; |
|
131 qreal unitInPixels; |
|
132 int maxColumns; |
|
133 }; |
|
134 |
|
135 /** |
|
136 * Gets event layout values. |
|
137 * |
|
138 * @param layoutValues structure to be filled with layout data |
|
139 */ |
|
140 void getTimedEventLayoutValues(LayoutValues& layoutValues); |
|
141 |
|
142 |
|
143 /** |
|
144 * creates absorbers which prevent touching to small items |
|
145 * (according to UI spec items smaller than ... are untouchable) |
|
146 */ |
|
147 void createTouchEventAbsorbers(); |
|
148 |
|
149 /** |
|
150 * |
|
151 */ |
|
152 TouchEventAbsorber* crateAbsorberBetweenSlots(int startSlot, int endSlot); |
|
153 |
|
154 private: |
|
155 |
|
156 bool mGeometryUpdated; |
|
157 |
|
158 QDateTime mDateTime; |
|
159 |
|
160 /** |
|
161 * Day event info. |
|
162 * Not own. |
|
163 */ |
|
164 CalenDayInfo* mInfo; |
|
165 |
|
166 LayoutValues mLayoutValues; |
|
167 QList<TouchEventAbsorber*> mAbsorbers; |
|
168 }; |
|
169 |
|
170 |
|
171 |
|
172 class TouchEventAbsorber : public HbWidget |
|
173 { |
|
174 Q_OBJECT |
|
175 public: |
|
176 TouchEventAbsorber(QGraphicsItem *parent=0); |
|
177 ~TouchEventAbsorber(); |
|
178 |
|
179 protected: |
|
180 void gestureEvent(QGestureEvent *event); |
|
181 |
|
182 #ifdef _DEBUG |
|
183 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, |
|
184 QWidget *widget); |
|
185 #endif |
|
186 |
|
187 }; |
|
188 |
|
189 #endif // CALENDAYCONTAINER_H |
|
190 |
|
191 // End of File |