logsui/AppSrc/CLogsNaviDecoratorWrapper.cpp
changeset 0 e686773b3f54
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 *      A singleton wrapper for Logs views CAknNavigationDecorator objects (Tab groups). 
       
    16 *      Each unique Tab group is only created if it doesn't already exist. This fixes 
       
    17 *      error MVHA-6TJDMJ.
       
    18 *
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include "CLogsNaviDecoratorWrapper.h"
       
    25 #include <AknTabObserver.h>
       
    26 #include <aknnavide.h>
       
    27 #include <aknnavi.h>
       
    28 
       
    29 #include <barsread.h>   // resource reader
       
    30 
       
    31 #include "LogsUID.h"
       
    32 
       
    33 
       
    34 
       
    35 
       
    36 // ================= MEMBER FUNCTIONS =======================
       
    37 
       
    38 // ----------------------------------------------------------------------------
       
    39 // CLogsNaviDecoratorWrapper::CLogsNaviDecmioratorWrapper
       
    40 // ----------------------------------------------------------------------------
       
    41 //
       
    42 CLogsNaviDecoratorWrapper::CLogsNaviDecoratorWrapper() : CCoeStatic( TUid::Uid( KLogsAppUID3 )), iNaviDecorator( NULL ), iCurrentNaviResource (0)
       
    43     {
       
    44     }
       
    45     
       
    46 // ----------------------------------------------------------------------------
       
    47 // CLogsNaviDecoratorWrapper::NewLC
       
    48 // ----------------------------------------------------------------------------
       
    49 //
       
    50 CLogsNaviDecoratorWrapper* CLogsNaviDecoratorWrapper::NewLC()
       
    51     {  
       
    52     CLogsNaviDecoratorWrapper* self = new (ELeave) CLogsNaviDecoratorWrapper;
       
    53     CleanupStack::PushL(self);
       
    54     return self; 
       
    55     }
       
    56 
       
    57 
       
    58 // ----------------------------------------------------------------------------
       
    59 // CLogsNaviDecoratorWrapper::GetNaviDecorator
       
    60 // 
       
    61 // Getter for the iNaviDecorator member. 
       
    62 // ----------------------------------------------------------------------------
       
    63 //  
       
    64 CAknNavigationDecorator* CLogsNaviDecoratorWrapper::GetNaviDecoratorL(CAknNavigationControlContainer* aNaviPane,
       
    65                                                                      MAknTabObserver* aTabObserver,
       
    66                                                                      TInt aResource)
       
    67     {   
       
    68     // If the iNaviDecorator is not yet created, or it is of wrong type
       
    69     // we need to create a new.
       
    70     if (iNaviDecorator == NULL || iCurrentNaviResource != aResource)
       
    71         {     
       
    72         TResourceReader reader;
       
    73         CCoeEnv::Static()->CreateResourceReaderLC( reader, aResource );
       
    74         
       
    75         if (iNaviDecorator != NULL )
       
    76             {
       
    77             // deleting the old navidecorator also Pops it from the Navi Panes's control stack
       
    78             delete iNaviDecorator;
       
    79             iNaviDecorator = NULL;
       
    80             }
       
    81         
       
    82         iNaviDecorator = aNaviPane->CreateTabGroupL( reader, aTabObserver );
       
    83         
       
    84         CleanupStack::PopAndDestroy(); // reader
       
    85         
       
    86         // Store the current iNaviDecorator's resource id 
       
    87         iCurrentNaviResource = aResource;
       
    88         }
       
    89         
       
    90     // Push the naviDecorator to the Navi Pane's control stack 
       
    91     aNaviPane->PushL( *( iNaviDecorator ) ); 
       
    92     return iNaviDecorator;
       
    93     }
       
    94     
       
    95     
       
    96 // ----------------------------------------------------------------------------
       
    97 // CLogsNaviDecoratorWrapper::GetNaviDecorator
       
    98 // 
       
    99 // Static Getter for the singleton instance of CLogsNaviDecoratorWrapper class. 
       
   100 // ----------------------------------------------------------------------------
       
   101 //       
       
   102 CLogsNaviDecoratorWrapper* CLogsNaviDecoratorWrapper::InstanceL()
       
   103     {
       
   104     CLogsNaviDecoratorWrapper* singleton = static_cast<CLogsNaviDecoratorWrapper*>
       
   105                     ( CCoeEnv::Static( TUid::Uid(KLogsAppUID3 ) ));
       
   106     if ( !singleton )
       
   107         {
       
   108         singleton = CLogsNaviDecoratorWrapper::NewLC();
       
   109         CleanupStack::Pop(singleton);
       
   110         }
       
   111     return singleton;
       
   112     
       
   113     }
       
   114    
       
   115 
       
   116 // ----------------------------------------------------------------------------
       
   117 // CLogsNaviDecoratorWrapper::~CLogsNaviDecoratorWrapper
       
   118 //
       
   119 // CCoeEnv handles the cleanup. Destructor called from CCoeEnv::DestroyEnvironmentStatic
       
   120 // ----------------------------------------------------------------------------
       
   121 //   
       
   122 CLogsNaviDecoratorWrapper::~CLogsNaviDecoratorWrapper()
       
   123     {
       
   124     delete iNaviDecorator;
       
   125     }
       
   126 
       
   127 
       
   128 // End of File