csxhelp/src/CSXHGenericView.cpp
changeset 0 1f04cf54edd8
child 5 d06b1526f62c
equal deleted inserted replaced
-1:000000000000 0:1f04cf54edd8
       
     1 /*
       
     2 * Copyright (c) 2006 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:  CCSXHGenericView class definition
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "CSXHGenericView.h"
       
    20 #include "CSXHGenericContainer.h"
       
    21 #include "CSXHAppUi.h"
       
    22 #include "CSXHDocument.h"
       
    23 #include <cshelp.rsg>
       
    24 #include "CsHelp.hrh"
       
    25 
       
    26 #include "CSXHHelpContentBase.h"
       
    27 #include "CSXHViewIDs.h"
       
    28 #include "CSXHHelpDataBase.h"
       
    29 
       
    30 #include <akntitle.h> 
       
    31 #include <coemain.h>
       
    32 #include <eikmenup.h>
       
    33 #include <eikbtgpc.h>
       
    34 
       
    35 #ifdef FF_HELP_TUTORIAL_MERGE
       
    36 
       
    37 #include <AiwMenu.h>
       
    38 #include <AiwCommon.h>
       
    39 #include <AiwServiceHandler.h>
       
    40 #include <AknGlobalNote.h>
       
    41 
       
    42 #endif // FF_HELP_TUTORIAL_MERGE
       
    43 
       
    44 CCSXHGenericView* CCSXHGenericView::NewL(const TUid& aUid, 
       
    45                                          const TInt& aFlags)
       
    46     {
       
    47     CCSXHGenericView* self = new(ELeave) CCSXHGenericView(aUid,aFlags);
       
    48     CleanupStack::PushL(self);
       
    49     self->ConstructL();
       
    50     CleanupStack::Pop(self);
       
    51     return self;
       
    52     }
       
    53     
       
    54 CCSXHGenericView::CCSXHGenericView(const TUid& aUid, const TInt& aFlags)
       
    55             :iResetContainerInActivate(EFalse),iUid(aUid),iAppFlags(aFlags)
       
    56     {//No Implementation required
       
    57     }
       
    58     
       
    59 void CCSXHGenericView::ConstructL() 
       
    60     {
       
    61     BaseConstructL(iAppFlags);
       
    62 
       
    63     }
       
    64     
       
    65 CCSXHGenericView::~CCSXHGenericView()
       
    66     {
       
    67     if(iContainer)
       
    68     	{
       
    69     	AppUi()->RemoveFromStack(iContainer); 
       
    70     	delete iContainer;
       
    71     	}
       
    72     }
       
    73     
       
    74 TUid CCSXHGenericView::Id() const
       
    75     {
       
    76     return iUid;
       
    77     }
       
    78 
       
    79 // --------------------------------
       
    80 // Message Handler
       
    81 // --------------------------------    
       
    82 void CCSXHGenericView::HandleCommandL(TInt aCommand)    
       
    83     {
       
    84     switch(aCommand)
       
    85         {           
       
    86         case EAknSoftkeyBack:
       
    87             {
       
    88             CCSXHDocument* doc = static_cast<CCSXHDocument*>(AppUi()->Document());
       
    89             if(iUid == KCSXHToc2ViewID)
       
    90                 doc->SetDisplayAndPrevTopic(doc->GetHelpDataBase()->GetMainTopics());
       
    91             else if(iUid == KCSXHKywdToc2ViewID)
       
    92                 doc->SetDisplayAndPrevTopic(doc->GetHelpDataBase()->GetKywdTopics());
       
    93             
       
    94             AppUi()->HandleCommandL(ECSXHOpenItem); 
       
    95             }
       
    96             break;
       
    97         case ECSXHOpenItemPropagated: //Will be called for AppUi    
       
    98             iContainer->SetDisplayTopicL();
       
    99             break;
       
   100         case ECSXHTOC1ListView:
       
   101             {
       
   102             CCSXHDocument* doc = static_cast<CCSXHDocument*>(AppUi()->Document());              
       
   103             doc->SetDisplayAndPrevTopic(doc->GetHelpDataBase()->GetMainTopics());
       
   104             AppUi()->HandleCommandL(ECSXHOpenItem);
       
   105             }
       
   106             break;      
       
   107         case ECSXHOpenItem:
       
   108         case ECSXHOpenTopicText:    
       
   109 #ifdef FF_HELP_TUTORIAL_MERGE
       
   110 
       
   111             if(iContainer->IsShowTutorialItemSelectedL())
       
   112                 {
       
   113                 if(CCSXHAppUi::GetInstance()->IsApplicationPresentInTutorialL())
       
   114                     {
       
   115                     CCSXHAppUi::GetInstance()->CallTutorialAiwProviderL();
       
   116                     }
       
   117                 else
       
   118                     {
       
   119                     HBufC* ErrorMessage = iCoeEnv->AllocReadResourceLC(
       
   120                                                         R_TYPE_NO_HELP_TOPICS);
       
   121                     CAknGlobalNote* note = CAknGlobalNote::NewLC();
       
   122                     note->ShowNoteL(EAknGlobalInformationNote, *ErrorMessage);
       
   123 
       
   124                     CleanupStack::PopAndDestroy(note);
       
   125                     CleanupStack::PopAndDestroy(ErrorMessage);
       
   126                     }
       
   127                 }
       
   128             else
       
   129 
       
   130 #endif // FF_HELP_TUTORIAL_MERGE
       
   131 	        	{        	
       
   132 	            iContainer->SetDisplayTopicL();
       
   133 	            AppUi()->HandleCommandL(aCommand);  
       
   134 	            }
       
   135             break; 
       
   136         default:
       
   137             AppUi()->HandleCommandL(aCommand);  
       
   138             break;              
       
   139         }
       
   140     }
       
   141 // --------------------------------------------------------------------------
       
   142 // Handler for view activation. If required the container object will be 
       
   143 // recreated. The recreation can be due to 1) Resetting the search pane
       
   144 // 2) Changing the selection of the items in the list box 3) Repopulating the
       
   145 // contents of the list box
       
   146 // --------------------------------------------------------------------------
       
   147 void CCSXHGenericView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,TUid,const TDesC8& )
       
   148     {
       
   149     CCSXHDocument* doc = static_cast<CCSXHDocument*>(AppUi()->Document());
       
   150     if(iResetContainerInActivate)
       
   151         {
       
   152         delete iContainer;
       
   153         iContainer = NULL;
       
   154         iResetContainerInActivate = EFalse;
       
   155         }
       
   156     if(!iContainer)
       
   157     	{
       
   158    	    if(iUid == KCSXHKywdToc2ViewID)
       
   159 			doc->InitProgressBarL();
       
   160    	    
       
   161 #ifdef FF_HELP_TUTORIAL_MERGE
       
   162         iContainer = CCSXHGenericContainer::NewL(ClientRect(),*doc,this);
       
   163 #else // !FF_HELP_TUTORIAL_MERGE
       
   164         iContainer = CCSXHGenericContainer::NewL(ClientRect(),*doc);
       
   165 #endif // FF_HELP_TUTORIAL_MERGE
       
   166 
       
   167         /*if(iUid == KCSXHKywdToc2ViewID)
       
   168 			doc->FreeProgressBarL();*/
       
   169     	}
       
   170     iContainer->HightLightItemL();	
       
   171     iContainer->MakeVisible(ETrue);
       
   172     iContainer->DrawNow();
       
   173     iContainer->SetMopParent(this);
       
   174     //iContainer->SetRect(ClientRect());   
       
   175     iContainer->SetCurrentView(this);
       
   176     AppUi()->AddToStackL(*this, iContainer);
       
   177     
       
   178     if(iUid == KCSXHToc1ViewID ||
       
   179        iUid == KCSXHKywdToc1ViewID)
       
   180         {
       
   181         doc->GetHelpDataBase()->ClearAllTOC1Contents();
       
   182         doc->ClearPrevTopic();
       
   183         }
       
   184     
       
   185     iContainer->CheckForMSK();
       
   186     
       
   187     //Set the title of the view
       
   188     CEikStatusPane* sp = StatusPane();
       
   189     CAknTitlePane* title = STATIC_CAST(CAknTitlePane*, 
       
   190     sp->ControlL(TUid::Uid(EEikStatusPaneUidTitle)));
       
   191     title->SetTextL(doc->GetDisplayTopic()->GetName());
       
   192     }
       
   193     
       
   194 void CCSXHGenericView::DoDeactivate()
       
   195     {
       
   196     if(iContainer)
       
   197         {
       
   198         iContainer->MakeVisible(EFalse);
       
   199         AppUi()->RemoveFromStack(iContainer);
       
   200         }
       
   201     }
       
   202     
       
   203 void CCSXHGenericView::ResetContainer()
       
   204     {
       
   205     iResetContainerInActivate = ETrue;
       
   206     }
       
   207 // --------------------------------------------------------------------------
       
   208 // Dynamically changing the items in the Options Menu
       
   209 // --------------------------------------------------------------------------
       
   210 
       
   211 void CCSXHGenericView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
       
   212     {    
       
   213     if ( aResourceId == R_CSXH_MENU_TOPICLIST &&
       
   214          iContainer->GetNumberOfListItems()== 0 )
       
   215         {
       
   216         aMenuPane->DeleteMenuItem(ECSXHOpenTopicText);
       
   217         }
       
   218         
       
   219     if ( aResourceId == R_CSXH_MENU_KYWDTOC1LIST &&
       
   220          iContainer->GetNumberOfListItems()== 0 )
       
   221         {
       
   222         aMenuPane->DeleteMenuItem(ECSXHOpenTopicText);
       
   223         }
       
   224         
       
   225     if ( aResourceId == R_CSXH_MENU &&
       
   226          iContainer->GetNumberOfListItems()== 0 )
       
   227         {
       
   228         aMenuPane->DeleteMenuItem(ECSXHOpenItem);
       
   229         }
       
   230         
       
   231     if ( aResourceId == R_CSXH_MENU_KYWDTOC2LIST &&
       
   232          iContainer->GetNumberOfListItems()== 0 )
       
   233         {
       
   234         aMenuPane->DeleteMenuItem(ECSXHOpenTopicText);
       
   235         }
       
   236     }    
       
   237 // --------------------------------------------------------------------------
       
   238 // MSK Handler Handling 
       
   239 // --------------------------------------------------------------------------
       
   240 void CCSXHGenericView::SetMiddleSoftKey(TBool aValue)
       
   241     {    
       
   242     Cba()->MakeCommandVisible(ECSXHOpenTopicText,aValue);
       
   243     Cba()->DrawDeferred();  
       
   244     }
       
   245 void CCSXHGenericView::ResourceChangeHdl(TInt aType)
       
   246     {
       
   247     if(iContainer)
       
   248         iContainer->HandleResourceChangeImpl(aType);
       
   249     }
       
   250 
       
   251