calendarui/views/dayview/src/calendayitemview.cpp
changeset 58 ef813d54df51
parent 50 579cc610882e
child 68 a5a1242fd2e8
--- a/calendarui/views/dayview/src/calendayitemview.cpp	Tue Jul 06 14:14:56 2010 +0300
+++ b/calendarui/views/dayview/src/calendayitemview.cpp	Wed Aug 18 09:47:38 2010 +0300
@@ -30,14 +30,13 @@
 #include "calendaymodel.h"
 #include "calenservices.h"
 #include "calencontext.h"
+#include "calenagendautils.h"
 #include "CalenUid.h"
 
 
-// -----------------------------------------------------------------------------
-// CalenDayItemView()
-// Constructor
-// -----------------------------------------------------------------------------
-//
+/*!
+   \brief Constructor
+*/
 CalenDayItemView::CalenDayItemView( MCalenServices &services, HbModelIterator *iterator, QGraphicsItem *parent ) 
 : HbAbstractItemView(mContainer = new CalenDayContainer(), iterator, parent),
   mServices( services )
@@ -71,53 +70,44 @@
     setupContextMenu();
 }
 
-// -----------------------------------------------------------------------------
-// ~CalenDayItemView()
-// Destructor
-// -----------------------------------------------------------------------------
-//
+/*!
+   \brief Destructor
+*/
 CalenDayItemView::~CalenDayItemView()
 {
     delete mInfo;
 }
 
-// -----------------------------------------------------------------------------
-// scrollTo()
-// 
-// -----------------------------------------------------------------------------
-//
+/*!
+   \brief Scrolls to given index
+*/
 void CalenDayItemView::scrollTo(const QModelIndex &index, HbAbstractItemView::ScrollHint hint)
 {
     HbAbstractItemView::scrollTo(index, hint);
 }
 
-// -----------------------------------------------------------------------------
-// reset()
-// 
-// -----------------------------------------------------------------------------
-//
+/*!
+   \brief Currently empty implementation.
+*/
 void CalenDayItemView::reset()
 {
-//    CalenDayItemView::reset();
+
 }
 
-// -----------------------------------------------------------------------------
-// modelAboutToBeReset()
-// Handles signal that is emitted when reset() is called, before the model's
-// internal state (e.g. persistent model indexes) has been invalidated.
-// -----------------------------------------------------------------------------
-//
+
+/*!
+   \brief Handles signal that is emitted when reset() is called, before the model's
+          internal state (e.g. persistent model indexes) has been invalidated.
+*/
 void CalenDayItemView::modelAboutToBeReset()
 {
     
 }
 
-// -----------------------------------------------------------------------------
-// modelReset()
-// Handles signal that is emitted when reset() is called, after the model's
-// internal state (e.g. persistent model indexes) has been invalidated.
-// -----------------------------------------------------------------------------
-//
+/*!
+   \brief Handles signal that is emitted when reset() is called, before the model's
+          internal state (e.g. persistent model indexes) has been invalidated.
+*/
 void CalenDayItemView::modelReset()
 {
     if ( !mInfo ) {
@@ -125,12 +115,14 @@
     }
     //reset day info
     mInfo->Reset();
-    
+
     CalenDayModel* model(0);
     model = static_cast<CalenDayModel*>(this->model());
     if ( !model ) {
         return;
     }
+    
+    mContainer->setDate(model->modelDate().date());
     int rowCount = model->rowCount( );
     SCalenApptInfo apptInfo; 
     for( int row = 0; row < rowCount; row++ ) {
@@ -154,12 +146,12 @@
         apptInfo.iId = id;
         apptInfo.iColor = 0xffff;
         
-        if ( entry.isTimedEntry() )
+        if ( entry.isTimedEntry() && !CalenAgendaUtils::isAlldayEvent(entry))
         	{
             apptInfo.iAllDay = false;
             mInfo->InsertTimedEvent( apptInfo );
         	}
-        else if( entry.type() == AgendaEntry::TypeEvent) //all-day event
+        else if(CalenAgendaUtils::isAlldayEvent(entry)) //all-day event
         	{
         	apptInfo.iAllDay = true;
         	mInfo->InsertAlldayEvent( apptInfo );
@@ -169,11 +161,11 @@
     HbAbstractItemView::reset();
 }
 
-// -----------------------------------------------------------------------------
-// scrollVertically()
-//  
-// -----------------------------------------------------------------------------
-//
+/*!
+   \brief Scrolls view vertically to the given position.
+   
+   \param newPosition position to scroll to.
+*/
 void CalenDayItemView::scrollVertically( const QPointF &newPosition )
 {
     QPointF currentPos = contentWidget()->pos();
@@ -183,31 +175,31 @@
     }
 }
 
-// -----------------------------------------------------------------------------
-// itemPressed()
-// This function is called when a touch down event is received within Abstract view item that is representing index. 
-// -----------------------------------------------------------------------------
-//
+/*!
+   \brief This function is called when a touch press event is received 
+          within Abstract view item that is representing index.
+          Currently it does nothing.
+*/
 void CalenDayItemView::itemPressed( const QPointF &position )
 {
     Q_UNUSED( position )
 }
 
-// -----------------------------------------------------------------------------
-// itemReleased()
-// This function is called when a touch release event is received within Abstract view item that is representing index.
-// -----------------------------------------------------------------------------
-//
+/*!
+   \brief This function is called when a touch release event is received 
+          within Abstract view item that is representing index.
+          Currently it does nothing.
+*/
 void CalenDayItemView::itemReleased( const QPointF &position )
 {
     Q_UNUSED( position )
 }
 
-// -----------------------------------------------------------------------------
-// itemActivated()
-// This function is called when the item specified by index is activated by the user.
-// -----------------------------------------------------------------------------
-//
+/*!
+   \brief This function is called when the item specified by index is activated by the user.
+   
+   \param position Not used.
+*/
 void CalenDayItemView::itemActivated( const QPointF &position )
 {
     Q_UNUSED( position )
@@ -220,11 +212,12 @@
     }
 }
 
-// -----------------------------------------------------------------------------
-// itemLongPressed()
-// This function is called when long press event is received within Abstract view item viewItem.
-// -----------------------------------------------------------------------------
-//
+/*!
+   \brief This function is called when long press event is received within Abstract view item viewItem.
+
+   \param item Pointer to pressed item.
+   \param coord Position where item was pressed.
+*/
 void CalenDayItemView::itemLongPressed(HbAbstractViewItem* item, QPointF coords)
 {
     QModelIndex index = item->modelIndex();
@@ -236,11 +229,11 @@
     }
 }
 
-// -----------------------------------------------------------------------------
-// orientationChanged()
-// Slot which is called whenever the orientation of the device changes.
-// -----------------------------------------------------------------------------
-//
+/*!
+   \brief Slot which is called whenever the orientation of the device changes.
+
+   \param orientation New orientation.
+*/
 void CalenDayItemView::orientationChanged( Qt::Orientation orientation )
 {
     // Update the width of screen
@@ -252,41 +245,33 @@
     }
 }
 
-// -----------------------------------------------------------------------------
-// openSelectedItem()
-// Opens currently selected model item.
-// -----------------------------------------------------------------------------
-//
+/*!
+   \brief Opens currently selected model item.
+*/
 void CalenDayItemView::openSelectedItem()
 {
     issueCommandOnSelectedItem( ECalenEventView );
 }
 
-// -----------------------------------------------------------------------------
-// editSelectedItem()
-// Edits currently selected model item.
-// -----------------------------------------------------------------------------
-//
+/*!
+   \brief Edits currently selected model item.
+*/
 void CalenDayItemView::editSelectedItem()
 {
     issueCommandOnSelectedItem( ECalenEditCurrentEntry );
 }
 
-// -----------------------------------------------------------------------------
-// deleteSelectedIten()
-// Deletes currently selected model item.
-// -----------------------------------------------------------------------------
-//
+/*!
+   \brief Deletes currently selected model item.
+*/
 void CalenDayItemView::deleteSelectedItem()
 {
     issueCommandOnSelectedItem( ECalenDeleteCurrentEntry );
 }
 
-// -----------------------------------------------------------------------------
-// setupSlots()
-// Connects item view's slots.
-// -----------------------------------------------------------------------------
-//
+/*!
+   \brief Connects item view's slots.
+*/
 void CalenDayItemView::setupSlots()
 {
     // Connect to main window's orientationChanged signal to handle orientation
@@ -317,11 +302,9 @@
         this, SLOT(itemLongPressed(HbAbstractViewItem*, QPointF)));
 }
 
-// -----------------------------------------------------------------------------
-// setupSlots()
-// Creates Context menu.
-// -----------------------------------------------------------------------------
-//
+/*!
+   \brief Creates context menu.
+*/
 void CalenDayItemView::setupContextMenu()
 {
     mContextMenu = new HbMenu();
@@ -340,11 +323,11 @@
     }
 }
 
-// -----------------------------------------------------------------------------
-// issueCommandOnSelectedItem()
-// Sets context to currently selected model item and issues calendar command.
-// -----------------------------------------------------------------------------
-//
+/*!
+   \brief Sets context to currently selected model item and issues calendar command.
+   
+   \param command A command to be issued.
+*/
 bool CalenDayItemView::issueCommandOnSelectedItem( int command )
 {
     bool retVal(false);
@@ -377,11 +360,9 @@
     return retVal;
 }
 
-// -----------------------------------------------------------------------------
-// clearSelectionInModel()
-// Clears current selection in Selection Model.
-// -----------------------------------------------------------------------------
-//
+/*!
+   \brief Clears current selection in Selection Model.
+*/
 void CalenDayItemView::clearSelectionInModel()
 {
     QItemSelectionModel* selModel(selectionModel());