Example Application Guide

 

CGeoProfileEditor Class Reference

#include <geoprofileeditor.h>

Inheritance diagram for CGeoProfileEditor:

List of all members.

Detailed Description

Geo Profile Editor

Definition at line 35 of file geoprofileeditor.h.

Public Member Functions

virtual ~CGeoProfileEditor ()
TInt ExecuteLD ()

Static Public Member Functions

static CGeoProfileEditorNewL (CGeoProfile &aGeoProfile)

Private Member Functions

TBool OkToExitL (TInt aButtonId)
void PreLayoutDynInitL ()
void LineChangedL (TInt aControlId)
void HandleControlStateChangeL (TInt aControlId)
void HandlePointerEventL (const TPointerEvent &aPointerEvent)
 CGeoProfileEditor (CGeoProfile &aGeoProfile)
void ConstructL ()
void LoadFormValuesL ()
void MakeTitleL (TDesC &aText)
void LoadPlaceL ()
void LoadProfileL ()
void LoadTriggerTypeL ()
void HandleProfileSelectionL ()
void HandlePlaceSelectionL ()
TInt CheckIfSavableL ()

Private Attributes

CGeoProfileiGeoProfile
CGeoProfileiNewGeoProfile
TInt iSelectedPlace
CAknInformationNote * iInfoNote


Constructor & Destructor Documentation

CGeoProfileEditor::~CGeoProfileEditor  )  [virtual]
 

C++ Destructor. Frees all the resources

Definition at line 67 of file geoprofileeditor.cpp.

References iNewGeoProfile.

00068     {
00069     delete iNewGeoProfile;
00070     }

CGeoProfileEditor::CGeoProfileEditor CGeoProfile aGeoProfile  )  [private]
 

Default Constructor

Definition at line 58 of file geoprofileeditor.cpp.

Referenced by NewL().

00059     :iGeoProfile( aGeoProfile )
00060     {
00061     }


Member Function Documentation

CGeoProfileEditor * CGeoProfileEditor::NewL CGeoProfile aGeoProfile  )  [static]
 

Constructs a new instance of CGeoProfile Entry.

Definition at line 76 of file geoprofileeditor.cpp.

References CGeoProfileEditor().

Referenced by CGeoProfilesView::ContainerCommandL(), and CGeoProfilesView::HandleCommandL().

00077     {
00078     GEOPROFILEDEBUG("+ CGeoProfilesEngine::NewL" )
00079     
00080     CGeoProfileEditor* self = new ( ELeave ) CGeoProfileEditor( aGeoProfile );
00081     CleanupStack::PushL( self );
00082     self->ConstructL();
00083     CleanupStack::Pop( self );
00084     
00085     GEOPROFILEDEBUG("- CGeoProfilesEngine::NewL" )
00086     
00087     return self;
00088     }

TBool CGeoProfileEditor::OkToExitL TInt  aButtonId  )  [private]
 

Inherited from CEikDialog

Definition at line 126 of file geoprofileeditor.cpp.

References CheckIfSavableL(), CGeoProfile::GeoPlaceName(), CGeoProfile::GeoPositionInfo(), CGeoProfile::GeoProfileId(), CGeoProfile::GeoProfileRadius(), HandleControlStateChangeL(), HandlePlaceSelectionL(), HandleProfileSelectionL(), iGeoProfile, iNewGeoProfile, CGeoProfile::SetGeoPositionInfoL(), CGeoProfile::SetGeoProfileIdL(), CGeoProfile::SetGeoProfileRadius(), CGeoProfile::SetTriggerType(), and CGeoProfile::TriggerType().

00127     {
00128     GEOPROFILEDEBUG("+ CGeoProfilesEngine::OkToExitL" )
00129     
00130     TInt retValue = EFalse;
00131     // Check for the Options Menu.
00132     switch ( aButtonId )
00133         {
00134         case EAknSoftkeyOk:
00135             {          
00136             retValue = ETrue;
00137                         
00138             if ( IsEditable())
00139                 {
00140                 
00141                 if ( !CheckIfSavableL())
00142                     {
00143                     retValue = EFalse;
00144                     }
00145                 else
00146                     {
00147                     iGeoProfile.SetGeoProfileIdL( iNewGeoProfile->GeoProfileId());
00148                     iGeoProfile.SetGeoPositionInfoL( iNewGeoProfile->GeoPlaceName(), 
00149                                                      iNewGeoProfile->GeoPositionInfo());
00150                     iGeoProfile.SetGeoProfileRadius( iNewGeoProfile->GeoProfileRadius());
00151                     iGeoProfile.SetTriggerType( iNewGeoProfile->TriggerType());                          
00152                     }                
00153                 }
00154             break;
00155             }
00156         case EAknSoftkeyCancel:
00157             {                        
00158             retValue = ETrue;
00159             break;
00160             }
00161         case EAknSoftkeyEdit:
00162             {
00163             SetEditableL( ETrue );
00164             
00165             // Set the CBA to Editable
00166             CEikButtonGroupContainer* cba   = CEikButtonGroupContainer::Current();
00167             CleanupStack::PushL( cba );
00168             
00169             TInt focusId = IdOfFocusControl();                        
00170             if ( focusId == EGeoRadius )
00171                 {
00172                 cba->SetCommandSetL ( R_GEOPROFILES_CBA_OK_CANCEL );
00173                 }
00174             else
00175                 {
00176                 cba->SetCommandSetL ( R_GEOPROFILES_CBA_OK_CANCEL_CHANGE );     
00177                 }
00178                       
00179             cba->DrawDeferred();    
00180             CleanupStack::Pop( cba );  
00181                 
00182             break;
00183             } 
00184         case EAknSoftkeyChange:
00185             {
00186             if ( IdOfFocusControl() == EGeoProfileName )
00187                 {
00188                 HandleProfileSelectionL();
00189                 }
00190             else if ( IdOfFocusControl() == EGeoPlace )
00191                 {
00192                 HandlePlaceSelectionL();    
00193                 }
00194             else if ( IdOfFocusControl() == EGeoProfileType )
00195                 {
00196                 
00197                 CAknPopupFieldText* triggerType = static_cast < CAknPopupFieldText* > ( Control( EGeoProfileType ));
00198                 if( triggerType )
00199                     {
00200                     if ( triggerType->CurrentValueIndex() == 0)
00201                         {
00202                         triggerType->SetCurrentValueIndex( 1 );
00203                         }
00204                     else
00205                         {
00206                         triggerType->SetCurrentValueIndex( 0 );    
00207                         }    
00208                     }                                 
00209                 HandleControlStateChangeL( EGeoProfileType );                
00210                 UpdatePageL( ETrue );               
00211                 }
00212             break;
00213             }
00214         case EGeoProfilesNone:
00215         default:
00216             {
00217             break;    
00218             }
00219         }
00220         
00221     GEOPROFILEDEBUG("- CGeoProfilesEngine::OkToExitL" )
00222     return retValue;
00223     }

void CGeoProfileEditor::PreLayoutDynInitL  )  [private]
 

Inherited from CEikDialog

Definition at line 229 of file geoprofileeditor.cpp.

References LoadFormValuesL().

00230     {
00231     GEOPROFILEDEBUG("+ CGeoProfilesEngine::PreLayoutDynInitL" )
00232     
00233     CAknForm::PreLayoutDynInitL();
00234     
00235     // Load the Form values 
00236     LoadFormValuesL();
00237     
00238     GEOPROFILEDEBUG("- CGeoProfilesEngine::PreLayoutDynInitL" )
00239     }

void CGeoProfileEditor::LineChangedL TInt  aControlId  )  [private]
 

Inherited from CAknDialog

Definition at line 245 of file geoprofileeditor.cpp.

00246     {
00247     GEOPROFILEDEBUG("+ CGeoProfilesEngine::LineChangedL" )
00248     
00249     if ( IsEditable() )
00250         {
00251         // Set the CBA to Editable
00252         CEikButtonGroupContainer* cba   = CEikButtonGroupContainer::Current();
00253         CleanupStack::PushL( cba );
00254                     
00255         TInt focusId = IdOfFocusControl();                        
00256         if ( focusId == EGeoRadius )
00257             {
00258             cba->SetCommandSetL ( R_GEOPROFILES_CBA_OK_CANCEL );
00259             }
00260         else
00261             {
00262             cba->SetCommandSetL ( R_GEOPROFILES_CBA_OK_CANCEL_CHANGE );     
00263             }
00264                   
00265         cba->DrawDeferred();    
00266         CleanupStack::Pop( cba );         
00267         }
00268     GEOPROFILEDEBUG("- CGeoProfilesEngine::LineChangedL" )    
00269     }

void CGeoProfileEditor::HandleControlStateChangeL TInt  aControlId  )  [private]
 

Inherited from CAknForm

Definition at line 275 of file geoprofileeditor.cpp.

References iNewGeoProfile, CGeoProfile::SetGeoProfileRadius(), and CGeoProfile::SetTriggerType().

Referenced by OkToExitL().

00276     {
00277     GEOPROFILEDEBUG("+ CGeoProfilesEngine::HandleControlStateChangeL" )
00278     
00279     switch ( aControlId )
00280         {
00281         case EGeoRadius:
00282             {
00283             GEOPROFILEDEBUG("+ Radius" )
00284             
00285             CAknIntegerEdwin* integerEd = static_cast < CAknIntegerEdwin* > ( ControlOrNull( EGeoRadius ));
00286             if ( integerEd )
00287                 {
00288                 TInt radius = 0;
00289                 TInt error = integerEd->GetTextAsInteger( radius );
00290                 if ( CAknIntegerEdwin::EValueValid  == error )
00291                     {
00292                     iNewGeoProfile->SetGeoProfileRadius( radius );    
00293                     }
00294                 }
00295                 
00296             GEOPROFILEDEBUG("- Radius" )
00297             break;    
00298             }
00299         case EGeoProfileType:
00300             {
00301             GEOPROFILEDEBUG("+ TriggerType" )
00302             
00303             CAknPopupFieldText* triggerType = static_cast < CAknPopupFieldText* > ( Control( EGeoProfileType ));
00304             if( triggerType )
00305                 {
00306                 if ( triggerType->CurrentValueIndex() == 0)
00307                     {
00308                     iNewGeoProfile->SetTriggerType( CGeoProfile::EEntryTrigger );
00309                     }
00310                 else
00311                     {
00312                     iNewGeoProfile->SetTriggerType( CGeoProfile::EExitTrigger );    
00313                     }    
00314                 }            
00315             GEOPROFILEDEBUG("- Trigger Type" )
00316             break;    
00317             }
00318         default:
00319             {
00320             break;    
00321             }
00322         }
00323     GEOPROFILEDEBUG("- CGeoProfilesEngine::HandleControlStateChangeL" ) 
00324     }

void CGeoProfileEditor::HandlePointerEventL const TPointerEvent &  aPointerEvent  )  [private]
 

Inherited from CCoeControl

Definition at line 330 of file geoprofileeditor.cpp.

References HandlePlaceSelectionL(), and HandleProfileSelectionL().

00331     {
00332     GEOPROFILEDEBUG("+ CGeoProfilesEngine::HandlePointerEventL" )
00333        
00334     if ( IsEditable())
00335         {
00336         CAknForm::HandlePointerEventL( aPointerEvent );         
00337         // Handle the Pointer Event  
00338         if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
00339             {
00340             switch( IdOfFocusControl())
00341                 {
00342                 case EGeoProfileName:
00343                     {
00344                     CAknForm::HandlePointerEventL( aPointerEvent );
00345                     
00346                     CEikEdwin* profile = static_cast < CEikEdwin* > ( ControlOrNull( EGeoProfileName ));
00347                     if ( profile->Rect().Contains( aPointerEvent.iPosition ) )
00348                         {
00349                         HandleProfileSelectionL();
00350                         }                
00351                     break;    
00352                     }
00353                 case EGeoPlace:
00354                     {
00355                     CAknForm::HandlePointerEventL( aPointerEvent );
00356                     CEikEdwin* place = static_cast < CEikEdwin* > ( ControlOrNull( EGeoPlace ));
00357                     if ( place->Rect().Contains( aPointerEvent.iPosition ) )
00358                         {
00359                         HandlePlaceSelectionL();
00360                         }                 
00361                     break;    
00362                     }     
00363                 default:
00364                     {
00365                     break;                    
00366                     }
00367                 }
00368             }            
00369         }
00370     else
00371         {
00372         CAknForm::HandlePointerEventL( aPointerEvent );     
00373         }        
00374     GEOPROFILEDEBUG("- CGeoProfilesEngine::HandlePointerEventL" )
00375     }

void CGeoProfileEditor::ConstructL  )  [private]
 

Second phase of two phase constructor

Definition at line 94 of file geoprofileeditor.cpp.

References CGeoProfile::GeoPlaceName(), CGeoProfile::GeoPositionInfo(), CGeoProfile::GeoProfileId(), CGeoProfile::GeoProfileRadius(), iGeoProfile, iNewGeoProfile, CGeoProfile::NewL(), CGeoProfile::TriggerId(), and CGeoProfile::TriggerType().

00095     {
00096     GEOPROFILEDEBUG("+ CGeoProfilesEngine::ConstructL" )
00097     
00098     CAknForm::ConstructL( R_GEOPROFILES_EDITOR_FORM ); 
00099         
00100     // Copy the contents of Geo Profile with the orignial contents
00101     iNewGeoProfile = CGeoProfile::NewL( iGeoProfile.GeoPlaceName(),
00102                                         iGeoProfile.GeoPositionInfo(),
00103                                         iGeoProfile.GeoProfileId(),
00104                                         iGeoProfile.GeoProfileRadius(),
00105                                         iGeoProfile.TriggerId(),
00106                                         iGeoProfile.TriggerType()
00107                                         );
00108     
00109     GEOPROFILEDEBUG("- CGeoProfilesEngine::ConstructL" )    
00110     }

void CGeoProfileEditor::LoadFormValuesL  )  [private]
 

Loads all the Values

Definition at line 381 of file geoprofileeditor.cpp.

References LoadPlaceL(), LoadProfileL(), and LoadTriggerTypeL().

Referenced by PreLayoutDynInitL().

00382     {
00383     GEOPROFILEDEBUG("+ CGeoProfilesEngine::LoadFormValuesL" )
00384     
00385     // Assign the Initial Values
00386     LoadProfileL();
00387     LoadPlaceL();
00388     LoadTriggerTypeL();
00389     GEOPROFILEDEBUG("- CGeoProfilesEngine::LoadFormValuesL" )    
00390     }

void CGeoProfileEditor::MakeTitleL TDesC &  aText  )  [private]
 

Set the Title text

void CGeoProfileEditor::LoadPlaceL  )  [private]
 

Loads place

Definition at line 415 of file geoprofileeditor.cpp.

References CGeoProfile::GeoPlaceName(), CGeoProfile::GeoProfileRadius(), and iNewGeoProfile.

Referenced by HandlePlaceSelectionL(), and LoadFormValuesL().

00416     { 
00417     GEOPROFILEDEBUG("+ CGeoProfilesEngine::LoadPlaceL" )
00418     
00419     // Load the Place field name   
00420     CEikEdwin* geoProfile = static_cast < CEikEdwin* > ( ControlOrNull( EGeoPlace ));
00421      if ( geoProfile )
00422          {
00423          TPtrC geoProfileName = iNewGeoProfile->GeoPlaceName();
00424          geoProfile->SetTextL( &geoProfileName );
00425          geoProfile->DrawDeferred();
00426          } 
00427  
00428     // Load the Radius
00429     CAknIntegerEdwin* integerEd = static_cast < CAknIntegerEdwin* > ( ControlOrNull( EGeoRadius ));
00430     if ( integerEd )
00431         {
00432         integerEd->SetValueL( iNewGeoProfile->GeoProfileRadius() );
00433         integerEd->DrawDeferred();
00434         }
00435           
00436     // Check the status of the lines and make them visible or invisible based on the Place
00437     DrawDeferred();
00438     
00439     GEOPROFILEDEBUG("- CGeoProfilesEngine::LoadPlaceL" )
00440     }

void CGeoProfileEditor::LoadProfileL  )  [private]
 

Loads the profile name

Definition at line 396 of file geoprofileeditor.cpp.

References iNewGeoProfile, and CGeoProfile::ProfileName().

Referenced by HandleProfileSelectionL(), and LoadFormValuesL().

00397     {
00398     GEOPROFILEDEBUG("+ CGeoProfilesEngine::LoadProfileL" )
00399     
00400     CEikEdwin* profile = static_cast < CEikEdwin* > ( ControlOrNull( EGeoProfileName ));
00401     if ( profile )
00402         {
00403         TPtrC profileName = iNewGeoProfile->ProfileName();
00404         profile->SetTextL( &profileName ); 
00405         profile->DrawDeferred();
00406         }
00407         
00408     GEOPROFILEDEBUG("- CGeoProfilesEngine::LoadProfileL" )         
00409     }

void CGeoProfileEditor::LoadTriggerTypeL  )  [private]
 

Loads the Trigger Type

Definition at line 446 of file geoprofileeditor.cpp.

References iNewGeoProfile, and CGeoProfile::TriggerType().

Referenced by LoadFormValuesL().

00447     {
00448     CAknPopupFieldText* triggerType = static_cast < CAknPopupFieldText* > ( Control( EGeoProfileType ));
00449     if( triggerType )
00450         {
00451         if ( iNewGeoProfile->TriggerType() == CGeoProfile::EEntryTrigger )
00452             {
00453             triggerType->SetCurrentValueIndex( 0 );
00454             }
00455         else
00456             {
00457             triggerType->SetCurrentValueIndex( 1 );    
00458             }    
00459         }
00460     DrawDeferred();   
00461     }

void CGeoProfileEditor::HandleProfileSelectionL  )  [private]
 

Process Profile Selector Command

Definition at line 467 of file geoprofileeditor.cpp.

References iNewGeoProfile, LoadProfileL(), CGeoProfileSelector::NewLC(), CGeoProfileSelector::SelectGeoProfileL(), and CGeoProfile::SetGeoProfileIdL().

Referenced by HandlePointerEventL(), and OkToExitL().

00468     {
00469     GEOPROFILEDEBUG("+ CGeoProfilesEngine::HandleProfileSelectionL" )
00470     
00471     // Allocate the Profile Selector class
00472     CGeoProfileSelector* profileSelector = CGeoProfileSelector::NewLC();
00473     
00474     // Launch the profile selector
00475     TInt profileId = 0;    
00476     TInt retVal = profileSelector->SelectGeoProfileL( profileId );
00477                                                       
00478     if ( !retVal )
00479         {
00480         // Profile Selection was successful. Update the Profile
00481         iNewGeoProfile->SetGeoProfileIdL( profileId );        
00482         LoadProfileL();
00483         }
00484     
00485     CleanupStack::PopAndDestroy( profileSelector );
00486     
00487     GEOPROFILEDEBUG("- CGeoProfilesEngine::HandleProfileSelectionL" )
00488     }

void CGeoProfileEditor::HandlePlaceSelectionL  )  [private]
 

Process Place selection command

Definition at line 494 of file geoprofileeditor.cpp.

References iNewGeoProfile, LoadPlaceL(), CGeoPlaceSelector::NewLC(), CGeoPlaceSelector::SelectGeoPlaceL(), and CGeoProfile::SetGeoPositionInfoL().

Referenced by HandlePointerEventL(), and OkToExitL().

00495     {
00496     GEOPROFILEDEBUG("+ CGeoProfilesEngine::HandlePlaceSelectionL" )
00497     
00498     // Allocate the Place Selector class
00499     CGeoPlaceSelector* placeSelector = CGeoPlaceSelector::NewLC();
00500             
00501     // Launch the profile selector
00502     TInt placeType = CGeoProfile::ECoordinate;
00503     TLocality locality;
00504     
00505     // Take a temporary buffer and copy the location   
00506     HBufC* place = HBufC::NewLC( KGeoPlaceNameMaxLength );
00507     place->Des().Zero();
00508     
00509     TPtr name( place->Des());
00510     TInt retVal = KErrCancel;   
00511     TRAPD( error, retVal = placeSelector->SelectGeoPlaceL( placeType,
00512                                                   locality,
00513                                                   name ));
00514     if ( error )
00515         {
00516         // Display error note
00517         HBufC* errorString = StringLoader::LoadLC( R_LBL_GEOPROFILES_LOCATION_FAIL );
00518         CAknErrorNote* note = new( ELeave ) CAknErrorNote;
00519         note->ExecuteLD( errorString->Des());
00520         CleanupStack::PopAndDestroy( errorString );
00521         }
00522     else if ( !retVal )
00523         {
00524         // Profile Selection was successful. Update the Profile
00525         iNewGeoProfile->SetGeoPositionInfoL( place->Des(), locality );               
00526         LoadPlaceL();
00527         }
00528     CleanupStack::PopAndDestroy( place ); 
00529     CleanupStack::PopAndDestroy( placeSelector );    
00530     
00531     LoadPlaceL();
00532      
00533     GEOPROFILEDEBUG("- CGeoProfilesEngine::HandlePlaceSelectionL" )   
00534     }


Member Data Documentation

CGeoProfile& CGeoProfileEditor::iGeoProfile [private]
 

Reference to a Geo Profile

Definition at line 137 of file geoprofileeditor.h.

Referenced by ConstructL(), and OkToExitL().

CGeoProfile* CGeoProfileEditor::iNewGeoProfile [private]
 

Temporary Geo Profile object

Definition at line 142 of file geoprofileeditor.h.

Referenced by CheckIfSavableL(), ConstructL(), HandleControlStateChangeL(), HandlePlaceSelectionL(), HandleProfileSelectionL(), LoadPlaceL(), LoadProfileL(), LoadTriggerTypeL(), OkToExitL(), and ~CGeoProfileEditor().


The documentation for this class was generated from the following files:

© Nokia 2009

Back to top