S60 3rd Edition SDK for Symbian OS
Example Applications Guide

CLandmarksEditDialog Class Reference

#include <LandmarksEditDialog.h>

Inheritance diagram for CLandmarksEditDialog:

MLandmarksOperationObserver List of all members.

Public Member Functions

 ~CLandmarksEditDialog ()
void DynInitMenuPaneL (TInt aResourceId, CEikMenuPane *aMenuPane)
void ProcessCommandL (TInt aCommandId)
void NotifyOperationProgressL (TOperation aOperation, TInt aProgress, TInt aErrorCode)

Static Public Member Functions

static CLandmarksEditDialog * NewLC (CPosLandmark &aLandmark, TBool aUseCurrentLocation, TBool &aEdited, CLandmarksApplicationEngine &aEngine, TInt aInitialFocusFieldId=0)

Protected Member Functions

TBool OkToExitL (TInt aButtonId)
TBool SaveFormDataL ()

Private Member Functions

void PreLayoutDynInitL ()
void PostLayoutDynInitL ()
void SetInitialCurrentLine ()
void HandleControlEventL (CCoeControl *aControl, TCoeEvent aEventType)
 CLandmarksEditDialog (CPosLandmark &aLandmark, TBool aUseCurrentLocation, TBool &aEdited, CLandmarksApplicationEngine &aEngine, TInt aInitialFocusFieldId)
void ConstructL ()
void ConfigureFieldsL ()
void ConfigureLocationFieldsL (TLocality &aLocation)
void ConfigureCategoryFieldL ()
void ConfigureTextFieldL (TInt aControlId, const TDesC &aText)
void UpdateTitleBarL (TBool aFromField=EFalse)
void FetchFloatL (TRealX &aFloat, TInt aEditorResourceId, TInt aErrorResourceId)
void NotifyErrorToUserL (TInt aResourceId)
void EditCategoriesL ()
void UpdateToCurrentLocationL ()

Private Attributes

CPosLandmark * iLandmark
 The landmark to be viewed/edited.
TBool iUseCurrentLocation
 Whether to get location on startup.
TBool & iEdited
 Indicates if the landmark has been edited or not.
CLandmarksApplicationEngine & iEngine
 Engine is used for reading categories.
TInt iInitialFocusFieldId
 Item selected on startup.
CAknTitlePane * iTitlePane
 The title pane that is dynamically updated.
HBufC * iOriginalTitle
 The original title that the title pane displayed before modified.
TPositionInfo iPositionInfo
 Contains a location if the user wants to update to current location.
HBufC * iAppName
 The name of the application. Used when fetching locations.
CLandmarksPositionRequest * iPositionRequest
 A position request used for retriveing locations.
CLandmarksLmCategoriesModel * iLmCategoriesModel
 The listbox model for categories editor.
RArray< TPosLmItemId > iCategoryIds
 The category ids that are set for this landmark.
TRealFormat iRealFormat
 Defines how real numbers are formatted.
RArray< TBool > iIsRealValueEdited
 Defines which real values that have been edited.

Detailed Description

A dialog that makes it possible to edit certain fields of a landmark.

Definition at line 41 of file LandmarksEditDialog.h.


Constructor & Destructor Documentation

CLandmarksEditDialog::~CLandmarksEditDialog (   ) 
 

Destructor.

Definition at line 124 of file LandmarksEditDialog.cpp.

References iAppName, iCategoryIds, iIsRealValueEdited, iLmCategoriesModel, iOriginalTitle, iPositionRequest, and iTitlePane.

00125     {
00126     delete iAppName;
00127     delete iPositionRequest;
00128     iCategoryIds.Close();
00129     iIsRealValueEdited.Close();
00130     delete iLmCategoriesModel;
00131 
00132     // Restore title pane. Ownership of iTitlePane transferred.
00133     if (iTitlePane && iOriginalTitle)
00134         {
00135         iTitlePane->SetText(iOriginalTitle);
00136         }
00137     }

CLandmarksEditDialog::CLandmarksEditDialog (  CPosLandmark &  aLandmark,
TBool  aUseCurrentLocation,
TBool &  aEdited,
CLandmarksApplicationEngine &  aEngine,
TInt  aInitialFocusFieldId
)  [private]
 

Constructor.

Parameters:
aLandmark the landmark to edit
aUseCurrentLocation whether to initiate landmark with current location
aEdited ETrue if the landmark has been modified, EFalse otherwise
aEngine the application engine used for accessing categories
aInitialFocusFieldId Item to select on startup

Definition at line 48 of file LandmarksEditDialog.cpp.

References iEdited, and iRealFormat.

00054 :   iLandmark(&aLandmark), 
00055     iUseCurrentLocation(aUseCurrentLocation),
00056     iEdited(aEdited),
00057     iEngine(aEngine),
00058     iInitialFocusFieldId(aInitialFocusFieldId)
00059     {
00060     iEdited = EFalse;
00061 
00062     // Configure real format
00063     const TChar KDecimalChar = '.';
00064     iRealFormat.iPlaces = KNrOfDecimals;
00065     iRealFormat.iPoint = KDecimalChar;
00066     iRealFormat.iTriLen = 0;
00067     iRealFormat.iWidth = KPosLmMaxTextFieldLength;
00068     iRealFormat.iType = KRealFormatFixed;
00069     }


Member Function Documentation

CLandmarksEditDialog * CLandmarksEditDialog::NewLC (  CPosLandmark &  aLandmark,
TBool  aUseCurrentLocation,
TBool &  aEdited,
CLandmarksApplicationEngine &  aEngine,
TInt  aInitialFocusFieldId = 0
)  [static]
 

Two-phased constructor.

Parameters:
aLandmark the landmark to edit
aUseCurrentLocation whether to initiate landmark with current location
aEdited ETrue if the landmark has been modified, EFalse otherwise
aEngine the application engine used for accessing categories
aInitialFocusFieldId Item to select on startup

Definition at line 109 of file LandmarksEditDialog.cpp.

References CLandmarksEditDialog().

00115     {
00116     CLandmarksEditDialog* self = new (ELeave) CLandmarksEditDialog(
00117         aLandmark, aUseCurrentLocation, aEdited, aEngine, aInitialFocusFieldId);
00118     CleanupStack::PushL(self);
00119     self->ConstructL();
00120     return self;
00121     }

void CLandmarksEditDialog::DynInitMenuPaneL (  TInt  aResourceId,
CEikMenuPane *  aMenuPane
) 
 

DynInitMenuPaneL initializes the menu pane before it is displayed.

Parameters:
aResourceId a resource ID indetifying the menu bar containing the menu pane to be initialized.
aMenuPane the menu pane to initialize.

Definition at line 145 of file LandmarksEditDialog.cpp.

00148     {
00149     CAknForm::DynInitMenuPaneL(aResourceId, aMenuPane);
00150     if (aResourceId == R_AVKON_FORM_MENUPANE)
00151         {
00152         // We do not want to allow the user to modify our Form therefore 
00153         // Disable the Label, Add, Delete, and Save Field 
00154         aMenuPane->SetItemDimmed(EAknFormCmdLabel, ETrue); 
00155         aMenuPane->SetItemDimmed(EAknFormCmdAdd, ETrue); 
00156         aMenuPane->SetItemDimmed(EAknFormCmdDelete, ETrue); 
00157         aMenuPane->SetItemDimmed(EAknFormCmdSave, ETrue);
00158 
00159         aMenuPane->SetItemDimmed(ELandmarksUpdateToCurrentLocation, 
00160             Control(ELandmarkCategoryField)->IsFocused());
00161         aMenuPane->SetItemDimmed(ELandmarksEditCategories, 
00162             !Control(ELandmarkCategoryField)->IsFocused());
00163         }
00164     }

void CLandmarksEditDialog::ProcessCommandL (  TInt  aCommandId  ) 
 

Processes user commands.

Parameters:
aCommandId id of the command to respond to

Definition at line 172 of file LandmarksEditDialog.cpp.

References EditCategoriesL(), and UpdateToCurrentLocationL().

00173         {
00174     switch (aCommandId)
00175         {
00176         case ELandmarksUpdateToCurrentLocation:
00177             UpdateToCurrentLocationL();
00178             break;
00179 
00180         case ELandmarksEditCategories:
00181             EditCategoriesL();
00182             break;
00183 
00184         default:
00185             break;
00186         }
00187 
00188         CAknForm::ProcessCommandL(aCommandId);
00189         }

void CLandmarksEditDialog::NotifyOperationProgressL (  TOperation  aOperation,
TInt  aProgress,
TInt  aErrorCode
)  [virtual]
 

NotifyOperationProgressL notifies the progress and status of an asynchronous operation.

Parameters:
aOperation the type of operation that is reported.
aProgress the progress of the operation.
aErrorCode the status of the operation.

Implements MLandmarksOperationObserver.

Definition at line 197 of file LandmarksEditDialog.cpp.

References ConfigureLocationFieldsL(), iIsRealValueEdited, and iPositionInfo.

00201     {
00202     if (aErrorCode == KErrNone && 
00203         aOperation == EAcquiringLocation)
00204         {
00205         // Update location fields with new location
00206         TPosition position;
00207         iPositionInfo.GetPosition(position);
00208         ConfigureLocationFieldsL(position);
00209         SetChangesPending(ETrue);
00210 
00211         // Indicate that editors have been updated
00212         for (TInt i = ELatitudeEditor; i <= EVerticalAccEditor; i++)
00213             {
00214             iIsRealValueEdited[i] = ETrue;
00215             }
00216         }
00217     }

TBool CLandmarksEditDialog::OkToExitL (  TInt  aButtonId  )  [protected]
 

Handles a dialog button press for the specified dialog button.

Parameters:
aButtonId 
Returns:
ETrue if OK to exit, EFalse to keep the dialog active

Definition at line 225 of file LandmarksEditDialog.cpp.

00226         {
00227     if (aButtonId == EAknSoftkeyDone)
00228         {
00229         // exit from CAknForm's "edit" mode
00230         return CAknForm::OkToExitL(EAknSoftkeyBack);
00231         }
00232     else
00233         {
00234         return CAknForm::OkToExitL(aButtonId);
00235         }
00236         }

TBool CLandmarksEditDialog::SaveFormDataL (   )  [protected]
 

SaveFormDataL deals with the occasion of a change from edit->view mode and the user wishes to save the changes.

Returns:
ETrue if the editable state can be left, EFalse otherwise

Definition at line 339 of file LandmarksEditDialog.cpp.

References FetchFloatL(), iCategoryIds, iIsRealValueEdited, and iLandmark.

00340     {
00341     CEikEdwin* editor = NULL;
00342 
00343     // Fetch name
00344     TBuf<KPosLmMaxTextFieldLength> name;
00345     editor = static_cast <CEikEdwin*> (Control(ELandmarkNameField));
00346     editor->GetText(name);
00347 
00348     // Fetch description
00349     HBufC* descBuf = HBufC::NewLC(KPosLmMaxDescriptionLength);
00350     TPtr desc = descBuf->Des();
00351     editor = static_cast <CEikEdwin*> (Control(ELandmarkDescField));
00352     editor->GetText(desc);
00353 
00354     // Fetch existing location
00355     TLocality existingLocation;
00356     TBool locationExists = 
00357         (iLandmark->GetPosition(existingLocation) == KErrNone);
00358     TRealX floatFieldValue;
00359 
00360     // Fetch Latitude
00361     TReal latitude = existingLocation.Latitude();
00362     if (iIsRealValueEdited[ELatitudeEditor] || !locationExists)
00363         {
00364         FetchFloatL(floatFieldValue, ELandmarkLatitudeField, 
00365             R_LMREFAPP_LATITUDE_ERROR);
00366         floatFieldValue.GetTReal(latitude);
00367         }
00368 
00369     // Fetch Longitude
00370     TReal longitude = existingLocation.Longitude();
00371     if (iIsRealValueEdited[ELongitudeEditor] || !locationExists)
00372         {
00373         FetchFloatL(floatFieldValue, ELandmarkLongitudeField, 
00374             R_LMREFAPP_LONGITUDE_ERROR);
00375         floatFieldValue.GetTReal(longitude);
00376         }
00377 
00378     // Fetch Altitude
00379     TReal32 altitude = existingLocation.Altitude();
00380     if (iIsRealValueEdited[EAltitudeEditor] || !locationExists)
00381         {
00382         FetchFloatL(floatFieldValue, ELandmarkAltitudeField, 
00383             R_LMREFAPP_ALTITUDE_ERROR);
00384         floatFieldValue.GetTReal(altitude);
00385         }
00386 
00387     // Fetch horizontal accuracy
00388     TReal32 horAcc = existingLocation.HorizontalAccuracy();
00389     if (iIsRealValueEdited[EHorizontalAccEditor] || !locationExists)
00390         {
00391         FetchFloatL(floatFieldValue, ELandmarkHorAccField, 
00392             R_LMREFAPP_HOR_ACC_ERROR);
00393         floatFieldValue.GetTReal(horAcc);
00394         }
00395 
00396     // Fetch vertical accuracy
00397     TReal32 verAcc = existingLocation.VerticalAccuracy();
00398     if (iIsRealValueEdited[EVerticalAccEditor] || !locationExists)
00399         {
00400         FetchFloatL(floatFieldValue, ELandmarkVerAccField, 
00401             R_LMREFAPP_VER_ACC_ERROR);
00402         floatFieldValue.GetTReal(verAcc);
00403         }
00404 
00405     // Fetch Coverage Radius
00406     TReal32 radius;
00407     TInt radiusExists = (iLandmark->GetCoverageRadius(radius) == KErrNone);
00408     if (iIsRealValueEdited[ERadiusEditor] || !radiusExists)
00409         {
00410         FetchFloatL(floatFieldValue, ELandmarkRadiusField, 
00411             R_LMREFAPP_RADIUS_ERROR);
00412         floatFieldValue.GetTReal(radius);
00413         }
00414 
00415     // Fetch street
00416     TBuf<KPosLmMaxTextFieldLength> street;
00417     editor = 
00418         static_cast <CEikEdwin*> (Control(ELandmarkStreetField));
00419     editor->GetText(street);
00420 
00421     // Fetch postal code
00422     TBuf<KPosLmMaxTextFieldLength> postalCode;
00423     editor = 
00424         static_cast <CEikEdwin*> (Control(ELandmarkPostalField));
00425     editor->GetText(postalCode);
00426 
00427     // Fetch city
00428     TBuf<KPosLmMaxTextFieldLength> city;
00429     editor = static_cast <CEikEdwin*> (Control(ELandmarkCityField));
00430     editor->GetText(city);
00431 
00432     // Fetch country
00433     TBuf<KPosLmMaxTextFieldLength> country;
00434     editor = 
00435         static_cast <CEikEdwin*> (Control(ELandmarkCountryField));
00436     editor->GetText(country);
00437 
00438     // Update category
00439     iLandmark->RemoveLandmarkAttributes(CPosLandmark::ECategoryInfo);
00440     for (TInt i = 0; i < iCategoryIds.Count(); i++)
00441         {
00442         iLandmark->AddCategoryL(iCategoryIds[i]);
00443         }
00444     // Check that at least some data is entered
00445     if (!name.Length() && !desc.Length() && 
00446         !street.Length() && !city.Length() && 
00447         !country.Length() && !postalCode.Length() &&
00448         !iCategoryIds.Count() &&
00449         Math::IsNaN(latitude) && Math::IsNaN(longitude) &&
00450         Math::IsNaN(altitude) && Math::IsNaN(radius) &&
00451         Math::IsNaN(horAcc) && Math::IsNaN(verAcc))
00452         {
00453         NotifyErrorToUserL(R_LMREFAPP_EMPTY_LANDMARK);
00454         }
00455 
00456     // Update name
00457     iLandmark->SetLandmarkNameL(name);
00458 
00459     // Update description
00460     iLandmark->SetLandmarkDescriptionL(desc);
00461     CleanupStack::PopAndDestroy(descBuf);
00462 
00463     // Update coverage radius
00464     if (!Math::IsNaN(radius) && radius < 0)
00465         {
00466         NotifyErrorToUserL(R_LMREFAPP_RADIUS_ERROR);
00467         }
00468     iLandmark->SetCoverageRadius(radius);
00469 
00470     // Update street
00471     iLandmark->SetPositionFieldL(EPositionFieldStreet, street);
00472 
00473     // Update postal code
00474     iLandmark->SetPositionFieldL(EPositionFieldPostalCode, postalCode);
00475 
00476     // Update city
00477     iLandmark->SetPositionFieldL(EPositionFieldCity, city);
00478 
00479     // Update country
00480     iLandmark->SetPositionFieldL(EPositionFieldCountry, country);
00481 
00482     // Update location. There are some rules specified by TLocality and 
00483     // TCoordinate how to update a location. These rules are taken into 
00484     // account below when validating the location data.
00485     if (Math::IsNaN(latitude) && Math::IsNaN(longitude))
00486         {
00487         // If lat long are undefined, then alt and hAcc
00488         // must be undefined
00489         if (!Math::IsNaN(horAcc))
00490             {
00491             NotifyErrorToUserL(R_LMREFAPP_HACC_LAT_LONG_ERROR);
00492             }
00493         else if (!Math::IsNaN(altitude))
00494             {
00495             NotifyErrorToUserL(R_LMREFAPP_ALT_LAT_LONG_ERROR);
00496             }
00497         else if (!Math::IsNaN(verAcc))
00498             {
00499             NotifyErrorToUserL(R_LMREFAPP_VACC_ALT_ERROR);
00500             }
00501         else 
00502             {
00503             // None position fields are set, Remove position info.
00504             iLandmark->RemoveLandmarkAttributes(CPosLandmark::EPosition);
00505             }
00506         }
00507     else if (!Math::IsNaN(latitude) && !Math::IsNaN(longitude))
00508         {
00509         // If lat long are defined, hAcc must be positive if defined
00510         if (!Math::IsNaN(horAcc) && horAcc < 0)
00511             {
00512             NotifyErrorToUserL(R_LMREFAPP_HOR_ACC_ERROR);
00513             }
00514 
00515         // if altitude is undefined, then vertical accuracy 
00516         // must be undefined
00517         if (Math::IsNaN(altitude) && !Math::IsNaN(verAcc))
00518             {
00519             NotifyErrorToUserL(R_LMREFAPP_VACC_ALT_ERROR);
00520             }
00521             
00522         // vertical accuracy must be positive if defined
00523         if (!Math::IsNaN(verAcc) && verAcc < 0)
00524             {
00525             NotifyErrorToUserL(R_LMREFAPP_VER_ACC_ERROR);
00526             }
00527             
00528         // We are allowed to set the new locality
00529         TCoordinate coordinate(latitude, longitude, altitude);
00530         TLocality newLocation(coordinate, horAcc, verAcc);
00531         iLandmark->SetPositionL(newLocation);
00532         }
00533     else 
00534         {
00535         // Inform user that no valid lat/long has been entered
00536         NotifyErrorToUserL(R_LMREFAPP_LAT_LONG_ERROR);
00537         }
00538 
00539     iEdited = ETrue;
00540     return ETrue;
00541     }

void CLandmarksEditDialog::PreLayoutDynInitL (   )  [private]
 

PreLayoutDynInitL initialises the dialog's controls before the dialog is sized and layed out.

Definition at line 244 of file LandmarksEditDialog.cpp.

References ConfigureCategoryFieldL(), and ConfigureFieldsL().

00245     {
00246     SetEditableL(ETrue);
00247     ConfigureFieldsL();
00248     ConfigureCategoryFieldL();
00249     }

void CLandmarksEditDialog::PostLayoutDynInitL (   )  [private]
 

PostLayoutDynInitL initialises the dialog's controls after the dialog has been sized but before it has been activated.

Definition at line 257 of file LandmarksEditDialog.cpp.

References iUseCurrentLocation, UpdateTitleBarL(), and UpdateToCurrentLocationL().

00258     {
00259     SetChangesPending(ETrue);
00260 
00261     UpdateTitleBarL();
00262     CAknForm::PostLayoutDynInitL();
00263     
00264     if (iUseCurrentLocation)
00265         {
00266         UpdateToCurrentLocationL();
00267         }
00268     }

void CLandmarksEditDialog::SetInitialCurrentLine (   )  [private]
 

Selects desired line on startup

Definition at line 276 of file LandmarksEditDialog.cpp.

References iInitialFocusFieldId.

00277     {
00278     CAknForm::SetInitialCurrentLine();
00279     
00280     if (iInitialFocusFieldId >= ELandmarkNameField &&
00281         iInitialFocusFieldId <= ELandmarkCountryField)
00282         {
00283         TInt err = KErrNone;
00284         TRAP(err, TryChangeFocusToL(iInitialFocusFieldId));
00285         }
00286     }

void CLandmarksEditDialog::HandleControlEventL (  CCoeControl *  aControl,
TCoeEvent  aEventType
)  [private]
 

Handles control events.

Parameters:
aControl The control reporting the event
aEventType The event type

Definition at line 294 of file LandmarksEditDialog.cpp.

References iIsRealValueEdited, and UpdateTitleBarL().

00297         {
00298     CAknForm::HandleControlEventL(aControl, aEventType);
00299 
00300     if (aEventType == EEventStateChanged)
00301         {
00302         if (aControl == ControlOrNull(ELandmarkLatitudeField))
00303             {
00304             iIsRealValueEdited[ELatitudeEditor] = ETrue;
00305             }
00306         else if (aControl == ControlOrNull(ELandmarkLongitudeField))
00307             {
00308             iIsRealValueEdited[ELongitudeEditor] = ETrue;
00309             }
00310         else if (aControl == ControlOrNull(ELandmarkAltitudeField))
00311             {
00312             iIsRealValueEdited[EAltitudeEditor] = ETrue;
00313             }
00314         else if (aControl == ControlOrNull(ELandmarkHorAccField))
00315             {
00316             iIsRealValueEdited[EHorizontalAccEditor] = ETrue;
00317             }
00318         else if (aControl == ControlOrNull(ELandmarkVerAccField))
00319             {
00320             iIsRealValueEdited[EVerticalAccEditor] = ETrue;
00321             }
00322         else if (aControl == ControlOrNull(ELandmarkRadiusField))
00323             {
00324             iIsRealValueEdited[ERadiusEditor] = ETrue;
00325             }
00326         else if (aControl == ControlOrNull(ELandmarkNameField))
00327             {
00328             UpdateTitleBarL(ETrue); // get it from name field
00329             }
00330         }
00331         }

void CLandmarksEditDialog::ConstructL (   )  [private]
 

By default Symbian 2nd phase constructor is private.

Definition at line 76 of file LandmarksEditDialog.cpp.

References iCategoryIds, iEngine, iIsRealValueEdited, iLandmark, iLmCategoriesModel, iOriginalTitle, iPositionRequest, iTitlePane, CLandmarksLmCategoriesModel::NewL(), and CLandmarksPositionRequest::NewL().

00077     {
00078     CAknForm::ConstructL(R_LMREFAPP_EDIT_MENU_BAR);
00079 
00080     // Save original title
00081     CEikStatusPane* statusPane = iAvkonAppUi->StatusPane();
00082     iTitlePane = (CAknTitlePane*) statusPane->ControlL(
00083         TUid::Uid(EEikStatusPaneUidTitle));
00084     iOriginalTitle = iTitlePane->Text()->AllocL();
00085 
00086     // Create iPositionRequest
00087     HBufC* appName = iCoeEnv->AllocReadResourceAsDes16LC(R_LMREFAPP_APP_TITLE);
00088     iPositionRequest = CLandmarksPositionRequest::NewL(*appName, this);
00089     CleanupStack::PopAndDestroy(appName);
00090 
00091     // Initialize iCategoryIds
00092     iLandmark->GetCategoriesL(iCategoryIds);
00093     
00094     iLmCategoriesModel = 
00095             CLandmarksLmCategoriesModel::NewL(iEngine, iCategoryIds);
00096 
00097     // Initialise states of real value editors
00098     for (TInt i = ELatitudeEditor; i <= ERadiusEditor; i++)
00099         {
00100         User::LeaveIfError(iIsRealValueEdited.Append(EFalse));
00101         }
00102     }

void CLandmarksEditDialog::ConfigureFieldsL (   )  [private]
 

Configures the fields of the landmark to view/edit.

Definition at line 549 of file LandmarksEditDialog.cpp.

References ConfigureLocationFieldsL(), ConfigureTextFieldL(), iLandmark, and iRealFormat.

00550     {
00551     TPtrC textFieldValue;
00552 
00553     // Configure landmark name
00554     textFieldValue.Set(KNullDesC);
00555     iLandmark->GetLandmarkName(textFieldValue);
00556 
00557     ConfigureTextFieldL(ELandmarkNameField, textFieldValue);
00558 
00559     // Configure description
00560     textFieldValue.Set(KNullDesC);
00561     iLandmark->GetLandmarkDescription(textFieldValue);
00562 
00563     ConfigureTextFieldL(ELandmarkDescField, textFieldValue);
00564 
00565     // Configure street;
00566     textFieldValue.Set(KNullDesC);
00567     iLandmark->GetPositionField(EPositionFieldStreet, textFieldValue);
00568 
00569     ConfigureTextFieldL(ELandmarkStreetField, textFieldValue);
00570 
00571     // Configure postalCode;
00572     textFieldValue.Set(KNullDesC);
00573     iLandmark->GetPositionField(EPositionFieldPostalCode, textFieldValue);
00574 
00575     ConfigureTextFieldL(ELandmarkPostalField, textFieldValue);
00576 
00577     // Configure city;
00578     textFieldValue.Set(KNullDesC);
00579     iLandmark->GetPositionField(EPositionFieldCity, textFieldValue);
00580 
00581     ConfigureTextFieldL(ELandmarkCityField, textFieldValue);
00582 
00583     // Configure country
00584     textFieldValue.Set(KNullDesC);
00585     iLandmark->GetPositionField(EPositionFieldCountry, textFieldValue);
00586 
00587     ConfigureTextFieldL(ELandmarkCountryField, textFieldValue);
00588 
00589     // Configure location fields
00590     TLocality location;
00591     iLandmark->GetPosition(location);
00592     ConfigureLocationFieldsL(location);
00593 
00594     // Configure coverage Radius
00595     TReal32 coverageRadius;
00596     TBuf<KPosLmMaxTextFieldLength> radiusBuf;
00597     TInt res = iLandmark->GetCoverageRadius(coverageRadius);
00598     if (res != KErrNotFound)
00599         {
00600         radiusBuf.AppendNum(coverageRadius, iRealFormat);
00601         }
00602 
00603     ConfigureTextFieldL(ELandmarkRadiusField, radiusBuf);
00604     }

void CLandmarksEditDialog::ConfigureLocationFieldsL (  TLocality &  aLocation  )  [private]
 

Configures the location fields of the landmark to view/edit.

Parameters:
aLocation contains the location data to update location fields with.

Definition at line 612 of file LandmarksEditDialog.cpp.

References ConfigureTextFieldL(), LandmarksUtils::FloatToDesL(), iRealFormat, and LandmarksUtils::LatLongToDes().

00613     {
00614     TBuf<KPosLmMaxTextFieldLength> textFieldValue;
00615 
00616     // Configure latitude in float format
00617     LandmarksUtils::LatLongToDes(aLocation.Latitude(), textFieldValue);
00618     ConfigureTextFieldL(ELandmarkLatitudeField, textFieldValue);
00619 
00620     // Configure longitude in float format
00621     LandmarksUtils::LatLongToDes(aLocation.Longitude(), textFieldValue);
00622     ConfigureTextFieldL(ELandmarkLongitudeField, textFieldValue);
00623 
00624     // Configure altitude
00625     LandmarksUtils::FloatToDesL(aLocation.Altitude(), textFieldValue, iRealFormat);
00626     ConfigureTextFieldL(ELandmarkAltitudeField, textFieldValue);
00627 
00628     // Configure horizontal accuracy
00629     LandmarksUtils::FloatToDesL(aLocation.HorizontalAccuracy(), textFieldValue, iRealFormat);
00630     ConfigureTextFieldL(ELandmarkHorAccField, textFieldValue);
00631 
00632     // Configure vertical accuracy
00633     LandmarksUtils::FloatToDesL(aLocation.VerticalAccuracy(), textFieldValue, iRealFormat);
00634     ConfigureTextFieldL(ELandmarkVerAccField, textFieldValue);
00635     }

void CLandmarksEditDialog::ConfigureCategoryFieldL (   )  [private]
 

Configures the category field.

Definition at line 643 of file LandmarksEditDialog.cpp.

References CLandmarksApplicationEngine::CategoryLC(), ConfigureTextFieldL(), iCategoryIds, and iEngine.

00644     {
00645     TInt nrOfCategories = iCategoryIds.Count();
00646     const TInt KExtraChars = 2; // CRLF
00647     
00648     HBufC* lmCategoriesBuf = HBufC::NewLC(
00649         (KPosLmMaxTextFieldLength + KExtraChars) * nrOfCategories);
00650     
00651     TPtr lmCategories = lmCategoriesBuf->Des();
00652     for (TInt i = 0; i < nrOfCategories; i++)
00653         {
00654         if (i > 0)
00655             {
00656             lmCategories.Append(CEditableText::ELineBreak);
00657             }
00658 
00659         CPosLandmarkCategory* category = iEngine.CategoryLC(iCategoryIds[i]);
00660         TPtrC categoryName;
00661         category->GetCategoryName(categoryName);
00662         lmCategories.Append(categoryName);
00663         CleanupStack::PopAndDestroy(category);
00664         }
00665 
00666     ConfigureTextFieldL(ELandmarkCategoryField, *lmCategoriesBuf);
00667 
00668     CleanupStack::PopAndDestroy(lmCategoriesBuf);
00669     }

void CLandmarksEditDialog::ConfigureTextFieldL (  TInt  aControlId,
const TDesC &  aText
)  [private]
 

Sets text to the specified field

Parameters:
aControlId ID of control in the dialog
aText Text to set to the control

Definition at line 671 of file LandmarksEditDialog.cpp.

00672     {
00673     CEikEdwin* editor = static_cast<CEikEdwin*>(Control(aId));
00674         editor->SetTextL(&aText);
00675     }

void CLandmarksEditDialog::UpdateTitleBarL (  TBool  aFromField = EFalse  )  [private]
 

Updates the title bar based on the contents in the name field.

Parameters:
aFromField Whether to get text from name field or from landmark.

Definition at line 683 of file LandmarksEditDialog.cpp.

References iLandmark, and iTitlePane.

00684     {
00685     if (aFromField)
00686         {
00687         TBuf<KPosLmMaxTextFieldLength> name;
00688 
00689         CEikEdwin* nameEditor = 
00690             static_cast<CEikEdwin*>(Control(ELandmarkNameField));
00691         nameEditor->GetText(name);
00692         iTitlePane->SetTextL(name);
00693         }
00694     else
00695         {
00696         TPtrC ptr;
00697         iLandmark->GetLandmarkName(ptr);
00698         iTitlePane->SetTextL(ptr);
00699         }
00700     }

void CLandmarksEditDialog::FetchFloatL (  TRealX &  aFloat,
TInt  aEditorResourceId,
TInt  aErrorResourceId
)  [private]
 

Retrieves a float from am EDWIN editor.

Parameters:
aFloat float that is retrieved from editor.
aEditorResourceId the resource id of the editor to read
aErrorResourceId a resource id for a descriptor containing an error message that is displayed in case fetching failed

Definition at line 708 of file LandmarksEditDialog.cpp.

References NotifyErrorToUserL().

00712     {
00713     const TChar KDecimalPoint = '.';
00714     TBuf<KPosLmMaxTextFieldLength> textFieldValue;
00715     TLex fieldLex;
00716     TInt result(KErrNone);
00717     CEikEdwin* editor = static_cast <CEikEdwin*> (Control(aEditorResourceId));
00718 
00719     editor->GetText(textFieldValue);
00720     if (textFieldValue == KNullDesC)
00721         {
00722         // User has indicated that he/she wants this value to be undefined.
00723         aFloat.SetNaN();
00724         }
00725     else 
00726         {
00727         // Try to extract value
00728         fieldLex = textFieldValue;
00729         TReal floatValue(0);
00730         result = fieldLex.Val(floatValue, KDecimalPoint);
00731         if (result != KErrNone)
00732             {
00733             NotifyErrorToUserL(aErrorResourceId);
00734             }
00735 
00736         // Update output parameter
00737         User::LeaveIfError(aFloat.Set(floatValue));
00738         }
00739     }

void CLandmarksEditDialog::NotifyErrorToUserL (  TInt  aResourceId  )  [private]
 

Launches an error dialog displaying an error message to the user.

Parameters:
aResourceId a resource id for a descriptor containing an error message

Definition at line 747 of file LandmarksEditDialog.cpp.

00748     {
00749     HBufC* msg = iCoeEnv->AllocReadResourceLC(aResourceId);
00750     CAknErrorNote* errorNote = new (ELeave) CAknErrorNote(ETrue);
00751     errorNote->ExecuteLD(*msg);
00752     CleanupStack::PopAndDestroy(msg);
00753 
00754     // Leave to interrupt saving of data. Other error codes than KErrNone 
00755     // results in an additional error dialog.
00756     User::Leave(KErrNone);
00757     }

void CLandmarksEditDialog::EditCategoriesL (   )  [private]
 

Launches a markable list dialog for editing categories for this landmark.

Definition at line 765 of file LandmarksEditDialog.cpp.

References ConfigureCategoryFieldL(), iLmCategoriesModel, and CLandmarksCategoriesDialog::RunDialogL().

00766     {
00767     TInt res = CLandmarksCategoriesDialog::RunDialogL(*iLmCategoriesModel); 
00768     if (res)
00769         {
00770         ConfigureCategoryFieldL();
00771         DrawDeferred();
00772         SetChangesPending(ETrue);
00773         }
00774     }

void CLandmarksEditDialog::UpdateToCurrentLocationL (   )  [private]
 

Start location request to update landmark with current location

Definition at line 782 of file LandmarksEditDialog.cpp.

References CLandmarksPositionRequest::FetchPositionInfoL(), iPositionInfo, and iPositionRequest.

00783     {
00784     // Update location fields to current location
00785     HBufC* title = 
00786         iCoeEnv->AllocReadResourceAsDes16LC(R_LMREFAPP_ACQUIRING_LOC);
00787     iPositionRequest->FetchPositionInfoL(*title, iPositionInfo);
00788     CleanupStack::PopAndDestroy(title);
00789     }


© Nokia 2006

Back to top