calendarui/views/dayview/src/calendayview.cpp
changeset 75 7ac58b2aae6f
parent 70 a5ed90760192
child 81 ce92091cbd61
--- a/calendarui/views/dayview/src/calendayview.cpp	Mon Sep 06 15:58:44 2010 +0530
+++ b/calendarui/views/dayview/src/calendayview.cpp	Mon Sep 20 12:44:39 2010 +0530
@@ -29,6 +29,7 @@
 #include <HbStyleLoader>
 #include <HbGroupBox>
 #include <HbExtendedLocale>
+#include <HbModelIterator>
 #include <agendautil.h>
 
 // User includes
@@ -41,6 +42,7 @@
 #include "calendaycontentscrollarea.h"
 #include "calendaycontentwidget.h"
 #include "calendayhourscrollarea.h"
+#include "calendayitemview.h"
 #include "calendaymodelmanager.h"
 #include "CalenUid.h"
 #include "CalendarPrivateCRKeys.h"
@@ -70,8 +72,9 @@
     mSettingsManager = new XQSettingsManager(this);
     mSettingsManager->startMonitoring(mRegionalInfoKey);
 
-    //setup Back functionality
-    if (ECalenDayView != mServices.getFirstView()) {
+    //setup Back functionality, launch the month view only when it is
+	// the first view
+    if (ECalenMonthView == mServices.getFirstView()) {
         HbAction* action = new HbAction(Hb::BackNaviAction, this);
         setNavigationAction(action);
         // Connect to the signal triggered by clicking on back button.
@@ -208,9 +211,10 @@
         = static_cast<CalenDayContentScrollArea *> (mDocLoader->findWidget(
             CALEN_DAYVIEW_CONTENTSCROLLAREA));
     // Pass parent object to mContentWidget to install event filters on parent
-    mContentWidget = new CalenDayContentWidget(*mModelManager, mContentScrollArea);
+    mContentWidget = new CalenDayContentWidget(mContentScrollArea);
     mContentScrollArea->setContentWidget(mContentWidget);
-
+    
+    initializeViews();
     setupSlots();
     
     // Set up regional info if variant is correct
@@ -356,6 +360,57 @@
 }
 
 /*!
+   \brief Initializes internal views.
+   
+   CalenDayView uses 3 child views which represent previous, current and next days.
+   This assures that swiping to prev/next day works smoothly, because population
+   of data is done earlier.
+*/
+void CalenDayView::initializeViews()
+{
+    // Create item views
+    HbModelIterator *iterator(0);
+
+    iterator = new HbModelIterator(&mModelManager->getModel(
+        CalenDayModelManager::PreviousDay));
+    CalenDayItemView *prevItemView = new CalenDayItemView(
+        mModelManager->getServices(), iterator, 0);
+
+    iterator = new HbModelIterator(&mModelManager->getModel(
+        CalenDayModelManager::CurrentDay));
+    CalenDayItemView *currItemView = new CalenDayItemView(
+        mModelManager->getServices(), iterator, 0);
+
+    iterator = new HbModelIterator(&mModelManager->getModel(
+        CalenDayModelManager::NextDay));
+    CalenDayItemView *nextItemView = new CalenDayItemView(
+        mModelManager->getServices(), iterator, 0);
+
+    // Connect views with widgetScrolled SLOT to support simultanous vertical scrolling
+    connect(prevItemView, SIGNAL(scrollPositionChanged(const QPointF&)), mContentWidget,
+        SLOT(widgetScrolled(const QPointF&)));
+    connect(currItemView, SIGNAL(scrollPositionChanged(const QPointF&)), mContentWidget,
+        SLOT(widgetScrolled(const QPointF&)));
+    connect(nextItemView, SIGNAL(scrollPositionChanged(const QPointF&)), mContentWidget,
+        SLOT(widgetScrolled(const QPointF&)));
+    
+    // Close menu once closeDialogs() is received
+    connect(this, SIGNAL(closeDialogs()), prevItemView->contextMenu(), SLOT(close()));
+    connect(this, SIGNAL(closeDialogs()), currItemView->contextMenu(), SLOT(close()));
+    connect(this, SIGNAL(closeDialogs()), nextItemView->contextMenu(), SLOT(close()));
+
+    // Install event filters to receive events necessary for gesture handling
+    prevItemView->installEventFilter(mContentScrollArea);
+    currItemView->installEventFilter(mContentScrollArea);
+    nextItemView->installEventFilter(mContentScrollArea);
+
+    // Add views to layout
+    mContentWidget->add(prevItemView);
+    mContentWidget->add(currItemView);
+    mContentWidget->add(nextItemView);
+}
+
+/*!
    \brief This slot triggers new meeting creation view
 */
 void CalenDayView::runNewMeeting()