|
1 /* |
|
2 * Copyright (c) 2009 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: CalenDayViewWidget class definition. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CALENDAYVIEWWIDGET_H |
|
19 #define CALENDAYVIEWWIDGET_H |
|
20 |
|
21 // System includes |
|
22 #include <QDateTime> |
|
23 #include <hbwidget.h> |
|
24 |
|
25 // User includes |
|
26 |
|
27 // Forward declarations |
|
28 class QStandardItemModel; |
|
29 class QGraphicsSceneMouseEvent; // TODO: Remove this after gestures are supported |
|
30 class HbAbstractViewItem; |
|
31 class HbGroupBox; |
|
32 class HbListView; |
|
33 class HbLabel; |
|
34 class HbDateTimePicker; |
|
35 class MCalenServices; |
|
36 class CalenDayView; |
|
37 class AgendaEntry; |
|
38 class CalenDocLoader; |
|
39 class CalenEventListViewItem; |
|
40 class NotesEditor; |
|
41 |
|
42 /** |
|
43 * @class CalenDayViewWidget |
|
44 * @brief The content widget for the day/agenda view. |
|
45 * It is responsible for showing all the events &/ to-do's |
|
46 * (if any) for a particular day selected by the user |
|
47 */ |
|
48 class CalenDayViewWidget : public HbWidget |
|
49 { |
|
50 Q_OBJECT |
|
51 |
|
52 public: |
|
53 |
|
54 /** |
|
55 * @brief Constructor |
|
56 * @param services The reference to the MCalenServices object |
|
57 * @param docLoader The document loader object |
|
58 */ |
|
59 Q_DECL_EXPORT CalenDayViewWidget(MCalenServices &services, |
|
60 CalenDocLoader *docLoader); |
|
61 |
|
62 /** |
|
63 * @brief Default C++ destructor |
|
64 */ |
|
65 Q_DECL_EXPORT ~CalenDayViewWidget(); |
|
66 |
|
67 /** |
|
68 * @brief Initializes the widget to show all the events/to-do's |
|
69 * for the selected day |
|
70 * @param view Pointer to the view to which this is the content |
|
71 */ |
|
72 void setupWidget(CalenDayView *view); |
|
73 |
|
74 /** |
|
75 * @brief Prepares the widget to be shown. |
|
76 * Initializes the widget with the day's events and other details |
|
77 */ |
|
78 void showWidget(); |
|
79 |
|
80 /** |
|
81 * @brief Called from the view whenever the orientation of the |
|
82 * device changes |
|
83 */ |
|
84 void orientationChanged(Qt::Orientation); |
|
85 |
|
86 /** |
|
87 * @brief Callback function to handle system locale change |
|
88 */ |
|
89 void handleLocaleChange(); |
|
90 |
|
91 private: |
|
92 |
|
93 /** |
|
94 * @brief Sets the context based on the item selected by the user |
|
95 * @param entry The entry using which the context is deduced |
|
96 */ |
|
97 void setContextFromHighlight(AgendaEntry entry); |
|
98 |
|
99 /** |
|
100 * @brief Initializes the child widgets of this widget |
|
101 */ |
|
102 void initChildWidgets(); |
|
103 |
|
104 /** |
|
105 * @brief Populates the list with the events for the current day. |
|
106 * Does nothing if the day has no events. To be called whenever |
|
107 * the view has to be refreshed |
|
108 */ |
|
109 void populateListWidget(); |
|
110 |
|
111 /** |
|
112 * @brief Gets the instance list for day |
|
113 */ |
|
114 void getInstanceList(); |
|
115 |
|
116 /** |
|
117 * @brief Sets the heading text to show the date for which this |
|
118 * widget is being shown |
|
119 */ |
|
120 void setHeadingText(); |
|
121 |
|
122 /** |
|
123 * @brief Creates and adds an item to the list at position index |
|
124 * @param index The position in the list when the item is added |
|
125 * @param entry The entry whose details must be shown in the item |
|
126 */ |
|
127 void createListItem(int index, AgendaEntry entry); |
|
128 |
|
129 /** |
|
130 * @brief Creates and add a list item for the event |
|
131 * @param index The position in the list when the item is added |
|
132 * @param entry The entry whose details must be shown in the item |
|
133 */ |
|
134 void addTimedEventToList(int index, AgendaEntry entry); |
|
135 |
|
136 /** |
|
137 * @brief Creates and add a list item for the event which is non timed |
|
138 * @param index The position in the list when the item is added |
|
139 * @param entry The entry whose details must be shown in the item |
|
140 */ |
|
141 void addNonTimedEventToList(int index, AgendaEntry entry); |
|
142 |
|
143 /** |
|
144 * @brief Sets strecthing to list items showing non-timed events |
|
145 */ |
|
146 void handleListItemStretching(Qt::Orientation orientation); |
|
147 |
|
148 /** |
|
149 * @brief Returns the index in the list to which scrolling must |
|
150 * happen. For ex: After creating a new event, the list must scroll |
|
151 * to the newly created event |
|
152 */ |
|
153 int getIndexToScrollTo(); |
|
154 |
|
155 private slots: |
|
156 |
|
157 /** |
|
158 * @brief Opens the editor to create a new entry |
|
159 */ |
|
160 void createNewEvent(); |
|
161 |
|
162 /** |
|
163 * @brief Opens the entry at position index in the list for |
|
164 * editing in the editor. Does nothing if the index is invalid |
|
165 */ |
|
166 void editEntry(); |
|
167 |
|
168 /** |
|
169 * @brief Opens the entry at position index in the list for |
|
170 * viewing in the viewer. Does nothing if the index is invalid |
|
171 */ |
|
172 void viewEntry(); |
|
173 |
|
174 /** |
|
175 * @brief Deletes the entry at position index in the list. |
|
176 * Does nothing if the list is empty |
|
177 */ |
|
178 void deleteEntry(); |
|
179 |
|
180 /** |
|
181 * @brief Marks a to-do as done |
|
182 */ |
|
183 void markAsDone(); |
|
184 |
|
185 /** |
|
186 * @brief Handles long press on a particular item. Presents a |
|
187 * context menu with various operations that the user can |
|
188 * perform |
|
189 * @param ite, The index item which is being long pressed |
|
190 * @param coords The (x, y) co-ordinates where the long tap has |
|
191 * occured |
|
192 */ |
|
193 void itemLongPressed(HbAbstractViewItem *item, const QPointF &coords); |
|
194 |
|
195 /** |
|
196 * @brief Handles user selection on a particular item of a |
|
197 * particular event in the list. Default action is to view it |
|
198 * @param index Index of the item which was selected |
|
199 */ |
|
200 void itemActivated(const QModelIndex &index); |
|
201 |
|
202 /** |
|
203 * @brief Called whenever a editing a to-do is completed |
|
204 * @param status Inidcates if the editing was successful or not |
|
205 */ |
|
206 void noteEditingCompleted(bool status); |
|
207 |
|
208 /** |
|
209 * @brief Callback function for navigating to today's agenda |
|
210 * This option must be available only if the view is showing |
|
211 * events for some day other than the current day |
|
212 */ |
|
213 void goToToday(); |
|
214 |
|
215 /** |
|
216 * @brief Callback function for deleting multiple entries |
|
217 */ |
|
218 void deleteEntries(); |
|
219 |
|
220 private: |
|
221 /** |
|
222 * @var mDate |
|
223 * @brief Stores the date for which this widget is being shown |
|
224 */ |
|
225 QDateTime mDate; |
|
226 |
|
227 /** |
|
228 * @var mInstanceArray |
|
229 * @brief Holds the list of instances for the day |
|
230 */ |
|
231 QList<AgendaEntry> mInstanceArray; |
|
232 |
|
233 /** |
|
234 * @var mHeadingLabel |
|
235 * @brief The heading widget which shows the date |
|
236 */ |
|
237 HbGroupBox *mHeadingLabel; |
|
238 |
|
239 /** |
|
240 * @var mEventsList |
|
241 * @brief The list view which shows the list of events |
|
242 */ |
|
243 HbListView *mEventsList; |
|
244 |
|
245 /** |
|
246 * @var mServices |
|
247 * @brief The reference to the MCalenServices object |
|
248 */ |
|
249 MCalenServices &mServices; |
|
250 |
|
251 /** |
|
252 * @var mView |
|
253 * @brief The pointer to the view |
|
254 */ |
|
255 CalenDayView *mView; |
|
256 |
|
257 /** |
|
258 * @var mDocLoader |
|
259 * @brief The pointer to the document loader which has |
|
260 * loaded this widget |
|
261 */ |
|
262 CalenDocLoader *mDocLoader; |
|
263 |
|
264 /** |
|
265 * @var mListViewPrototype |
|
266 * @brief Acts as the item prototype for list view. |
|
267 * Allows providing own layout for list items |
|
268 */ |
|
269 CalenEventListViewItem *mListViewPrototype; |
|
270 |
|
271 /** |
|
272 * @var mEmptyListLabel |
|
273 * @brief The pointer to the empty view label |
|
274 */ |
|
275 HbLabel *mEmptyListLabel; |
|
276 |
|
277 /** |
|
278 * @var mListModel |
|
279 * @brief The event list model |
|
280 */ |
|
281 QStandardItemModel *mListModel; |
|
282 |
|
283 /** |
|
284 * @var mSelectedIndex |
|
285 * @brief Stores the index of the item being acted upon |
|
286 * Since there is no focus, it becomes necessary to store the |
|
287 * index of the item on which user is performing some action |
|
288 */ |
|
289 int mSelectedIndex; |
|
290 |
|
291 /** |
|
292 * @var NotesEditor |
|
293 * @brief Pointer to the notes editor |
|
294 */ |
|
295 NotesEditor *mNotesEditor; |
|
296 |
|
297 /** |
|
298 * @var mDatePicker |
|
299 * @brief The date picker component |
|
300 */ |
|
301 HbDateTimePicker *mDatePicker; |
|
302 }; |
|
303 |
|
304 #endif //CALENDAYVIEWWIDGET_H |
|
305 |
|
306 // End of file --Don't remove this. |