9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: Day view control of calendar |
14 * Description: Day view container - parent widget for events (CalenDayItem) and |
|
15 * hours area widgets (CalenDayEventsPane) |
|
16 * Responsible for positioning and resizing events widgets. |
15 * |
17 * |
16 */ |
18 */ |
17 |
19 |
18 #ifndef CALENDAYCONTAINER_H |
20 #ifndef CALENDAYCONTAINER_H |
19 #define CALENDAYCONTAINER_H |
21 #define CALENDAYCONTAINER_H |
20 |
22 |
21 //System includes |
23 //System includes |
22 #include <QDateTime> |
24 #include <QDateTime> |
23 |
|
24 #include "../../../../../mw/hb/src/hbwidgets/itemviews/hbabstractitemcontainer_p.h" |
25 #include "../../../../../mw/hb/src/hbwidgets/itemviews/hbabstractitemcontainer_p.h" |
25 |
26 |
26 //User includes |
|
27 |
27 |
28 //Forward declarations |
28 //Forward declarations |
29 class CalenDayInfo; |
29 class CalenDayInfo; |
30 class TouchEventAbsorber; |
30 class TouchEventAbsorber; |
31 |
31 |
32 class CalenDayContainer : public HbAbstractItemContainer |
32 class CalenDayContainer : public HbAbstractItemContainer |
33 { |
33 { |
34 Q_OBJECT |
34 Q_OBJECT |
35 |
35 |
36 public: |
36 public: |
37 |
|
38 /** |
|
39 * Constructor. |
|
40 */ |
|
41 CalenDayContainer(QGraphicsItem *parent = 0); |
37 CalenDayContainer(QGraphicsItem *parent = 0); |
42 |
|
43 /** |
|
44 * Destructor. |
|
45 */ |
|
46 ~CalenDayContainer(); |
38 ~CalenDayContainer(); |
47 |
39 |
48 /** |
|
49 * |
|
50 */ |
|
51 void itemAdded (int index, HbAbstractViewItem *item, bool animate); |
40 void itemAdded (int index, HbAbstractViewItem *item, bool animate); |
52 |
|
53 /** |
|
54 * |
|
55 */ |
|
56 void itemRemoved (HbAbstractViewItem *item, bool animate); |
41 void itemRemoved (HbAbstractViewItem *item, bool animate); |
57 |
|
58 /** |
|
59 * |
|
60 */ |
|
61 void reset(); |
42 void reset(); |
62 |
|
63 /** |
|
64 * |
|
65 */ |
|
66 void viewResized (const QSizeF &size); |
43 void viewResized (const QSizeF &size); |
67 |
44 |
68 /** |
|
69 * Sets day's info structer to the container. |
|
70 * |
|
71 * @param dayInfo Day info. |
|
72 */ |
|
73 void setDayInfo( CalenDayInfo* dayInfo ); |
45 void setDayInfo( CalenDayInfo* dayInfo ); |
|
46 |
|
47 void setDate( const QDate &date ); |
|
48 const QDate &date() const; |
74 |
49 |
75 public slots: |
50 public slots: |
76 |
|
77 /** |
|
78 * Slot handles layout switch. |
|
79 * @param orientation Current device orientation |
|
80 */ |
|
81 void orientationChanged(Qt::Orientation orientation); |
51 void orientationChanged(Qt::Orientation orientation); |
82 |
52 |
83 protected: |
53 protected: |
84 |
|
85 /** |
|
86 * |
|
87 */ |
|
88 HbAbstractViewItem * createDefaultPrototype() const; |
54 HbAbstractViewItem * createDefaultPrototype() const; |
89 |
|
90 /** |
|
91 * |
|
92 */ |
|
93 void setItemModelIndex(HbAbstractViewItem *item, const QModelIndex &index); |
55 void setItemModelIndex(HbAbstractViewItem *item, const QModelIndex &index); |
94 |
56 |
95 /** |
|
96 * Updates geometry of a timed event. |
|
97 */ |
|
98 void updateTimedEventGeometry(HbAbstractViewItem *item, |
57 void updateTimedEventGeometry(HbAbstractViewItem *item, |
99 const QModelIndex &index); |
58 const QModelIndex &index); |
100 |
|
101 /** |
|
102 * Updates geometry of a all-day events |
|
103 */ |
|
104 void updateAllDayEventGeometry(HbAbstractViewItem *item, |
59 void updateAllDayEventGeometry(HbAbstractViewItem *item, |
105 const QModelIndex &index); |
60 const QModelIndex &index); |
|
61 |
|
62 /*! |
|
63 \class LayoutValues |
|
64 \brief Structure with event layout values. |
|
65 |
|
66 eventAreaX X value for event area start. |
|
67 eventAreaWidth The width of event area. |
|
68 eventMargin Margins between the multiple events. |
|
69 slotHeight Half hour slot's height. |
|
70 unitInPixels No. of pixels in 1un |
|
71 maxColumns Max. no. of touchable overlapping timed events |
106 |
72 |
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 */ |
73 */ |
116 |
74 class LayoutValues { |
117 struct LayoutValues { |
75 public: |
118 LayoutValues() |
76 LayoutValues() |
119 :eventAreaX(0), |
77 :eventAreaX(0), |
120 eventAreaWidth(0), |
78 eventAreaWidth(0), |
121 eventMargin(0), |
79 eventMargin(0), |
122 slotHeight(0), |
80 slotHeight(0), |
123 unitInPixels(0), |
81 unitInPixels(0), |
124 maxColumns(0) |
82 maxColumns(0) |
125 {} |
83 {} |
126 |
|
127 qreal eventAreaX; |
84 qreal eventAreaX; |
128 qreal eventAreaWidth; |
85 qreal eventAreaWidth; |
129 qreal eventMargin; |
86 qreal eventMargin; |
130 qreal slotHeight; |
87 qreal slotHeight; |
131 qreal unitInPixels; |
88 qreal unitInPixels; |
132 int maxColumns; |
89 int maxColumns; |
133 }; |
90 }; |
134 |
91 |
135 /** |
|
136 * Gets event layout values. |
|
137 * |
|
138 * @param layoutValues structure to be filled with layout data |
|
139 */ |
|
140 void getTimedEventLayoutValues(LayoutValues& layoutValues); |
92 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(); |
93 void createTouchEventAbsorbers(); |
148 |
94 TouchEventAbsorber* crateAbsorberBetweenSlots(int startSlot, int endSlot, bool forAllDayEvents); |
149 /** |
|
150 * |
|
151 */ |
|
152 TouchEventAbsorber* crateAbsorberBetweenSlots(int startSlot, int endSlot); |
|
153 |
95 |
154 private: |
96 private: |
|
97 bool mGeometryUpdated; |
155 |
98 |
156 bool mGeometryUpdated; |
99 CalenDayInfo* mInfo; //!<Day event info. Not owned. |
157 |
100 LayoutValues mLayoutValues; //!<Keeps layout values, see LayoutValues class |
158 QDateTime mDateTime; |
101 QList<TouchEventAbsorber*> mAbsorbers; //!<Keeps needed touch absorbers. |
159 |
102 QDate mDate; //!<Keeps date currently associated with this container. |
160 /** |
|
161 * Day event info. |
|
162 * Not own. |
|
163 */ |
|
164 CalenDayInfo* mInfo; |
|
165 |
|
166 LayoutValues mLayoutValues; |
|
167 QList<TouchEventAbsorber*> mAbsorbers; |
|
168 }; |
103 }; |
169 |
104 |
170 |
105 |
171 |
106 |
|
107 /*! |
|
108 \class TouchEventAbsorber |
|
109 \brief TouchEventAbsorber objects are used to catch touch events. |
|
110 \brief Used when event widgets are to small (see UI spec.) |
|
111 */ |
172 class TouchEventAbsorber : public HbWidget |
112 class TouchEventAbsorber : public HbWidget |
173 { |
113 { |
174 Q_OBJECT |
114 Q_OBJECT |
175 public: |
115 public: |
176 TouchEventAbsorber(QGraphicsItem *parent=0); |
116 TouchEventAbsorber(QGraphicsItem *parent=0); |
177 ~TouchEventAbsorber(); |
117 ~TouchEventAbsorber(); |
178 |
|
179 protected: |
118 protected: |
180 void gestureEvent(QGestureEvent *event); |
119 void gestureEvent(QGestureEvent *event); |
181 |
120 |
182 #ifdef _DEBUG |
121 #ifdef _DEBUG |
183 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, |
122 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, |
184 QWidget *widget); |
123 QWidget *widget); |
185 #endif |
124 #endif |
186 |
|
187 }; |
125 }; |
188 |
126 |
189 #endif // CALENDAYCONTAINER_H |
127 #endif // CALENDAYCONTAINER_H |
190 |
|
191 // End of File |
128 // End of File |