|
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 implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <QStandardItemModel> |
|
20 #include <QGraphicsSceneEvent> |
|
21 #include <QDir> |
|
22 #include <QPluginLoader> |
|
23 #include <hbi18ndef.h> |
|
24 #include <hbextendedlocale.h> |
|
25 #include <hbgroupbox.h> |
|
26 #include <hbmenu.h> |
|
27 #include <hbaction.h> |
|
28 #include <hbmainwindow.h> |
|
29 #include <hbstyleloader.h> |
|
30 #include <hbdatetimepicker.h> |
|
31 #include <hbdialog.h> |
|
32 #include <xqsettingsmanager.h> |
|
33 #include <agendautil.h> |
|
34 #include <NotesEditorInterface> |
|
35 |
|
36 // User includes |
|
37 #include "calenagendaviewwidget.h" |
|
38 #include "calencommon.h" |
|
39 #include "calenagendaview.h" |
|
40 #include "calendocloader.h" |
|
41 #include "calenservices.h" |
|
42 #include "calencontext.h" |
|
43 #include "calendateutils.h" |
|
44 #include "calenagendautils.h" |
|
45 #include "CalenUid.h" |
|
46 #include "caleneventlistviewitem.h" |
|
47 #include "calenpluginlabel.h" |
|
48 #include "calendarprivatecrkeys.h" |
|
49 #include "OstTraceDefinitions.h" |
|
50 #ifdef OST_TRACE_COMPILER_IN_USE |
|
51 #include "calenagendaviewwidgetTraces.h" |
|
52 #endif |
|
53 |
|
54 |
|
55 // Constants |
|
56 const QString singleSpace(" "); |
|
57 const QString doubleSpace(" "); |
|
58 const QString space(" "); |
|
59 const QString singleHyphen("-"); |
|
60 const QString customLayout("custom"); |
|
61 const char *stretchLayout("stretchItem"); |
|
62 const QString toDoIcon("qtg_small_todo"); |
|
63 const QString reminderIcon("qtg_mono_alarm"); |
|
64 const QString locationIcon("qtg_mono_location"); |
|
65 const QString repeatIcon("qtg_mono_repeat"); |
|
66 // TODO: Replace with actual image name once its available |
|
67 const QString allDayIcon("qtg_small_day"); |
|
68 const QString exceptionIcon("qtg_mono_repeat_exception"); |
|
69 const int singleColumn(1); |
|
70 |
|
71 // ---------------------------------------------------------------------------- |
|
72 // CalenAgendaViewWidget::CalenAgendaViewWidget |
|
73 // Rest of the details are commented in the header |
|
74 // ---------------------------------------------------------------------------- |
|
75 // |
|
76 EXPORT_C CalenAgendaViewWidget::CalenAgendaViewWidget(MCalenServices &services, |
|
77 CalenDocLoader *docLoader) : |
|
78 mServices(services), |
|
79 mDocLoader(docLoader), |
|
80 mRegionalInfoGroupBox(NULL), |
|
81 mLongTapEventFlag(false), |
|
82 mNotesPluginLoaded(false), |
|
83 mIndex(0), |
|
84 mIconCheck(false) |
|
85 { |
|
86 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_CALENAGENDAVIEWWIDGET_ENTRY ); |
|
87 |
|
88 // Construct the list view prototype |
|
89 mListViewPrototype = new CalenEventListViewItem(this); |
|
90 |
|
91 // Create the list model |
|
92 mListModel = new QStandardItemModel(this); |
|
93 |
|
94 // Register the custom docml and css to provide our own style to the list items |
|
95 HbStyleLoader::registerFilePath(":/"); |
|
96 |
|
97 //Create the setting manager |
|
98 mSettingsManager = new XQSettingsManager(this); |
|
99 |
|
100 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_CALENAGENDAVIEWWIDGET_EXIT ); |
|
101 } |
|
102 |
|
103 // ---------------------------------------------------------------------------- |
|
104 // CalenAgendaViewWidget::~CalenAgendaViewWidget |
|
105 // Rest of the details are commented in the header |
|
106 // ---------------------------------------------------------------------------- |
|
107 // |
|
108 EXPORT_C CalenAgendaViewWidget::~CalenAgendaViewWidget() |
|
109 { |
|
110 OstTraceFunctionEntry0( DUP1_CALENAGENDAVIEWWIDGET_CALENAGENDAVIEWWIDGET_ENTRY ); |
|
111 |
|
112 // Unload notes editor if loaded. |
|
113 if (mNotesEditorPluginLoader) { |
|
114 mNotesEditorPluginLoader->unload(); |
|
115 delete mNotesEditorPluginLoader; |
|
116 mNotesEditorPluginLoader = 0; |
|
117 } |
|
118 |
|
119 if (mSettingsManager) { |
|
120 delete mSettingsManager; |
|
121 mSettingsManager = NULL; |
|
122 } |
|
123 |
|
124 OstTraceFunctionExit0( DUP1_CALENAGENDAVIEWWIDGET_CALENAGENDAVIEWWIDGET_EXIT ); |
|
125 } |
|
126 |
|
127 // ---------------------------------------------------------------------------- |
|
128 // CalenAgendaViewWidget::setupWidget |
|
129 // Rest of the details are commented in the header |
|
130 // ---------------------------------------------------------------------------- |
|
131 // |
|
132 void CalenAgendaViewWidget::setupWidget(CalenAgendaView *view) |
|
133 { |
|
134 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_SETUPWIDGET_ENTRY ); |
|
135 |
|
136 // Store the view for future reference |
|
137 mView = view; |
|
138 |
|
139 if (!mDocLoader) { |
|
140 // Nothing much can be done. Simply return |
|
141 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_SETUPWIDGET_EXIT ); |
|
142 return; |
|
143 } |
|
144 |
|
145 // Initialize the child widgets |
|
146 initChildWidgets(); |
|
147 OstTraceFunctionExit0( DUP1_CALENAGENDAVIEWWIDGET_SETUPWIDGET_EXIT ); |
|
148 } |
|
149 |
|
150 // ---------------------------------------------------------------------------- |
|
151 // CalenAgendaViewWidget::showWidget |
|
152 // Rest of the details are commented in the header |
|
153 // ---------------------------------------------------------------------------- |
|
154 // |
|
155 void CalenAgendaViewWidget::showWidget() |
|
156 { |
|
157 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_SHOWWIDGET_ENTRY ); |
|
158 |
|
159 // Get the date for which this view has been launched |
|
160 mDate = mServices.Context().focusDateAndTime(); |
|
161 |
|
162 // Set the heading text |
|
163 setHeadingText(); |
|
164 |
|
165 // Get the instance list |
|
166 getInstanceList(); |
|
167 |
|
168 // Check if regional information needs to be shown |
|
169 // and add it or remove it |
|
170 showHideRegionalInformation(); |
|
171 |
|
172 // Load the appropriate section based on the number of events for the day |
|
173 if (0 == mInstanceArray.count()) { |
|
174 // There are no entries for the day |
|
175 // Load and show the empty list section |
|
176 bool loadSuccess = false; |
|
177 |
|
178 // Hide the list which shows the events |
|
179 mEventsList->hide(); |
|
180 |
|
181 // Show the empty list text |
|
182 mEmptyListLabel->show(); |
|
183 |
|
184 // Get the current device orientation |
|
185 int orientation = mServices.MainWindow().orientation(); |
|
186 if (Qt::Vertical == orientation) { |
|
187 mDocLoader->load(CALEN_AGENDAVIEW_XML_FILE, "emptyList", &loadSuccess); |
|
188 } else { |
|
189 mDocLoader->load(CALEN_AGENDAVIEW_XML_FILE, "emptyLandscape", &loadSuccess); |
|
190 } |
|
191 if (!loadSuccess) { |
|
192 qFatal("calenagendaviewwidget.cpp : Unable to load empty list section"); |
|
193 } |
|
194 } else { |
|
195 // Hide the empty view label |
|
196 mEmptyListLabel->hide(); |
|
197 |
|
198 // Show the events list |
|
199 mEventsList->show(); |
|
200 |
|
201 // There are one or more events. Load the non-empty section |
|
202 bool loadSuccess = false; |
|
203 mDocLoader->load(CALEN_AGENDAVIEW_XML_FILE, "nonEmptyList", &loadSuccess); |
|
204 if (!loadSuccess) { |
|
205 qFatal("calenagendaviewwidget.cpp : Unable to load non-empty list section"); |
|
206 } |
|
207 // Now populate the list with the events |
|
208 populateListWidget(); |
|
209 } |
|
210 |
|
211 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_SHOWWIDGET_EXIT ); |
|
212 } |
|
213 |
|
214 // ---------------------------------------------------------------------------- |
|
215 // CalenAgendaViewWidget::orientationChanged |
|
216 // Rest of the details are commented in the header |
|
217 // ---------------------------------------------------------------------------- |
|
218 // |
|
219 void CalenAgendaViewWidget::orientationChanged(Qt::Orientation orientation) |
|
220 { |
|
221 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_ORIENTATIONCHANGED_ENTRY ); |
|
222 |
|
223 // Load the appropriate section based on the number of events for the day |
|
224 if (0 == mInstanceArray.count()) { |
|
225 // There are no entries for the day |
|
226 // Load and show the empty list section |
|
227 bool loadSuccess = false; |
|
228 |
|
229 // Hide the list which shows the events |
|
230 mEventsList->hide(); |
|
231 |
|
232 // Show the empty list text |
|
233 mEmptyListLabel->show(); |
|
234 |
|
235 if (Qt::Vertical == orientation) { |
|
236 mDocLoader->load(CALEN_AGENDAVIEW_XML_FILE, "emptyList", &loadSuccess); |
|
237 } else { |
|
238 mDocLoader->load(CALEN_AGENDAVIEW_XML_FILE, "emptyLandscape", &loadSuccess); |
|
239 } |
|
240 if (!loadSuccess) { |
|
241 qFatal("calenagendaviewwidget.cpp : Unable to load empty list section"); |
|
242 } |
|
243 } else { |
|
244 // Hide the empty view label |
|
245 mEmptyListLabel->hide(); |
|
246 |
|
247 // Show the events list |
|
248 mEventsList->show(); |
|
249 |
|
250 // There are one or more events. Load the non-empty section |
|
251 bool loadSuccess = false; |
|
252 mDocLoader->load(CALEN_AGENDAVIEW_XML_FILE, "nonEmptyList", &loadSuccess); |
|
253 if (!loadSuccess) { |
|
254 qFatal("calenagendaviewwidget.cpp : Unable to load non-empty list section"); |
|
255 } |
|
256 handleListItemStretching(orientation); |
|
257 } |
|
258 |
|
259 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_ORIENTATIONCHANGED_EXIT ); |
|
260 } |
|
261 |
|
262 // ---------------------------------------------------------------------------- |
|
263 // CalenAgendaViewWidget::handleLocaleChange |
|
264 // Rest of the details are commented in the header |
|
265 // ---------------------------------------------------------------------------- |
|
266 // |
|
267 void CalenAgendaViewWidget::handleLocaleChange() |
|
268 { |
|
269 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_HANDLELOCALECHANGE_ENTRY ); |
|
270 |
|
271 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_HANDLELOCALECHANGE_EXIT ); |
|
272 } |
|
273 |
|
274 // ---------------------------------------------------------------------------- |
|
275 // CalenAgendaViewWidget::setContextFromHighlight |
|
276 // Rest of the details are commented in the header |
|
277 // ---------------------------------------------------------------------------- |
|
278 // |
|
279 void CalenAgendaViewWidget::setContextFromHighlight(AgendaEntry entry) |
|
280 { |
|
281 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_SETCONTEXTFROMHIGHLIGHT_ENTRY ); |
|
282 |
|
283 if (entry.isTimedEntry()) { |
|
284 // Timed entry. |
|
285 QDateTime start = entry.startTime(); |
|
286 // start.setDate(mDate.date()); |
|
287 mServices.Context().setFocusDateAndTimeAndInstance(start, |
|
288 TCalenInstanceId::create(entry)); |
|
289 } else { |
|
290 // Untimed entry. |
|
291 if (CalenDateUtils::onSameDay(TCalenInstanceId::create(entry).mInstanceTime, |
|
292 mDate)) { |
|
293 mServices.Context().setInstanceId(TCalenInstanceId::create(entry)); |
|
294 } else { |
|
295 // Multi-day untimed note (either multi-day day note or weird todo). |
|
296 // Focus on the instance and set the focus time to the highlighted day. |
|
297 mServices.Context().setFocusDateAndTimeAndInstance(mDate, |
|
298 TCalenInstanceId::create(entry)); |
|
299 } |
|
300 } |
|
301 |
|
302 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_SETCONTEXTFROMHIGHLIGHT_EXIT ); |
|
303 } |
|
304 |
|
305 // ---------------------------------------------------------------------------- |
|
306 // CalenAgendaViewWidget::initChildWidgets |
|
307 // Rest of the details are commented in the header |
|
308 // ---------------------------------------------------------------------------- |
|
309 // |
|
310 void CalenAgendaViewWidget::initChildWidgets() |
|
311 { |
|
312 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_INITCHILDWIDGETS_ENTRY ); |
|
313 |
|
314 // Get the pointer to the events list |
|
315 mEventsList = static_cast<HbListView*> (mDocLoader->findWidget(CALEN_AGENDAVIEW_LISTWIDGET)); |
|
316 if (!mEventsList) { |
|
317 qFatal("calenagendaviewwidget.cpp : Unable to find the events list"); |
|
318 } |
|
319 // NOTE: Layout name MUST be same as the name mentioned in the css |
|
320 mEventsList->setLayoutName(customLayout); |
|
321 |
|
322 // TODO : remove this line after gestures are available |
|
323 mEventsList->installEventFilter(mView); |
|
324 |
|
325 // Connect to the long press and activation signals |
|
326 connect(mEventsList, SIGNAL(longPressed(HbAbstractViewItem*, const QPointF&)), |
|
327 this, SLOT(itemLongPressed(HbAbstractViewItem*, const QPointF&))); |
|
328 connect(mEventsList, SIGNAL(activated(const QModelIndex&)), this, |
|
329 SLOT(itemActivated(const QModelIndex&))); |
|
330 |
|
331 // Get the pointer to label from the loader. |
|
332 mHeadingLabel = qobject_cast<HbGroupBox*> (mDocLoader->findWidget(CALEN_AGENDAVIEW_HEADING)); |
|
333 if (!mHeadingLabel) { |
|
334 qFatal("calenagendaviewwidget.cpp : Unable to find heading widget"); |
|
335 } |
|
336 |
|
337 // Get the pointer to the empty view label |
|
338 mEmptyListLabel = qobject_cast<HbLabel*> (mDocLoader->findWidget("noEventsLabel")); |
|
339 if (!mEmptyListLabel) { |
|
340 qFatal("calenagendaviewwidget.cpp : Unable to find empty list label"); |
|
341 } |
|
342 HbWidget *headingPluginWidget = |
|
343 qobject_cast<HbWidget*> (mDocLoader->findWidget(CALEN_AGENDAVIEW_HEADING_REGIONALPLUGIN_WIDGET)); |
|
344 |
|
345 mRegionalPluginLayout = static_cast<QGraphicsLinearLayout*>(headingPluginWidget->layout()); |
|
346 |
|
347 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_INITCHILDWIDGETS_EXIT ); |
|
348 } |
|
349 |
|
350 // ---------------------------------------------------------------------------- |
|
351 // CalenAgendaViewWidget::populateListWidget |
|
352 // Rest of the details are commented in the header |
|
353 // ---------------------------------------------------------------------------- |
|
354 // |
|
355 void CalenAgendaViewWidget::populateListWidget() |
|
356 { |
|
357 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_POPULATELISTWIDGET_ENTRY ); |
|
358 |
|
359 // Recycle the list items so that only needed rows |
|
360 // are added or removed |
|
361 if (mInstanceArray.count() == 0) { |
|
362 // Reset the list |
|
363 mEventsList->reset(); |
|
364 // Clear the model to ensure it does not have any old items |
|
365 mListModel->clear(); |
|
366 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_POPULATELISTWIDGET_EXIT ); |
|
367 return; |
|
368 } else if (mInstanceArray.count() > mListModel->rowCount()) { |
|
369 // There are more events than the number of items |
|
370 // in the list. Add more rows |
|
371 mListModel->insertRows(0, mInstanceArray.count() - mListModel->rowCount()); |
|
372 } else if (mInstanceArray.count() < mListModel->rowCount()) { |
|
373 // There are less number of events than the number |
|
374 // of items in the list. Remove the extra rows |
|
375 mListModel->removeRows(0, mListModel->rowCount() - mInstanceArray.count()); |
|
376 } |
|
377 //to set the index to first item of the list , when view refresh |
|
378 mIndex = 0; |
|
379 //status reset for not setting any property |
|
380 mIconCheck = false; |
|
381 mListModel->setColumnCount(singleColumn); |
|
382 mIconCheck = true; |
|
383 // Add all the events to the list |
|
384 for (int index = 0; index < mInstanceArray.count(); index++) { |
|
385 // Get each of the entry details |
|
386 AgendaEntry entry = mInstanceArray[index]; |
|
387 // Create a list item for each entry |
|
388 createListItem(index, entry); |
|
389 } |
|
390 // Add the item on to the list widget |
|
391 mEventsList->setModel(mListModel, mListViewPrototype); |
|
392 |
|
393 // Now get the item to scroll to |
|
394 int scrollToIndex = getIndexToScrollTo(); |
|
395 if (mListModel->rowCount() > 0) { |
|
396 // Scroll to the index only if index is valid |
|
397 mEventsList->scrollTo(mListModel->index(scrollToIndex, 0)); |
|
398 } |
|
399 |
|
400 OstTraceFunctionExit0( DUP1_CALENAGENDAVIEWWIDGET_POPULATELISTWIDGET_EXIT ); |
|
401 } |
|
402 |
|
403 // ---------------------------------------------------------------------------- |
|
404 // CalenAgendaViewWidget::getInstanceList |
|
405 // Rest of the details are commented in the header |
|
406 // ---------------------------------------------------------------------------- |
|
407 // |
|
408 void CalenAgendaViewWidget::getInstanceList() |
|
409 { |
|
410 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_GETINSTANCELIST_ENTRY ); |
|
411 |
|
412 // Clear the previous instance list |
|
413 mInstanceArray.clear(); |
|
414 |
|
415 // Check if the date is valid |
|
416 if (!CalenDateUtils::isValidDay(mDate)) { |
|
417 mDate = CalenDateUtils::today(); |
|
418 } |
|
419 |
|
420 // Set the filter flags to fetch all relevant entries |
|
421 AgendaUtil::FilterFlags filter = AgendaUtil::FilterFlags(AgendaUtil::IncludeAnniversaries | |
|
422 AgendaUtil::IncludeAppointments | |
|
423 AgendaUtil::IncludeEvents | |
|
424 AgendaUtil::IncludeReminders | |
|
425 AgendaUtil::IncludeIncompletedTodos); |
|
426 |
|
427 // Fetch the instance list from the agenda interface |
|
428 mInstanceArray = mServices.agendaInterface()->createEntryIdListForDay(mDate, filter); |
|
429 |
|
430 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_GETINSTANCELIST_EXIT ); |
|
431 } |
|
432 |
|
433 // ---------------------------------------------------------------------------- |
|
434 // CalenAgendaViewWidget::setDateToLabel |
|
435 // Rest of the details are commented in the header |
|
436 // ---------------------------------------------------------------------------- |
|
437 // |
|
438 void CalenAgendaViewWidget::setHeadingText() |
|
439 { |
|
440 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_SETHEADINGTEXT_ENTRY ); |
|
441 |
|
442 // Format the date as per the device locale settings |
|
443 HbExtendedLocale systemLocale = HbExtendedLocale::system(); |
|
444 |
|
445 // Get localised name of the day from locale |
|
446 QString dayString = systemLocale.dayName(mDate.date().dayOfWeek()); |
|
447 // Append a single space |
|
448 dayString.append(singleSpace); |
|
449 // Set the heading |
|
450 // Append the date which is formatted as per the locale |
|
451 mHeadingLabel->setHeading(hbTrId( |
|
452 "txt_calendar_subhead_1_2").arg(dayString).arg( |
|
453 systemLocale.format(mDate.date(), r_qtn_date_usual_with_zero))); |
|
454 |
|
455 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_SETHEADINGTEXT_EXIT ); |
|
456 } |
|
457 |
|
458 // ---------------------------------------------------------------------------- |
|
459 // CalenAgendaViewWidget::createListItem |
|
460 // Rest of the details are commented in the header |
|
461 // ---------------------------------------------------------------------------- |
|
462 // |
|
463 void CalenAgendaViewWidget::createListItem(int index, AgendaEntry entry) |
|
464 { |
|
465 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_CREATELISTITEM_ENTRY ); |
|
466 |
|
467 if (index < 0 || entry.isNull()) { |
|
468 // Not a valid index or entry. Dont do anything |
|
469 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_CREATELISTITEM_EXIT ); |
|
470 return; |
|
471 } |
|
472 // Check if the entry is a timed entry and not all day event |
|
473 // an all-day event when it is synched from OUTLOOK then entry type will be EAppt |
|
474 if (!CalenAgendaUtils::isAlldayEvent(entry) && entry.isTimedEntry()) { |
|
475 // Get the text and icon data for the entry |
|
476 addTimedEventToList(index, entry); |
|
477 } else { |
|
478 addNonTimedEventToList(index, entry); |
|
479 } |
|
480 |
|
481 OstTraceFunctionExit0( DUP1_CALENAGENDAVIEWWIDGET_CREATELISTITEM_EXIT ); |
|
482 } |
|
483 |
|
484 // ---------------------------------------------------------------------------- |
|
485 // CalenAgendaViewWidget::addTimedEventToList |
|
486 // Rest of the details are commented in the header |
|
487 // ---------------------------------------------------------------------------- |
|
488 // |
|
489 void CalenAgendaViewWidget::addTimedEventToList(int index, AgendaEntry entry) |
|
490 { |
|
491 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_ADDTIMEDEVENTTOLIST_ENTRY ); |
|
492 |
|
493 // Create text and icon list to set to the model |
|
494 QVariantList textData; |
|
495 QVariantList iconData; |
|
496 bool twoLines = false; |
|
497 |
|
498 /** |
|
499 * IMPORTANT NOTE: All the text and icon items must be |
|
500 * inserted into the variant list in a specific order. |
|
501 * If not, chaos will set it!!! |
|
502 * On a more serious note, the mesh layout depends on the |
|
503 * fact that the icons and text data will be added in a |
|
504 * particular order. If one of the items go missing, the |
|
505 * layout might get messed up. Also in case a particular item |
|
506 * is not required to be added in the middle of the list, an |
|
507 * empty QVariant must be added to indicate to the list view |
|
508 * that the item must be removed from the layout. |
|
509 * Do not mess with the order in case you are not sure what |
|
510 * you are exactly doing. |
|
511 */ |
|
512 |
|
513 // The first icon to show to-do or all day should not be shown |
|
514 // Append empty data to the icons list |
|
515 iconData << QVariant(); |
|
516 |
|
517 // Check if alarm is enabled for the entry |
|
518 if (entry.alarm().isNull()) { |
|
519 // Insert a blank icon. Else the next icon |
|
520 // will get replaced in this icon's position |
|
521 iconData << QVariant(); |
|
522 } else { |
|
523 iconData << HbIcon(reminderIcon); |
|
524 } |
|
525 |
|
526 // Check if the entry is recurring |
|
527 if (entry.isRepeating()) { |
|
528 iconData << HbIcon(repeatIcon); |
|
529 } else if (!entry.recurrenceId().isNull()) { |
|
530 // This is an exceptional entry |
|
531 iconData << HbIcon(exceptionIcon); |
|
532 } else { |
|
533 // Insert a blank icon. Else the next icon |
|
534 // will get replaced in this icon's position |
|
535 iconData << QVariant(); |
|
536 } |
|
537 |
|
538 HbExtendedLocale locale = HbExtendedLocale::system(); |
|
539 // Get the start time and format as per the locale |
|
540 QDateTime startTime = entry.startTime(); |
|
541 QTime eventStartTime; |
|
542 |
|
543 if (CalenDateUtils::beginningOfDay(startTime) |
|
544 < CalenDateUtils::beginningOfDay(mDate)) { |
|
545 // event is started previous day, show StarTime as 12:00 am in Agendaview, |
|
546 eventStartTime.setHMS(00, 00, 00); |
|
547 } else { |
|
548 eventStartTime = entry.startTime().time(); |
|
549 } |
|
550 QString eventTime = locale.format(eventStartTime, r_qtn_time_usual_with_zero); |
|
551 |
|
552 // Get the event end time |
|
553 QDateTime endTime = entry.endTime(); |
|
554 QTime eventEndTime; |
|
555 |
|
556 if (CalenDateUtils::beginningOfDay(endTime) |
|
557 > CalenDateUtils::beginningOfDay(mDate)) { |
|
558 // event has MidNight crossover, show EndTime as 11:59pm in Agendaview, |
|
559 eventEndTime.setHMS(23, 59, 59); |
|
560 } else { |
|
561 eventEndTime = entry.endTime().time(); |
|
562 } |
|
563 |
|
564 if (eventStartTime < eventEndTime) { |
|
565 // Raise the flag to indicate that the list item |
|
566 // would wrap to two lines |
|
567 twoLines = true; |
|
568 // Append '-' to indicate an end time is present |
|
569 eventTime.append(singleHyphen); |
|
570 } else { |
|
571 // To align the subject properly if the start and endtime are same |
|
572 eventTime.append(doubleSpace); |
|
573 } |
|
574 |
|
575 // Add the event time to the text list |
|
576 // This MUST be the first item to be added to the list |
|
577 textData << eventTime; |
|
578 |
|
579 // Get the entry subject |
|
580 QString subject = entry.summary(); |
|
581 if (subject.isEmpty() || subject.isNull()) { |
|
582 // No subject. Add "(No subject)" text |
|
583 subject.append(hbTrId("txt_calendar_dblist_unnamed")); |
|
584 } |
|
585 // Add the subject to the text list |
|
586 // This MUST be the second item in the list |
|
587 textData << subject; |
|
588 |
|
589 // Check if the entry has location |
|
590 // TODO: This must change to check for geo-location |
|
591 // This MUST be the third item in the list |
|
592 if (entry.location().isEmpty()) { |
|
593 // Insert a blank icon. Else the next icon |
|
594 // will get replaced in this icon's position |
|
595 iconData << QVariant(); |
|
596 if (twoLines) { |
|
597 /** |
|
598 * NOTE: If the primary text is wrapping to two |
|
599 * lines, then the location must be set as blank |
|
600 * since the bottom of the list item is anchored to |
|
601 * the bottom of the secondary text. Else the bottom |
|
602 * of the list will overlap on the primary text |
|
603 */ |
|
604 textData << singleSpace; |
|
605 } else { |
|
606 /** |
|
607 * Else, set the secondary text to empty to indicate |
|
608 * to the list view to remove the item itself and |
|
609 * shrink its size to a single line size |
|
610 */ |
|
611 textData << QVariant(); |
|
612 } |
|
613 } else { |
|
614 // TODO: Location icon must be shown |
|
615 // only if valid geo-coordinates are present |
|
616 if (!entry.geoValue().isNull()){ |
|
617 iconData << HbIcon(locationIcon); |
|
618 } |
|
619 else { |
|
620 iconData << QVariant(); |
|
621 } |
|
622 textData << entry.location(); |
|
623 } |
|
624 // Add the end time to the list item |
|
625 if (eventStartTime < eventEndTime) { |
|
626 QString endtime = locale.format(eventEndTime, r_qtn_time_usual_with_zero); |
|
627 endtime.append(singleSpace); |
|
628 textData << endtime; |
|
629 }else { |
|
630 textData<<QString(space); |
|
631 } |
|
632 // Get the list model index and set the text and icon data |
|
633 QModelIndex listIndex = mListModel->index(index, 0); |
|
634 mNextEntry = false; |
|
635 mListModel->setData(listIndex, textData, Qt::DisplayRole); |
|
636 mNextEntry = true; |
|
637 mListModel->setData(listIndex, iconData, Qt::DecorationRole); |
|
638 |
|
639 // Disable item stretching by removing the dynamic property |
|
640 HbListViewItem *listViewItem = static_cast<HbListViewItem*> |
|
641 (mEventsList->itemByIndex(mListModel->index(index, 0))); |
|
642 if (listViewItem) { |
|
643 listViewItem->setProperty(stretchLayout, false); |
|
644 } |
|
645 |
|
646 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_ADDTIMEDEVENTTOLIST_EXIT ); |
|
647 } |
|
648 |
|
649 // ---------------------------------------------------------------------------- |
|
650 // CalenAgendaViewWidget::addNonTimedEventToList |
|
651 // Rest of the details are commented in the header |
|
652 // ---------------------------------------------------------------------------- |
|
653 // |
|
654 void CalenAgendaViewWidget::addNonTimedEventToList(int index, AgendaEntry entry) |
|
655 { |
|
656 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_ADDNONTIMEDEVENTTOLIST_ENTRY ); |
|
657 |
|
658 QVariantList textData; |
|
659 QVariantList iconData; |
|
660 |
|
661 /** |
|
662 * IMPORTANT NOTE: All the text and icon items must be |
|
663 * inserted into the variant list in a specific order. |
|
664 * If not, chaos will set it!!! |
|
665 * On a more serious note, the mesh layout depends on the |
|
666 * fact that the icons and text data will be added in a |
|
667 * particular order. If one of the items go missing, the |
|
668 * layout might get messed up. Also in case a particular item |
|
669 * is not required to be added in the middle of the list, an |
|
670 * empty QVariant must be added to indicate to the list view |
|
671 * that the item must be removed from the layout. |
|
672 * Do not mess with the order in case you are not sure what |
|
673 * you are exactly doing. |
|
674 */ |
|
675 |
|
676 // The first column text has to be empty |
|
677 textData << QVariant(); |
|
678 |
|
679 // Get the entry subject |
|
680 QString subject = entry.summary(); |
|
681 if (subject.isEmpty() || subject.isNull()) { |
|
682 // No subject. Add "(No subject)" text |
|
683 subject.append(hbTrId("txt_calendar_dblist_unnamed")); |
|
684 } |
|
685 // Add the subject to the text list |
|
686 // This MUST be the second item in the list |
|
687 textData << subject; |
|
688 |
|
689 // Get the entry type |
|
690 AgendaEntry::Type entryType = entry.type(); |
|
691 |
|
692 if (entryType == AgendaEntry::TypeAnniversary) { |
|
693 // Nothing to do as of now as anniversary events |
|
694 // cannot be created |
|
695 // TODO: To be handled in case of sync |
|
696 } else if (CalenAgendaUtils::isAlldayEvent(entry)) { |
|
697 // This is an all day event |
|
698 // Append the all-day icon |
|
699 iconData << HbIcon(allDayIcon); |
|
700 |
|
701 // Check if alarm is enabled for the entry |
|
702 if (entry.alarm().isNull()) { |
|
703 // Insert a blank icon. Else next text item will get shifted to left |
|
704 iconData << QVariant(); |
|
705 } else { |
|
706 // if entry is not repeating in place of reminder icon put a blank |
|
707 // icon and move reminder icon to the place of repeating icon |
|
708 if (!entry.isRepeating()) { |
|
709 iconData << QVariant(); |
|
710 } |
|
711 iconData << HbIcon(reminderIcon); |
|
712 } |
|
713 |
|
714 // Check if the entry is recurring |
|
715 if (entry.isRepeating()) { |
|
716 iconData << HbIcon(repeatIcon); |
|
717 } else if (!entry.recurrenceId().isNull()) { |
|
718 // This is an exceptional entry |
|
719 iconData << HbIcon(exceptionIcon); |
|
720 } else { |
|
721 // put the blank icon only when both reminder and repeating icons |
|
722 // are not there |
|
723 if (entry.alarm().isNull()) { |
|
724 iconData << QVariant(); |
|
725 } |
|
726 } |
|
727 |
|
728 // Append the location |
|
729 if (!entry.location().isEmpty()) { |
|
730 textData << entry.location(); |
|
731 // TODO: Location icon must be shown |
|
732 // only if valid geo-coordinates are present |
|
733 if (!entry.geoValue().isNull()){ |
|
734 iconData << HbIcon(locationIcon); |
|
735 }else { |
|
736 iconData << QVariant(); |
|
737 |
|
738 } |
|
739 } else { |
|
740 textData << QVariant(); |
|
741 } |
|
742 // The fourth text item has to be empty |
|
743 textData << QVariant(); |
|
744 |
|
745 } else if (entryType == AgendaEntry::TypeTodo) { |
|
746 // Append the to-do icon |
|
747 iconData << HbIcon(toDoIcon); |
|
748 |
|
749 // Get the due date |
|
750 QDateTime dueDate = entry.endTime(); |
|
751 |
|
752 // Append the date first |
|
753 QString dueDateString(hbTrId("txt_calendar_dblist_val_due_on_1")); |
|
754 QString dueText; |
|
755 dueText.setNum(dueDate.date().day()); |
|
756 dueText.append(singleSpace); |
|
757 |
|
758 // Append the month name next |
|
759 HbExtendedLocale locale = HbExtendedLocale::system(); |
|
760 QString month = locale.monthName(dueDate.date().month()); |
|
761 dueText.append(month); |
|
762 dueText.append(singleSpace); |
|
763 |
|
764 // Append the year |
|
765 QString year; |
|
766 year.setNum(dueDate.date().year()); |
|
767 dueText.append(year); |
|
768 |
|
769 textData << dueDateString.arg(dueText); |
|
770 |
|
771 // The fourth text item has to be empty |
|
772 textData << QVariant(); |
|
773 |
|
774 // Check if alarm is enabled for the entry |
|
775 if (entry.alarm().isNull()) { |
|
776 // Insert a blank icon. Else next text item will get shifted to left |
|
777 iconData << QVariant(); |
|
778 } else { |
|
779 // if entry is not repeating in place of reminder icon put a blank |
|
780 // icon and move reminder icon to the place of repeating icon |
|
781 if (!entry.isRepeating()) { |
|
782 iconData << QVariant(); |
|
783 } |
|
784 iconData << HbIcon(reminderIcon); |
|
785 } |
|
786 |
|
787 // Check if the entry is recurring |
|
788 if (entry.isRepeating()) { |
|
789 iconData << HbIcon(repeatIcon); |
|
790 } else { |
|
791 // Insert the blank icon only when both reminder and repeating icons |
|
792 // are not there |
|
793 if (entry.alarm().isNull()) { |
|
794 iconData << QVariant(); |
|
795 } |
|
796 } |
|
797 } |
|
798 |
|
799 // Get the list model index and set the text and icon data |
|
800 QModelIndex listIndex = mListModel->index(index, 0); |
|
801 mNextEntry = false; |
|
802 mListModel->setData(listIndex, textData, Qt::DisplayRole); |
|
803 mNextEntry = true; |
|
804 mListModel->setData(listIndex, iconData, Qt::DecorationRole); |
|
805 |
|
806 // Enable item stretching by adding the dynamic property |
|
807 HbListViewItem *listViewItem = static_cast<HbListViewItem*> |
|
808 (mEventsList->itemByIndex(mListModel->index(index, 0))); |
|
809 Qt::Orientation orientation = mServices.MainWindow().orientation(); |
|
810 // Apply stretch only for landscape orientation |
|
811 if (listViewItem) { |
|
812 if (Qt::Horizontal == orientation) { |
|
813 listViewItem->setProperty(stretchLayout, true); |
|
814 } else { |
|
815 listViewItem->setProperty(stretchLayout, false); |
|
816 } |
|
817 } |
|
818 |
|
819 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_ADDNONTIMEDEVENTTOLIST_EXIT ); |
|
820 } |
|
821 |
|
822 // ---------------------------------------------------------------------------- |
|
823 // CalenAgendaViewWidget::handleListItemStretching |
|
824 // Rest of the details are commented in the header |
|
825 // ---------------------------------------------------------------------------- |
|
826 // |
|
827 void CalenAgendaViewWidget::handleListItemStretching(Qt::Orientation orientation) |
|
828 { |
|
829 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_HANDLELISTITEMSTRETCHING_ENTRY ); |
|
830 |
|
831 if (mInstanceArray.count() == 0) { |
|
832 // Nothing much to do. Simply return |
|
833 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_HANDLELISTITEMSTRETCHING_EXIT ); |
|
834 return; |
|
835 } |
|
836 for(int index = 0; index < mInstanceArray.count() ; index ++) { |
|
837 AgendaEntry entry = mInstanceArray[index]; |
|
838 if (!entry.isNull()) { |
|
839 AgendaEntry::Type eventType = entry.type(); |
|
840 // Need to check explicitly for Appt that got synched from OUTLOOK |
|
841 // that can be an all-day event |
|
842 if (AgendaEntry::TypeAppoinment == eventType) { |
|
843 if (CalenAgendaUtils::isAlldayEvent(entry)) { |
|
844 eventType = AgendaEntry::TypeEvent; |
|
845 } |
|
846 } |
|
847 switch(eventType) { |
|
848 // Apply the stretching to only to-do's, |
|
849 // anniversary and all-day event types |
|
850 case AgendaEntry::TypeTodo: |
|
851 case AgendaEntry::TypeEvent: |
|
852 case AgendaEntry::TypeAnniversary: |
|
853 { |
|
854 // Get the list view item corresponding to the index |
|
855 HbListViewItem *listItem = static_cast<HbListViewItem*> |
|
856 (mEventsList->itemByIndex(mListModel->index(index, 0))); |
|
857 if (listItem) { |
|
858 if (orientation == Qt::Horizontal) { |
|
859 // Set a dynamic property to indicate that this list item |
|
860 // must be stretched in landscape. |
|
861 // NOTE: Property name MUST match the name specified in |
|
862 // css file, else wierd things might happen |
|
863 listItem->setProperty(stretchLayout, true); |
|
864 } |
|
865 } |
|
866 } |
|
867 break; |
|
868 default: |
|
869 { |
|
870 HbListViewItem *listItem = static_cast<HbListViewItem*> |
|
871 (mEventsList->itemByIndex(mListModel->index(index, 0))); |
|
872 if (listItem) { |
|
873 listItem->setProperty(stretchLayout, false); |
|
874 } |
|
875 break; |
|
876 } |
|
877 } |
|
878 } |
|
879 } |
|
880 |
|
881 OstTraceFunctionExit0( DUP1_CALENAGENDAVIEWWIDGET_HANDLELISTITEMSTRETCHING_EXIT ); |
|
882 } |
|
883 |
|
884 // ---------------------------------------------------------------------------- |
|
885 // CalenAgendaViewWidget::getIndexToScrollTo |
|
886 // Rest of the details are commented in the header |
|
887 // ---------------------------------------------------------------------------- |
|
888 // |
|
889 int CalenAgendaViewWidget::getIndexToScrollTo() |
|
890 { |
|
891 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_GETINDEXTOSCROLLTO_ENTRY ); |
|
892 |
|
893 int scrollIndex = 0; |
|
894 TCalenInstanceId instanceId = mServices.Context().instanceId(); |
|
895 if (instanceId == TCalenInstanceId::nullInstanceId()) { |
|
896 // If the instance is not set, then scroll to zero index |
|
897 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_GETINDEXTOSCROLLTO_EXIT ); |
|
898 return scrollIndex; |
|
899 } |
|
900 |
|
901 for (int index = 0 ; index < mInstanceArray.count() ; index++) { |
|
902 AgendaEntry entry = mInstanceArray[index]; |
|
903 if (entry.id() == instanceId.mEntryLocalUid) { |
|
904 // Match found. |
|
905 scrollIndex = index; |
|
906 break; |
|
907 } |
|
908 } |
|
909 OstTraceFunctionExit0( DUP1_CALENAGENDAVIEWWIDGET_GETINDEXTOSCROLLTO_EXIT ); |
|
910 return scrollIndex; |
|
911 } |
|
912 |
|
913 // ---------------------------------------------------------------------------- |
|
914 // CalenAgendaViewWidget::showHideRegionalInformation |
|
915 // To Show and hide regional plugin label depends upon settings |
|
916 // ---------------------------------------------------------------------------- |
|
917 // |
|
918 void CalenAgendaViewWidget::showHideRegionalInformation() |
|
919 { |
|
920 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_SHOWHIDEREGIONALINFORMATION_ENTRY ); |
|
921 |
|
922 if (mView->pluginEnabled()) { |
|
923 XQSettingsKey regionalInfo(XQSettingsKey::TargetCentralRepository, |
|
924 KCRUidCalendar, KCalendarShowRegionalInfo); |
|
925 |
|
926 int showRegionalInfo = |
|
927 mSettingsManager->readItemValue(regionalInfo).toUInt(); |
|
928 if (showRegionalInfo) { |
|
929 |
|
930 if (!mRegionalInfoGroupBox) { |
|
931 mRegionalInfoGroupBox = new HbGroupBox(); |
|
932 CalenPluginLabel *regionalInfo = new CalenPluginLabel( |
|
933 mServices, this); |
|
934 regionalInfo->setFontSpec(HbFontSpec(HbFontSpec::Primary)); |
|
935 mRegionalInfoGroupBox->setContentWidget(regionalInfo); |
|
936 mRegionalPluginLayout->insertItem(1, mRegionalInfoGroupBox); |
|
937 } |
|
938 QString *pluginString = mView->pluginText(); |
|
939 HbLabel *pluginInfoLabel = qobject_cast <HbLabel *> |
|
940 (mRegionalInfoGroupBox->contentWidget()); |
|
941 pluginInfoLabel->setPlainText(*pluginString); |
|
942 } |
|
943 } else { |
|
944 if (mRegionalInfoGroupBox) { |
|
945 mRegionalPluginLayout->removeItem(mRegionalInfoGroupBox); |
|
946 delete mRegionalInfoGroupBox; |
|
947 mRegionalInfoGroupBox = NULL; |
|
948 } |
|
949 } |
|
950 |
|
951 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_SHOWHIDEREGIONALINFORMATION_EXIT ); |
|
952 } |
|
953 |
|
954 // ---------------------------------------------------------------------------- |
|
955 // CalenAgendaViewWidget::createNewEvent |
|
956 // Rest of the details are commented in the header |
|
957 // ---------------------------------------------------------------------------- |
|
958 // |
|
959 void CalenAgendaViewWidget::createNewEvent() |
|
960 { |
|
961 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_CREATENEWEVENT_ENTRY ); |
|
962 |
|
963 // Issue a command to launch editor to create |
|
964 // a new event |
|
965 mServices.IssueCommandL(ECalenNewMeeting); |
|
966 |
|
967 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_CREATENEWEVENT_EXIT ); |
|
968 } |
|
969 |
|
970 // ---------------------------------------------------------------------------- |
|
971 // CalenAgendaViewWidget::editEntry |
|
972 // Rest of the details are commented in the header |
|
973 // ---------------------------------------------------------------------------- |
|
974 // |
|
975 void CalenAgendaViewWidget::editEntry() |
|
976 { |
|
977 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_EDITENTRY_ENTRY ); |
|
978 |
|
979 // Check if the selected index is valid |
|
980 if (mSelectedIndex < 0 || mSelectedIndex > mInstanceArray.count()) { |
|
981 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_EDITENTRY_EXIT ); |
|
982 return; |
|
983 } |
|
984 |
|
985 // Get the entry details first |
|
986 AgendaEntry entry = mInstanceArray[mSelectedIndex]; |
|
987 if (AgendaEntry::TypeTodo == entry.type()) { |
|
988 // Load the notes editor plugin if not loaded. |
|
989 if (!mNotesPluginLoaded) { |
|
990 // Launch the to-do editor using notes editor plugin api |
|
991 QDir dir(NOTES_EDITOR_PLUGIN_PATH); |
|
992 QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME); |
|
993 |
|
994 // Create NotesEditor plugin loader object. |
|
995 mNotesEditorPluginLoader = new QPluginLoader(pluginName); |
|
996 |
|
997 // Load the plugin |
|
998 mNotesPluginLoaded = mNotesEditorPluginLoader->load(); |
|
999 } |
|
1000 |
|
1001 QObject *plugin = qobject_cast<QObject*> ( |
|
1002 mNotesEditorPluginLoader->instance()); |
|
1003 |
|
1004 NotesEditorInterface* interface = |
|
1005 qobject_cast<NotesEditorInterface*>(plugin); |
|
1006 |
|
1007 interface->edit(entry, mServices.agendaInterface()); |
|
1008 |
|
1009 connect( |
|
1010 interface, SIGNAL(editingCompleted(bool)), |
|
1011 this, SLOT(noteEditingCompleted(bool))); |
|
1012 } else { |
|
1013 // Set the context |
|
1014 setContextFromHighlight(entry); |
|
1015 // Issue a command to launch the editor to edit this entry |
|
1016 mServices.IssueCommandL(ECalenEditCurrentEntry); |
|
1017 } |
|
1018 |
|
1019 OstTraceFunctionExit0( DUP1_CALENAGENDAVIEWWIDGET_EDITENTRY_EXIT ); |
|
1020 } |
|
1021 |
|
1022 // ---------------------------------------------------------------------------- |
|
1023 // CalenAgendaViewWidget::viewEntry |
|
1024 // Rest of the details are commented in the header |
|
1025 // ---------------------------------------------------------------------------- |
|
1026 // |
|
1027 void CalenAgendaViewWidget::viewEntry() |
|
1028 { |
|
1029 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_VIEWENTRY_ENTRY ); |
|
1030 |
|
1031 // Get the entry details first |
|
1032 AgendaEntry entry = mInstanceArray[mSelectedIndex]; |
|
1033 |
|
1034 // Set the context |
|
1035 setContextFromHighlight(entry); |
|
1036 |
|
1037 //for not setting any property again |
|
1038 mIconCheck = false; |
|
1039 // Launch the event viewer. |
|
1040 mServices.IssueCommandL(ECalenEventView); |
|
1041 |
|
1042 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_VIEWENTRY_EXIT ); |
|
1043 } |
|
1044 |
|
1045 |
|
1046 // ---------------------------------------------------------------------------- |
|
1047 // CalenAgendaViewWidget::deleteEntry |
|
1048 // Rest of the details are commented in the header |
|
1049 // ---------------------------------------------------------------------------- |
|
1050 // |
|
1051 void CalenAgendaViewWidget::deleteEntry() |
|
1052 { |
|
1053 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_DELETEENTRY_ENTRY ); |
|
1054 |
|
1055 // Check if the selected index is valid |
|
1056 if (mSelectedIndex < 0 || mSelectedIndex > mInstanceArray.count()) { |
|
1057 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_DELETEENTRY_EXIT ); |
|
1058 return; |
|
1059 } |
|
1060 |
|
1061 // Get the entry details |
|
1062 AgendaEntry entry = mInstanceArray[mSelectedIndex]; |
|
1063 // Set the context |
|
1064 setContextFromHighlight(entry); |
|
1065 // Issue the command to delete the entry |
|
1066 mServices.IssueCommandL(ECalenDeleteCurrentEntry); |
|
1067 |
|
1068 OstTraceFunctionExit0( DUP1_CALENAGENDAVIEWWIDGET_DELETEENTRY_EXIT ); |
|
1069 } |
|
1070 |
|
1071 // ---------------------------------------------------------------------------- |
|
1072 // CalenAgendaViewWidget::markAsDone |
|
1073 // Rest of the details are commented in the header |
|
1074 // ---------------------------------------------------------------------------- |
|
1075 // |
|
1076 void CalenAgendaViewWidget::markAsDone() |
|
1077 { |
|
1078 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_MARKASDONE_ENTRY ); |
|
1079 |
|
1080 // Check if the selected index is valid |
|
1081 if (mSelectedIndex < 0 || mSelectedIndex > mInstanceArray.count()) { |
|
1082 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_MARKASDONE_EXIT ); |
|
1083 return; |
|
1084 } |
|
1085 |
|
1086 // Get the entry details |
|
1087 AgendaEntry entry = mInstanceArray[mSelectedIndex]; |
|
1088 |
|
1089 // Check again if the event is of type to-to |
|
1090 if (AgendaEntry::TypeTodo == entry.type()) { |
|
1091 // Set the status of the to-do as completed |
|
1092 entry.setStatus(AgendaEntry::TodoCompleted); |
|
1093 // Update the completed date and time |
|
1094 entry.setCompletedDateTime(mDate); |
|
1095 |
|
1096 // Update the entry in the database |
|
1097 mServices.agendaInterface()->setCompleted(entry, true, mDate); |
|
1098 mServices.IssueCommandL(ECalenStartActiveStep); |
|
1099 } |
|
1100 |
|
1101 OstTraceFunctionExit0( DUP1_CALENAGENDAVIEWWIDGET_MARKASDONE_EXIT ); |
|
1102 } |
|
1103 |
|
1104 // ---------------------------------------------------------------------------- |
|
1105 // CalenAgendaViewWidget::itemLongPressed |
|
1106 // Rest of the details are commented in the header |
|
1107 // ---------------------------------------------------------------------------- |
|
1108 // |
|
1109 void CalenAgendaViewWidget::itemLongPressed(HbAbstractViewItem* listViewItem, |
|
1110 const QPointF& coords) |
|
1111 { |
|
1112 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_ITEMLONGPRESSED_ENTRY ); |
|
1113 |
|
1114 mLongTapEventFlag = true; |
|
1115 // Update the selection index first |
|
1116 mSelectedIndex = listViewItem->modelIndex().row(); |
|
1117 |
|
1118 if (mSelectedIndex < 0 || mSelectedIndex > mInstanceArray.count()) { |
|
1119 // Invalid index |
|
1120 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_ITEMLONGPRESSED_EXIT ); |
|
1121 return; |
|
1122 } |
|
1123 |
|
1124 AgendaEntry entry = mInstanceArray[mSelectedIndex]; |
|
1125 |
|
1126 // Create new menu. |
|
1127 HbMenu *contextMenu = new HbMenu(); |
|
1128 |
|
1129 // Add the open option |
|
1130 HbAction *openAction = contextMenu->addAction( |
|
1131 hbTrId("txt_common_menu_open")); |
|
1132 |
|
1133 // Check the type of event |
|
1134 if (AgendaEntry::TypeTodo == entry.type()) { |
|
1135 // Add an option to mark the note as complete |
|
1136 HbAction *completeAction = contextMenu->addAction( |
|
1137 hbTrId("txt_calendar_menu_mark_as_done")); |
|
1138 } |
|
1139 |
|
1140 // Add the edit option |
|
1141 HbAction *editAction = contextMenu->addAction( |
|
1142 hbTrId("txt_common_menu_edit")); |
|
1143 |
|
1144 // Add the delete option |
|
1145 HbAction *deleteAction = contextMenu->addAction( |
|
1146 hbTrId("txt_common_menu_delete")); |
|
1147 |
|
1148 contextMenu->setDismissPolicy(HbMenu::TapAnywhere); |
|
1149 |
|
1150 // Show context sensitive menu. |
|
1151 // Param const QPointF& coordinate - is a longpress position. |
|
1152 contextMenu->setPreferredPos(coords); |
|
1153 connect(contextMenu, SIGNAL(aboutToClose()), |
|
1154 this, |
|
1155 SLOT(contextMenuClosed())); |
|
1156 |
|
1157 contextMenu->open(this, SLOT(contextManuTriggered(HbAction *))); |
|
1158 |
|
1159 OstTraceFunctionExit0( DUP1_CALENAGENDAVIEWWIDGET_ITEMLONGPRESSED_EXIT ); |
|
1160 } |
|
1161 |
|
1162 // ---------------------------------------------------------------------------- |
|
1163 // CalenAgendaViewWidget::itemActivated |
|
1164 // Rest of the details are commented in the header |
|
1165 // ---------------------------------------------------------------------------- |
|
1166 // |
|
1167 void CalenAgendaViewWidget::itemActivated(const QModelIndex &index) |
|
1168 { |
|
1169 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_ITEMACTIVATED_ENTRY ); |
|
1170 |
|
1171 // Update the selection index first |
|
1172 mSelectedIndex = index.row(); |
|
1173 |
|
1174 // Check if the selected index is valid |
|
1175 if (mSelectedIndex < 0 || mSelectedIndex > mInstanceArray.count()) { |
|
1176 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_ITEMACTIVATED_EXIT ); |
|
1177 return; |
|
1178 } |
|
1179 if( !mLongTapEventFlag ) { |
|
1180 // Open the event for viewing |
|
1181 viewEntry(); |
|
1182 } |
|
1183 |
|
1184 OstTraceFunctionExit0( DUP1_CALENAGENDAVIEWWIDGET_ITEMACTIVATED_EXIT ); |
|
1185 } |
|
1186 |
|
1187 // ---------------------------------------------------------------------------- |
|
1188 // CalenAgendaViewWidget::itemActivated |
|
1189 // Rest of the details are commented in the header |
|
1190 // ---------------------------------------------------------------------------- |
|
1191 // |
|
1192 void CalenAgendaViewWidget::noteEditingCompleted(bool status) |
|
1193 { |
|
1194 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_NOTEEDITINGCOMPLETED_ENTRY ); |
|
1195 |
|
1196 // We need to refresh the list since user |
|
1197 // might have marked the to-do as complete or |
|
1198 // edited it or deleted it. So get the instance |
|
1199 // list again |
|
1200 if (status) { |
|
1201 mServices.IssueCommandL(ECalenStartActiveStep); |
|
1202 } |
|
1203 |
|
1204 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_NOTEEDITINGCOMPLETED_EXIT ); |
|
1205 } |
|
1206 |
|
1207 // ---------------------------------------------------------------------------- |
|
1208 // CalenAgendaViewWidget::goToToday |
|
1209 // Rest of the details are commented in the header |
|
1210 // ---------------------------------------------------------------------------- |
|
1211 // |
|
1212 void CalenAgendaViewWidget::goToToday() |
|
1213 { |
|
1214 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_GOTOTODAY_ENTRY ); |
|
1215 |
|
1216 // First check if we are not already |
|
1217 // showing today's agenda |
|
1218 if (mDate == CalenDateUtils::today()) { |
|
1219 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_GOTOTODAY_EXIT ); |
|
1220 return; |
|
1221 } |
|
1222 |
|
1223 // Set the context for the current day |
|
1224 mServices.Context().setFocusDate(CalenDateUtils::today()); |
|
1225 |
|
1226 mView->refreshViewOnGoToDate(); |
|
1227 |
|
1228 OstTraceFunctionExit0( DUP1_CALENAGENDAVIEWWIDGET_GOTOTODAY_EXIT ); |
|
1229 } |
|
1230 |
|
1231 // ---------------------------------------------------------------------------- |
|
1232 // CalenAgendaViewWidget::contextMenuClosed |
|
1233 // Rest of the details are commented in the header |
|
1234 // ---------------------------------------------------------------------------- |
|
1235 // |
|
1236 void CalenAgendaViewWidget::contextMenuClosed() |
|
1237 { |
|
1238 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_CONTEXTMENUCLOSED_ENTRY ); |
|
1239 |
|
1240 mLongTapEventFlag = false; |
|
1241 |
|
1242 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_CONTEXTMENUCLOSED_EXIT ); |
|
1243 } |
|
1244 |
|
1245 // ---------------------------------------------------------------------------- |
|
1246 // CalenAgendaViewWidget::contextManuTriggered |
|
1247 // Rest of the details are commented in the header |
|
1248 // ---------------------------------------------------------------------------- |
|
1249 // |
|
1250 void CalenAgendaViewWidget::contextManuTriggered(HbAction *action) |
|
1251 { |
|
1252 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_CONTEXTMANUTRIGGERED_ENTRY ); |
|
1253 |
|
1254 if (action->text() == hbTrId("txt_common_menu_open")) { |
|
1255 viewEntry(); |
|
1256 } else if (action->text() == hbTrId("txt_calendar_menu_mark_as_done")) { |
|
1257 markAsDone(); |
|
1258 } else if (action->text() == hbTrId("txt_common_menu_edit")) { |
|
1259 editEntry(); |
|
1260 } else { |
|
1261 if (action->text() == hbTrId("txt_common_menu_delete")) { |
|
1262 deleteEntry(); |
|
1263 } |
|
1264 } |
|
1265 |
|
1266 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_CONTEXTMANUTRIGGERED_EXIT ); |
|
1267 } |
|
1268 // ---------------------------------------------------------------------------- |
|
1269 // CalenAgendaViewWidget::clearListModel |
|
1270 // clears the list model |
|
1271 // ---------------------------------------------------------------------------- |
|
1272 // |
|
1273 void CalenAgendaViewWidget::clearListModel() |
|
1274 { |
|
1275 OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_CLEARLISTMODEL_ENTRY ); |
|
1276 |
|
1277 mListModel->clear(); |
|
1278 |
|
1279 OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_CLEARLISTMODEL_EXIT ); |
|
1280 } |
|
1281 |
|
1282 // ---------------------------------------------------------------------------- |
|
1283 // CalenAgendaViewWidget::hasAllDayIcon |
|
1284 // return true if property for all day icon to set |
|
1285 // ---------------------------------------------------------------------------- |
|
1286 // |
|
1287 bool CalenAgendaViewWidget::hasAllDayIcon() |
|
1288 { |
|
1289 return mIconCheck; |
|
1290 } |
|
1291 |
|
1292 |
|
1293 // ---------------------------------------------------------------------------- |
|
1294 // CalenAgendaViewWidget::checkEntryIcons |
|
1295 // check if all day icon is present |
|
1296 // ---------------------------------------------------------------------------- |
|
1297 // |
|
1298 void CalenAgendaViewWidget::checkEntryIcons() |
|
1299 { |
|
1300 int index = 0; |
|
1301 //check the number of entries |
|
1302 index = mInstanceArray.count(); |
|
1303 // Get each of the entry details |
|
1304 AgendaEntry entry; |
|
1305 if(mIndex < index ) |
|
1306 entry = mInstanceArray[mIndex]; |
|
1307 |
|
1308 mLeftAllDayIcon = false; |
|
1309 |
|
1310 if(!entry.isTimedEntry() || CalenAgendaUtils::isAlldayEvent(entry)){ |
|
1311 //all day icon is not there if its a timed entry |
|
1312 mLeftAllDayIcon = true; |
|
1313 } |
|
1314 |
|
1315 //check if shift to next entry |
|
1316 if(mNextEntry) |
|
1317 mIndex++; |
|
1318 |
|
1319 } |
|
1320 |
|
1321 // ---------------------------------------------------------------------------- |
|
1322 // CalenAgendaViewWidget::isAllDayIcon |
|
1323 // retirn true if all day icon is present |
|
1324 // ---------------------------------------------------------------------------- |
|
1325 // |
|
1326 bool CalenAgendaViewWidget::isAllDayIcon() |
|
1327 { |
|
1328 return mLeftAllDayIcon; |
|
1329 } |
|
1330 |
|
1331 // End of file --Don't remove this. |