calendarui/views/dayview/src/calendayitemview.cpp
changeset 77 b0711afde476
parent 68 a5a1242fd2e8
child 80 fa7c359294fa
equal deleted inserted replaced
68:a5a1242fd2e8 77:b0711afde476
     1 /*
     1 /*
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     8  *
     9 * Initial Contributors:
     9  * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11 *
    11  *
    12 * Contributors:
    12  * Contributors:
    13 *
    13  *
    14 * Description:  Day view control of calendar
    14  * Description:  Day view control of calendar
    15 *
    15  *
    16 */
    16  */
    17 
    17 
    18 //System includes
    18 //System includes
    19 #include <QGesture>
    19 #include <QGesture>
    20 #include <QGraphicsLinearLayout>
    20 #include <QGraphicsLinearLayout>
    21 #include <HbAbstractViewItem>
    21 #include <HbAbstractViewItem>
    31 #include "calenservices.h"
    31 #include "calenservices.h"
    32 #include "calencontext.h"
    32 #include "calencontext.h"
    33 #include "calenagendautils.h"
    33 #include "calenagendautils.h"
    34 #include "CalenUid.h"
    34 #include "CalenUid.h"
    35 
    35 
    36 
    36 /*!
    37 /*!
    37  \brief Constructor
    38    \brief Constructor
    38  */
    39 */
    39 CalenDayItemView::CalenDayItemView(
    40 CalenDayItemView::CalenDayItemView( MCalenServices &services, HbModelIterator *iterator, QGraphicsItem *parent ) 
    40     MCalenServices &services,
    41 : HbAbstractItemView(mContainer = new CalenDayContainer(), iterator, parent),
    41     HbModelIterator *iterator,
    42   mServices( services )
    42     QGraphicsItem *parent) :
    43 {
    43     HbAbstractItemView(mContainer = new CalenDayContainer(), iterator, parent),
    44     mInfo = new CalenDayInfo( CalenDayInfo::ETwo );
    44         mServices(services)
    45     mContainer->setDayInfo( mInfo );
    45 {
    46 	
    46     mInfo = new CalenDayInfo(CalenDayInfo::EFour);
       
    47     mContainer->setDayInfo(mInfo);
       
    48 
    47     //setup Selection Model
    49     //setup Selection Model
    48     QItemSelectionModel* selModel = new QItemSelectionModel(this->model());
    50     QItemSelectionModel* selModel = new QItemSelectionModel(this->model());
    49     if ( selModel ) {
    51     if (selModel) {
    50         setSelectionMode( HbAbstractItemView::SingleSelection );
    52         setSelectionMode(HbAbstractItemView::SingleSelection);
    51         setSelectionModel( selModel );
    53         setSelectionModel(selModel);
    52     }
    54     }
    53     
    55 
    54     setScrollDirections(Qt::Vertical);
    56     setScrollDirections(Qt::Vertical);
    55     setScrollingStyle(HbScrollArea::PanWithFollowOn);
    57     setScrollingStyle(HbScrollArea::PanWithFollowOn);
    56     setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff);
    58     setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff);
    57     
    59 
    58     //TODO: KG: Animate item pressed?! HbAbstractItemView::TouchDown
    60     //TODO: KG: Animate item pressed?! HbAbstractItemView::TouchDown
    59     setEnabledAnimations( HbAbstractItemView::None );
    61     setEnabledAnimations(HbAbstractItemView::None);
    60     
    62 
    61     // Get the width of content and fix its size
    63     // Get the width of content and fix its size
    62     qreal contentWidth = CalenDayUtils::instance()->contentWidth();
    64     qreal contentWidth = CalenDayUtils::instance()->contentWidth();
    63     setMinimumWidth(contentWidth);
    65     setMinimumWidth(contentWidth);
    64     setMaximumWidth(contentWidth);
    66     setMaximumWidth(contentWidth);
    65       
    67 
    66     setupSlots();
    68     setupSlots();
    67     setupContextMenu();
    69     setupContextMenu();
    68 }
    70 }
    69 
    71 
    70 /*!
    72 /*!
    71    \brief Destructor
    73  \brief Destructor
    72 */
    74  */
    73 CalenDayItemView::~CalenDayItemView()
    75 CalenDayItemView::~CalenDayItemView()
    74 {
    76 {
    75     delete mInfo;
    77     delete mInfo;
    76 }
    78 }
    77 
    79 
    78 /*!
    80 /*!
    79    \brief Scrolls to given index
    81  \brief Scrolls to given index
    80 */
    82  */
    81 void CalenDayItemView::scrollTo(const QModelIndex &index, HbAbstractItemView::ScrollHint hint)
    83 void CalenDayItemView::scrollTo(
       
    84     const QModelIndex &index,
       
    85     HbAbstractItemView::ScrollHint hint)
    82 {
    86 {
    83     HbAbstractItemView::scrollTo(index, hint);
    87     HbAbstractItemView::scrollTo(index, hint);
    84 }
    88 }
    85 
    89 
    86 /*!
    90 /*!
    87    \brief Currently empty implementation.
    91  \brief Currently empty implementation.
    88 */
    92  */
    89 void CalenDayItemView::reset()
    93 void CalenDayItemView::reset()
    90 {
    94 {
    91 
    95 
    92 }
    96 }
    93 
    97 
    94 
    98 /*!
    95 /*!
    99  \brief Handles signal that is emitted when reset() is called, before the model's
    96    \brief Handles signal that is emitted when reset() is called, before the model's
   100  internal state (e.g. persistent model indexes) has been invalidated.
    97           internal state (e.g. persistent model indexes) has been invalidated.
   101  */
    98 */
       
    99 void CalenDayItemView::modelAboutToBeReset()
   102 void CalenDayItemView::modelAboutToBeReset()
   100 {
   103 {
   101     
   104 
   102 }
   105 }
   103 
   106 
   104 /*!
   107 /*!
   105    \brief Handles signal that is emitted when reset() is called, before the model's
   108  \brief Handles signal that is emitted when reset() is called, before the model's
   106           internal state (e.g. persistent model indexes) has been invalidated.
   109  internal state (e.g. persistent model indexes) has been invalidated.
   107 */
   110  */
   108 void CalenDayItemView::modelReset()
   111 void CalenDayItemView::modelReset()
   109 {
   112 {
   110     if ( !mInfo ) {
   113     if (!mInfo) {
   111         return;
   114         return;
   112     }
   115     }
   113     //reset day info
   116     //reset day info
   114     mInfo->Reset();
   117     mInfo->Reset();
   115 
   118 
   116     CalenDayModel* model(0);
   119     CalenDayModel* model(0);
   117     model = static_cast<CalenDayModel*>(this->model());
   120     model = static_cast<CalenDayModel*> (this->model());
   118     if ( !model ) {
   121     if (!model) {
   119         return;
   122         return;
   120     }
   123     }
   121     
   124 
   122     mContainer->setDate(model->modelDate().date());
   125     mContainer->setDate(model->modelDate().date());
   123     int rowCount = model->rowCount( );
   126     int rowCount = model->rowCount();
   124     SCalenApptInfo apptInfo; 
   127     SCalenApptInfo apptInfo;
   125     for( int row = 0; row < rowCount; row++ ) {
   128     for (int row = 0; row < rowCount; row++) {
   126         QModelIndex idx = model->index( row, 0 );
   129         QModelIndex idx = model->index(row, 0);
   127         QVariant variant = idx.data( CalenDayEntry );
   130         QVariant variant = idx.data(CalenDayEntry);
   128         AgendaEntry entry = variant.value<AgendaEntry>();
   131         AgendaEntry entry = variant.value<AgendaEntry> ();
   129         apptInfo.iIndex = idx;
   132         apptInfo.iIndex = idx;
   130         
   133 
   131         QDateTime start;
   134         QDateTime start;
   132         QDateTime end;
   135         QDateTime end;
   133         QDateTime currDate( model->modelDate() );
   136         QDateTime currDate(model->modelDate());
   134         CalenDayUtils::instance()->getEventValidStartEndTime( start, end, 
   137         CalenDayUtils::instance()->getEventValidStartEndTime(start, end, entry,
   135                                                               entry, currDate );
   138             currDate);
   136 
   139 
   137         apptInfo.iStartTime = start;
   140         apptInfo.iStartTime = start;
   138         apptInfo.iEndTime = end;
   141         apptInfo.iEndTime = end;
   139         
   142 
   140         TCalenInstanceId id = TCalenInstanceId::nullInstanceId();//index.row() - temporary ID
   143         TCalenInstanceId id = TCalenInstanceId::nullInstanceId();//index.row() - temporary ID
   141         id.mEntryLocalUid = row;
   144         id.mEntryLocalUid = row;
   142         id.mInstanceTime = apptInfo.iStartTime; 
   145         id.mInstanceTime = apptInfo.iStartTime;
   143         apptInfo.iId = id;
   146         apptInfo.iId = id;
   144         apptInfo.iColor = 0xffff;
   147         apptInfo.iColor = 0xffff;
   145         
   148 
   146         if ( entry.isTimedEntry() && !CalenAgendaUtils::isAlldayEvent(entry))
   149         if (entry.isTimedEntry() && !CalenAgendaUtils::isAlldayEvent(entry)) {
   147         	{
       
   148             apptInfo.iAllDay = false;
   150             apptInfo.iAllDay = false;
   149             mInfo->InsertTimedEvent( apptInfo );
   151             mInfo->InsertTimedEvent(apptInfo);
   150         	}
   152         }
   151         else if(CalenAgendaUtils::isAlldayEvent(entry)) //all-day event
   153         else
   152         	{
   154             if (CalenAgendaUtils::isAlldayEvent(entry)) //all-day event
   153         	apptInfo.iAllDay = true;
   155             {
   154         	mInfo->InsertAlldayEvent( apptInfo );
   156                 apptInfo.iAllDay = true;
   155         	}
   157                 mInfo->InsertAlldayEvent(apptInfo);
   156     }
   158             }
   157     
   159     }
       
   160 
   158     HbAbstractItemView::reset();
   161     HbAbstractItemView::reset();
   159 }
   162 }
   160 
   163 
   161 /*!
   164 /*!
   162    \brief Scrolls view vertically to the given position.
   165  \brief Scrolls view vertically to the given position.
   163    
   166  
   164    \param newPosition position to scroll to.
   167  \param newPosition position to scroll to.
   165 */
   168  */
   166 void CalenDayItemView::scrollVertically( const QPointF &newPosition )
   169 void CalenDayItemView::scrollVertically(const QPointF &newPosition)
   167 {
   170 {
   168     QPointF currentPos = contentWidget()->pos();
   171     QPointF currentPos = contentWidget()->pos();
   169     if (abs(newPosition.y()) != abs(currentPos.y())) {
   172     if (abs(newPosition.y()) != abs(currentPos.y())) {
   170         currentPos.setY(newPosition.y());
   173         currentPos.setY(newPosition.y());
   171         scrollContentsTo(currentPos, 0);
   174         scrollContentsTo(currentPos, 0);
   172     }
   175     }
   173 }
   176 }
   174 
   177 
   175 /*!
   178 /*!
   176    \brief This function is called when a touch press event is received 
   179  \brief This function is called when a touch press event is received 
   177           within Abstract view item that is representing index.
   180  within Abstract view item that is representing index.
   178           Currently it does nothing.
   181  Currently it does nothing.
   179 */
   182  */
   180 void CalenDayItemView::itemPressed( const QPointF &position )
   183 void CalenDayItemView::itemPressed(const QModelIndex &index)
   181 {
   184 {
   182     Q_UNUSED( position )
   185     Q_UNUSED( index )
   183 }
   186 }
   184 
   187 
   185 /*!
   188 /*!
   186    \brief This function is called when a touch release event is received 
   189  \brief This function is called when a touch release event is received 
   187           within Abstract view item that is representing index.
   190  within Abstract view item that is representing index.
   188           Currently it does nothing.
   191  Currently it does nothing.
   189 */
   192  */
   190 void CalenDayItemView::itemReleased( const QPointF &position )
   193 void CalenDayItemView::itemReleased(const QModelIndex &index)
   191 {
   194 {
   192     Q_UNUSED( position )
   195     Q_UNUSED( index )
   193 }
   196 }
   194 
   197 
   195 /*!
   198 /*!
   196    \brief This function is called when the item specified by index is activated by the user.
   199  \brief This function is called when the item specified by index is activated by the user.
   197    
   200  
   198    \param position Not used.
   201  \param position Not used.
   199 */
   202  */
   200 void CalenDayItemView::itemActivated( const QPointF &position )
   203 void CalenDayItemView::itemActivated(const QModelIndex &index)
   201 {
   204 {
   202     Q_UNUSED( position )
   205     QItemSelectionModel* selModel(selectionModel());
   203     HbAbstractViewItem *item = qobject_cast<HbAbstractViewItem *>(sender());
   206     if (index.isValid() && selModel) {
       
   207         selModel->select(index, QItemSelectionModel::Current
       
   208             | QItemSelectionModel::Select);
       
   209         openSelectedItem();
       
   210     }
       
   211 }
       
   212 
       
   213 /*!
       
   214  \brief This function is called when long press event is received within Abstract view item viewItem.
       
   215 
       
   216  \param item Pointer to pressed item.
       
   217  \param coord Position where item was pressed.
       
   218  */
       
   219 void CalenDayItemView::itemLongPressed(HbAbstractViewItem* item, QPointF coords)
       
   220 {
   204     QModelIndex index = item->modelIndex();
   221     QModelIndex index = item->modelIndex();
   205     QItemSelectionModel* selModel( selectionModel() );
   222     QItemSelectionModel* selModel(selectionModel());
   206     if ( index.isValid() && selModel) {
   223     if (index.isValid() && selModel && mContextMenu) {
   207         selModel->select( index, QItemSelectionModel::Current | QItemSelectionModel::Select );
   224         selModel->select(index, QItemSelectionModel::Current
   208         openSelectedItem();
   225             | QItemSelectionModel::Select);
   209     }
   226         mContextMenu->setPreferredPos(coords, HbPopup::BottomRightCorner);
   210 }
       
   211 
       
   212 /*!
       
   213    \brief This function is called when long press event is received within Abstract view item viewItem.
       
   214 
       
   215    \param item Pointer to pressed item.
       
   216    \param coord Position where item was pressed.
       
   217 */
       
   218 void CalenDayItemView::itemLongPressed(HbAbstractViewItem* item, QPointF coords)
       
   219 {
       
   220     QModelIndex index = item->modelIndex();
       
   221     QItemSelectionModel* selModel( selectionModel() );
       
   222     if ( index.isValid() && selModel && mContextMenu) {
       
   223         selModel->select( index, QItemSelectionModel::Current | QItemSelectionModel::Select );
       
   224         mContextMenu->setPreferredPos( coords, HbPopup::BottomRightCorner );
       
   225         mContextMenu->open();
   227         mContextMenu->open();
   226     }
   228     }
   227 }
   229 }
   228 
   230 
   229 /*!
   231 /*!
   230    \brief Slot which is called whenever the orientation of the device changes.
   232  \brief Slot which is called whenever the orientation of the device changes.
   231 
   233 
   232    \param orientation New orientation.
   234  \param orientation New orientation.
   233 */
   235  */
   234 void CalenDayItemView::orientationChanged( Qt::Orientation orientation )
   236 void CalenDayItemView::orientationChanged(Qt::Orientation orientation)
   235 {
   237 {
   236     // Update the width of screen
   238     // Update the width of screen
   237     qreal contentWidth = CalenDayUtils::instance()->contentWidth();
   239     qreal contentWidth = CalenDayUtils::instance()->contentWidth();
   238     setMinimumWidth(contentWidth);
   240     setMinimumWidth(contentWidth);
   239     setMaximumWidth(contentWidth);
   241     setMaximumWidth(contentWidth);
   240     if( mContainer ) {
   242     if (mContainer) {
   241         mContainer->orientationChanged( orientation );
   243         mContainer->orientationChanged(orientation);
   242     }
   244     }
   243 }
   245 }
   244 
   246 
   245 /*!
   247 /*!
   246    \brief Opens currently selected model item.
   248  \brief Opens currently selected model item.
   247 */
   249  */
   248 void CalenDayItemView::openSelectedItem()
   250 void CalenDayItemView::openSelectedItem()
   249 {
   251 {
   250     issueCommandOnSelectedItem( ECalenEventView );
   252     issueCommandOnSelectedItem(ECalenEventView);
   251 }
   253 }
   252 
   254 
   253 /*!
   255 /*!
   254    \brief Edits currently selected model item.
   256  \brief Edits currently selected model item.
   255 */
   257  */
   256 void CalenDayItemView::editSelectedItem()
   258 void CalenDayItemView::editSelectedItem()
   257 {
   259 {
   258     issueCommandOnSelectedItem( ECalenEditCurrentEntry );
   260     issueCommandOnSelectedItem(ECalenEditCurrentEntry);
   259 }
   261 }
   260 
   262 
   261 /*!
   263 /*!
   262    \brief Deletes currently selected model item.
   264  \brief Deletes currently selected model item.
   263 */
   265  */
   264 void CalenDayItemView::deleteSelectedItem()
   266 void CalenDayItemView::deleteSelectedItem()
   265 {
   267 {
   266     issueCommandOnSelectedItem( ECalenDeleteCurrentEntry );
   268     issueCommandOnSelectedItem(ECalenDeleteCurrentEntry);
   267 }
   269 }
   268 
   270 
   269 /*!
   271 /*!
   270    \brief Connects item view's slots.
   272  \brief Connects item view's slots.
   271 */
   273  */
   272 void CalenDayItemView::setupSlots()
   274 void CalenDayItemView::setupSlots()
   273 {
   275 {
   274     // Connect to main window's orientationChanged signal to handle orientation
   276     // Connect to main window's orientationChanged signal to handle orientation
   275     // switching
   277     // switching
   276     QObject::connect(CalenDayUtils::instance()->mainWindow(), 
   278     QObject::connect(CalenDayUtils::instance()->mainWindow(),
   277         SIGNAL(orientationChanged(Qt::Orientation)), this,
   279         SIGNAL(orientationChanged(Qt::Orientation)), this,
   278         SLOT(orientationChanged(Qt::Orientation)));
   280         SLOT(orientationChanged(Qt::Orientation)));
   279 
   281 
   280     // Connect with model signals
   282     // Connect with model signals
   281     if (this->model()) {
   283     if (this->model()) {
   287     if (mContainer) {
   289     if (mContainer) {
   288         // Connect with base class to enable handling item press by model index
   290         // Connect with base class to enable handling item press by model index
   289         QObject::connect(mContainer, SIGNAL(itemCreated(HbAbstractViewItem *)),
   291         QObject::connect(mContainer, SIGNAL(itemCreated(HbAbstractViewItem *)),
   290             this, SLOT(itemCreated(HbAbstractViewItem*)));
   292             this, SLOT(itemCreated(HbAbstractViewItem*)));
   291     }
   293     }
   292     QObject::connect(this, SIGNAL(pressed(const QPointF&)), this,
   294     QObject::connect(this, SIGNAL(pressed(const QModelIndex&)), this,
   293         SLOT(itemPressed(const QPointF&)));
   295         SLOT(itemPressed(const QModelIndex&)));
   294     QObject::connect(this, SIGNAL(released(const QPointF&)), this,
   296     QObject::connect(this, SIGNAL(released(const QModelIndex&)), this,
   295         SLOT(itemReleased(const QPointF&)));
   297         SLOT(itemReleased(const QModelIndex&)));
   296     QObject::connect(this, SIGNAL(activated(const QPointF&)), this,
   298     QObject::connect(this, SIGNAL(activated(const QModelIndex&)), this,
   297         SLOT(const QPointF&));
   299         SLOT(itemActivated(const QModelIndex&)));
   298     QObject::connect(this, SIGNAL(longPressed(HbAbstractViewItem*, QPointF)),
   300     QObject::connect(this, SIGNAL(longPressed(HbAbstractViewItem*, QPointF)),
   299         this, SLOT(itemLongPressed(HbAbstractViewItem*, QPointF)));
   301         this, SLOT(itemLongPressed(HbAbstractViewItem*, QPointF)));
   300 }
   302 }
   301 
   303 
   302 /*!
   304 /*!
   303    \brief Creates context menu.
   305  \brief Creates context menu.
   304 */
   306  */
   305 void CalenDayItemView::setupContextMenu()
   307 void CalenDayItemView::setupContextMenu()
   306 {
   308 {
   307     mContextMenu = new HbMenu();
   309     mContextMenu = new HbMenu();
   308     HbAction *openAction = mContextMenu->addAction(hbTrId("txt_common_menu_open"));
   310     HbAction *openAction = mContextMenu->addAction(hbTrId(
       
   311         "txt_common_menu_open"));
   309     if (openAction) {
   312     if (openAction) {
   310         connect(openAction, SIGNAL(triggered()), this, SLOT(openSelectedItem()));
   313         connect(openAction, SIGNAL(triggered()), this, SLOT(openSelectedItem()));
   311     }
   314     }
   312     HbAction *editAction = mContextMenu->addAction(hbTrId("txt_common_menu_edit"));
   315     HbAction *editAction = mContextMenu->addAction(hbTrId(
       
   316         "txt_common_menu_edit"));
   313     if (editAction) {
   317     if (editAction) {
   314         connect(editAction, SIGNAL(triggered()), this, SLOT(editSelectedItem()));
   318         connect(editAction, SIGNAL(triggered()), this, SLOT(editSelectedItem()));
   315     }
   319     }
   316     HbAction *deleteAction = mContextMenu->addAction(hbTrId("txt_common_menu_delete"));
   320     HbAction *deleteAction = mContextMenu->addAction(hbTrId(
       
   321         "txt_common_menu_delete"));
   317     if (deleteAction) {
   322     if (deleteAction) {
   318         connect(deleteAction, SIGNAL(triggered()), this,
   323         connect(deleteAction, SIGNAL(triggered()), this,
   319             SLOT(deleteSelectedItem()));
   324             SLOT(deleteSelectedItem()));
   320     }
   325     }
   321 }
   326 }
   322 
   327 
   323 /*!
   328 /*!
   324    \brief Sets context to currently selected model item and issues calendar command.
   329  \brief Sets context to currently selected model item and issues calendar command.
   325    
   330  
   326    \param command A command to be issued.
   331  \param command A command to be issued.
   327 */
   332  */
   328 bool CalenDayItemView::issueCommandOnSelectedItem( int command )
   333 bool CalenDayItemView::issueCommandOnSelectedItem(int command)
   329 {
   334 {
   330     bool retVal(false);
   335     bool retVal(false);
   331     QItemSelectionModel* selModel(selectionModel());
   336     QItemSelectionModel* selModel(selectionModel());
   332     if (!selModel){
   337     if (!selModel) {
   333         return retVal;
   338         return retVal;
   334     }
   339     }
   335     QModelIndex index( selModel->currentIndex() );
   340     QModelIndex index(selModel->currentIndex());
   336     if( index.isValid() ) {
   341     if (index.isValid()) {
   337         retVal = true;
   342         retVal = true;
   338         QVariant variant = index.data( CalenDayEntry );
   343         QVariant variant = index.data(CalenDayEntry);
   339         AgendaEntry entry = variant.value<AgendaEntry>();
   344         AgendaEntry entry = variant.value<AgendaEntry> ();
   340         QDateTime start;
   345         QDateTime start;
   341         QDateTime end;
   346         QDateTime end;
   342         CalenDayModel* model(0);
   347         CalenDayModel* model(0);
   343         model = static_cast<CalenDayModel*>(this->model());
   348         model = static_cast<CalenDayModel*> (this->model());
   344         QDateTime currDate( model->modelDate() );
   349         QDateTime currDate(model->modelDate());
   345         CalenDayUtils::instance()->getEventValidStartEndTime( start, end, 
   350         CalenDayUtils::instance()->getEventValidStartEndTime(start, end, entry,
   346                                                               entry, currDate );
   351             currDate);
   347         TRAPD(error,
   352         TRAPD(error,
   348                 mServices.Context().setFocusDateAndTimeAndInstance(start,
   353             mServices.Context().setFocusDateAndTimeAndInstance(start,
   349                          TCalenInstanceId::create(entry));
   354                 TCalenInstanceId::create(entry));
   350                 mServices.IssueCommandL( command );
   355             mServices.IssueCommandL( command );
   351               );
   356         );
   352         if( error ) {
   357         if (error) {
   353             retVal = false;
   358             retVal = false;
   354         }
   359         }
   355         clearSelectionInModel();
   360         clearSelectionInModel();
   356     }
   361     }
   357     return retVal;
   362     return retVal;
   358 }
   363 }
   359 
   364 
   360 /*!
   365 /*!
   361    \brief Clears current selection in Selection Model.
   366  \brief Clears current selection in Selection Model.
   362 */
   367  */
   363 void CalenDayItemView::clearSelectionInModel()
   368 void CalenDayItemView::clearSelectionInModel()
   364 {
   369 {
   365     QItemSelectionModel* selModel(selectionModel());
   370     QItemSelectionModel* selModel(selectionModel());
   366     if (selModel) {
   371     if (selModel) {
   367         selModel->clear();
   372         selModel->clear();