|
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: CalenAgendaViewWidget class definition. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CALENAGENDAVIEWWIDGET_H |
|
19 #define CALENAGENDAVIEWWIDGET_H |
|
20 |
|
21 // System includes |
|
22 #include <QGraphicsLinearLayout> |
|
23 #include <QDateTime> |
|
24 #include <QPointer> |
|
25 #include <hbwidget.h> |
|
26 |
|
27 // User includes |
|
28 |
|
29 // Forward declarations |
|
30 class QStandardItemModel; |
|
31 class QGraphicsSceneMouseEvent; // TODO: Remove this after gestures are supported |
|
32 class HbAbstractViewItem; |
|
33 class HbGroupBox; |
|
34 class HbListView; |
|
35 class QPluginLoader; |
|
36 class HbLabel; |
|
37 class HbAction; |
|
38 class HbDateTimePicker; |
|
39 class XQSettingsManager; |
|
40 class MCalenServices; |
|
41 class CalenAgendaView; |
|
42 class AgendaEntry; |
|
43 class CalenDocLoader; |
|
44 class CalenEventListViewItem; |
|
45 class NotesEditor; |
|
46 |
|
47 /** |
|
48 * @class CalenAgendaViewWidget |
|
49 * @brief The content widget for the agenda view. |
|
50 * It is responsible for showing all the events &/ to-do's |
|
51 * (if any) for a particular day selected by the user |
|
52 */ |
|
53 class CalenAgendaViewWidget : public HbWidget |
|
54 { |
|
55 Q_OBJECT |
|
56 |
|
57 public: |
|
58 |
|
59 /** |
|
60 * @brief Constructor |
|
61 * @param services The reference to the MCalenServices object |
|
62 * @param docLoader The document loader object |
|
63 */ |
|
64 IMPORT_C CalenAgendaViewWidget(MCalenServices &services, |
|
65 CalenDocLoader *docLoader); |
|
66 |
|
67 /** |
|
68 * @brief Default C++ destructor |
|
69 */ |
|
70 IMPORT_C ~CalenAgendaViewWidget(); |
|
71 |
|
72 /** |
|
73 * @brief Initializes the widget to show all the events/to-do's |
|
74 * for the selected day |
|
75 * @param view Pointer to the view to which this is the content |
|
76 */ |
|
77 void setupWidget(CalenAgendaView *view); |
|
78 |
|
79 /** |
|
80 * @brief Prepares the widget to be shown. |
|
81 * Initializes the widget with the day's events and other details |
|
82 */ |
|
83 void showWidget(); |
|
84 |
|
85 /** |
|
86 * @brief Called from the view whenever the orientation of the |
|
87 * device changes |
|
88 */ |
|
89 void orientationChanged(Qt::Orientation); |
|
90 |
|
91 /** |
|
92 * @brief Callback function to handle system locale change |
|
93 */ |
|
94 void handleLocaleChange(); |
|
95 |
|
96 /** |
|
97 * @brief clears the list model from the view |
|
98 */ |
|
99 void clearListModel(); |
|
100 |
|
101 /** |
|
102 * @brief Opens the editor to create a new entry |
|
103 */ |
|
104 void createNewEvent(); |
|
105 |
|
106 /** |
|
107 * @brief check if property has to set |
|
108 */ |
|
109 bool hasAllDayIcon(); |
|
110 |
|
111 /** |
|
112 * @brief check if all day icon is present |
|
113 */ |
|
114 void checkEntryIcons(); |
|
115 |
|
116 /** |
|
117 * @brief return true if all day icon is present |
|
118 */ |
|
119 bool isAllDayIcon(); |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 private: |
|
126 |
|
127 /** |
|
128 * @brief Sets the context based on the item selected by the user |
|
129 * @param entry The entry using which the context is deduced |
|
130 */ |
|
131 void setContextFromHighlight(AgendaEntry entry); |
|
132 |
|
133 /** |
|
134 * @brief Initializes the child widgets of this widget |
|
135 */ |
|
136 void initChildWidgets(); |
|
137 |
|
138 /** |
|
139 * @brief Populates the list with the events for the current day. |
|
140 * Does nothing if the day has no events. To be called whenever |
|
141 * the view has to be refreshed |
|
142 */ |
|
143 void populateListWidget(); |
|
144 |
|
145 /** |
|
146 * @brief Gets the instance list for day |
|
147 */ |
|
148 void getInstanceList(); |
|
149 |
|
150 /** |
|
151 * @brief Sets the heading text to show the date for which this |
|
152 * widget is being shown |
|
153 */ |
|
154 void setHeadingText(); |
|
155 |
|
156 /** |
|
157 * @brief Creates and adds an item to the list at position index |
|
158 * @param index The position in the list when the item is added |
|
159 * @param entry The entry whose details must be shown in the item |
|
160 */ |
|
161 void createListItem(int index, AgendaEntry entry); |
|
162 |
|
163 /** |
|
164 * @brief Creates and add a list item for the event |
|
165 * @param index The position in the list when the item is added |
|
166 * @param entry The entry whose details must be shown in the item |
|
167 */ |
|
168 void addTimedEventToList(int index, AgendaEntry entry); |
|
169 |
|
170 /** |
|
171 * @brief Creates and add a list item for the event which is non timed |
|
172 * @param index The position in the list when the item is added |
|
173 * @param entry The entry whose details must be shown in the item |
|
174 */ |
|
175 void addNonTimedEventToList(int index, AgendaEntry entry); |
|
176 |
|
177 /** |
|
178 * @brief Sets strecthing to list items showing non-timed events |
|
179 */ |
|
180 void handleListItemStretching(Qt::Orientation orientation); |
|
181 |
|
182 /** |
|
183 * @brief Returns the index in the list to which scrolling must |
|
184 * happen. For ex: After creating a new event, the list must scroll |
|
185 * to the newly created event |
|
186 */ |
|
187 int getIndexToScrollTo(); |
|
188 |
|
189 /** |
|
190 * @brief To Show and hide regional plugin label depends upon settings |
|
191 */ |
|
192 |
|
193 void showHideRegionalInformation(); |
|
194 |
|
195 |
|
196 private slots: |
|
197 |
|
198 /** |
|
199 * @brief Opens the entry at position index in the list for |
|
200 * editing in the editor. Does nothing if the index is invalid |
|
201 */ |
|
202 void editEntry(); |
|
203 |
|
204 /** |
|
205 * @brief Opens the entry at position index in the list for |
|
206 * viewing in the viewer. Does nothing if the index is invalid |
|
207 */ |
|
208 void viewEntry(); |
|
209 |
|
210 /** |
|
211 * @brief Deletes the entry at position index in the list. |
|
212 * Does nothing if the list is empty |
|
213 */ |
|
214 void deleteEntry(); |
|
215 |
|
216 /** |
|
217 * @brief Marks a to-do as done |
|
218 */ |
|
219 void markAsDone(); |
|
220 |
|
221 /** |
|
222 * @brief Handles long press on a particular item. Presents a |
|
223 * context menu with various operations that the user can |
|
224 * perform |
|
225 * @param ite, The index item which is being long pressed |
|
226 * @param coords The (x, y) co-ordinates where the long tap has |
|
227 * occured |
|
228 */ |
|
229 void itemLongPressed(HbAbstractViewItem *item, const QPointF &coords); |
|
230 |
|
231 /** |
|
232 * @brief Handles user selection on a particular item of a |
|
233 * particular event in the list. Default action is to view it |
|
234 * @param index Index of the item which was selected |
|
235 */ |
|
236 void itemActivated(const QModelIndex &index); |
|
237 |
|
238 /** |
|
239 * @brief Called whenever a editing a to-do is completed |
|
240 * @param status Inidcates if the editing was successful or not |
|
241 */ |
|
242 void noteEditingCompleted(bool status); |
|
243 |
|
244 /** |
|
245 * @brief Callback function for navigating to today's agenda |
|
246 * This option must be available only if the view is showing |
|
247 * events for some day other than the current day |
|
248 */ |
|
249 void goToToday(); |
|
250 |
|
251 /** |
|
252 * @brief This slot connected to aboutToClose()signal of contextmenu |
|
253 * To reset the flag of mLongTapEventFlag |
|
254 */ |
|
255 void contextMenuClosed(); |
|
256 |
|
257 /** |
|
258 * @brief Called when contextMenu item is triggered |
|
259 */ |
|
260 void contextManuTriggered(HbAction *action); |
|
261 |
|
262 private: |
|
263 /** |
|
264 * @var mDate |
|
265 * @brief Stores the date for which this widget is being shown |
|
266 */ |
|
267 QDateTime mDate; |
|
268 |
|
269 /** |
|
270 * @var mInstanceArray |
|
271 * @brief Holds the list of instances for the day |
|
272 */ |
|
273 QList<AgendaEntry> mInstanceArray; |
|
274 |
|
275 /** |
|
276 * @var mHeadingLabel |
|
277 * @brief The heading widget which shows the date |
|
278 */ |
|
279 HbGroupBox *mHeadingLabel; |
|
280 |
|
281 /** |
|
282 * @var mEventsList |
|
283 * @brief The list view which shows the list of events |
|
284 */ |
|
285 HbListView *mEventsList; |
|
286 |
|
287 /** |
|
288 * @var mServices |
|
289 * @brief The reference to the MCalenServices object |
|
290 */ |
|
291 MCalenServices &mServices; |
|
292 |
|
293 /** |
|
294 * @var mView |
|
295 * @brief The pointer to the view |
|
296 */ |
|
297 CalenAgendaView *mView; |
|
298 |
|
299 /** |
|
300 * @var mDocLoader |
|
301 * @brief The pointer to the document loader which has |
|
302 * loaded this widget |
|
303 */ |
|
304 CalenDocLoader *mDocLoader; |
|
305 |
|
306 /** |
|
307 * @var mListViewPrototype |
|
308 * @brief Acts as the item prototype for list view. |
|
309 * Allows providing own layout for list items |
|
310 */ |
|
311 CalenEventListViewItem *mListViewPrototype; |
|
312 |
|
313 /** |
|
314 * @var mEmptyListLabel |
|
315 * @brief The pointer to the empty view label |
|
316 */ |
|
317 HbLabel *mEmptyListLabel; |
|
318 |
|
319 /** |
|
320 * @var mListModel |
|
321 * @brief The event list model |
|
322 */ |
|
323 QStandardItemModel *mListModel; |
|
324 |
|
325 /** |
|
326 * @var mSelectedIndex |
|
327 * @brief Stores the index of the item being acted upon |
|
328 * Since there is no focus, it becomes necessary to store the |
|
329 * index of the item on which user is performing some action |
|
330 */ |
|
331 int mSelectedIndex; |
|
332 |
|
333 /** |
|
334 * @var NotesEditorPluginLoader |
|
335 * @brief Pointer to the notes editor plugin loader |
|
336 */ |
|
337 QPointer<QPluginLoader> mNotesEditorPluginLoader; |
|
338 |
|
339 /** |
|
340 * @var mDatePicker |
|
341 * @brief The date picker component |
|
342 */ |
|
343 HbDateTimePicker *mDatePicker; |
|
344 |
|
345 /** |
|
346 * @var mRegionalPluginLayout |
|
347 * @brief Regional Plugin layout pointer |
|
348 */ |
|
349 QGraphicsLinearLayout* mRegionalPluginLayout; |
|
350 |
|
351 /** |
|
352 * @var mRegionalInfoGroupBox |
|
353 * @brief Regional Plugin Info groupbox |
|
354 */ |
|
355 HbGroupBox *mRegionalInfoGroupBox; |
|
356 |
|
357 /** |
|
358 * @var mSettingsManager |
|
359 * @brief Setting Manager pointer |
|
360 */ |
|
361 |
|
362 XQSettingsManager *mSettingsManager; |
|
363 |
|
364 /** |
|
365 * @var mLongTapeventFlag |
|
366 * @brief Set flag true if contextmenu is opened |
|
367 */ |
|
368 bool mLongTapEventFlag; |
|
369 |
|
370 /** |
|
371 * @var mNotesPluginLoaded |
|
372 * @brief Holds notes editor plugin load info. |
|
373 */ |
|
374 bool mNotesPluginLoaded; |
|
375 int mIndex; |
|
376 bool mIconCheck; |
|
377 bool mNextEntry; |
|
378 bool mLeftAllDayIcon; |
|
379 |
|
380 }; |
|
381 |
|
382 #endif //CALENAGENDAVIEWWIDGET_H |
|
383 |
|
384 // End of file --Don't remove this. |