logsui/AppSrc/CLogsSubAppListView.cpp
changeset 0 e686773b3f54
child 21 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 "Sub application list" view class implementation
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <AknQueryDialog.h>
       
    22 #include <featmgr.h>
       
    23 
       
    24 #include <Logs.rsg>
       
    25 
       
    26 #include "CLogsSubAppListView.h"
       
    27 #include "CLogsSubAppListControlContainer.h"
       
    28 #include "CLogsAppUi.h"
       
    29 #include "CLogsEngine.h"
       
    30 #include "MLogsClearLog.h"
       
    31 #include "MLogsSharedData.h"
       
    32 
       
    33 
       
    34 // EXTERNAL DATA STRUCTURES
       
    35 
       
    36 // EXTERNAL FUNCTION PROTOTYPES  
       
    37 
       
    38 // CONSTANTS
       
    39 
       
    40 // MACROS
       
    41 
       
    42 // LOCAL CONSTANTS AND MACROS
       
    43 
       
    44 // MODULE DATA STRUCTURES
       
    45 
       
    46 // LOCAL FUNCTION PROTOTYPES
       
    47 
       
    48 // ==================== LOCAL FUNCTIONS ====================
       
    49 
       
    50 // ================= MEMBER FUNCTIONS =======================
       
    51 
       
    52 // ----------------------------------------------------------------------------
       
    53 // CLogsSubAppListView::NewL
       
    54 // ----------------------------------------------------------------------------
       
    55 //
       
    56 CLogsSubAppListView* CLogsSubAppListView::NewL()
       
    57     {
       
    58     CLogsSubAppListView* self = new ( ELeave ) CLogsSubAppListView;
       
    59     CleanupStack::PushL( self );
       
    60     self->ConstructL();
       
    61     CleanupStack::Pop();  // self
       
    62     return self;
       
    63     }
       
    64 
       
    65 // ----------------------------------------------------------------------------
       
    66 // CLogsSubAppListView::~CLogsSubAppListView
       
    67 // ----------------------------------------------------------------------------
       
    68 //
       
    69 CLogsSubAppListView::~CLogsSubAppListView()
       
    70     {
       
    71     if( iContainer )
       
    72         {
       
    73         AppUi()->RemoveFromViewStack( *this, iContainer );
       
    74         delete iContainer;
       
    75         }
       
    76     }
       
    77 
       
    78 // ----------------------------------------------------------------------------
       
    79 // CLogsSubAppListView::HandleCommandL
       
    80 // ----------------------------------------------------------------------------
       
    81 //
       
    82 void CLogsSubAppListView::HandleCommandL( TInt aCommandId )
       
    83     {
       
    84     switch( aCommandId )
       
    85         {
       
    86         case ELogsCmdMenuClearRecentRegisters:
       
    87             CmdClearRecentListsL();
       
    88             break;
       
    89 
       
    90         case ELogsCmdMenuOpen:
       
    91             LogsAppUi()->CmdOkL( iContainer->ListBox()->CurrentItemIndex() );
       
    92             break;
       
    93 
       
    94         default:
       
    95             CLogsBaseView::HandleCommandL( aCommandId );
       
    96         }
       
    97     }
       
    98 
       
    99 // ----------------------------------------------------------------------------
       
   100 // CLogsSubAppListView::Id
       
   101 // ----------------------------------------------------------------------------
       
   102 //
       
   103 TUid CLogsSubAppListView::Id() const
       
   104     {
       
   105     return TUid::Uid( ELogSubAppListViewId );
       
   106     }
       
   107 
       
   108 
       
   109 // ----------------------------------------------------------------------------
       
   110 // CLogsSubAppListView::HandleClientRectChange
       
   111 // ----------------------------------------------------------------------------
       
   112 //
       
   113 void CLogsSubAppListView::HandleClientRectChange()
       
   114     {
       
   115     if (iContainer)
       
   116         {
       
   117         iContainer->SetRect( ClientRect() );  
       
   118         }
       
   119     }
       
   120 
       
   121 // ----------------------------------------------------------------------------
       
   122 // CLogsSubAppListView::DoActivateL
       
   123 // ----------------------------------------------------------------------------
       
   124 //
       
   125 void CLogsSubAppListView::DoActivateL( const TVwsViewId& aPrevViewId, 
       
   126           TUid aCustomMessageId, const TDesC8& /*aCustomMessage*/ )
       
   127     {
       
   128     //Reset ProvideOnlyRecentViews always when other than CLogsRecentListView is activated. 
       
   129     LogsAppUi()->SetProvideOnlyRecentViews( EFalse );
       
   130     
       
   131     if( iContainer == NULL )
       
   132         {
       
   133         iContainer = CLogsSubAppListControlContainer::NewL( this, ClientRect() );
       
   134         AppUi()->AddToViewStackL( *this, iContainer );
       
   135         }
       
   136 
       
   137     if ( aCustomMessageId.iUid == ELogsViewActivationBackground )
       
   138         {
       
   139         // when activating in background, restore the initial selection
       
   140         iSelectedLine = 0;
       
   141         }
       
   142 
       
   143     //Set focus to correct row if we return from subselection view
       
   144     switch( aPrevViewId.iViewUid.iUid )
       
   145         {
       
   146         case EStmReceivedListViewId:
       
   147             iSelectedLine = 1;
       
   148             break;    
       
   149         case EStmDialledListViewId:
       
   150             iSelectedLine = 2;
       
   151             break;    
       
   152         case EStmMissedListViewId:
       
   153         default:
       
   154             iSelectedLine = 0;    
       
   155         }
       
   156 
       
   157 	iContainer->ListBox()->SetCurrentItemIndex( iSelectedLine );    
       
   158     Engine()->SharedDataL()->SetObserver( this );
       
   159     iContainer->ListBox()->SetListBoxObserver( this );
       
   160 
       
   161     LogsAppUi()->SetPreviousViewId( aPrevViewId.iViewUid );
       
   162     LogsAppUi()->SetCurrentViewId( Id() );    
       
   163 
       
   164     if ( aCustomMessageId.iUid == ELogsViewActivationBackground )
       
   165         {
       
   166         // We have activated this view because we are putting the 
       
   167         // Logs into background so this view is waiting when Logs is again foregrounded.
       
   168         AppUi()->SetCustomControl(0); 
       
   169         AppUi()->HideInBackground(); 
       
   170         }
       
   171     
       
   172     // Just to make sure the inputblocker is not on
       
   173     RemoveInputBlocker();
       
   174     }
       
   175 
       
   176 // ----------------------------------------------------------------------------
       
   177 // CLogsSubAppListView::DoDeactivate
       
   178 // ----------------------------------------------------------------------------
       
   179 //
       
   180 void CLogsSubAppListView::DoDeactivate()
       
   181     {
       
   182     if( iContainer )
       
   183         {
       
   184         iSelectedLine = iContainer->ListBox()->CurrentItemIndex();
       
   185         // Remove view and its control from the view stack
       
   186         AppUi()->RemoveFromViewStack( *this, iContainer );
       
   187         // Destroy the container control
       
   188         delete iContainer;
       
   189         iContainer = NULL;
       
   190         }
       
   191     }
       
   192 
       
   193 // ----------------------------------------------------------------------------
       
   194 // CLogsSubAppListView::ConstructL
       
   195 // ----------------------------------------------------------------------------
       
   196 //
       
   197 void CLogsSubAppListView::ConstructL()
       
   198     {
       
   199     if ( FeatureManager::FeatureSupported( KFeatureIdSimpleLogs ) )
       
   200         {
       
   201         BaseConstructL( R_LOGS_SUB_APP_LIST_SIMPLE_VIEW );
       
   202         }
       
   203     else
       
   204         {
       
   205         BaseConstructL( R_LOGS_SUB_APP_LIST_VIEW );
       
   206         }
       
   207     }
       
   208 
       
   209 // ----------------------------------------------------------------------------
       
   210 // CLogsSubAppListView::CLogsSubAppListView
       
   211 // ----------------------------------------------------------------------------
       
   212 //
       
   213 CLogsSubAppListView::CLogsSubAppListView()
       
   214     {
       
   215     }
       
   216 
       
   217 // ----------------------------------------------------------------------------
       
   218 // CLogsSubAppListView::CmdClearRecentListsL
       
   219 // ----------------------------------------------------------------------------
       
   220 //
       
   221 void CLogsSubAppListView::CmdClearRecentListsL()
       
   222     {
       
   223     CAknQueryDialog* queryDlg = CAknQueryDialog::NewL();
       
   224     
       
   225     if( queryDlg->ExecuteLD( R_CLEAR_RECENT_LISTS_CONFIRMATION_QUERY ) )
       
   226         {
       
   227         Engine()->ClearLogsL()->ClearModelL( ELogsAllRecent );
       
   228         Engine()->SharedDataL()->NewMissedCalls( ETrue );
       
   229         if( iContainer )
       
   230             {
       
   231             iContainer->CreateListBoxContentsL();
       
   232             }
       
   233         }
       
   234     }
       
   235 
       
   236 // ----------------------------------------------------------------------------
       
   237 // CLogsSubAppListView::StateChangedL
       
   238 // ----------------------------------------------------------------------------
       
   239 //
       
   240 void CLogsSubAppListView::StateChangedL( MLogsStateHolder* /*aHolder*/ )
       
   241     {
       
   242     if( iContainer )
       
   243         {
       
   244         iContainer->CreateListBoxL();
       
   245         iContainer->ListBox()->SetListBoxObserver( this );
       
   246         }
       
   247     }
       
   248 
       
   249 
       
   250 //  End of File
       
   251