logsui/AppSrc/CLogsDetailView.cpp
changeset 0 e686773b3f54
child 68 9da50d567e3c
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002 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: 
       
    15 *     Logs application "Detail" view
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <baclipb.h>      
       
    22 #include <eikmenub.h>   
       
    23 #include <StringLoader.h> 
       
    24 #include <aknnotewrappers.h> 
       
    25 #include <Logs.rsg>
       
    26 
       
    27 #include "CLogsDetailView.h"
       
    28 #include "CLogsDetailControlContainer.h"
       
    29 #include "CLogsAppUi.h"
       
    30 #include "CLogsEngine.h"
       
    31 #include "MLogsModel.h"
       
    32 #include "MLogsEventGetter.h"
       
    33 #include "MLogsStateHolder.h"
       
    34 #include "MLogsGetEvent.h"
       
    35 #include "MLogsSharedData.h"
       
    36 #include "LogsConstants.hrh"    //KLogsSipUriMaxLen
       
    37 
       
    38 // EXTERNAL DATA STRUCTURES
       
    39 
       
    40 // EXTERNAL FUNCTION PROTOTYPES  
       
    41 
       
    42 // CONSTANTS
       
    43 
       
    44 // MACROS
       
    45 
       
    46 // LOCAL CONSTANTS AND MACROS
       
    47 
       
    48 // MODULE DATA STRUCTURES
       
    49 
       
    50 // LOCAL FUNCTION PROTOTYPES
       
    51 
       
    52 // ==================== LOCAL FUNCTIONS ====================
       
    53 
       
    54 // ================= MEMBER FUNCTIONS =======================
       
    55 
       
    56 // ----------------------------------------------------------------------------
       
    57 // CLogsDetailView::NewL
       
    58 // ----------------------------------------------------------------------------
       
    59 //
       
    60 CLogsDetailView* CLogsDetailView::NewL()
       
    61     {
       
    62     CLogsDetailView* self = new( ELeave ) CLogsDetailView;
       
    63     CleanupStack::PushL( self );
       
    64     self->ConstructL();
       
    65     CleanupStack::Pop();  // self
       
    66     return self;
       
    67     }
       
    68 
       
    69 // ----------------------------------------------------------------------------
       
    70 // CLogsDetailView::~CLogsDetailView
       
    71 // ----------------------------------------------------------------------------
       
    72 //
       
    73 CLogsDetailView::~CLogsDetailView()
       
    74     {
       
    75     if( iContainer )
       
    76         {
       
    77         AppUi()->RemoveFromViewStack( *this, iContainer );
       
    78         delete iContainer;
       
    79         }
       
    80     }
       
    81 
       
    82 // ----------------------------------------------------------------------------
       
    83 // CLogsDetailView::StateChangedL
       
    84 //
       
    85 // CLogsModel informs that it has changed event array, e.g. asynch get event 
       
    86 // is now done (also array resets etc informed)
       
    87 // ----------------------------------------------------------------------------
       
    88 //
       
    89 void CLogsDetailView::StateChangedL( MLogsStateHolder* aHolder )
       
    90     {
       
    91     if( !aHolder )
       
    92         {
       
    93         return;
       
    94         }
       
    95     
       
    96     iState = aHolder->State();
       
    97     
       
    98     if( iState == EStateCheckContactLinkFinished )
       
    99         {
       
   100         CLogsBaseView::StateChangedL(aHolder);
       
   101         return;
       
   102         }
       
   103     
       
   104     if( iState == EStateFinished ) 
       
   105         {
       
   106         TInt index( LogsAppUi()->EventListViewCurrent() );
       
   107         Cba()->MakeCommandVisible( 
       
   108             EAknSoftkeyContextOptions, 
       
   109             IsOkToShowContextMenu( Engine()->Model( ELogsMainModel )->At( index ) ));          
       
   110               
       
   111         //Force remaining construct operations if not yet already done
       
   112         ConstructDelayedL( EFalse );   //EFalse: perform immediately
       
   113         SetToolbarItems( Engine()->Model( ELogsMainModel )->At( index ) );                        
       
   114         }
       
   115     
       
   116     if( iContainer )
       
   117         {
       
   118         iContainer->UpdateL();
       
   119         }
       
   120     }
       
   121 
       
   122 
       
   123 // ----------------------------------------------------------------------------
       
   124 // CLogsDetailView::ProcessKeyEventL
       
   125 // ----------------------------------------------------------------------------
       
   126 //
       
   127 TBool CLogsDetailView::ProcessKeyEventL(
       
   128     const TKeyEvent& aKeyEvent,
       
   129     TEventCode aType )
       
   130     {    
       
   131     if( aType == EEventKey )
       
   132         {
       
   133         switch( aKeyEvent.iCode )
       
   134             {
       
   135             case EKeyLeftArrow:
       
   136                 AknLayoutUtils::LayoutMirrored() ? CmdNextEventL():
       
   137                                                    CmdPreviousEventL();
       
   138                 return ETrue;
       
   139 
       
   140             case EKeyRightArrow:
       
   141                 AknLayoutUtils::LayoutMirrored() ? CmdPreviousEventL():
       
   142                                                    CmdNextEventL();
       
   143                 return ETrue;
       
   144                 
       
   145             default:
       
   146                 break;
       
   147             }
       
   148         }
       
   149         
       
   150     const MLogsEventGetter* event; 
       
   151     event = Engine()->Model( ELogsMainModel )->At( LogsAppUi()->EventListViewCurrent() );            
       
   152     return CLogsBaseView::ProcessKeyEventEventL( aKeyEvent,aType, event );        
       
   153     }
       
   154 
       
   155 // ----------------------------------------------------------------------------
       
   156 // CLogsDetailView::ProcessPointerEventL
       
   157 //
       
   158 // Handler for pointer events, when the current focused item is tapped
       
   159 // ----------------------------------------------------------------------------
       
   160 //
       
   161 void CLogsDetailView::ProcessPointerEventL( TInt /* aIndex */)
       
   162 	{
       
   163 	// Open the context sensitive menu
       
   164 	ProcessCommandL( EAknSoftkeyContextOptions );    
       
   165 	}
       
   166 	
       
   167 // ----------------------------------------------------------------------------
       
   168 // CLogsDetailView::HandleListBoxEventL
       
   169 //
       
   170 // If touch support is on, we handle the touch related events here.
       
   171 // ----------------------------------------------------------------------------
       
   172 //
       
   173 void CLogsDetailView::HandleListBoxEventL(
       
   174     CEikListBox* aListBox,
       
   175     TListBoxEvent aEventType)
       
   176     { 
       
   177     if( AknLayoutUtils::PenEnabled() )  
       
   178         { 
       
   179         switch ( aEventType )
       
   180             {
       
   181             case EEventItemSingleClicked:
       
   182             case EEventEnterKeyPressed:
       
   183                 {
       
   184                 ProcessPointerEventL(aListBox->CurrentItemIndex()); //aListBox->CurrentItemIndex() not used         
       
   185                 break;
       
   186                 }
       
   187                 
       
   188             default:
       
   189                break;
       
   190             }
       
   191             
       
   192       	}
       
   193     }
       
   194 	
       
   195 // ----------------------------------------------------------------------------
       
   196 // CLogsDetailView::HandleNaviDecoratorEventL
       
   197 // Handler for pointer events, when the Navi Pane arrows have been tapped
       
   198 // ----------------------------------------------------------------------------
       
   199 //
       
   200 void CLogsDetailView::HandleNaviDecoratorEventL( TInt aEventID )
       
   201     {
       
   202         switch (aEventID)
       
   203             {
       
   204             case MAknNaviDecoratorObserver::EAknNaviDecoratorEventRightTabArrow:
       
   205                 AknLayoutUtils::LayoutMirrored() ? CmdPreviousEventL():
       
   206                                                    CmdNextEventL();
       
   207                 break;
       
   208             
       
   209             case MAknNaviDecoratorObserver::EAknNaviDecoratorEventLeftTabArrow:
       
   210                 AknLayoutUtils::LayoutMirrored() ? CmdNextEventL():
       
   211                                                    CmdPreviousEventL();
       
   212                 break;
       
   213             }
       
   214     } 
       
   215   
       
   216 // ----------------------------------------------------------------------------
       
   217 // CLogsDetailView::HandleCommandL
       
   218 // ----------------------------------------------------------------------------
       
   219 //
       
   220 void CLogsDetailView::HandleCommandL( TInt aCommandId )
       
   221     {
       
   222     TInt index( LogsAppUi()->EventListViewCurrent() );    
       
   223     const MLogsEventGetter*  event = Engine()->Model( ELogsMainModel )->At( index );        
       
   224     
       
   225     switch( aCommandId )
       
   226         { 
       
   227         case ELogsCmdHandleMSK:
       
   228             //Select key pressed
       
   229             if( iContainer->ListBox()->View() )
       
   230                 {
       
   231                 CmdContextMenuL();
       
   232                 }
       
   233             break;            
       
   234             
       
   235         default:
       
   236             CLogsBaseView::HandleCommandEventL( aCommandId, event );
       
   237         }    
       
   238     }
       
   239 
       
   240 // ----------------------------------------------------------------------------
       
   241 // CLogsDetailView::ChangeTitlePaneTextToDefaultL
       
   242 // ----------------------------------------------------------------------------
       
   243 //
       
   244 void CLogsDetailView::ChangeTitlePaneTextToDefaultL()
       
   245     {       
       
   246     iContainer->UpdateL();
       
   247     } 
       
   248 
       
   249 // ----------------------------------------------------------------------------
       
   250 // CLogsDetailView::Id
       
   251 // ----------------------------------------------------------------------------
       
   252 //
       
   253 TUid CLogsDetailView::Id() const
       
   254     {
       
   255     return TUid::Uid( ELogDetailViewId );
       
   256     }
       
   257 
       
   258 // ----------------------------------------------------------------------------
       
   259 // CLogsDetailView::DynInitMenuPaneL
       
   260 // ----------------------------------------------------------------------------
       
   261 //
       
   262 void CLogsDetailView::DynInitMenuPaneL( 
       
   263     TInt aResourceId, 
       
   264     CEikMenuPane* aMenuPane )
       
   265     {
       
   266     //Get event, may not yet be available if asynch request(s) not completed. 
       
   267     TInt index( LogsAppUi()->EventListViewCurrent() );    
       
   268     const MLogsEventGetter*  event = Engine()->Model( ELogsMainModel )->At( index );     
       
   269     
       
   270     // If Logs settings is changed to "no log" returning back from settings view results in an
       
   271     // invalid state: details shown of a non-existent event. Prevent this by removing the "Settings"
       
   272     // option from 
       
   273     if (aResourceId == R_LOGS_SYSTEM_MENU_BOTTOM)
       
   274         {
       
   275         aMenuPane->DeleteMenuItem(ELogsCmdMenuSettings);
       
   276         }
       
   277     
       
   278     CLogsBaseView::DynInitMenuPaneEventL( aResourceId, aMenuPane, event );    
       
   279     // Detail view has no item specific commands
       
   280     switch ( aResourceId )
       
   281         {
       
   282         case ( R_COMMON_EVENT_MENU_EDIT_CALLS ):
       
   283         case ( R_COMMON_SAVETOPBK_SUBMENU ):
       
   284         case ( R_COMMON_SEND_MESSAGE_SUBMENU ):
       
   285         case ( R_COMMON_POC_SUBMENU ):
       
   286         case ( R_COMMON_CALLUI_SUBMENU ):
       
   287             {
       
   288             SetMenuItemsItemSpecificProperty( aMenuPane, EFalse );
       
   289             }
       
   290         default:
       
   291             {
       
   292             break;
       
   293             }
       
   294         }
       
   295     }
       
   296 
       
   297 
       
   298 // ----------------------------------------------------------------------------
       
   299 // CLogsDetailView::HandleClientRectChange
       
   300 // ----------------------------------------------------------------------------
       
   301 //
       
   302 void CLogsDetailView::HandleClientRectChange()
       
   303     {
       
   304     if (iContainer)
       
   305         {
       
   306         iContainer->SetRect( ClientRect() );  
       
   307         }
       
   308     }
       
   309 
       
   310 // ----------------------------------------------------------------------------
       
   311 // CLogsDetailView::DrawComponents
       
   312 // ----------------------------------------------------------------------------
       
   313 //
       
   314 void CLogsDetailView::DrawComponents()
       
   315     {
       
   316     if (iContainer)
       
   317         {
       
   318         iContainer->DrawNow();
       
   319         }
       
   320     }
       
   321 
       
   322 // ----------------------------------------------------------------------------
       
   323 // CLogsDetailView::ViewActivatedL
       
   324 // ----------------------------------------------------------------------------
       
   325 //
       
   326 void CLogsDetailView::ViewActivatedL(const TVwsViewId& aPrevViewId,
       
   327                                         TUid aCustomMessageId,
       
   328                                         const TDesC8& aCustomMessage)
       
   329     { 
       
   330     SetToolbarStateL(ELogsToolbarOn, EFalse);      
       
   331     CAknView::ViewActivatedL(aPrevViewId, aCustomMessageId, aCustomMessage); 
       
   332     }
       
   333 
       
   334 // ----------------------------------------------------------------------------
       
   335 // CLogsDetailView::ViewDeactivated
       
   336 // ----------------------------------------------------------------------------
       
   337 //
       
   338 void CLogsDetailView::ViewDeactivated()
       
   339     {
       
   340     if (iFocusChangeControl != ELogsNoChange_PbkUpdPending )
       
   341            {
       
   342            SetToolbarState(ELogsToolbarOff, EFalse);  
       
   343            }
       
   344     CAknView::ViewDeactivated();
       
   345     }
       
   346 
       
   347 
       
   348 // ----------------------------------------------------------------------------
       
   349 // CLogsDetailView::DoActivateL
       
   350 // ----------------------------------------------------------------------------
       
   351 //
       
   352 void CLogsDetailView::DoActivateL( 
       
   353     const TVwsViewId& aPrevViewId, 
       
   354     TUid aCustomMessageId,
       
   355     const TDesC8& aCustomMessage )
       
   356     {
       
   357     CLogsBaseView::DoActivateL( aPrevViewId, aCustomMessageId, aCustomMessage );  
       
   358     
       
   359     
       
   360     if( ! iContainer )
       
   361         {
       
   362         iContainer = CLogsDetailControlContainer::NewL( this, ClientRect() );
       
   363         AppUi()->AddToViewStackL( *this, iContainer );
       
   364         } 
       
   365         
       
   366     //To prevent first time flicker of context menu if no ctx mnu will be displayed
       
   367     Cba()->MakeCommandVisible( EAknSoftkeyContextOptions, EFalse );
       
   368 
       
   369     Engine()->GetEventL()->SetObserver( this ); //Engine will inform when asynch get event is ok
       
   370     iContainer->ListBox()->SetListBoxObserver( this ); 
       
   371     LogsAppUi()->SetPreviousViewId( aPrevViewId.iViewUid );
       
   372     LogsAppUi()->SetCurrentViewId( Id() );
       
   373 
       
   374     TInt index( LogsAppUi()->EventListViewCurrent() );
       
   375 	SetEventListCurrent(index  );	// update this detail view objects iEventListCurrent
       
   376     
       
   377     if( index != KErrNotFound )         
       
   378         {
       
   379         TLogId id( Engine()->Model( ELogsMainModel )->At( index )->LogId() ); //Get id from event array
       
   380         Engine()->GetEventL()->Get( id );  									  //Read details using event id (asynch read)
       
   381         }
       
   382     
       
   383     // Just to make sure the inputblocker is not on
       
   384     RemoveInputBlocker();
       
   385     }
       
   386 
       
   387 // ----------------------------------------------------------------------------
       
   388 // CLogsDetailView::DoDeactivate
       
   389 // ----------------------------------------------------------------------------
       
   390 //
       
   391 void CLogsDetailView::DoDeactivate()
       
   392     {
       
   393     if( iContainer )
       
   394         {
       
   395         AppUi()->RemoveFromViewStack( *this, iContainer );
       
   396         delete iContainer;
       
   397         iContainer = NULL;
       
   398         } 
       
   399     Engine()->DeleteGetEvent();
       
   400     
       
   401     //To prevent second time flicker of context menu if ctx mnu was was displayed
       
   402     //but will not later be displayed
       
   403     Cba()->MakeCommandVisible( EAknSoftkeyContextOptions, EFalse );
       
   404     }
       
   405 
       
   406 
       
   407 // ----------------------------------------------------------------------------
       
   408 // CLogsDetailView::ConstructL
       
   409 // ----------------------------------------------------------------------------
       
   410 //
       
   411 void CLogsDetailView::ConstructL()
       
   412     {
       
   413     BaseConstructL( R_LOGS_DETAIL_VIEW );
       
   414 
       
   415     //Perform some time consuming operations 
       
   416     ConstructDelayedL( ETrue );   //ETrue: perform using idle time
       
   417     }
       
   418 
       
   419 // ----------------------------------------------------------------------------
       
   420 // CLogsDetailView::CmdContextMenuL
       
   421 // ----------------------------------------------------------------------------
       
   422 //
       
   423 void CLogsDetailView::CmdContextMenuL()
       
   424     {
       
   425     TInt index( LogsAppUi()->EventListViewCurrent() );
       
   426     
       
   427     if( IsOkToShowContextMenu( Engine()->Model( ELogsMainModel )->At( index ) ))
       
   428         {
       
   429         LaunchPopupMenuL( R_LOGS_LOG_DETAIL_OK_MENUBAR );
       
   430         }
       
   431     }
       
   432 
       
   433 // ----------------------------------------------------------------------------
       
   434 // CLogsDetailView::CmdNextEventL
       
   435 // ----------------------------------------------------------------------------
       
   436 //
       
   437 void CLogsDetailView::CmdNextEventL()
       
   438     {
       
   439     TInt index( LogsAppUi()->EventListViewCurrent() );
       
   440     TInt count( Engine()->Model( ELogsMainModel )->Count() );
       
   441 
       
   442     if( index != KErrNotFound && ( index < count - 1 ) )
       
   443         {
       
   444         LogsAppUi()->SetEventListViewCurrent( index + 1 );  // update the event list views objects iEventListCurrent
       
   445         SetEventListCurrent(index + 1 );                    // update this deteail view objects iEventListCurrent
       
   446         index = LogsAppUi()->EventListViewCurrent();
       
   447         TLogId id = Engine()->Model( ELogsMainModel )->At( index )->LogId(); //Get id from event array
       
   448         Engine()->GetEventL()->Get( id );                                    //Read details using event id (asynch read)
       
   449         }
       
   450     }
       
   451 
       
   452 // ----------------------------------------------------------------------------
       
   453 // CLogsDetailView::CmdPreviousEventL
       
   454 // ----------------------------------------------------------------------------
       
   455 //
       
   456 void CLogsDetailView::CmdPreviousEventL()
       
   457     {
       
   458     TInt index( LogsAppUi()->EventListViewCurrent() );
       
   459 
       
   460     if( index != KErrNotFound && index != 0 )
       
   461         {
       
   462         LogsAppUi()->SetEventListViewCurrent( index - 1 ); // update the event list views objects iEventListCurrent
       
   463         SetEventListCurrent(index - 1 );                   // update this deteail view objects iEventListCurrent
       
   464         index = LogsAppUi()->EventListViewCurrent();
       
   465         TLogId id = Engine()->Model( ELogsMainModel )->At( index )->LogId(); //Get id from event array
       
   466         Engine()->GetEventL()->Get( id );                                    //Read details using event id (asynch read)
       
   467         }
       
   468     }
       
   469 
       
   470 // ----------------------------------------------------------------------------
       
   471 // CLogsDetailView::PopUpNoteL
       
   472 // ----------------------------------------------------------------------------
       
   473 //
       
   474 void CLogsDetailView::PopUpNoteL()
       
   475     {
       
   476     CAknNoteDialog* noteDlg = new( ELeave ) 
       
   477         CAknNoteDialog( CAknNoteDialog::ENoTone, CAknNoteDialog::ELongTimeout );
       
   478     noteDlg->ExecuteLD( R_NUMBER_COPIED_TO_CB_NOTE );
       
   479     }
       
   480 
       
   481 // ----------------------------------------------------------------------------
       
   482 // CLogsDetailView::SetMenuItemsItemSpecificProperty
       
   483 //
       
   484 // Sets menu items item specific property.
       
   485 // ----------------------------------------------------------------------------
       
   486 //
       
   487 void CLogsDetailView::SetMenuItemsItemSpecificProperty(
       
   488         CEikMenuPane* aMenuPane, TBool aItemSpecific )
       
   489     {
       
   490     if ( aMenuPane )
       
   491         {
       
   492         TInt menuItemCount( aMenuPane->NumberOfItemsInPane() );
       
   493         TInt commandId( 0 );
       
   494         for ( TInt i = 0; i < menuItemCount; i++ )
       
   495             {
       
   496             commandId = aMenuPane->MenuItemCommandId( i );
       
   497             aMenuPane->SetItemSpecific( commandId, aItemSpecific );
       
   498             }
       
   499         }
       
   500     }
       
   501 //  End of File