25 #include <hbaction.h> |
25 #include <hbaction.h> |
26 #include <hbmainwindow.h> |
26 #include <hbmainwindow.h> |
27 #include <hbstyleloader.h> |
27 #include <hbstyleloader.h> |
28 #include <hbdatetimepicker.h> |
28 #include <hbdatetimepicker.h> |
29 #include <hbdialog.h> |
29 #include <hbdialog.h> |
|
30 #include <xqsettingsmanager.h> |
30 #include <agendautil.h> |
31 #include <agendautil.h> |
31 #include <noteseditor.h> |
32 #include <noteseditor.h> |
32 |
33 |
33 // User includes |
34 // User includes |
34 #include "calendayviewwidget.h" |
35 #include "calendayviewwidget.h" |
38 #include "calenservices.h" |
39 #include "calenservices.h" |
39 #include "calencontext.h" |
40 #include "calencontext.h" |
40 #include "calendateutils.h" |
41 #include "calendateutils.h" |
41 #include "CalenUid.h" |
42 #include "CalenUid.h" |
42 #include "caleneventlistviewitem.h" |
43 #include "caleneventlistviewitem.h" |
|
44 #include "calenpluginlabel.h" |
|
45 #include "CalendarInternalCRKeys.h" |
43 |
46 |
44 // Constants |
47 // Constants |
45 static const QString singleSpace(" "); |
48 static const QString singleSpace(" "); |
46 static const QString newLine("\n"); |
49 static const QString newLine("\n"); |
47 static const QString customLayout("custom"); |
50 static const QString customLayout("custom"); |
58 // ---------------------------------------------------------------------------- |
61 // ---------------------------------------------------------------------------- |
59 // CalenDayViewWidget::CalenDayViewWidget |
62 // CalenDayViewWidget::CalenDayViewWidget |
60 // Rest of the details are commented in the header |
63 // Rest of the details are commented in the header |
61 // ---------------------------------------------------------------------------- |
64 // ---------------------------------------------------------------------------- |
62 // |
65 // |
63 CalenDayViewWidget::CalenDayViewWidget(MCalenServices &services, |
66 EXPORT_C CalenDayViewWidget::CalenDayViewWidget(MCalenServices &services, |
64 CalenDocLoader *docLoader) : |
67 CalenDocLoader *docLoader) : |
65 mServices(services), |
68 mServices(services), |
66 mDocLoader(docLoader) |
69 mDocLoader(docLoader), |
|
70 mRegionalInfoGroupBox(NULL) |
67 { |
71 { |
68 // Construct the list view prototype |
72 // Construct the list view prototype |
69 mListViewPrototype = new CalenEventListViewItem(this); |
73 mListViewPrototype = new CalenEventListViewItem(this); |
70 |
74 |
71 // Create the list model |
75 // Create the list model |
72 mListModel = new QStandardItemModel(this); |
76 mListModel = new QStandardItemModel(this); |
73 |
77 |
74 // Register the custom docml and css to provide our own style to the list items |
78 // Register the custom docml and css to provide our own style to the list items |
75 HbStyleLoader::registerFilePath(":/"); |
79 HbStyleLoader::registerFilePath(":/"); |
|
80 |
|
81 //Create the setting manager |
|
82 mSettingsManager = new XQSettingsManager(this); |
76 } |
83 } |
77 |
84 |
78 // ---------------------------------------------------------------------------- |
85 // ---------------------------------------------------------------------------- |
79 // CalenDayViewWidget::~CalenDayViewWidget |
86 // CalenDayViewWidget::~CalenDayViewWidget |
80 // Rest of the details are commented in the header |
87 // Rest of the details are commented in the header |
81 // ---------------------------------------------------------------------------- |
88 // ---------------------------------------------------------------------------- |
82 // |
89 // |
83 CalenDayViewWidget::~CalenDayViewWidget() |
90 EXPORT_C CalenDayViewWidget::~CalenDayViewWidget() |
84 { |
91 { |
85 if (mListViewPrototype) { |
92 if (mListViewPrototype) { |
86 delete mListViewPrototype; |
93 delete mListViewPrototype; |
87 mListViewPrototype = NULL; |
94 mListViewPrototype = NULL; |
88 } |
95 } |
124 // Set the heading text |
131 // Set the heading text |
125 setHeadingText(); |
132 setHeadingText(); |
126 |
133 |
127 // Get the instance list |
134 // Get the instance list |
128 getInstanceList(); |
135 getInstanceList(); |
|
136 |
|
137 // Check if regional information needs to be shown |
|
138 // and add it or remove it |
|
139 showHideRegionalInformation(); |
129 |
140 |
130 // Load the appropriate section based on the number of events for the day |
141 // Load the appropriate section based on the number of events for the day |
131 if (0 == mInstanceArray.count()) { |
142 if (0 == mInstanceArray.count()) { |
132 // There are no entries for the day |
143 // There are no entries for the day |
133 // Load and show the empty list section |
144 // Load and show the empty list section |
293 // Get the pointer to the empty view label |
304 // Get the pointer to the empty view label |
294 mEmptyListLabel = qobject_cast<HbLabel*> (mDocLoader->findWidget("noEventsLabel")); |
305 mEmptyListLabel = qobject_cast<HbLabel*> (mDocLoader->findWidget("noEventsLabel")); |
295 if (!mEmptyListLabel) { |
306 if (!mEmptyListLabel) { |
296 qFatal("calendayviewwidget.cpp : Unable to find empty list label"); |
307 qFatal("calendayviewwidget.cpp : Unable to find empty list label"); |
297 } |
308 } |
|
309 HbWidget *headingPluginWidget = |
|
310 qobject_cast<HbWidget*> (mDocLoader->findWidget(CALEN_DAYVIEW_HEADING_REGIONALPLUGIN_WIDGET)); |
|
311 |
|
312 mRegionalPluginLayout = static_cast<QGraphicsLinearLayout*>(headingPluginWidget->layout()); |
|
313 |
298 } |
314 } |
299 |
315 |
300 // ---------------------------------------------------------------------------- |
316 // ---------------------------------------------------------------------------- |
301 // CalenDayViewWidget::populateListWidget |
317 // CalenDayViewWidget::populateListWidget |
302 // Rest of the details are commented in the header |
318 // Rest of the details are commented in the header |
370 // There are no events to populate |
386 // There are no events to populate |
371 // Hide the events list |
387 // Hide the events list |
372 mEventsList->hide(); |
388 mEventsList->hide(); |
373 // Show the empty list text |
389 // Show the empty list text |
374 mEmptyListLabel->show(); |
390 mEmptyListLabel->show(); |
375 // Inform the view about the change |
|
376 mView->hasEvents(false); |
|
377 return; |
391 return; |
378 } else { |
|
379 mView->hasEvents(true); |
|
380 } |
392 } |
381 } |
393 } |
382 |
394 |
383 // ---------------------------------------------------------------------------- |
395 // ---------------------------------------------------------------------------- |
384 // CalenDayViewWidget::setDateToLabel |
396 // CalenDayViewWidget::setDateToLabel |
474 // will get replaced in this icon's position |
486 // will get replaced in this icon's position |
475 iconData << QVariant(); |
487 iconData << QVariant(); |
476 } |
488 } |
477 |
489 |
478 HbExtendedLocale locale = HbExtendedLocale::system(); |
490 HbExtendedLocale locale = HbExtendedLocale::system(); |
479 // Get the start time and format as per the locale |
491 // Get the start time and format as per the locale |
480 QTime eventStartTime = entry.startTime().time(); |
492 QDateTime startTime = entry.startTime(); |
|
493 QTime eventStartTime; |
|
494 |
|
495 if (CalenDateUtils::beginningOfDay(startTime) |
|
496 < CalenDateUtils::beginningOfDay(mDate)) { |
|
497 // event is started previous day, show StarTime as 12:00 am in Agendaview, |
|
498 eventStartTime.setHMS(00, 00, 00); |
|
499 } else { |
|
500 eventStartTime = entry.startTime().time(); |
|
501 } |
481 QString eventTime = locale.format(eventStartTime, r_qtn_time_usual_with_zero); |
502 QString eventTime = locale.format(eventStartTime, r_qtn_time_usual_with_zero); |
482 |
503 |
483 // Get the event end time |
504 // Get the event end time |
484 QTime eventEndTime = entry.endTime().time(); |
505 QDateTime endTime = entry.endTime(); |
|
506 QTime eventEndTime; |
|
507 |
|
508 if (CalenDateUtils::beginningOfDay(endTime) |
|
509 > CalenDateUtils::beginningOfDay(mDate)) { |
|
510 // event has MidNight crossover, show EndTime as 11:59pm in Agendaview, |
|
511 eventEndTime.setHMS(23, 59, 59); |
|
512 } else { |
|
513 eventEndTime = entry.endTime().time(); |
|
514 } |
485 |
515 |
486 if (eventStartTime < eventEndTime) { |
516 if (eventStartTime < eventEndTime) { |
487 // Raise the flag to indicate that the list item |
517 // Raise the flag to indicate that the list item |
488 // would wrap to two lines |
518 // would wrap to two lines |
489 twoLines = true; |
519 twoLines = true; |
772 } |
802 } |
773 return scrollIndex; |
803 return scrollIndex; |
774 } |
804 } |
775 |
805 |
776 // ---------------------------------------------------------------------------- |
806 // ---------------------------------------------------------------------------- |
|
807 // CalenDayViewWidget::showHideRegionalInformation |
|
808 // To Show and hide regional plugin label depends upon settings |
|
809 // ---------------------------------------------------------------------------- |
|
810 // |
|
811 void CalenDayViewWidget::showHideRegionalInformation() |
|
812 { |
|
813 XQSettingsKey regionalInfo(XQSettingsKey::TargetCentralRepository, |
|
814 KCRUidCalendar.iUid, KShowRegionalInformation); |
|
815 |
|
816 int showRegionalInfo = mSettingsManager->readItemValue(regionalInfo).toUInt(); |
|
817 if (showRegionalInfo) { |
|
818 |
|
819 if (!mRegionalInfoGroupBox) { |
|
820 mRegionalInfoGroupBox = new HbGroupBox(); |
|
821 CalenPluginLabel *regionalInfo = new CalenPluginLabel( |
|
822 mServices, this); |
|
823 mRegionalInfoGroupBox->setContentWidget(regionalInfo); |
|
824 mRegionalPluginLayout->insertItem(1, mRegionalInfoGroupBox); |
|
825 } |
|
826 |
|
827 if (mView->pluginEnabled()) { |
|
828 QString *pluginString = mView->pluginText(); |
|
829 HbLabel *pluginInfoLabel = qobject_cast <HbLabel *> |
|
830 (mRegionalInfoGroupBox->contentWidget()); |
|
831 pluginInfoLabel->setPlainText(*pluginString); |
|
832 } |
|
833 } else { |
|
834 if (mRegionalInfoGroupBox) { |
|
835 mRegionalPluginLayout->removeItem(mRegionalInfoGroupBox); |
|
836 delete mRegionalInfoGroupBox; |
|
837 mRegionalInfoGroupBox = NULL; |
|
838 } |
|
839 } |
|
840 } |
|
841 |
|
842 // ---------------------------------------------------------------------------- |
777 // CalenDayViewWidget::createNewEvent |
843 // CalenDayViewWidget::createNewEvent |
778 // Rest of the details are commented in the header |
844 // Rest of the details are commented in the header |
779 // ---------------------------------------------------------------------------- |
845 // ---------------------------------------------------------------------------- |
780 // |
846 // |
781 void CalenDayViewWidget::createNewEvent() |
847 void CalenDayViewWidget::createNewEvent() |
980 } |
1046 } |
981 |
1047 |
982 // Set the context for the current day |
1048 // Set the context for the current day |
983 mServices.Context().setFocusDateL(CalenDateUtils::today(), KCalenDayViewUidValue); |
1049 mServices.Context().setFocusDateL(CalenDateUtils::today(), KCalenDayViewUidValue); |
984 |
1050 |
985 // Issue a command to re-populate the entire view |
1051 mView->refreshViewOnGoToDate(); |
986 mServices.IssueCommandL(ECalenStartActiveStep); |
|
987 } |
|
988 |
|
989 // ---------------------------------------------------------------------------- |
|
990 // CalenDayViewWidget::deleteEntries |
|
991 // Rest of the details are commented in the header |
|
992 // ---------------------------------------------------------------------------- |
|
993 // |
|
994 void CalenDayViewWidget::deleteEntries() |
|
995 { |
|
996 // TODO: Show a checklist to allow multiple delete |
|
997 } |
1052 } |
998 |
1053 |
999 // End of file --Don't remove this. |
1054 // End of file --Don't remove this. |