|
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 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 |
|
172 |
|
173 private slots: |
|
174 |
|
175 /** |
|
176 * @brief Opens the editor to create a new entry |
|
177 */ |
|
178 void createNewEvent(); |
|
179 |
|
180 /** |
|
181 * @brief Opens the entry at position index in the list for |
|
182 * editing in the editor. Does nothing if the index is invalid |
|
183 */ |
|
184 void editEntry(); |
|
185 |
|
186 /** |
|
187 * @brief Opens the entry at position index in the list for |
|
188 * viewing in the viewer. Does nothing if the index is invalid |
|
189 */ |
|
190 void viewEntry(); |
|
191 |
|
192 /** |
|
193 * @brief Deletes the entry at position index in the list. |
|
194 * Does nothing if the list is empty |
|
195 */ |
|
196 void deleteEntry(); |
|
197 |
|
198 /** |
|
199 * @brief Marks a to-do as done |
|
200 */ |
|
201 void markAsDone(); |
|
202 |
|
203 /** |
|
204 * @brief Handles long press on a particular item. Presents a |
|
205 * context menu with various operations that the user can |
|
206 * perform |
|
207 * @param ite, The index item which is being long pressed |
|
208 * @param coords The (x, y) co-ordinates where the long tap has |
|
209 * occured |
|
210 */ |
|
211 void itemLongPressed(HbAbstractViewItem *item, const QPointF &coords); |
|
212 |
|
213 /** |
|
214 * @brief Handles user selection on a particular item of a |
|
215 * particular event in the list. Default action is to view it |
|
216 * @param index Index of the item which was selected |
|
217 */ |
|
218 void itemActivated(const QModelIndex &index); |
|
219 |
|
220 /** |
|
221 * @brief Called whenever a editing a to-do is completed |
|
222 * @param status Inidcates if the editing was successful or not |
|
223 */ |
|
224 void noteEditingCompleted(bool status); |
|
225 |
|
226 /** |
|
227 * @brief Callback function for navigating to today's agenda |
|
228 * This option must be available only if the view is showing |
|
229 * events for some day other than the current day |
|
230 */ |
|
231 void goToToday(); |
|
232 |
|
233 /** |
|
234 * @brief This slot connected to aboutToClose()signal of contextmenu |
|
235 * To reset the flag of mLongTapEventFlag |
|
236 */ |
|
237 void contextMenuClosed(); |
|
238 |
|
239 /** |
|
240 * @brief Called when contextMenu item is triggered |
|
241 */ |
|
242 void contextManuTriggered(HbAction *action); |
|
243 |
|
244 private: |
|
245 /** |
|
246 * @var mDate |
|
247 * @brief Stores the date for which this widget is being shown |
|
248 */ |
|
249 QDateTime mDate; |
|
250 |
|
251 /** |
|
252 * @var mInstanceArray |
|
253 * @brief Holds the list of instances for the day |
|
254 */ |
|
255 QList<AgendaEntry> mInstanceArray; |
|
256 |
|
257 /** |
|
258 * @var mHeadingLabel |
|
259 * @brief The heading widget which shows the date |
|
260 */ |
|
261 HbGroupBox *mHeadingLabel; |
|
262 |
|
263 /** |
|
264 * @var mEventsList |
|
265 * @brief The list view which shows the list of events |
|
266 */ |
|
267 HbListView *mEventsList; |
|
268 |
|
269 /** |
|
270 * @var mServices |
|
271 * @brief The reference to the MCalenServices object |
|
272 */ |
|
273 MCalenServices &mServices; |
|
274 |
|
275 /** |
|
276 * @var mView |
|
277 * @brief The pointer to the view |
|
278 */ |
|
279 CalenAgendaView *mView; |
|
280 |
|
281 /** |
|
282 * @var mDocLoader |
|
283 * @brief The pointer to the document loader which has |
|
284 * loaded this widget |
|
285 */ |
|
286 CalenDocLoader *mDocLoader; |
|
287 |
|
288 /** |
|
289 * @var mListViewPrototype |
|
290 * @brief Acts as the item prototype for list view. |
|
291 * Allows providing own layout for list items |
|
292 */ |
|
293 CalenEventListViewItem *mListViewPrototype; |
|
294 |
|
295 /** |
|
296 * @var mEmptyListLabel |
|
297 * @brief The pointer to the empty view label |
|
298 */ |
|
299 HbLabel *mEmptyListLabel; |
|
300 |
|
301 /** |
|
302 * @var mListModel |
|
303 * @brief The event list model |
|
304 */ |
|
305 QStandardItemModel *mListModel; |
|
306 |
|
307 /** |
|
308 * @var mSelectedIndex |
|
309 * @brief Stores the index of the item being acted upon |
|
310 * Since there is no focus, it becomes necessary to store the |
|
311 * index of the item on which user is performing some action |
|
312 */ |
|
313 int mSelectedIndex; |
|
314 |
|
315 /** |
|
316 * @var NotesEditorPluginLoader |
|
317 * @brief Pointer to the notes editor plugin loader |
|
318 */ |
|
319 QPointer<QPluginLoader> mNotesEditorPluginLoader; |
|
320 |
|
321 /** |
|
322 * @var mDatePicker |
|
323 * @brief The date picker component |
|
324 */ |
|
325 HbDateTimePicker *mDatePicker; |
|
326 |
|
327 /** |
|
328 * @var mRegionalPluginLayout |
|
329 * @brief Regional Plugin layout pointer |
|
330 */ |
|
331 QGraphicsLinearLayout* mRegionalPluginLayout; |
|
332 |
|
333 /** |
|
334 * @var mRegionalInfoGroupBox |
|
335 * @brief Regional Plugin Info groupbox |
|
336 */ |
|
337 HbGroupBox *mRegionalInfoGroupBox; |
|
338 |
|
339 /** |
|
340 * @var mSettingsManager |
|
341 * @brief Setting Manager pointer |
|
342 */ |
|
343 |
|
344 XQSettingsManager *mSettingsManager; |
|
345 |
|
346 /** |
|
347 * @var mLongTapeventFlag |
|
348 * @brief Set flag true if contextmenu is opened |
|
349 */ |
|
350 bool mLongTapEventFlag; |
|
351 |
|
352 /** |
|
353 * @var mNotesPluginLoaded |
|
354 * @brief Holds notes editor plugin load info. |
|
355 */ |
|
356 bool mNotesPluginLoaded; |
|
357 |
|
358 }; |
|
359 |
|
360 #endif //CALENAGENDAVIEWWIDGET_H |
|
361 |
|
362 // End of file --Don't remove this. |