landmarksui/commonui/src/CLmkEditorDlg.cpp
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     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:    Landmark editor dialog.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "CLmkEditorDlg.h"
       
    23 #include "CLmkEditorImpl.h"
       
    24 #include "CLmkSender.h"
       
    25 #include <lmkerrors.h>
       
    26 
       
    27 // CONSTANTS
       
    28 /// Unnamed namespace for local definitions
       
    29 namespace {
       
    30 #if defined(_DEBUG)
       
    31 
       
    32 _LIT( KPanicMsg, "CLmkEditorDlg" );
       
    33 
       
    34 void Panic( TPanicCode aReason )
       
    35     {
       
    36     User::Panic( KPanicMsg, aReason );
       
    37     }
       
    38 #endif
       
    39 }  // namespace
       
    40 
       
    41 // ============================= LOCAL FUNCTIONS ===============================
       
    42 // -----------------------------------------------------------------------------
       
    43 // TLmkEditorParams::TLmkEditorParams
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 EXPORT_C CLmkEditorDlg::TLmkEditorParams::TLmkEditorParams()
       
    47     : iAttributes( ELmkAll ),
       
    48       iEditorMode( ELmkEditor )
       
    49 	{
       
    50 	}
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CLmkEditorDlg::NewL
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 EXPORT_C CLmkEditorDlg* CLmkEditorDlg::NewL( CPosLandmarkDatabase& aDb,
       
    57                                     TPosLmItemId aLandmarkId,
       
    58                                     TLmkEditorParams& aParams )
       
    59 	{
       
    60     CLmkEditorDlg* self = new( ELeave ) CLmkEditorDlg();
       
    61     CleanupStack::PushL( self );
       
    62     self->ConstructL( aDb, aParams, aLandmarkId, NULL );
       
    63     CleanupStack::Pop(); //self
       
    64     return self;
       
    65 	}
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CLmkEditorDlg::NewL
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 EXPORT_C CLmkEditorDlg* CLmkEditorDlg::NewL( CPosLandmarkDatabase& aDb,
       
    72                                     CPosLandmark& aLandmark,
       
    73                                     TLmkEditorParams& aParams )
       
    74 	{
       
    75     CLmkEditorDlg* self = new( ELeave ) CLmkEditorDlg();
       
    76     CleanupStack::PushL( self );
       
    77     self->ConstructL( aDb, aParams, aLandmark.LandmarkId(), &aLandmark );
       
    78     CleanupStack::Pop(); //self
       
    79     return self;
       
    80 	}
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CLmkEditorDlg::~CLmkEditorDlg
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 EXPORT_C CLmkEditorDlg::~CLmkEditorDlg()
       
    87 	{
       
    88     if ( iDestroyedPtr )
       
    89         {
       
    90         *iDestroyedPtr = ETrue;
       
    91         }
       
    92     delete iEditorImpl;
       
    93     delete iSender;
       
    94 	}
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CLmkEditorDlg::CLmkEditorDlg
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 CLmkEditorDlg::CLmkEditorDlg()
       
   101 	{
       
   102 	}
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 // CLmkEditorDlg::ConstructL
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 void CLmkEditorDlg::ConstructL(
       
   109     CPosLandmarkDatabase& aDb,
       
   110     TLmkEditorParams& aParams,
       
   111     TPosLmItemId aLandmarkId,
       
   112     CPosLandmark* aLandmark )
       
   113 	{
       
   114     iSender = CLmkSender::NewL( aDb );
       
   115 
       
   116     if ( aLandmark )
       
   117         {
       
   118         iEditorImpl = CLmkEditorImpl::NewL( aDb,
       
   119                                             *iSender,
       
   120                                             aParams.iAttributes,
       
   121                                             aParams.iEditorMode,
       
   122                                             aLandmark );
       
   123         }
       
   124     else
       
   125         {
       
   126         iEditorImpl = CLmkEditorImpl::NewL( aDb,
       
   127                                             *iSender,
       
   128                                             aParams.iAttributes,
       
   129                                             aParams.iEditorMode,
       
   130                                             aLandmarkId );
       
   131         }
       
   132 	}
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 // CLmkEditorDlg::SetMopParent
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 EXPORT_C void CLmkEditorDlg::SetMopParent( MObjectProvider* aParent )
       
   139 	{
       
   140     __ASSERT_DEBUG( iEditorImpl, Panic( KLmkPanicNullMember ) );
       
   141     iEditorImpl->SetMopParent( aParent );
       
   142 	}
       
   143 
       
   144 // -----------------------------------------------------------------------------
       
   145 // CLmkEditorDlg::SetHelpContext
       
   146 // -----------------------------------------------------------------------------
       
   147 //
       
   148 EXPORT_C void CLmkEditorDlg::SetHelpContext( TCoeHelpContext aContext )
       
   149     {
       
   150     __ASSERT_DEBUG( iEditorImpl, Panic( KLmkPanicNullMember ) );
       
   151     iEditorImpl->SetHelpContext( aContext );
       
   152     }
       
   153 
       
   154 // -----------------------------------------------------------------------------
       
   155 // CLmkEditorDlg::ExecuteLD
       
   156 // -----------------------------------------------------------------------------
       
   157 //
       
   158 EXPORT_C TInt CLmkEditorDlg::ExecuteLD()
       
   159 	{
       
   160 	CleanupStack::PushL( this );
       
   161 
       
   162     TBool thisDestroyed( EFalse );
       
   163     iDestroyedPtr = &thisDestroyed;
       
   164 
       
   165 	TInt ret( iEditorImpl->ExecuteLD() );
       
   166     iEditorImpl = NULL;
       
   167 
       
   168     if ( thisDestroyed )
       
   169         {
       
   170         // this object has been deleted already
       
   171         CleanupStack::Pop( this );
       
   172         }
       
   173     else
       
   174         {
       
   175         CleanupStack::PopAndDestroy(this); //this
       
   176         }
       
   177     return ret;
       
   178 	}
       
   179 
       
   180 // -----------------------------------------------------------------------------
       
   181 // CLmkEditorDlg::DisableMapAndNavigationMenuOptions
       
   182 // -----------------------------------------------------------------------------
       
   183 //
       
   184 EXPORT_C void CLmkEditorDlg::DisableMapAndNavigationMenuOptions()
       
   185 	{
       
   186 	iEditorImpl->DisableMapAndNavigationMenuOptions();
       
   187 	}
       
   188 
       
   189 //  End of File