locationlandmarksrefappfors60/Inc/LandmarksEditDialog.h
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2004-2007 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 *     See class description below
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __LANDMARKS_EDIT_DIALOG_H__
       
    21 #define __LANDMARKS_EDIT_DIALOG_H__
       
    22 
       
    23 
       
    24 #include <AknForm.h>
       
    25 #include <AknForm.h>
       
    26 #include "LandmarksOperationObserver.h"
       
    27 
       
    28 class CLandmarksApplicationEngine;
       
    29 class CLandmarksLmCategoriesModel;
       
    30 class CLandmarksPositionRequest;
       
    31 class CPosLandmarkCategory;
       
    32 class CAknTitlePane;
       
    33 class CAknWaitDialog;
       
    34 class CPosLandmark;
       
    35 class TLocality;
       
    36 class TPositionInfo;
       
    37 
       
    38 
       
    39 
       
    40 /**
       
    41 *  A dialog that makes it possible to edit certain fields of a landmark.
       
    42 */
       
    43 class CLandmarksEditDialog : 
       
    44     public CAknForm, 
       
    45     public MLandmarksOperationObserver
       
    46     {
       
    47     public: // Constructors and destructor
       
    48 
       
    49         /**
       
    50         * Two-phased constructor.
       
    51         *
       
    52         * @param aLandmark the landmark to edit
       
    53         * @param aUseCurrentLocation whether to initiate landmark with
       
    54         * current location
       
    55         * @param aEdited ETrue if the landmark has been modified,
       
    56         * EFalse otherwise
       
    57         * @param aEngine the application engine used for accessing categories
       
    58         * @param aInitialFocusFieldId Item to select on startup
       
    59         */
       
    60         static CLandmarksEditDialog* NewLC(
       
    61             CPosLandmark& aLandmark,
       
    62             TBool aUseCurrentLocation,
       
    63             TBool& aEdited,
       
    64             CLandmarksApplicationEngine& aEngine,
       
    65             TInt aInitialFocusFieldId = 0);
       
    66 
       
    67         /**
       
    68         * Destructor.
       
    69         */
       
    70         ~CLandmarksEditDialog();
       
    71 
       
    72     public: // From CAknDialog
       
    73 
       
    74         /**
       
    75         * DynInitMenuPaneL initializes the menu pane before it is displayed.
       
    76         *
       
    77         * @param aResourceId a resource ID indetifying the menu bar containing
       
    78         * the menu pane to be initialized.
       
    79         * @param aMenuPane the menu pane to initialize.
       
    80         */
       
    81         void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
       
    82 
       
    83         /**
       
    84         * Processes user commands.
       
    85         *
       
    86         * @param aCommandId id of the command to respond to
       
    87         */
       
    88         void ProcessCommandL(TInt aCommandId);
       
    89 
       
    90     public: // From MLandmarksOperationObserver
       
    91 
       
    92         /**
       
    93         * NotifyOperationProgressL notifies the progress and status of an
       
    94         * asynchronous operation.
       
    95         *
       
    96         * @param aOperation the type of operation that is reported.
       
    97         * @param aProgress the progress of the operation.
       
    98         * @param aErrorCode the status of the operation.
       
    99         */
       
   100         void NotifyOperationProgressL(
       
   101             TOperation aOperation,
       
   102             TInt aProgress,
       
   103             TInt aErrorCode);
       
   104 
       
   105     protected: // From CAknForm
       
   106 
       
   107         /**
       
   108         * Handles a dialog button press for the specified dialog button.
       
   109         *
       
   110         * @param aButtonId
       
   111         * @return ETrue if OK to exit, EFalse to keep the dialog active
       
   112         */
       
   113         TBool OkToExitL(TInt aButtonId);
       
   114 
       
   115 
       
   116         /**
       
   117         * SaveFormDataL deals with the occasion of a change from
       
   118         * edit->view mode and the user wishes to save the changes.
       
   119         *
       
   120         * @return ETrue if the editable state can be left, EFalse otherwise
       
   121         */
       
   122         TBool SaveFormDataL();
       
   123 
       
   124     private: // From CEikDialog
       
   125 
       
   126         /**
       
   127         * PreLayoutDynInitL initialises the dialog's controls before the dialog
       
   128         * is sized and layed out.
       
   129         */
       
   130         void PreLayoutDynInitL();
       
   131 
       
   132         /**
       
   133         * PostLayoutDynInitL initialises the dialog's controls after the dialog
       
   134         * has been sized but before it has been activated.
       
   135         */
       
   136         void PostLayoutDynInitL();
       
   137 
       
   138         /**
       
   139         * Selects desired line on startup
       
   140         */
       
   141         void SetInitialCurrentLine();
       
   142 
       
   143         /**
       
   144         * Handles control events.
       
   145         *
       
   146         * @param aControl The control reporting the event
       
   147         * @param aEventType The event type
       
   148         */
       
   149         void HandleControlEventL(
       
   150             CCoeControl* aControl,
       
   151             TCoeEvent aEventType);
       
   152 
       
   153         /** Handles layout switch */
       
   154         void HandleResourceChange( TInt aType );
       
   155 
       
   156     private:
       
   157 
       
   158         enum TErrorInForm
       
   159             {
       
   160             ENoErrors,
       
   161             EWrongLatitude,
       
   162             EWrongLongitude,
       
   163             EWrongAltitude,
       
   164             EWrongHorAcc,
       
   165             EWrongVerAcc,
       
   166             EWrongRadius,
       
   167             EOnlyLatOrLon,
       
   168             ENoLatLonButHorAcc,
       
   169             ENoLatLonButAltitude,
       
   170             ENoAltButVerAcc,
       
   171             EEmptyLandmarkName,
       
   172             };
       
   173 
       
   174         /** Constructor
       
   175          *
       
   176          *  @param aLandmark the landmark to edit
       
   177          *  @param aUseCurrentLocation whether to initiate landmark with current location
       
   178          *  @param aEdited ETrue if the landmark has been modified, EFalse otherwise
       
   179          *  @param aEngine the application engine used for accessing categories
       
   180          *  @param aInitialFocusFieldId Item to select on startup
       
   181          */
       
   182         CLandmarksEditDialog(
       
   183             CPosLandmark& aLandmark,
       
   184             TBool aUseCurrentLocation,
       
   185             TBool& aEdited,
       
   186             CLandmarksApplicationEngine& aEngine,
       
   187             TInt aInitialFocusFieldId);
       
   188 
       
   189         void ConstructL();
       
   190 
       
   191         /** Configures the fields of the landmark to view/edit */
       
   192         void ConfigureFieldsL();
       
   193 
       
   194         /** Copies address data from landmark to fields */
       
   195         void ConfigureAddressFieldsL();
       
   196 
       
   197         /** Copies the location data from landmark to fields.
       
   198          *  @param aLocation contains the location data to update location fields with.
       
   199          */
       
   200         void ConfigureLocationFieldsL(TLocality& aLocation);
       
   201 
       
   202         /** Configures the category field */
       
   203         void ConfigureCategoryFieldL();
       
   204 
       
   205         /** Sets text to the specified field
       
   206          * @param aControlId ID of control in the dialog
       
   207          * @param aText Text to set to the control
       
   208          */
       
   209         void SetTextFieldL(TInt aControlId, const TDesC& aText);
       
   210 
       
   211         /** Sets text to the specified location field
       
   212          * @param aControlId ID of control in the dialog
       
   213          * @param aPosition Position value to set to the editor
       
   214          */
       
   215         void SetLocationFieldL( TInt aId, const TPosition& aPosition );
       
   216 
       
   217         /** Updates the title bar based on the contents in the name field.
       
   218          * @param aFromField Whether to get text from name field or from landmark.
       
   219          */
       
   220         void UpdateTitleBarL(TBool aFromField = EFalse);
       
   221 
       
   222         /** Launches a markable list dialog for editing categories for this landmark */
       
   223         void EditCategoriesL();
       
   224         
       
   225         /** Start location request to update landmark with current location */
       
   226         void UpdateToCurrentLocationL();
       
   227 
       
   228         /** Gets all data from fields, checks and saves to current landmark */
       
   229         TErrorInForm FetchAndSaveFormDataL();
       
   230 
       
   231         /** Saves values of address fields to current landmark */
       
   232         void SaveAddressDataL();
       
   233 
       
   234         /** Saves values of coordinates fields to current landmark 
       
   235          *  \return one of TErrorsInFields values
       
   236          */
       
   237         TErrorInForm SaveCoordinateDataL();
       
   238 
       
   239         /** Launches an error dialog displaying an error message to the user.
       
   240          *  @param aResourceId a resource id for a descriptor containing an
       
   241          *  error message
       
   242          */
       
   243         void ProcessErrorsInFormL( TErrorInForm aErrorId );
       
   244 
       
   245         /** Launches an error dialog displaying an error message to the user.
       
   246          *  @param aResourceId a resource id for a descriptor containing an
       
   247          *  error message
       
   248          */
       
   249         void NotifyErrorToUserL( TInt aResourceId );
       
   250 
       
   251         /** Copies address information (address and building position fields) from
       
   252          *  source landmark to target.
       
   253          */
       
   254         void CopyAddressDataL( CPosLandmark& aSrc, CPosLandmark& aTrg );
       
   255 
       
   256         /** Copies coordinate information (locality and coverage) from
       
   257          *  source landmark to target. If some fields are empty in source,
       
   258          *  they will also be emptied in result.
       
   259          */
       
   260         void CopyCoordinateDataL( CPosLandmark& aSrc, CPosLandmark& aTrg );
       
   261         
       
   262         /** Checks whether current landmark has any address fields */
       
   263         TBool HasAddressData();
       
   264 
       
   265         /** Checks whether current landmark has coordinate set */
       
   266         TBool HasCoordinateData();
       
   267 
       
   268         /** Start wait dialog for modal async operations */
       
   269         void StartWaitDialogL( TInt aResId );
       
   270 
       
   271         /** Closes wait dialog */
       
   272         void CloseWaitDialog();
       
   273         
       
   274         /** Reset coordinates of current landmark */
       
   275         void ResetCoordinatesL();
       
   276 
       
   277     private: // Data
       
   278 
       
   279         //! The landmark to be edited
       
   280         CPosLandmark& iOriginalLandmark;
       
   281         
       
   282         //! Own copy of the original landmark's data
       
   283         CPosLandmark* iLandmark;
       
   284         
       
   285         //! Whether to get location on startup
       
   286         TBool iUseCurrentLocation;
       
   287 
       
   288         //! Indicates if the landmark has been edited or not
       
   289         TBool& iEdited;
       
   290 
       
   291         //! Engine is used for reading categories
       
   292         CLandmarksApplicationEngine& iEngine;
       
   293 
       
   294         //! Item selected on startup
       
   295         TInt iInitialFocusFieldId;
       
   296 
       
   297         //! The title pane that is dynamically updated
       
   298         CAknTitlePane* iTitlePane;
       
   299 
       
   300         //! The original title that the title pane displayed before modified
       
   301         HBufC* iOriginalTitle;
       
   302 
       
   303         //! Contains a location if the user wants to update to current location
       
   304         TPositionInfo iPositionInfo;
       
   305 
       
   306         //! The name of the application. Used when fetching locations
       
   307         HBufC* iAppName;
       
   308 
       
   309         //! A position request used for retriveing locations
       
   310         CLandmarksPositionRequest* iPositionRequest;
       
   311 
       
   312         //! The listbox model for categories editor
       
   313         CLandmarksLmCategoriesModel* iLmCategoriesModel;
       
   314 
       
   315         //! The category ids that are set for this landmark
       
   316         RArray<TPosLmItemId> iCategoryIds;
       
   317 
       
   318         //! Defines how real numbers are formatted
       
   319         TRealFormat iRealFormat;
       
   320 
       
   321         //! Defines which real values that have been edited
       
   322         RArray<TBool> iIsRealValueEdited;
       
   323 
       
   324         CAknWaitDialog*         iWaitDialog;
       
   325     };
       
   326 
       
   327 #endif // __LANDMARKS_EDIT_DIALOG__
       
   328