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 <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 CalenDayView; |
|
42 class AgendaEntry; |
|
43 class CalenDocLoader; |
|
44 class CalenEventListViewItem; |
|
45 class NotesEditor; |
|
46 |
|
47 /** |
|
48 * @class CalenDayViewWidget |
|
49 * @brief The content widget for the day/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 CalenDayViewWidget : 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 CalenDayViewWidget(MCalenServices &services, |
|
65 CalenDocLoader *docLoader); |
|
66 |
|
67 /** |
|
68 * @brief Default C++ destructor |
|
69 */ |
|
70 IMPORT_C ~CalenDayViewWidget(); |
|
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(CalenDayView *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 private: |
|
102 |
|
103 /** |
|
104 * @brief Sets the context based on the item selected by the user |
|
105 * @param entry The entry using which the context is deduced |
|
106 */ |
|
107 void setContextFromHighlight(AgendaEntry entry); |
|
108 |
|
109 /** |
|
110 * @brief Initializes the child widgets of this widget |
|
111 */ |
|
112 void initChildWidgets(); |
|
113 |
|
114 /** |
|
115 * @brief Populates the list with the events for the current day. |
|
116 * Does nothing if the day has no events. To be called whenever |
|
117 * the view has to be refreshed |
|
118 */ |
|
119 void populateListWidget(); |
|
120 |
|
121 /** |
|
122 * @brief Gets the instance list for day |
|
123 */ |
|
124 void getInstanceList(); |
|
125 |
|
126 /** |
|
127 * @brief Sets the heading text to show the date for which this |
|
128 * widget is being shown |
|
129 */ |
|
130 void setHeadingText(); |
|
131 |
|
132 /** |
|
133 * @brief Creates and adds an item to the list at position index |
|
134 * @param index The position in the list when the item is added |
|
135 * @param entry The entry whose details must be shown in the item |
|
136 */ |
|
137 void createListItem(int index, AgendaEntry entry); |
|
138 |
|
139 /** |
|
140 * @brief Creates and add a list item for the event |
|
141 * @param index The position in the list when the item is added |
|
142 * @param entry The entry whose details must be shown in the item |
|
143 */ |
|
144 void addTimedEventToList(int index, AgendaEntry entry); |
|
145 |
|
146 /** |
|
147 * @brief Creates and add a list item for the event which is non timed |
|
148 * @param index The position in the list when the item is added |
|
149 * @param entry The entry whose details must be shown in the item |
|
150 */ |
|
151 void addNonTimedEventToList(int index, AgendaEntry entry); |
|
152 |
|
153 /** |
|
154 * @brief Sets strecthing to list items showing non-timed events |
|
155 */ |
|
156 void handleListItemStretching(Qt::Orientation orientation); |
|
157 |
|
158 /** |
|
159 * @brief Returns the index in the list to which scrolling must |
|
160 * happen. For ex: After creating a new event, the list must scroll |
|
161 * to the newly created event |
|
162 */ |
|
163 int getIndexToScrollTo(); |
|
164 |
|
165 /** |
|
166 * @brief To Show and hide regional plugin label depends upon settings |
|
167 */ |
|
168 |
|
169 void showHideRegionalInformation(); |
|
170 |
|
171 private slots: |
|
172 |
|
173 /** |
|
174 * @brief Opens the editor to create a new entry |
|
175 */ |
|
176 void createNewEvent(); |
|
177 |
|
178 /** |
|
179 * @brief Opens the entry at position index in the list for |
|
180 * editing in the editor. Does nothing if the index is invalid |
|
181 */ |
|
182 void editEntry(); |
|
183 |
|
184 /** |
|
185 * @brief Opens the entry at position index in the list for |
|
186 * viewing in the viewer. Does nothing if the index is invalid |
|
187 */ |
|
188 void viewEntry(); |
|
189 |
|
190 /** |
|
191 * @brief Deletes the entry at position index in the list. |
|
192 * Does nothing if the list is empty |
|
193 */ |
|
194 void deleteEntry(); |
|
195 |
|
196 /** |
|
197 * @brief Marks a to-do as done |
|
198 */ |
|
199 void markAsDone(); |
|
200 |
|
201 /** |
|
202 * @brief Handles long press on a particular item. Presents a |
|
203 * context menu with various operations that the user can |
|
204 * perform |
|
205 * @param ite, The index item which is being long pressed |
|
206 * @param coords The (x, y) co-ordinates where the long tap has |
|
207 * occured |
|
208 */ |
|
209 void itemLongPressed(HbAbstractViewItem *item, const QPointF &coords); |
|
210 |
|
211 /** |
|
212 * @brief Handles user selection on a particular item of a |
|
213 * particular event in the list. Default action is to view it |
|
214 * @param index Index of the item which was selected |
|
215 */ |
|
216 void itemActivated(const QModelIndex &index); |
|
217 |
|
218 /** |
|
219 * @brief Called whenever a editing a to-do is completed |
|
220 * @param status Inidcates if the editing was successful or not |
|
221 */ |
|
222 void noteEditingCompleted(bool status); |
|
223 |
|
224 /** |
|
225 * @brief Callback function for navigating to today's agenda |
|
226 * This option must be available only if the view is showing |
|
227 * events for some day other than the current day |
|
228 */ |
|
229 void goToToday(); |
|
230 |
|
231 /** |
|
232 * @brief This slot connected to aboutToClose()signal of contextmenu |
|
233 * To reset the flag of mLongTapEventFlag |
|
234 */ |
|
235 void contextMenuClosed(); |
|
236 |
|
237 /** |
|
238 * @brief Called when contextMenu item is triggered |
|
239 */ |
|
240 void contextManuTriggered(HbAction *action); |
|
241 |
|
242 private: |
|
243 /** |
|
244 * @var mDate |
|
245 * @brief Stores the date for which this widget is being shown |
|
246 */ |
|
247 QDateTime mDate; |
|
248 |
|
249 /** |
|
250 * @var mInstanceArray |
|
251 * @brief Holds the list of instances for the day |
|
252 */ |
|
253 QList<AgendaEntry> mInstanceArray; |
|
254 |
|
255 /** |
|
256 * @var mHeadingLabel |
|
257 * @brief The heading widget which shows the date |
|
258 */ |
|
259 HbGroupBox *mHeadingLabel; |
|
260 |
|
261 /** |
|
262 * @var mEventsList |
|
263 * @brief The list view which shows the list of events |
|
264 */ |
|
265 HbListView *mEventsList; |
|
266 |
|
267 /** |
|
268 * @var mServices |
|
269 * @brief The reference to the MCalenServices object |
|
270 */ |
|
271 MCalenServices &mServices; |
|
272 |
|
273 /** |
|
274 * @var mView |
|
275 * @brief The pointer to the view |
|
276 */ |
|
277 CalenDayView *mView; |
|
278 |
|
279 /** |
|
280 * @var mDocLoader |
|
281 * @brief The pointer to the document loader which has |
|
282 * loaded this widget |
|
283 */ |
|
284 CalenDocLoader *mDocLoader; |
|
285 |
|
286 /** |
|
287 * @var mListViewPrototype |
|
288 * @brief Acts as the item prototype for list view. |
|
289 * Allows providing own layout for list items |
|
290 */ |
|
291 CalenEventListViewItem *mListViewPrototype; |
|
292 |
|
293 /** |
|
294 * @var mEmptyListLabel |
|
295 * @brief The pointer to the empty view label |
|
296 */ |
|
297 HbLabel *mEmptyListLabel; |
|
298 |
|
299 /** |
|
300 * @var mListModel |
|
301 * @brief The event list model |
|
302 */ |
|
303 QStandardItemModel *mListModel; |
|
304 |
|
305 /** |
|
306 * @var mSelectedIndex |
|
307 * @brief Stores the index of the item being acted upon |
|
308 * Since there is no focus, it becomes necessary to store the |
|
309 * index of the item on which user is performing some action |
|
310 */ |
|
311 int mSelectedIndex; |
|
312 |
|
313 /** |
|
314 * @var NotesEditorPluginLoader |
|
315 * @brief Pointer to the notes editor plugin loader |
|
316 */ |
|
317 QPointer<QPluginLoader> mNotesEditorPluginLoader; |
|
318 |
|
319 /** |
|
320 * @var mDatePicker |
|
321 * @brief The date picker component |
|
322 */ |
|
323 HbDateTimePicker *mDatePicker; |
|
324 |
|
325 /** |
|
326 * @var mRegionalPluginLayout |
|
327 * @brief Regional Plugin layout pointer |
|
328 */ |
|
329 QGraphicsLinearLayout* mRegionalPluginLayout; |
|
330 |
|
331 /** |
|
332 * @var mRegionalInfoGroupBox |
|
333 * @brief Regional Plugin Info groupbox |
|
334 */ |
|
335 HbGroupBox *mRegionalInfoGroupBox; |
|
336 |
|
337 /** |
|
338 * @var mSettingsManager |
|
339 * @brief Setting Manager pointer |
|
340 */ |
|
341 |
|
342 XQSettingsManager *mSettingsManager; |
|
343 |
|
344 /** |
|
345 * @var mLongTapeventFlag |
|
346 * @brief Set flag true if contextmenu is opened |
|
347 */ |
|
348 bool mLongTapEventFlag; |
|
349 |
|
350 /** |
|
351 * @var mNotesPluginLoaded |
|
352 * @brief Holds notes editor plugin load info. |
|
353 */ |
|
354 bool mNotesPluginLoaded; |
|
355 |
|
356 }; |
|
357 |
|
358 #endif //CALENDAYVIEWWIDGET_H |
|
359 |
|
360 // End of file --Don't remove this. |
|