logsui/AppSrc/CLogsEventListControlContainer.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 "Event list" view container control class implementation
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <AknIconArray.h>
       
    22 #include <eikclbd.h>
       
    23 #include <aknnavide.h>
       
    24 #include <akntabgrp.h>
       
    25 #include <AknsConstants.h>  //for skinned icons
       
    26 
       
    27 #include <Logs.rsg>
       
    28 #include <logs.mbg>
       
    29 
       
    30 #include "CLogsEventListControlContainer.h"
       
    31 #include "CLogsEventListView.h"
       
    32 #include "CLogsAppUi.h"
       
    33 #include "CLogsEventListAdapter.h"
       
    34 #include "CLogsEngine.h"
       
    35 #include "MLogsModel.h"
       
    36 #include "MLogsSharedData.h"
       
    37 #include "CLogsNaviDecoratorWrapper.h"
       
    38 
       
    39 #include "LogsIcons.hrh"
       
    40 
       
    41 #include "LogsUID.h"
       
    42 #include <csxhelp/log.hlp.hrh>
       
    43 
       
    44 // EXTERNAL DATA STRUCTURES
       
    45 
       
    46 // EXTERNAL FUNCTION PROTOTYPES  
       
    47 
       
    48 // CONSTANTS
       
    49 
       
    50 // MACROS
       
    51 
       
    52 // LOCAL CONSTANTS AND MACROS
       
    53 
       
    54 // MODULE DATA STRUCTURES
       
    55 
       
    56 // LOCAL FUNCTION PROTOTYPES
       
    57 
       
    58 // ==================== LOCAL FUNCTIONS ====================
       
    59 
       
    60 // ================= MEMBER FUNCTIONS =======================
       
    61 
       
    62 // ----------------------------------------------------------------------------
       
    63 // CLogsEventListControlContainer::NewL
       
    64 // ----------------------------------------------------------------------------
       
    65 //
       
    66 CLogsEventListControlContainer* CLogsEventListControlContainer::NewL( 
       
    67     CLogsEventListView* aView, 
       
    68     const TRect& aRect )
       
    69     {
       
    70     CLogsEventListControlContainer* self = new( ELeave ) 
       
    71                 CLogsEventListControlContainer( aView );
       
    72     self->SetMopParent( aView );
       
    73     CleanupStack::PushL( self );
       
    74     self->ConstructL( aRect );
       
    75     CleanupStack::Pop();  // self
       
    76     return self;
       
    77     }
       
    78 
       
    79 // ----------------------------------------------------------------------------
       
    80 // CLogsEventListControlContainer::~CLogsEventListControlContainer
       
    81 // ----------------------------------------------------------------------------
       
    82 //
       
    83 CLogsEventListControlContainer::~CLogsEventListControlContainer()
       
    84     {
       
    85     delete iListBox;
       
    86     }
       
    87 
       
    88 // ----------------------------------------------------------------------------
       
    89 // CLogsEventListControlContainer::CLogsEventListControlContainer
       
    90 // ----------------------------------------------------------------------------
       
    91 //
       
    92 CLogsEventListControlContainer::CLogsEventListControlContainer(
       
    93     CLogsEventListView* aView ) : 
       
    94         CLogsBaseControlContainer( aView ),
       
    95         iView( aView )
       
    96     {
       
    97     }
       
    98 
       
    99 
       
   100 // ----------------------------------------------------------------------------
       
   101 // CLogsEventListControlContainer::ComponentControl
       
   102 // ----------------------------------------------------------------------------
       
   103 //
       
   104 CCoeControl* CLogsEventListControlContainer::ComponentControl(
       
   105     TInt /*aIndex*/ ) const
       
   106     {
       
   107     return iListBox;
       
   108     }
       
   109 
       
   110 // ----------------------------------------------------------------------------
       
   111 // CLogsEventListControlContainer::SizeChanged
       
   112 // ----------------------------------------------------------------------------
       
   113 //
       
   114 void CLogsEventListControlContainer::SizeChanged()
       
   115     {
       
   116     if( iListBox )
       
   117         {
       
   118         iListBox->SetRect( Rect() );
       
   119         }
       
   120     }
       
   121 
       
   122 // ----------------------------------------------------------------------------
       
   123 // CLogsEventListControlContainer::ConstructL
       
   124 // ----------------------------------------------------------------------------
       
   125 //
       
   126 void CLogsEventListControlContainer::ConstructL( const TRect& aRect)
       
   127     {
       
   128     BaseConstructL();
       
   129 
       
   130     // Constructing a compound control or a window-owning control.
       
   131     iListBox = new ( ELeave ) CAknSingleGraphicHeadingStyleListBox();
       
   132     iListBox->ConstructL( this, EEikListBoxMultipleSelection );
       
   133 
       
   134     AddControlContainerIconsL();
       
   135     CLogsEventListAdapter* adapter = CLogsEventListAdapter::NewL( this );
       
   136 
       
   137     iListBox->Model()->SetItemTextArray( adapter );
       
   138     iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
       
   139 
       
   140     if( iView->Engine()->Model( ELogsMainModel )->Count() == 0 )
       
   141         {
       
   142         UpdateEmptyViewTextL();
       
   143         }
       
   144     else
       
   145         {
       
   146         InitListBoxL();
       
   147         }
       
   148 
       
   149     MakeScrollArrowsL( iListBox );
       
   150 
       
   151     MakeTitleL( R_LOGS_TITLE_TEXT );
       
   152     
       
   153     CAknNavigationDecorator* decoratedTabGroup = NavigationTabGroupL( R_LOGS_NAVI_PANE_TAB_GROUP, 
       
   154                                                                       CLogsNaviDecoratorWrapper::InstanceL() );
       
   155 
       
   156     CAknTabGroup* tabGroup = static_cast<CAknTabGroup*>( 
       
   157                                  decoratedTabGroup->DecoratedControl() );
       
   158     tabGroup->SetActiveTabById( EEventListTabId );
       
   159     
       
   160     SetRect( aRect );
       
   161     ActivateL();
       
   162     }
       
   163 
       
   164 // ----------------------------------------------------------------------------
       
   165 // CLogsEventListControlContainer::ListBox
       
   166 // ----------------------------------------------------------------------------
       
   167 //
       
   168 CAknSingleGraphicHeadingStyleListBox* CLogsEventListControlContainer::ListBox()
       
   169     {
       
   170     return iListBox;
       
   171     }
       
   172     
       
   173 // ----------------------------------------------------------------------------
       
   174 // CLogsEventListControlContainer::View
       
   175 // ----------------------------------------------------------------------------
       
   176 //
       
   177 CLogsEventListView* CLogsEventListControlContainer::View()
       
   178     {
       
   179     return iView;
       
   180     }
       
   181 
       
   182 // ----------------------------------------------------------------------------
       
   183 // CLogsEventListControlContainer::InitListBoxL
       
   184 // ----------------------------------------------------------------------------
       
   185 //
       
   186 void CLogsEventListControlContainer::InitListBoxL()
       
   187     {
       
   188     TInt current( iView->EventListCurrent() );
       
   189     TInt top( iView->EventListTop() );
       
   190 
       
   191     if (top < 0 || current < 0)   
       
   192         {
       
   193         // In case top and current are illegal, set top and current to zero. 
       
   194         // For example it occasionally happens when switching quickly back and forth 
       
   195         // between Log and Main view, that top and current are -1 (KErrNotFound).
       
   196         // See error "EAJA-7389Y9: Crash when changing views quickly" 
       
   197         iView->SetEventListTop( 0 );
       
   198         iListBox->SetCurrentItemIndex( 0 ); 
       
   199         }
       
   200     else if( top > current ) 
       
   201         { 
       
   202         // user has browsed upwards
       
   203         top = current;
       
   204         iView->SetEventListTop( top );
       
   205         iListBox->SetCurrentItemIndex( current );
       
   206         }
       
   207     else 
       
   208         {  
       
   209         // user has browsed downwards
       
   210         // past "one" window size
       
   211         if( current - top > iListBox->ItemHeight() ) 
       
   212             {
       
   213             top = current - iListBox->ItemHeight();
       
   214             iView->SetEventListTop( top );
       
   215             }
       
   216         iListBox->SetCurrentItemIndex( current );
       
   217         iListBox->SetTopItemIndex( top );
       
   218         }
       
   219     }
       
   220 
       
   221 // ----------------------------------------------------------------------------
       
   222 // CLogsEventListControlContainer::UpdateEmptyViewTextL
       
   223 //
       
   224 // Show "Retrieving", "No data", "No data due to filter selection
       
   225 // or "Logging is not enabled"
       
   226 // ----------------------------------------------------------------------------
       
   227 //
       
   228 void CLogsEventListControlContainer::UpdateEmptyViewTextL()
       
   229     {
       
   230     // Construct informative text based on following constraints:
       
   231     // * logging on/off
       
   232     // * event reading finished yes/no
       
   233     // * filter selected yes/no
       
   234     //      
       
   235     if (iView->Engine()->SharedDataL()->IsLoggingEnabled())
       
   236         {
       
   237         if( iView->State() == EStateUndefined || iView->State() == EStateInitializing )
       
   238             {
       
   239             MakeEmptyTextListBoxL( iListBox, R_LOGS_EVENTVIEW_FETCHING_TEXT );
       
   240             }
       
   241         /// If filter is "on" ( != all communications) and there are no events
       
   242         /// in the log DB display text "No events due to filter selection".
       
   243         else if( iView->CurrentFilter() != ELogsFilterAllComms
       
   244                   && iView->Engine()->Model( ELogsMainModel )->Count() == 0 )
       
   245             {                                   
       
   246             MakeEmptyTextListBoxL( iListBox, R_LOGS_EVENTVIEW_NO_DATA_DTFS_TEXT );
       
   247             }
       
   248         else
       
   249             {
       
   250             /// If filter is "off" (all communications) and there are no events
       
   251             /// in the log DB display text "No events".
       
   252             MakeEmptyTextListBoxL( iListBox, R_LOGS_EVENTVIEW_NO_DATA_TEXT );
       
   253             }  
       
   254         }
       
   255      // If logging is off, show informative text
       
   256     else   
       
   257         {
       
   258         MakeEmptyTextListBoxL( iListBox, R_QTN_LOGS_LOGGING_OFF);
       
   259         }
       
   260     }
       
   261 
       
   262 
       
   263 // ----------------------------------------------------------------------------
       
   264 // CLogsEventListControlContainer::UpdateL
       
   265 // ----------------------------------------------------------------------------
       
   266 //
       
   267 void CLogsEventListControlContainer::UpdateL()
       
   268     {
       
   269     iListBox->HandleItemAdditionL();
       
   270     if( iListBox->Model()->NumberOfItems() == 0 )
       
   271         {
       
   272         UpdateEmptyViewTextL();
       
   273         }
       
   274     }
       
   275 
       
   276 // ----------------------------------------------------------------------------
       
   277 // CLogsEventListControlContainer::GetHelpContext
       
   278 // ----------------------------------------------------------------------------
       
   279 //
       
   280 void CLogsEventListControlContainer::GetHelpContext( TCoeHelpContext& aContext ) const
       
   281     {
       
   282     aContext.iMajor = TUid::Uid( KLogsAppUID3 );
       
   283     aContext.iContext = KLOGS_HLP_MAIN;
       
   284     }
       
   285 
       
   286 // ----------------------------------------------------------------------------
       
   287 // CLogsEventListControlContainer::AddControlContainerIconsL
       
   288 // ----------------------------------------------------------------------------
       
   289 //
       
   290 void CLogsEventListControlContainer::AddControlContainerIconsL()
       
   291     {
       
   292     if( iListBox->ItemDrawer()->ColumnData()->IconArray() != NULL )
       
   293         {
       
   294         CArrayPtr<CGulIcon>* iconArray = iListBox->ItemDrawer()->ColumnData()->IconArray();
       
   295         delete iconArray;
       
   296         iconArray = NULL;
       
   297         iListBox->ItemDrawer()->ColumnData()->SetIconArray( iconArray);  
       
   298         }
       
   299 
       
   300     // Load and assign icons to the list box control; 3 is number of icons
       
   301     CAknIconArray* icons = new( ELeave ) CAknIconArray( KEventListCCNrOfItems );
       
   302 
       
   303     iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons );
       
   304 
       
   305     // First icon & mask.
       
   306     AddIconL(   icons
       
   307             ,   KLogsIconFile
       
   308             ,   KAknsIIDQgnPropLogIn  //KAknsIIDNone   
       
   309             ,   icon_prop_log_in
       
   310             ,   icon_prop_log_in_mask
       
   311             );
       
   312 
       
   313     // Second icon & mask.
       
   314     AddIconL(   icons
       
   315             ,   KLogsIconFile
       
   316             ,   KAknsIIDQgnPropLogOut //KAknsIIDNone   
       
   317             ,   icon_prop_log_out
       
   318             ,   icon_prop_log_out_mask
       
   319             );
       
   320 
       
   321     // Third icon & mask.
       
   322     AddIconL(   icons
       
   323             ,   KLogsIconFile
       
   324             ,   KAknsIIDQgnPropLogMissed //KAknsIIDNone   
       
   325             ,   icon_prop_log_missed
       
   326             ,   icon_prop_log_missed_mask
       
   327             );
       
   328     }
       
   329     
       
   330 // ----------------------------------------------------------------------------
       
   331 // CLogsEventListControlContainer::FocusChanged
       
   332 //
       
   333 // This is needed to hand focus changes to list. Otherwise animations are not displayed.
       
   334 // ----------------------------------------------------------------------------
       
   335 //
       
   336 void CLogsEventListControlContainer::FocusChanged(TDrawNow /* aDrawNow */ )
       
   337     {
       
   338     if( iListBox)
       
   339         {
       
   340         iListBox->SetFocus( IsFocused() );
       
   341         }
       
   342     }
       
   343 
       
   344 //  End of File