calendarui/views/src/calentodoview.cpp
branchRCL_3
changeset 30 bd7edf625bdd
child 31 97232defd20e
equal deleted inserted replaced
29:12af337248b1 30:bd7edf625bdd
       
     1 /*
       
     2 * Copyright (c) 2002-2008 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:  CCalenTodoView is derived from CCalenNativeView.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <calenagendautils.h>
       
    20 #include <calsession.h>
       
    21 #include <calinstance.h>
       
    22 #include <StringLoader.h>
       
    23 #include <centralrepository.h>
       
    24 #include <hlplch.h>
       
    25 #include <eikclb.h>
       
    26 #include <eikmenup.h>
       
    27 #include <sendui.h>
       
    28 #include <featmgr.h>
       
    29 #include <aknbutton.h>
       
    30 #include <akntoolbar.h>
       
    31 #include <Calendar.rsg>
       
    32 #include <calencommonui.rsg>
       
    33 #include <Sendnorm.rsg>
       
    34 #include <calencontext.h>
       
    35 #include <CalenStatusPaneUtils.h>
       
    36 #include <aknnotewrappers.h>
       
    37 #include <calenservices.h>
       
    38 #include <caleninstanceid.h>
       
    39 #include <calenviewutils.h>
       
    40 
       
    41 #include "calendarui_debug.h"
       
    42 #include "calentodoview.h"
       
    43 #include "CalendarPrivateCRKeys.h"  
       
    44 #include "calencontroller.h"
       
    45 #include "calensend.h"
       
    46 #include "calentitlepane.h"
       
    47 #include "calentodocontroller.h"
       
    48 #include "calentodocontainer.h"
       
    49 #include "CalenInterimUtils2.h"
       
    50 #include "CalenUid.h"
       
    51 #include "CalenUid.h"
       
    52 #include "calendar.hrh"
       
    53 #include "multicaluidialog.h"
       
    54 
       
    55 // ================= MEMBER FUNCTIONS =========================================
       
    56 
       
    57 // ----------------------------------------------------------------------------
       
    58 // CCalenTodoView::NewL
       
    59 // Two-phased constructor.
       
    60 // ----------------------------------------------------------------------------
       
    61 //
       
    62 EXPORT_C CCalenTodoView* CCalenTodoView::NewL( MCalenServices& aServices )
       
    63     {
       
    64     TRACE_ENTRY_POINT;
       
    65 
       
    66     CCalenTodoView* self = new( ELeave )CCalenTodoView( aServices );
       
    67     CleanupStack::PushL( self );
       
    68     self->ConstructL();
       
    69     CleanupStack::Pop( self );
       
    70 
       
    71     TRACE_EXIT_POINT;
       
    72     return self;
       
    73     }
       
    74 
       
    75 // ----------------------------------------------------------------------------
       
    76 // CCalenTodoView::ConstructL
       
    77 // Constructor
       
    78 // ----------------------------------------------------------------------------
       
    79 //
       
    80 void CCalenTodoView::ConstructL()
       
    81     {
       
    82     TRACE_ENTRY_POINT;
       
    83 
       
    84     iCountOfSelectedItems = -1;
       
    85     CommonConstructL( R_TODO_LISTVIEW );
       
    86 
       
    87     TRACE_EXIT_POINT;
       
    88     }
       
    89 
       
    90 // ----------------------------------------------------------------------------
       
    91 // CCalenTodoView::CCalenTodoView
       
    92 // C++ constructor.
       
    93 // ----------------------------------------------------------------------------
       
    94 //
       
    95 CCalenTodoView::CCalenTodoView( MCalenServices& aServices )
       
    96     : CCalenNativeView( aServices ),
       
    97       iPopulationStep( ENothingDone )
       
    98     {
       
    99     TRACE_ENTRY_POINT;
       
   100     TRACE_EXIT_POINT;
       
   101     }
       
   102 
       
   103 // ----------------------------------------------------------------------------
       
   104 // CCalenTodoView::~CCalenTodoView
       
   105 // Destructor
       
   106 // ----------------------------------------------------------------------------
       
   107 //
       
   108 CCalenTodoView::~CCalenTodoView()
       
   109     {
       
   110     TRACE_ENTRY_POINT;
       
   111 
       
   112     delete iIdle;
       
   113     if( iCmdCallback )
       
   114         {
       
   115         delete iCmdCallback;
       
   116         }
       
   117     iMarkedInstances.Reset();
       
   118     iMarkedInstances.Close();
       
   119     
       
   120     if(iMarkedTodoItems)
       
   121         {
       
   122         delete iMarkedTodoItems;
       
   123         iMarkedTodoItems = NULL;
       
   124         }
       
   125 
       
   126     TRACE_EXIT_POINT;
       
   127     }
       
   128 
       
   129 // ----------------------------------------------------------------------------
       
   130 // CCalenTodoView::OnCmdDeleteEntryL
       
   131 // Handling command "Delete"
       
   132 // (other items were commented in a header).
       
   133 // ----------------------------------------------------------------------------
       
   134 //
       
   135 void CCalenTodoView::OnCmdDeleteEntryL(void)
       
   136     {
       
   137     TRACE_ENTRY_POINT;
       
   138 
       
   139     const TInt count( Container()->Controller()->Count() );
       
   140     const TInt markCount( Container()->MarkedCount() );
       
   141 
       
   142     if( markCount > 0 )
       
   143         {
       
   144         CreateMultiplecontextForMarkedItemsL(ECalenDeleteEntryWithoutQuery);
       
   145         }
       
   146     else
       
   147         {
       
   148         // Delete the current item.
       
   149         iServices.IssueCommandL( ECalenDeleteCurrentEntry );
       
   150         }
       
   151     TRACE_EXIT_POINT;
       
   152     }
       
   153 
       
   154 // ----------------------------------------------------------------------------
       
   155 // CCalenTodoView::OnLocaleChangedL
       
   156 // This function is called when Locale or Today was changed.
       
   157 // (other items were commented in a header).
       
   158 // ----------------------------------------------------------------------------
       
   159 //
       
   160 void CCalenTodoView::OnLocaleChangedL(TInt aReason)  // Notify reson EChangesLocale | EChangesMidnightCrossover
       
   161     {
       
   162     TRACE_ENTRY_POINT;
       
   163 
       
   164     if (!iContainer)
       
   165         {
       
   166         return;
       
   167         }
       
   168     // FIXME...See examples from day, week and month views
       
   169 
       
   170     // JH although this does the refresh it might not be even needed as we don't have any UI
       
   171     // elements(?) that change after local change.
       
   172     if (IsContainerFocused())
       
   173         {
       
   174 
       
   175         if (!iContainer->IsFocused())
       
   176 
       
   177             {
       
   178             iLocChangeReason = EChangesLocale;
       
   179             }
       
   180         else
       
   181             {
       
   182             if (aReason & EChangesLocale)
       
   183                 {
       
   184                 BeginRepopulationL();
       
   185                 }
       
   186             else
       
   187                 {
       
   188                 RedrawStatusPaneL();
       
   189                 }
       
   190             }
       
   191         }
       
   192     else
       
   193         {
       
   194         iLocChangeReason = EChangesLocale;
       
   195         }
       
   196 
       
   197     TRACE_EXIT_POINT;
       
   198     }
       
   199 
       
   200 // ----------------------------------------------------------------------------
       
   201 // CCalenTodoView::ItemCount
       
   202 // Return number of item.
       
   203 // (other items were commented in a header).
       
   204 // ----------------------------------------------------------------------------
       
   205 //
       
   206 TInt CCalenTodoView::ItemCount()
       
   207     {
       
   208     TRACE_ENTRY_POINT;
       
   209 
       
   210     TRACE_EXIT_POINT;
       
   211     return Container()->Controller()->Count();
       
   212     }
       
   213 
       
   214 // ----------------------------------------------------------------------------
       
   215 // CCalenTodoView::CurrentItemIsCrossOutL
       
   216 // Check cross out of current item.
       
   217 // (other items were commented in a header).
       
   218 // ----------------------------------------------------------------------------
       
   219 //
       
   220 TBool CCalenTodoView::CurrentItemIsCrossOutL()
       
   221     {
       
   222     TRACE_ENTRY_POINT;
       
   223 
       
   224     TBool status( EFalse );
       
   225     TInt index( Container()->CurrentItemIndex() );
       
   226 
       
   227     if( index >= 0 )
       
   228         {
       
   229         status = Container()->Controller()->IsCrossOutL( index );
       
   230         }
       
   231 
       
   232     TRACE_EXIT_POINT;
       
   233     return status;
       
   234     }
       
   235 
       
   236 // ----------------------------------------------------------------------------
       
   237 // CCalenTodoView::SaveCurrentItemIndexL
       
   238 // Save the index of current item.
       
   239 // ----------------------------------------------------------------------------
       
   240 //
       
   241 void CCalenTodoView::SaveCurrentItemIndexL()
       
   242     {
       
   243     TRACE_ENTRY_POINT;
       
   244 
       
   245     TInt index = Container()->CurrentItemIndex();
       
   246 
       
   247     CCalInstance* instance = Container()->Controller()->InstanceL( index );
       
   248 
       
   249     if( index >= 0 && instance )
       
   250         {
       
   251         TCalenInstanceId id = TCalenInstanceId::CreateL( *instance );
       
   252         iServices.Context().SetInstanceIdL( id,
       
   253                                       TVwsViewId( KUidCalendar, KUidCalenTodoView ) );
       
   254 
       
   255         iFirstEntryOnScreenIndex = Container()->ListBox()->TopItemIndex();
       
   256         iHighlightedRowNumber = Container()->ListBox()->CurrentItemIndex();
       
   257         }
       
   258 
       
   259     TRACE_EXIT_POINT;
       
   260     }
       
   261 
       
   262 // ----------------------------------------------------------------------------
       
   263 // CCalenTodoView::Container
       
   264 // Return the container pointer.
       
   265 // ----------------------------------------------------------------------------
       
   266 //
       
   267 CCalenTodoContainer* CCalenTodoView::Container()
       
   268     {
       
   269     TRACE_ENTRY_POINT;
       
   270 
       
   271     TRACE_EXIT_POINT;
       
   272     return static_cast<CCalenTodoContainer*>( iContainer );
       
   273     }
       
   274 
       
   275 // ----------------------------------------------------------------------------
       
   276 // CCalenTodoView::HandleCommandL
       
   277 // Command handling for each view
       
   278 // (other items were commented in a header).
       
   279 // ----------------------------------------------------------------------------
       
   280 //
       
   281 void CCalenTodoView::HandleCommandL( TInt aCommand ) // command ID
       
   282     {
       
   283     TRACE_ENTRY_POINT;
       
   284 
       
   285     switch( aCommand )
       
   286         {
       
   287         // Handle MSK command Open
       
   288         case ECalenViewCurrentEntry:
       
   289         case EAknSoftkeyOpen:
       
   290             SaveCurrentItemIndexL();
       
   291           
       
   292            if(!Container()->IsEmptyView() && !iEventViewCommandHandled)
       
   293                {
       
   294                if(!Container()->MarkedCount())
       
   295                    {
       
   296                    CCalenNativeView::HandleCommandL(ECalenEventView);
       
   297                    iEventViewCommandHandled = ETrue;
       
   298                    break;
       
   299                    }
       
   300                
       
   301                
       
   302                else
       
   303                    {
       
   304                    CListBoxView* listboxview = Container()->ListBox()->View();
       
   305                    TInt index = Container()->CurrentItemIndex();
       
   306                    TBool iselected=listboxview->ItemIsSelected(index);
       
   307 
       
   308                    if( !Container()->Controller()->Count() || iselected )
       
   309                    	{
       
   310                     	 // display the context sensitive menu
       
   311                      	/* CEikMenuBar* menuBar = MenuBar();
       
   312                     	 menuBar->SetContextMenuTitleResourceId( R_TODO_LIST_SELECTION_CONTEXT_MENUBAR );
       
   313                     	 menuBar->TryDisplayContextMenuBarL();
       
   314                     	 */
       
   315                     	 }
       
   316                	   else
       
   317                     	 {
       
   318                     	 CCalenNativeView::HandleCommandL( ECalenEventView );
       
   319                     	 }
       
   320                    }
       
   321                }
       
   322             break;
       
   323         //TODO: will be uncommented with copy to cal functionality.   
       
   324         case ECalenCopyToCalendars:
       
   325             {
       
   326             SaveCurrentItemIndexL();
       
   327             CopyToCalendarsL();
       
   328             }
       
   329             break;
       
   330             
       
   331 #ifdef RD_CALEN_ENHANCED_MSK            
       
   332         case ECalenCmdOpenMskDialog:
       
   333         	CCalenNativeView::HandleCommandL( ECalenNewMeeting );
       
   334         	break;
       
   335 #else
       
   336         case EAknSoftkeyContextOptions:
       
   337             MenuBar()->TryDisplayContextMenuBarL();
       
   338             break;
       
   339 #endif //RD_CALEN_ENHANCED_MSK
       
   340             
       
   341         case ECalenDeleteCurrentEntry:
       
   342             {
       
   343             SaveCurrentItemIndexL();
       
   344 
       
   345             if( Container()->MarkedCount() >= 1 )
       
   346                 {
       
   347                 // delete marked entries
       
   348                 OnCmdDeleteEntryL();
       
   349                 }
       
   350             else
       
   351                 {
       
   352                 SaveCurrentItemIndexL();
       
   353                 CCalenNativeView::HandleCommandL( aCommand );
       
   354                 }
       
   355             }
       
   356             break;
       
   357         case ECalenMarkOne:
       
   358             SaveCurrentItemIndexL();
       
   359             Container()->MarkCurrentL( ETrue );
       
   360             break;
       
   361 
       
   362         case ECalenUnmarkOne:
       
   363             SaveCurrentItemIndexL();
       
   364             Container()->MarkCurrentL( EFalse );
       
   365             break;
       
   366 
       
   367         case ECalenMarkAll:
       
   368             SaveCurrentItemIndexL();
       
   369             Container()->MarkAllL( ETrue );
       
   370             break;
       
   371 
       
   372         case ECalenUnmarkAll:
       
   373             SaveCurrentItemIndexL();
       
   374             Container()->MarkAllL( EFalse );
       
   375             break;
       
   376             
       
   377         case ECalenMarkDone:
       
   378             SaveCurrentItemIndexL();
       
   379             CreateMultiplecontextForMarkedItemsL(ECalenMarkDone);
       
   380             break;
       
   381         case ECalenMarkUnDone:
       
   382             SaveCurrentItemIndexL();
       
   383             CreateMultiplecontextForMarkedItemsL(ECalenMarkUnDone);
       
   384             break;
       
   385 
       
   386         // These differ from native view because all new entries from the
       
   387         // todo view start today. However this does mean that if the user
       
   388         // discards changes to the new entry, we are returned to the top of
       
   389         // the list as the context is today. Can't see an easy way round it.
       
   390         case ECalenNewMeeting:
       
   391         case ECalenNewMeetingRequest:
       
   392         case ECalenNewAnniv:
       
   393         case ECalenNewDayNote:
       
   394         case ECalenNewTodo:
       
   395             {
       
   396             // set the editoractive for not showing the preview popup or preview pane
       
   397             SetEditorActive(ETrue);
       
   398             
       
   399             MCalenContext& context = iServices.Context();
       
   400             // Set the date on the context to today. It will set it to be the
       
   401             // default of view (8am) on that day as we don't specify the time.
       
   402             TTime homeTime;
       
   403             homeTime.HomeTime();
       
   404             TCalTime today;
       
   405             today.SetTimeLocalL( homeTime );
       
   406             context.SetFocusDateL( today,
       
   407                                    TVwsViewId( KUidCalendar, Id() ) );
       
   408             iServices.IssueCommandL( aCommand );
       
   409             break;
       
   410             }
       
   411 
       
   412         case ECalenDayView:
       
   413         case ECalenWeekView:
       
   414         case ECalenMonthView:
       
   415             {
       
   416             SaveCurrentItemIndexL();
       
   417             
       
   418             // clear marked to do items before launching the native views 
       
   419             if(iMarkedTodoItems)
       
   420                 {
       
   421                 ClearMarkedToDoItems();
       
   422                 }
       
   423             
       
   424             iServices.IssueCommandL( aCommand );
       
   425             }
       
   426             break;
       
   427         case ECalenShowCalendars:            
       
   428 			SaveCurrentItemIndexL();
       
   429             Container()->MarkAllL( EFalse ); 
       
   430 			CCalenNativeView::HandleCommandL( aCommand );
       
   431 			break;
       
   432         default:
       
   433             SaveCurrentItemIndexL();
       
   434             CCalenNativeView::HandleCommandL( aCommand );
       
   435             break;
       
   436         }
       
   437     UpdateCBAButtonsL();
       
   438 
       
   439     TRACE_EXIT_POINT;
       
   440     }
       
   441 
       
   442 // ----------------------------------------------------------------------------
       
   443 // CCalenTodoView::DeleteMarkedNotesL
       
   444 // Delete marked notes.
       
   445 // (other items were commented in a header).
       
   446 // ----------------------------------------------------------------------------
       
   447 //
       
   448 void CCalenTodoView::DeleteMarkedNotesL()
       
   449     {
       
   450     TRACE_ENTRY_POINT;
       
   451 
       
   452     CEikColumnListBox* listbox = Container()->ListBox();
       
   453 
       
   454     const CListBoxView::CSelectionIndexArray& selectedItems = *(listbox->SelectionIndexes());
       
   455 
       
   456     TInt markCount( selectedItems.Count() );
       
   457     ASSERT( markCount );
       
   458 
       
   459     iCountOfSelectedItems = markCount;  // Save count of marked item
       
   460 
       
   461     CCalenTodoController* controller = Container()->Controller();
       
   462     iMarkedInstances.Reset();
       
   463 
       
   464     for( TInt i(0); i < markCount; ++i )
       
   465         {
       
   466         TInt indexPos( selectedItems[i] );
       
   467         iMarkedInstances.AppendL( controller->InstanceL( indexPos ) );
       
   468         }
       
   469 	
       
   470 	SetMultipleContexts();
       
   471 		
       
   472     // Find index of the item to be focused after deletion.
       
   473     FindFocusAfterDeletionL( selectedItems );
       
   474 
       
   475     iServices.IssueCommandL( ECalenDeleteEntryWithoutQuery );
       
   476   
       
   477     TRACE_EXIT_POINT;
       
   478     }
       
   479 
       
   480 // ----------------------------------------------------------------------------
       
   481 // CCalenTodoView::FindFocusAfterDeletionL
       
   482 // Save new current postion of item after deleting marked items.
       
   483 // ----------------------------------------------------------------------------
       
   484 //
       
   485 void CCalenTodoView::FindFocusAfterDeletionL(const CListBoxView::CSelectionIndexArray& aSelectedItems)
       
   486     {
       
   487     TRACE_ENTRY_POINT;
       
   488 
       
   489     // calculate the item position after deleting marked items.
       
   490     TInt index( Container()->CurrentItemIndex() );
       
   491     TInt indexpos( 0 );
       
   492     TInt adjustitems( 0 );
       
   493     TBool markedAndFocus( EFalse );
       
   494     iItemIndexAfterDeletion = 0;    // Initialize item position
       
   495 
       
   496     for( TInt n(0); n < iCountOfSelectedItems; n++ )
       
   497         {
       
   498         indexpos = (aSelectedItems)[n];
       
   499 
       
   500         if( indexpos <= index )
       
   501             {
       
   502             ++adjustitems;
       
   503             }
       
   504 
       
   505         if( indexpos == index )
       
   506             {
       
   507             markedAndFocus = ETrue;  // Focused item is marked.
       
   508             }
       
   509         }
       
   510 
       
   511     // (Selection Service Spec 10.0 section 1.2.2.)
       
   512     indexpos = index -adjustitems; // Adjust postion
       
   513 
       
   514     // Current item is marked and focused.
       
   515     if( markedAndFocus )
       
   516         {
       
   517         TInt prevcount( Container()->Controller()->Count() );
       
   518 
       
   519         if( indexpos < (prevcount -iCountOfSelectedItems -1) )
       
   520             {
       
   521             // Focused item is not last.
       
   522             // Focus goes to the next item.
       
   523             ++indexpos;
       
   524             }
       
   525         }
       
   526 
       
   527     // Save new item position after deleting.
       
   528     iItemIndexAfterDeletion = indexpos;
       
   529 
       
   530     TRACE_EXIT_POINT;
       
   531     }
       
   532 
       
   533 // ----------------------------------------------------------------------------
       
   534 // CCalenTodoView::DynInitMenuPaneL
       
   535 // This function called to initialize menu pane.
       
   536 // ----------------------------------------------------------------------------
       
   537 //
       
   538 void CCalenTodoView::DynInitMenuPaneL(TInt aResourceId,          // Resource Id
       
   539                                  CEikMenuPane* aMenuPane)   // Menu pane pointer
       
   540     {
       
   541     TRACE_ENTRY_POINT;
       
   542 
       
   543     CCalenNativeView::DynInitMenuPaneL( aResourceId, aMenuPane );
       
   544 
       
   545     switch( aResourceId )
       
   546         {
       
   547         case R_TODO_LIST_MENUPANE:
       
   548             {
       
   549 
       
   550 #ifdef RD_CALEN_EXTERNAL_CAL
       
   551             TBool isit=ExtCalendarAvailableL();
       
   552             if (!isit)
       
   553                 {
       
   554                 //ECalenExtAiwCommandId
       
   555                 ReleaseServiceHandler();
       
   556                 TInt dummy;
       
   557                 if (aMenuPane->MenuItemExists(ECalenExtAiwCommandId,dummy))
       
   558                     {
       
   559                     aMenuPane->DeleteMenuItem(ECalenExtAiwCommandId);
       
   560                     }
       
   561                 }
       
   562 #endif //RD_CALEN_EXTERNAL_CAL
       
   563 
       
   564             if ( ! FeatureManager::FeatureSupported(KFeatureIdHelp) )
       
   565                 {
       
   566                 aMenuPane->DeleteMenuItem(EAknCmdHelp);
       
   567                 }
       
   568             if( !ItemCount() )
       
   569                 {
       
   570                 aMenuPane->DeleteMenuItem( ECalenViewCurrentEntry );
       
   571                 aMenuPane->DeleteMenuItem( ECalenDeleteCurrentEntry );
       
   572                 aMenuPane->DeleteMenuItem( ECalenCompleteTodo );
       
   573                 aMenuPane->DeleteMenuItem( ECalenRestoreTodo );
       
   574                 aMenuPane->DeleteMenuItem( ECalenCmdComplete );
       
   575                 aMenuPane->DeleteMenuItem( ECalenMarkDone );
       
   576                 aMenuPane->DeleteMenuItem( ECalenMarkUnDone );                
       
   577                 aMenuPane->DeleteMenuItem( ECalenCmdMark );
       
   578                 aMenuPane->DeleteMenuItem( ECalenSend );
       
   579                 
       
   580                 //TODO: will be uncommented with copy to cal functionality.
       
   581                 aMenuPane->DeleteMenuItem(ECalenCopyToCalendars);
       
   582                 }
       
   583             else
       
   584                 {
       
   585                 if( Container()->MarkedCount() )
       
   586                     {
       
   587                     aMenuPane->SetItemSpecific( ECalenDeleteCurrentEntry, ETrue );
       
   588                     if(Container()->IsCurrentItemSelected()) // If focused list item is marked
       
   589                         {
       
   590                         aMenuPane->DeleteMenuItem( ECalenViewCurrentEntry );
       
   591                         }
       
   592                     aMenuPane->DeleteMenuItem( ECalenNewMeeting );
       
   593                     aMenuPane->DeleteMenuItem( ECalenCompleteTodo );
       
   594                     aMenuPane->DeleteMenuItem( ECalenRestoreTodo );
       
   595                     aMenuPane->DeleteMenuItem( ECalenSend );
       
   596                     aMenuPane->DeleteMenuItem(ECalenCopyToCalendars);
       
   597                     
       
   598                     TBool crossout( EFalse );
       
   599                     //When mark as done, crossout is ETrue.
       
   600                     crossout = CheckMarkedItemCompletedL();
       
   601                     if( crossout )
       
   602                         {
       
   603                         aMenuPane->SetItemSpecific(ECalenMarkUnDone, ETrue);
       
   604                         }
       
   605                     else
       
   606                         {
       
   607                         aMenuPane->SetItemSpecific(ECalenMarkDone, ETrue);
       
   608                         }
       
   609                     
       
   610                     if(Container()->MarkedCount() == 1)
       
   611                         {
       
   612                         aMenuPane->DeleteMenuItem( ECalenCmdComplete );
       
   613                         }
       
   614                     }
       
   615                 else
       
   616                     {
       
   617                     aMenuPane->SetItemSpecific( ECalenDeleteCurrentEntry, ETrue );
       
   618                     TBool crossout( EFalse );                    
       
   619                     aMenuPane->DeleteMenuItem( ECalenCmdComplete );
       
   620                     aMenuPane->DeleteMenuItem( ECalenMarkDone );
       
   621                     aMenuPane->DeleteMenuItem( ECalenMarkUnDone );
       
   622                     crossout = CurrentItemIsCrossOutL();
       
   623 
       
   624                     if( crossout )
       
   625                         {
       
   626                         aMenuPane->DeleteMenuItem( ECalenCompleteTodo );
       
   627                         }
       
   628                     else
       
   629                         {
       
   630                         aMenuPane->DeleteMenuItem( ECalenRestoreTodo );
       
   631                         }
       
   632                     }
       
   633                 }
       
   634             if( !iServices.InterimUtilsL().MRViewersEnabledL( ETrue ) )
       
   635                 {
       
   636                 aMenuPane->DeleteMenuItem( ECalenNewMeetingRequest );
       
   637                 }
       
   638                 
       
   639             // Offer the menu pane to the services for customisation by the
       
   640             // the view manager/plugins
       
   641             iServices.OfferMenuPaneL( aResourceId, aMenuPane );
       
   642 
       
   643             // Single click integration
       
   644             TInt menuIndex( 0 );
       
   645             if ( aMenuPane->MenuItemExists( ECalenSend, menuIndex ) )
       
   646                 {
       
   647                 aMenuPane->SetItemSpecific( ECalenSend, ETrue );
       
   648                 }
       
   649             break;
       
   650             }
       
   651 
       
   652         // setup edit/mark menu
       
   653         case R_CALENDAR_MARK_UNMARK:
       
   654             if( ItemCount() )
       
   655                 {
       
   656                 if( Container()->MarkedCount() )
       
   657                     {
       
   658                     // all selected
       
   659                     if( Container()->MarkedCount() == ItemCount() )
       
   660                         {
       
   661                         aMenuPane->DeleteMenuItem( ECalenMarkAll );
       
   662                         aMenuPane->DeleteMenuItem( ECalenMarkOne );
       
   663                         }
       
   664                     else // some selected
       
   665                         {
       
   666                         if( Container()->IsCurrentItemSelected() )
       
   667                             {
       
   668                             aMenuPane->DeleteMenuItem( ECalenMarkOne );
       
   669                             }
       
   670                         else
       
   671                             {
       
   672                             aMenuPane->DeleteMenuItem( ECalenUnmarkOne );
       
   673                             }
       
   674                         }
       
   675                     }
       
   676                 else // none selected
       
   677                     {
       
   678                     aMenuPane->DeleteMenuItem( ECalenUnmarkAll );
       
   679                     aMenuPane->DeleteMenuItem( ECalenUnmarkOne );
       
   680                    
       
   681                     }
       
   682                 }
       
   683             break;
       
   684             // setup edit/mark menu
       
   685             case R_CALENDAR_DONE_UNDONE:
       
   686                 {
       
   687                 if( Container()->MarkedCount() )
       
   688                     {
       
   689                     TBool crossout( EFalse );
       
   690                     crossout = CheckMarkedItemCompletedL();
       
   691                     
       
   692                     if( crossout )
       
   693                         {
       
   694                         aMenuPane->DeleteMenuItem( ECalenMarkDone );
       
   695                         }
       
   696                     else
       
   697                         {
       
   698                         aMenuPane->DeleteMenuItem( ECalenMarkUnDone );
       
   699                         }
       
   700                     }
       
   701                 }
       
   702             break;
       
   703        /* case R_TODO_LIST_SELECTION_CONTEXT_MENUPANE:
       
   704             if( !ItemCount() || !Container()->MarkedCount() )
       
   705                 {
       
   706                 aMenuPane->DeleteMenuItem( ECalenDeleteCurrentEntry );
       
   707                 }
       
   708             break;
       
   709 */
       
   710 
       
   711         default:
       
   712             break;
       
   713         }
       
   714 
       
   715     TRACE_EXIT_POINT;
       
   716     }
       
   717 
       
   718 // ----------------------------------------------------------------------------
       
   719 // CCalenTodoView::DoActivateImplL
       
   720 // Called when List View becomes active.
       
   721 // (other items were commented in a header).
       
   722 // ----------------------------------------------------------------------------
       
   723 //
       
   724 void CCalenTodoView::DoActivateImplL( const TVwsViewId& /*aPrevViewId*/,
       
   725                                       TUid /*aCustomMessageId*/,
       
   726                                       const TDesC8& /*aCustomMessage*/ )
       
   727     {
       
   728     TRACE_ENTRY_POINT;
       
   729 
       
   730     RedrawStatusPaneL(); // Set a text to title pane.
       
   731     
       
   732     /*MCalenToolbar* toolbarImpl = iServices.ToolbarOrNull();
       
   733     if(toolbarImpl) 
       
   734         {
       
   735         CAknToolbar& toolbar = toolbarImpl->Toolbar();
       
   736 
       
   737         // dim clear and clear all toolbar buttons
       
   738         toolbar.SetItemDimmed(ECalenGotoToday,ETrue,ETrue);
       
   739         }*/
       
   740     iEventViewCommandHandled = EFalse;
       
   741     
       
   742     TRACE_EXIT_POINT;
       
   743     }
       
   744 
       
   745 // ----------------------------------------------------------------------------
       
   746 // CCalenTodoView::DoDeactivateImpl
       
   747 // Called when List View becomes inactive.
       
   748 // ----------------------------------------------------------------------------
       
   749 //
       
   750 void CCalenTodoView::DoDeactivateImpl()
       
   751     {
       
   752     TRACE_ENTRY_POINT;
       
   753     
       
   754     /*MCalenToolbar* toolbarImpl = iServices.ToolbarOrNull();
       
   755     if(toolbarImpl) 
       
   756         {
       
   757         CAknToolbar& toolbar = toolbarImpl->Toolbar();
       
   758         
       
   759         if(&toolbar)
       
   760             {
       
   761             // dim clear and clear all toolbar buttons
       
   762             toolbar.SetItemDimmed(ECalenGotoToday,EFalse,ETrue);
       
   763             }
       
   764         }*/
       
   765     
       
   766     // Remove all markings when the view is deactivated.
       
   767     static_cast< CCalenTodoContainer* > ( iContainer )->MarkAllL( 
       
   768 														EFalse );
       
   769     
       
   770     TRACE_EXIT_POINT;
       
   771     }
       
   772 
       
   773 // ----------------------------------------------------------------------------
       
   774 // CCalenTodoView::RedrawStatusPaneL
       
   775 // Redraw status pane when Form is closed
       
   776 // (other items were commented in a header).
       
   777 // ----------------------------------------------------------------------------
       
   778 //
       
   779 void CCalenTodoView::RedrawStatusPaneL()
       
   780     {
       
   781     TRACE_ENTRY_POINT;
       
   782 
       
   783     HBufC* titleText = StringLoader::LoadLC( R_QTN_CALE_TITLE_TODOS, iCoeEnv );
       
   784     iSPUtils->UnderLineTitleText( EFalse );
       
   785     iSPUtils->SetTitleText( titleText );    // ownership passed
       
   786     CleanupStack::Pop( titleText );
       
   787     iSPUtils->RefreshStatusPane();
       
   788 
       
   789     TRACE_EXIT_POINT;
       
   790     }
       
   791 
       
   792 // ----------------------------------------------------------------------------
       
   793 // CCalenTodoView::CreateContainerImplL
       
   794 // making CCalenContainer. In this class, it is CCalenTodoContainer.
       
   795 // (other items were commented in a header).
       
   796 // ----------------------------------------------------------------------------
       
   797 //
       
   798 CCalenContainer* CCalenTodoView::CreateContainerImplL()
       
   799     {
       
   800     TRACE_ENTRY_POINT;
       
   801 
       
   802     TRACE_EXIT_POINT;
       
   803     return new( ELeave )CCalenTodoContainer( this,
       
   804                                              iHighlightedRowNumber,
       
   805                                              iFirstEntryOnScreenIndex,
       
   806                                              iServices );
       
   807     }
       
   808 
       
   809 
       
   810 // ----------------------------------------------------------------------------
       
   811 // CCalenTodoView::UpdateCBAButtonsL
       
   812 // Update CBA buttons depending if we have empty view or not.
       
   813 // FIXME: Same function is also implemented in day view -> could
       
   814 // be virtual in CalenView.
       
   815 // (other items were commented in a header).
       
   816 // ----------------------------------------------------------------------------
       
   817 void CCalenTodoView::UpdateCBAButtonsL()
       
   818     {
       
   819     TRACE_ENTRY_POINT;
       
   820 
       
   821     const TInt index( Container()->CurrentItemIndex() );
       
   822     const TBool isSelected( Container()->ListBox()->View()->ItemIsSelected( index ) );
       
   823     TInt cbaId, menuId;
       
   824 
       
   825     // select CBA
       
   826 #ifndef RD_CALEN_ENHANCED_MSK
       
   827     if( Container()->IsEmptyView() || isSelected )
       
   828 #else
       
   829     if( Container()->IsEmptyView())
       
   830 #endif //RD_CALEN_ENHANCED_MSK    
       
   831         {
       
   832         // context sensitive CBA
       
   833         cbaId = R_CALEN_DAY_AND_TODO_VIEW_CONTEXT_MENU_CBA;
       
   834         }
       
   835 #ifdef RD_CALEN_ENHANCED_MSK        
       
   836     else if(isSelected)
       
   837         {
       
   838         // focused toDo is marked
       
   839         cbaId = R_CALEN_TODO_VIEW_CONTEXT_MENU_CBA;
       
   840         }    
       
   841 #endif //RD_CALEN_ENHANCED_MSK
       
   842     else // normal CBA
       
   843         {
       
   844         cbaId = R_CALEN_DAY_AND_TODO_VIEW_NORMAL_CBA;
       
   845         }
       
   846 
       
   847     // select menu
       
   848     if( isSelected )
       
   849         {
       
   850         // context sensitice menu
       
   851         menuId = R_TODO_LIST_SELECTION_CONTEXT_MENUBAR;
       
   852         }
       
   853     else // normal menu
       
   854         {
       
   855         menuId = R_TODO_NEW_ENTRY_CONTEXT_MENUBAR;
       
   856         }
       
   857 
       
   858     SetCbaL( cbaId );
       
   859     MenuBar()->SetContextMenuTitleResourceId( menuId );
       
   860 
       
   861     TRACE_EXIT_POINT;
       
   862     }
       
   863 
       
   864 // ----------------------------------------------------------------------------
       
   865 // CCalenTodoView::Id
       
   866 // From CAknView
       
   867 // Return the UID of the todo view
       
   868 // (other items were commented in a header)
       
   869 // ----------------------------------------------------------------------------
       
   870 TUid CCalenTodoView::Id() const
       
   871     {
       
   872     TRACE_ENTRY_POINT;
       
   873 
       
   874     TRACE_EXIT_POINT;
       
   875     return KUidCalenTodoView;
       
   876     }
       
   877 
       
   878 // ----------------------------------------------------------------------------
       
   879 // CCalenTodoView::ClearViewSpecificDataL
       
   880 // Clears any cached data for the specific view, e.g. currently
       
   881 // highlighted row, column, etc.
       
   882 // (other items were commented in a header)
       
   883 // ----------------------------------------------------------------------------
       
   884 //
       
   885 void CCalenTodoView::ClearViewSpecificDataL()
       
   886     {
       
   887     TRACE_ENTRY_POINT;
       
   888 
       
   889     iFirstEntryOnScreenIndex = KErrNotFound;
       
   890     iHighlightedRowNumber = KErrNotFound;
       
   891     
       
   892     ClearMarkedToDoItems();
       
   893     
       
   894     TRACE_EXIT_POINT;
       
   895     }
       
   896 
       
   897 // ----------------------------------------------------------------------------
       
   898 // CCalenTodoView::IsViewSpecificDataNullL
       
   899 // From CCalenNativeView
       
   900 // Returns ETrue if the view specific data is null, EFalse otherwise.
       
   901 // (other items were commented in a header)
       
   902 // ----------------------------------------------------------------------------
       
   903 //
       
   904 TBool CCalenTodoView::IsViewSpecificDataNullL()
       
   905     {
       
   906     TRACE_ENTRY_POINT;
       
   907     TRACE_EXIT_POINT;
       
   908     return ( iFirstEntryOnScreenIndex == KErrNotFound ) &&
       
   909            ( iHighlightedRowNumber == KErrNotFound );
       
   910     }
       
   911 
       
   912 
       
   913 
       
   914 // ----------------------------------------------------------------------------
       
   915 // CCalenTodoView::ActiveStepL
       
   916 // From CCalenView
       
   917 // (other items were commented in a header)
       
   918 // ----------------------------------------------------------------------------
       
   919 //
       
   920 CCalenView::TNextPopulationStep CCalenTodoView::ActiveStepL()
       
   921     {
       
   922     TRACE_ENTRY_POINT;
       
   923 
       
   924     switch( iPopulationStep )
       
   925         {
       
   926         case ENothingDone:
       
   927             {
       
   928            iPopulationStep = ERequestedInstanceView;
       
   929            RArray<TInt> colIdArray;
       
   930            CCalenNativeView::GetActiveCollectionidsL( iServices, colIdArray );
       
   931             
       
   932             if(colIdArray.Count() > 0)
       
   933                 {
       
   934                 colIdArray.Close();
       
   935                 if( !iServices.InstanceViewL(colIdArray) )
       
   936                     {
       
   937                     TRACE_EXIT_POINT;
       
   938                     return CCalenView::EWaitForInstanceView;
       
   939                     }
       
   940                 else
       
   941                     {
       
   942                     TRACE_EXIT_POINT;
       
   943                     return CCalenView::EKeepGoing;
       
   944                     }
       
   945                 }
       
   946             else
       
   947                 {
       
   948                 colIdArray.Close();
       
   949                 if( !iServices.InstanceViewL() )
       
   950                     {
       
   951                     TRACE_EXIT_POINT;
       
   952                     return CCalenView::EWaitForInstanceView;
       
   953                     }
       
   954                 else
       
   955                     {
       
   956                     TRACE_EXIT_POINT;
       
   957                     return CCalenView::EKeepGoing;
       
   958                     }
       
   959                 }
       
   960             }
       
   961             // else fall through...
       
   962         case ERequestedInstanceView:
       
   963         	{
       
   964         	MCalenContext& context = iServices.Context();
       
   965         	if ( !(context.InstanceId() == TCalenInstanceId::NullInstanceId()) )
       
   966             	{
       
   967             	iHighlightedRowNumber = Container()->Controller()->FindInstanceIndexL( context.InstanceId() );
       
   968             	}
       
   969             Container()->BeginPopulationWithInstanceViewL();
       
   970             iPopulationStep = EAddToStackNext;
       
   971             TRACE_EXIT_POINT;
       
   972             return CCalenView::EKeepGoing;
       
   973         	}
       
   974         case EAddToStackNext:
       
   975         default:
       
   976             Container()->CompletePopulationL();
       
   977             iPopulationStep = EPopulationDone;
       
   978             TRACE_EXIT_POINT;
       
   979             return CCalenView::EDone;
       
   980         }
       
   981     }
       
   982 
       
   983 // ----------------------------------------------------------------------------
       
   984 // CCalenTodoView::CancelPopulation
       
   985 // From CCalenView
       
   986 // (other items were commented in a header)
       
   987 // ----------------------------------------------------------------------------
       
   988 //
       
   989 void CCalenTodoView::CancelPopulation()
       
   990     {
       
   991     TRACE_ENTRY_POINT;
       
   992 
       
   993     iPopulationStep = ENothingDone;
       
   994 
       
   995     TRACE_EXIT_POINT;
       
   996     }
       
   997 
       
   998 // ----------------------------------------------------------------------------
       
   999 // CCalenTodoView::CyclePosition
       
  1000 // From CCalenView
       
  1001 // (other items were commented in a header)
       
  1002 // ----------------------------------------------------------------------------
       
  1003 //
       
  1004 CCalenView::TCyclePosition CCalenTodoView::CyclePosition() const
       
  1005     {
       
  1006     TRACE_ENTRY_POINT;
       
  1007     TRACE_EXIT_POINT;
       
  1008     return CCalenView::EReplaceTodoView;
       
  1009     }
       
  1010 
       
  1011 // ----------------------------------------------------------------------------
       
  1012 // CCalenTodoView::LocalisedViewNameL
       
  1013 // From CCalenView
       
  1014 // (other items were commented in a header)
       
  1015 // ----------------------------------------------------------------------------
       
  1016 //
       
  1017 const TDesC& CCalenTodoView::LocalisedViewNameL( CCalenView::TViewName aViewName )
       
  1018 	{
       
  1019 	TRACE_ENTRY_POINT;
       
  1020 
       
  1021 	HBufC* ret = NULL;
       
  1022 
       
  1023 	switch (aViewName)
       
  1024 		{
       
  1025 		case CCalenView::EMenuName:
       
  1026 			if( !iMenuName )
       
  1027 				{
       
  1028 				iMenuName = StringLoader::LoadL( R_CALEN_VIEW_TODO, iCoeEnv );
       
  1029 				}
       
  1030 			ret = iMenuName;
       
  1031 			break;
       
  1032 		case CCalenView::ESettingsName:
       
  1033 			if( !iSettingsName )
       
  1034 				{
       
  1035 				iSettingsName = StringLoader::LoadL(
       
  1036 					R_CALEN_QTN_DEFAULT_TODO_VIEW, iCoeEnv );
       
  1037 				}
       
  1038 			ret = iSettingsName;
       
  1039 			break;
       
  1040 		default:
       
  1041 			ASSERT( EFalse );
       
  1042 			break;
       
  1043 		}
       
  1044 
       
  1045 	TRACE_EXIT_POINT;
       
  1046 	return *ret;
       
  1047 	}
       
  1048 
       
  1049 // ----------------------------------------------------------------------------
       
  1050 // CCalenTodoView::ViewIcon
       
  1051 // From CCalenView
       
  1052 // (other items were commented in a header)
       
  1053 // ----------------------------------------------------------------------------
       
  1054 //
       
  1055 CGulIcon* CCalenTodoView::ViewIconL() const
       
  1056 	{
       
  1057 	TRACE_ENTRY_POINT;
       
  1058 	
       
  1059 	TRACE_EXIT_POINT;
       
  1060 	
       
  1061 	return iServices.GetIconL( MCalenServices::ECalenTodoViewIcon );
       
  1062 	}
       
  1063 
       
  1064 // ----------------------------------------------------------------------------
       
  1065 // CCalenTodoView::NotifyMarkedEntryDeletedL()
       
  1066 // From CCalenView
       
  1067 // (other items were commented in a header)
       
  1068 // ----------------------------------------------------------------------------
       
  1069 //
       
  1070 void CCalenTodoView::NotifyMarkedEntryDeletedL()
       
  1071 	{
       
  1072 	TRACE_ENTRY_POINT;
       
  1073 
       
  1074 	// reset the marked items count
       
  1075 	iCountOfSelectedItems = iServices.Context().MutlipleContextIdsCount();
       
  1076 
       
  1077 	ClearMarkedToDoItems();
       
  1078 
       
  1079 	iFirstEntryOnScreenIndex = KErrNotFound;
       
  1080 	iHighlightedRowNumber = KErrNotFound;
       
  1081 
       
  1082 	// DON'T issue MultipleEntriesDeleted notification immediately, which would result in
       
  1083 	// alter the state, on recieving a another notification. It would fxxk up the state.
       
  1084 	// Instead create a callback to issue new notification
       
  1085 	if( !iCmdCallback )
       
  1086 		{
       
  1087 		TCallBack callback( NotificationCallback, this );
       
  1088 		iCmdCallback = new ( ELeave ) CAsyncCallBack( callback,
       
  1089 			CActive::EPriorityHigh );
       
  1090 		}
       
  1091 	iCmdCallback->CallBack();
       
  1092 
       
  1093 	TRACE_EXIT_POINT;
       
  1094 	}
       
  1095 
       
  1096 // ----------------------------------------------------------------------------
       
  1097 // CCalenTodoView::NotificationCallback
       
  1098 // static callback function
       
  1099 // (other items were commented in a header)
       
  1100 // ----------------------------------------------------------------------------
       
  1101 //
       
  1102 TInt CCalenTodoView::NotificationCallback( TAny* aCommandStruct )
       
  1103 	{
       
  1104 	TRACE_ENTRY_POINT;
       
  1105 
       
  1106 	CCalenTodoView* self = static_cast<CCalenTodoView*> ( aCommandStruct );
       
  1107 	PIM_TRAPD_HANDLE( self->DoNotificationCallbackL() );
       
  1108 
       
  1109 	TRACE_EXIT_POINT;
       
  1110 	return EFalse;
       
  1111 	}
       
  1112 
       
  1113 // ----------------------------------------------------------------------------
       
  1114 // CCalenTodoView::DoNotificationCallbackL
       
  1115 // Leaving implementation of the callback function
       
  1116 // (other items were commented in a header)
       
  1117 // ----------------------------------------------------------------------------
       
  1118 //
       
  1119 void CCalenTodoView::DoNotificationCallbackL()
       
  1120 	{
       
  1121 	TRACE_ENTRY_POINT;
       
  1122 
       
  1123 	iServices.IssueNotificationL( ECalenNotifyMultipleEntriesDeleted );
       
  1124 
       
  1125 	TRACE_EXIT_POINT;
       
  1126 	}
       
  1127 
       
  1128 // ----------------------------------------------------------------------------
       
  1129 // CCalenTodoView::DeleteMarkedNotesL
       
  1130 // Delete marked notes.
       
  1131 // (other items were commented in a header).
       
  1132 // ----------------------------------------------------------------------------
       
  1133 //
       
  1134 void CCalenTodoView::CreateMultiplecontextForMarkedItemsL(TInt aCommand)
       
  1135 	{
       
  1136 	TRACE_ENTRY_POINT;
       
  1137 
       
  1138 	CEikColumnListBox* listbox = Container()->ListBox();
       
  1139 
       
  1140 	const CListBoxView::CSelectionIndexArray& selectedItems =
       
  1141 			*( listbox->SelectionIndexes() );
       
  1142 
       
  1143 	TInt markCount( selectedItems.Count() );
       
  1144 	ASSERT( markCount );
       
  1145 
       
  1146 	iCountOfSelectedItems = markCount; // Save count of marked item
       
  1147 
       
  1148 	CCalenTodoController* controller = Container()->Controller();
       
  1149 	iMarkedInstances.Reset();
       
  1150 
       
  1151 	switch (aCommand)
       
  1152 		{
       
  1153 		case ECalenMarkDone:
       
  1154 			{
       
  1155 			for (TInt i( 0 ); i < markCount; ++i)
       
  1156 				{
       
  1157 				TInt indexPos( selectedItems[ i ] );
       
  1158 				if( !( controller->IsCrossOutL( indexPos ) ) )
       
  1159 					{
       
  1160 					iMarkedInstances.AppendL(
       
  1161 						controller->InstanceL( indexPos ) );
       
  1162 					}
       
  1163 				}
       
  1164 
       
  1165 			if( !iMarkedInstances.Count() )
       
  1166 				{
       
  1167 				TInt resID = R_CALEN_QTN_TODO_ALL_TASK_UPDATED;
       
  1168 				HBufC* buf =
       
  1169 						StringLoader::LoadLC( resID, CEikonEnv::Static() );
       
  1170 				CAknInformationNote* dialog =
       
  1171 						new ( ELeave ) CAknInformationNote();
       
  1172 
       
  1173 				dialog->ExecuteLD( *buf );
       
  1174 
       
  1175 				CleanupStack::PopAndDestroy( buf );
       
  1176 
       
  1177 				// Remove all markings before completing the execution of cmd.
       
  1178 				static_cast<CCalenTodoContainer*> ( iContainer )->MarkAllL(
       
  1179 					EFalse );
       
  1180 				}
       
  1181 			else
       
  1182 				{
       
  1183 				SetMultipleContexts();
       
  1184 
       
  1185 				iServices.IssueCommandL( ECalenMarkEntryAsDone );
       
  1186 				}
       
  1187 			}
       
  1188 			break;
       
  1189 
       
  1190 		case ECalenMarkUnDone:
       
  1191 			{
       
  1192 			for (TInt i( 0 ); i < markCount; ++i)
       
  1193 				{
       
  1194 				TInt indexPos( selectedItems[ i ] );
       
  1195 				if( controller->IsCrossOutL( indexPos ) )
       
  1196 					{
       
  1197 					iMarkedInstances.AppendL(
       
  1198 						controller->InstanceL( indexPos ) );
       
  1199 					}
       
  1200 				}
       
  1201 			if( !iMarkedInstances.Count() )
       
  1202 				{
       
  1203 				TInt resID = R_CALEN_QTN_TODO_ALL_TASK_UPDATED;
       
  1204 				HBufC* buf =
       
  1205 						StringLoader::LoadLC( resID, CEikonEnv::Static() );
       
  1206 				CAknInformationNote* dialog =
       
  1207 						new ( ELeave ) CAknInformationNote();
       
  1208 
       
  1209 				dialog->ExecuteLD( *buf );
       
  1210 
       
  1211 				CleanupStack::PopAndDestroy( buf );
       
  1212 
       
  1213 				// Remove all markings before completing the execution of cmd.
       
  1214 				static_cast<CCalenTodoContainer*> ( iContainer )->MarkAllL(
       
  1215 					EFalse );
       
  1216 				}
       
  1217 			else
       
  1218 				{
       
  1219 				SetMultipleContexts();
       
  1220 
       
  1221 				iServices.IssueCommandL( ECalenMarkEntryAsUnDone );
       
  1222 				}
       
  1223 			}
       
  1224 			break;
       
  1225 
       
  1226 		case ECalenDeleteEntryWithoutQuery:
       
  1227 			{
       
  1228 			for( TInt i( 0 ); i < markCount; ++i )
       
  1229 				{
       
  1230 				TInt indexPos( selectedItems[ i ] );
       
  1231 				iMarkedInstances.AppendL( controller->InstanceL( indexPos ) );
       
  1232 				}
       
  1233 
       
  1234 			SetMultipleContexts();
       
  1235 			// Find index of the item to be focused after deletion.
       
  1236 			FindFocusAfterDeletionL( selectedItems );
       
  1237 
       
  1238 			iServices.IssueCommandL( ECalenDeleteEntryWithoutQuery );
       
  1239 			}
       
  1240 			break;
       
  1241 			
       
  1242 		default:
       
  1243 			//no implemenatation as of now.
       
  1244 			break;
       
  1245 		}
       
  1246 
       
  1247 	TRACE_EXIT_POINT;
       
  1248 	}
       
  1249 
       
  1250 // ----------------------------------------------------------------------------
       
  1251 // CCalenTodoView::SetMutlipleContexts
       
  1252 // Set Multiple contexts
       
  1253 // (other items were commented in a header)
       
  1254 // ----------------------------------------------------------------------------
       
  1255 //
       
  1256 void CCalenTodoView::SetMultipleContexts()
       
  1257 	{
       
  1258 	TRACE_ENTRY_POINT;
       
  1259 
       
  1260 	if( iMarkedInstances.Count() )
       
  1261 		{
       
  1262 		RArray< TCalenInstanceId > multipleContextIds;
       
  1263 		TCalenInstanceId instanceId;
       
  1264 		for( TInt index = 0; index < iMarkedInstances.Count(); index++ )
       
  1265 			{
       
  1266 			// pack instance ids of the marked instancesS
       
  1267 			TRAPD( error, 
       
  1268 				instanceId = TCalenInstanceId::CreateL( *iMarkedInstances[ index ] ) );
       
  1269 			if( error != KErrNone )
       
  1270 				{
       
  1271 				// Do nothing to avoid warning	
       
  1272 				}
       
  1273 			multipleContextIds.Append( instanceId );
       
  1274 			}
       
  1275 
       
  1276 		// set the multiple contexts
       
  1277 		iServices.Context().SetMutlipleContextIds( multipleContextIds );
       
  1278 		}
       
  1279 
       
  1280 	TRACE_EXIT_POINT;
       
  1281 	}
       
  1282 
       
  1283 // ----------------------------------------------------------------------------
       
  1284 // CCalenTodoView::SetMarkedToDoItems
       
  1285 // Set marked to do items
       
  1286 // ----------------------------------------------------------------------------
       
  1287 //
       
  1288 void CCalenTodoView::SetMarkedToDoItems(
       
  1289 				CListBoxView::CSelectionIndexArray* aMarkedTodoItems)
       
  1290 	{
       
  1291 	TRACE_ENTRY_POINT;
       
  1292 	
       
  1293 	if( iMarkedTodoItems )
       
  1294 		{
       
  1295 		delete iMarkedTodoItems;
       
  1296 		iMarkedTodoItems = NULL;
       
  1297 		}
       
  1298 	iMarkedTodoItems = aMarkedTodoItems;
       
  1299 
       
  1300 	TRACE_EXIT_POINT;
       
  1301 	}
       
  1302 
       
  1303 // ----------------------------------------------------------------------------
       
  1304 // CCalenTodoView::GetMarkedToDoItems
       
  1305 // Get marked to do items
       
  1306 // ----------------------------------------------------------------------------
       
  1307 //
       
  1308 CListBoxView::CSelectionIndexArray* CCalenTodoView::GetMarkedToDoItems()
       
  1309 	{
       
  1310 	TRACE_ENTRY_POINT;
       
  1311 	
       
  1312 	TRACE_EXIT_POINT;
       
  1313 
       
  1314 	return iMarkedTodoItems;
       
  1315 	}
       
  1316 
       
  1317 // ----------------------------------------------------------------------------
       
  1318 // CCalenTodoView::ClearMarkedToDoItems
       
  1319 // Clear all marked todo items
       
  1320 // (other items were commented in a header)
       
  1321 // ----------------------------------------------------------------------------
       
  1322 //
       
  1323 void CCalenTodoView::ClearMarkedToDoItems()
       
  1324 	{
       
  1325 	TRACE_ENTRY_POINT;
       
  1326 
       
  1327 	if( iMarkedTodoItems )
       
  1328 		{
       
  1329 		delete iMarkedTodoItems;
       
  1330 		iMarkedTodoItems = NULL;
       
  1331 		}
       
  1332 
       
  1333 	TRACE_EXIT_POINT;
       
  1334 	}
       
  1335 
       
  1336 // ----------------------------------------------------------------------------
       
  1337 // CCalenTodoView::NotifyMarkedEntryCompletedL
       
  1338 // (other items were commented in a header)
       
  1339 // ----------------------------------------------------------------------------
       
  1340 //
       
  1341 void CCalenTodoView::NotifyMarkedEntryCompletedL()
       
  1342 	{
       
  1343 	TRACE_ENTRY_POINT;
       
  1344 
       
  1345 	Container()->MarkAllL( EFalse );
       
  1346 
       
  1347 	TRACE_EXIT_POINT;
       
  1348 	}
       
  1349 
       
  1350 // ----------------------------------------------------------------------------
       
  1351 // CCalenTodoView::CheckMarkedItemCompletedL
       
  1352 // (other items were commented in a header)
       
  1353 // ----------------------------------------------------------------------------
       
  1354 //
       
  1355 TBool CCalenTodoView::CheckMarkedItemCompletedL()
       
  1356 	{
       
  1357 	TRACE_ENTRY_POINT;
       
  1358 
       
  1359 	CEikColumnListBox* listbox = Container()->ListBox();
       
  1360 	const CListBoxView::CSelectionIndexArray& selectedItems =
       
  1361 			*( listbox->SelectionIndexes() );
       
  1362 	return Container()->Controller()->IsCrossOutL( selectedItems[ 0 ] );
       
  1363 
       
  1364 	TRACE_EXIT_POINT;
       
  1365 	}
       
  1366 
       
  1367 // End of File