locationlandmarksrefappfors60/Src/LandmarksInfoView.cpp
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2004-2005 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 *       Implements the CLandmarksInfoView class
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <eikmenup.h>
       
    21 #include <aknViewAppUi.h>
       
    22 #include <aknnavide.h>
       
    23 
       
    24 #include <lbspositioninfo.h>
       
    25 #include <EPos_Landmarks.h>
       
    26 
       
    27 #include <lmrefapp.rsg>
       
    28 #include "LmRefApp.hrh"
       
    29 
       
    30 #include "LandmarksAppUi.h"
       
    31 #include "LandmarksUtils.h"
       
    32 #include "LandmarksInfoView.h"
       
    33 #include "LandmarksApplicationEngine.h"
       
    34 #include "LandmarksInfoContainer.h"
       
    35 #include "LandmarksEditDialog.h"
       
    36 
       
    37 // ============================ MEMBER FUNCTIONS ===============================
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 CLandmarksInfoView::CLandmarksInfoView(
       
    43     CAknNavigationDecorator* aNaviDecorator,
       
    44     CLandmarksApplicationEngine& aEngine)
       
    45 :   iEngine(aEngine), 
       
    46     iNaviDecorator(aNaviDecorator)
       
    47     {
       
    48     }
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 void CLandmarksInfoView::ConstructL()
       
    54     {
       
    55     BaseConstructL(R_LMREFAPP_INFO_VIEW);
       
    56     iAppName = iCoeEnv->AllocReadResourceAsDes16L(R_LMREFAPP_APP_TITLE);
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 CLandmarksInfoView* CLandmarksInfoView::NewLC(
       
    63     CAknNavigationDecorator* aNaviDecorator,
       
    64     CLandmarksApplicationEngine& aEngine)
       
    65     {
       
    66     CLandmarksInfoView* self = new (ELeave) CLandmarksInfoView(
       
    67         aNaviDecorator, aEngine);
       
    68     CleanupStack::PushL(self);
       
    69     self->ConstructL();
       
    70     return self;
       
    71     }
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 CLandmarksInfoView::~CLandmarksInfoView()
       
    77     {
       
    78     delete iContainer;
       
    79     delete iAppName;
       
    80     }
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 TUid CLandmarksInfoView::Id() const
       
    86     {
       
    87     return TUid::Uid(ELandmarksInfoViewId);
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 void CLandmarksInfoView::HandleCommandL(TInt aCommand)
       
    94     {
       
    95     switch (aCommand)
       
    96         {
       
    97         case EAknSoftkeyEdit:
       
    98             iContainer->EditLandmarkL();
       
    99             break;
       
   100 
       
   101         case EAknSoftkeyBack:
       
   102             AppUi()->ActivateLocalViewL(TUid::Uid(ELandmarksViewId));
       
   103             break;
       
   104 
       
   105         default:
       
   106             AppUi()->HandleCommandL(aCommand);
       
   107             break;
       
   108         }
       
   109     }
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // -----------------------------------------------------------------------------
       
   113 //
       
   114 void CLandmarksInfoView::DoActivateL(
       
   115     const TVwsViewId& /*aPrevViewId*/,
       
   116     TUid aCustomMessageId,
       
   117     const TDesC8& aCustomMessage)
       
   118     {
       
   119     __ASSERT_ALWAYS(aCustomMessageId.iUid == ELandmarksViewInfoById,
       
   120                     LandmarksUtils::Panic(KErrGeneral));
       
   121     
       
   122     if (!iContainer)
       
   123         {
       
   124         iContainer = new (ELeave) CLandmarksInfoContainer(
       
   125             *this, iEngine, iNaviDecorator);
       
   126         iContainer->SetMopParent(this);
       
   127 	    iContainer->ConstructL(ClientRect());
       
   128         }
       
   129 
       
   130     iContainer->StoreTitlePaneL();
       
   131 
       
   132     // Enable receiving of keyboard events.
       
   133     AppUi()->AddToStackL(*this, iContainer);
       
   134 
       
   135     // custom message contains landmark id
       
   136     TPckgBuf<TPosLmItemId> lmid;
       
   137     lmid.Copy(aCustomMessage);
       
   138     iContainer->LoadLandmarkL(lmid());
       
   139     
       
   140     // Make view visible.
       
   141     iNaviDecorator->MakeVisible(EFalse);
       
   142     iContainer->MakeVisible(ETrue);
       
   143 
       
   144     // Notify that this view is active
       
   145     iEngine.NotifyViewActivated(Id(), ETrue);
       
   146     }
       
   147 
       
   148 // -----------------------------------------------------------------------------
       
   149 // -----------------------------------------------------------------------------
       
   150 //
       
   151 void CLandmarksInfoView::DoDeactivate()
       
   152     {
       
   153     // Hide view.
       
   154     iContainer->MakeVisible(EFalse);
       
   155     iNaviDecorator->MakeVisible(ETrue);
       
   156     iContainer->RestoreTitlePane();
       
   157 
       
   158     // Notify that this view is inactive
       
   159     TBool isActive = EFalse;
       
   160     iEngine.NotifyViewActivated(Id(), isActive);
       
   161 
       
   162     // Disable receiving keyboard events.
       
   163     AppUi()->RemoveFromStack(iContainer);
       
   164     }
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 // -----------------------------------------------------------------------------
       
   168 //
       
   169 void CLandmarksInfoView::HandleResourceChange( TInt aType )
       
   170     {
       
   171     if ( iContainer )
       
   172         {
       
   173         iContainer->HandleResourceChange( aType );
       
   174         }
       
   175     }
       
   176 
       
   177