Example Application Guide

 

CGeoProfilesView Class Reference

#include <geoprofilesview.h>

Inheritance diagram for CGeoProfilesView:

MGeoProfilesEngineObserver List of all members.

Detailed Description

GeoProfiles Application's View class.

Since:
S60 v5.0

Definition at line 39 of file geoprofilesview.h.

Public Member Functions

virtual ~CGeoProfilesView ()
void ScreenSizeChanged ()
void ContainerCommandL (TInt aCommand)
void DoActivateL (const TVwsViewId &aPrevViewId, TUid aCustomMessageId, const TDesC8 &aCustomMessage)
void DoDeactivate ()
TUid Id () const
void HandleCommandL (TInt aCommand)
void DynInitMenuPaneL (TInt aResourceId, CEikMenuPane *aMenuPane)
void ProfileStatusChangedL ()

Static Public Member Functions

static CGeoProfilesViewNewL ()
static CGeoProfilesViewNewLC ()

Private Member Functions

 CGeoProfilesView ()
void ConstructL ()
void SetCbaL ()

Private Attributes

CGeoProfilesContaineriContainer
CGeoProfilesLBModeliLBModel
RPointerArray< CGeoProfileiGeoProfiles
CGeoProfilesEngineiEngine


Constructor & Destructor Documentation

CGeoProfilesView::~CGeoProfilesView  )  [virtual]
 

C++ Destructor.

Definition at line 54 of file geoprofilesview.cpp.

References iContainer, iEngine, iGeoProfiles, and iLBModel.

00055     {
00056     // Delete the container resource
00057     if ( iContainer )
00058         {
00059         AppUi()->RemoveFromViewStack( *this, iContainer );
00060         }
00061     delete iContainer;
00062     
00063     // Delete the list box model
00064     delete iLBModel;
00065     
00066     delete iEngine;
00067     
00068     // Reset And Destroy the buffer
00069     iGeoProfiles.ResetAndDestroy();
00070     iGeoProfiles.Close();
00071     
00072     }

CGeoProfilesView::CGeoProfilesView  )  [private]
 

Overloaded C++ Contructor.

Definition at line 46 of file geoprofilesview.cpp.

Referenced by NewLC().

00047     {
00048     }


Member Function Documentation

CGeoProfilesView * CGeoProfilesView::NewL  )  [static]
 

Static Two phase constructor

Returns:
CGeoProfilesView*, Pointer to the newly created object.

Definition at line 78 of file geoprofilesview.cpp.

References NewLC().

Referenced by CGeoProfilesAppUi::ConstructL().

00079     {   
00080     CGeoProfilesView* self = CGeoProfilesView::NewLC();
00081     CleanupStack::Pop( self );
00082     return self;
00083     }

CGeoProfilesView * CGeoProfilesView::NewLC  )  [static]
 

Static Two phase constructor. Leaves the created instance on the Cleanup Stack.

Returns:
CGeoProfilesView*, Pointer to the newly created object.

Definition at line 89 of file geoprofilesview.cpp.

References CGeoProfilesView().

Referenced by NewL().

00090     {   
00091     CGeoProfilesView* self = new ( ELeave ) CGeoProfilesView();
00092     CleanupStack::PushL( self );
00093     self->ConstructL();
00094     return self;
00095     }

void CGeoProfilesView::ScreenSizeChanged  ) 
 

Handles the event generated when the Screen size is changed when this View is being displayed.

Definition at line 169 of file geoprofilesview.cpp.

References iContainer.

Referenced by ContainerCommandL().

00170         {
00171         // Request the Client container to change its rect to a new Rect
00172         if( iContainer )
00173         {
00174         iContainer->SetRect( ClientRect());     
00175         }       
00176         }

void CGeoProfilesView::ContainerCommandL TInt  aCommand  ) 
 

Handles the Container specific commands

Definition at line 121 of file geoprofilesview.cpp.

References CGeoProfileEditor::ExecuteLD(), CGeoProfilesContainer::GetFocussedItem(), iContainer, iEngine, iGeoProfiles, CGeoProfileEditor::NewL(), ScreenSizeChanged(), and CGeoProfilesEngine::UpdateProfileL().

Referenced by CGeoProfilesContainer::HandleListBoxEventL(), and CGeoProfilesContainer::HandleResourceChange().

00122     {
00123     switch ( aCommand )
00124         {
00125         case KEikDynamicLayoutVariantSwitch:
00126             {
00127             ScreenSizeChanged();
00128             break;
00129             }
00130         case EGeoProfilesOpen:
00131             {
00132             // Get the focussed item
00133             TInt index = iContainer->GetFocussedItem();
00134             
00135             if ( index >= 0 && index < iGeoProfiles.Count())
00136                 {
00137                 CGeoProfile* profile = iGeoProfiles[ index ];
00138                 if ( profile )
00139                     {
00140                     // Launch the editor
00141                     CGeoProfileEditor* editor = CGeoProfileEditor::NewL( *profile );
00142                     if ( editor->ExecuteLD())
00143                         {
00144                         TRAPD( error, iEngine->UpdateProfileL( *profile ));
00145                         if ( error )
00146                             {
00147                             // Display error note
00148                             HBufC* errorString = StringLoader::LoadLC( R_LBL_GEOPROFILES_OPERATION_FAIL );
00149                             CAknErrorNote* note = new( ELeave ) CAknErrorNote;
00150                             note->ExecuteLD( errorString->Des());
00151                             CleanupStack::PopAndDestroy( errorString );
00152                             }                           
00153                             }                                       
00154                     }              
00155                 }                                           
00156             break;    
00157             }            
00158         default:
00159             {
00160             break;    
00161             }
00162         }
00163     }

void CGeoProfilesView::DoActivateL const TVwsViewId &  aPrevViewId,
TUid  aCustomMessageId,
const TDesC8 &  aCustomMessage
 

Inherited from CAknView

Definition at line 182 of file geoprofilesview.cpp.

References iContainer.

00185     {
00186     // Destroy the existing container if it exists
00187     if( iContainer )
00188         {
00189         AppUi()->RemoveFromViewStack( *this, iContainer );
00190         delete iContainer;
00191         iContainer=NULL;
00192         }                       
00193     
00194     // Create new Container 
00195     iContainer = CGeoProfilesContainer::NewL( ClientRect(), *iLBModel, *this );
00196     iContainer->SetMopParent( this );
00197     AppUi()->AddToViewStackL( *this, iContainer );
00198     SetCbaL();          
00199     }

void CGeoProfilesView::DoDeactivate  ) 
 

Inherited from CAknView

Definition at line 205 of file geoprofilesview.cpp.

References iContainer.

00206     {
00207     // Destroy Container
00208     if ( iContainer )
00209         {
00210         AppUi()->RemoveFromViewStack( *this, iContainer );
00211         delete iContainer;
00212         iContainer = NULL;
00213         }
00214     }

TUid CGeoProfilesView::Id  )  const
 

Inherited from CAknView

Definition at line 220 of file geoprofilesview.cpp.

00221     {
00222     return KGeoProfilesViewId;
00223     }

void CGeoProfilesView::HandleCommandL TInt  aCommand  ) 
 

Inherited from CAknView

Definition at line 229 of file geoprofilesview.cpp.

References CGeoProfilesEngine::AddProfileL(), CGeoProfileEditor::ExecuteLD(), iEngine, CGeoProfileEditor::NewL(), and CGeoProfile::NewL().

00230     {
00231     // This Class only handles the Help feature. All the other events are handled
00232     // by the App UI class.
00233     switch( aCommand )
00234         {
00235         case EGeoProfilesAdd:
00236             {
00237             // Launch an empty Geo-Profile structure
00238             CGeoProfile* geoProfile = CGeoProfile::NewL();
00239             CleanupStack::PushL( geoProfile );
00240             
00241             // Launch the Editor
00242             CGeoProfileEditor* editor = CGeoProfileEditor::NewL( *geoProfile );
00243             if ( editor->ExecuteLD())
00244                 {
00245                 TRAPD( error, iEngine->AddProfileL( *geoProfile ));
00246                 if ( error )
00247                     {
00248                     // Display error note
00249                     HBufC* errorString = StringLoader::LoadLC( R_LBL_GEOPROFILES_OPERATION_FAIL );
00250                     CAknErrorNote* note = new( ELeave ) CAknErrorNote;
00251                     note->ExecuteLD( errorString->Des());
00252                     CleanupStack::PopAndDestroy( errorString );
00253                     }                   
00254                 }           
00255             // Delete the Geo-Profile object
00256             CleanupStack::PopAndDestroy( geoProfile );
00257             
00258             break;    
00259             }
00260         case EGeoProfilesOpen:
00261             {
00262             // Get the focussed item
00263             TInt index = iContainer->GetFocussedItem();
00264             
00265             if ( index >= 0 && index < iGeoProfiles.Count())
00266                 {
00267                 CGeoProfile* profile = iGeoProfiles[ index ];
00268                 if ( profile )
00269                     {
00270                     // Launch the editor
00271                     CGeoProfileEditor* editor = CGeoProfileEditor::NewL( *profile );
00272                     if ( editor->ExecuteLD())
00273                         {
00274                         TRAPD( error, iEngine->UpdateProfileL( *profile ));
00275                         if ( error )
00276                             {
00277                             // Display error note
00278                             HBufC* errorString = StringLoader::LoadLC( R_LBL_GEOPROFILES_OPERATION_FAIL );
00279                             CAknErrorNote* note = new( ELeave ) CAknErrorNote;
00280                             note->ExecuteLD( errorString->Des());
00281                             CleanupStack::PopAndDestroy( errorString );
00282                             } 
00283                             }                                       
00284                     }              
00285                 }                                           
00286             break;    
00287             }
00288         case EGeoProfilesDelete:
00289             {
00290             // Removing a profile from the list
00291             TInt index = iContainer->GetFocussedItem();
00292             if ( index >= 0 && index < iGeoProfiles.Count())
00293                 {
00294                 CGeoProfile* profile = iGeoProfiles[ index ];
00295                 if ( profile )
00296                     {
00297                     // Remove it from the Engine
00298                     TRAPD( error, iEngine->RemoveProfileL( *profile ));
00299                     if ( error )
00300                         {
00301                         // Display error note
00302                         HBufC* errorString = StringLoader::LoadLC( R_LBL_GEOPROFILES_OPERATION_FAIL );
00303                         CAknErrorNote* note = new( ELeave ) CAknErrorNote;
00304                         note->ExecuteLD( errorString->Des());
00305                         CleanupStack::PopAndDestroy( errorString );
00306                         }                                                   
00307                     }               
00308                 }           
00309             break;    
00310             }                                                               
00311         default:
00312                 {
00313                         AppUi()->HandleCommandL( aCommand );
00314                         break;          
00315                 }
00316         }
00317     }

void CGeoProfilesView::DynInitMenuPaneL TInt  aResourceId,
CEikMenuPane *  aMenuPane
 

Inherited from CAknView

Definition at line 323 of file geoprofilesview.cpp.

References iGeoProfiles.

00326     {
00327     switch ( aResourceId )
00328         {
00329         case R_GEOPROFILES_MENU:
00330             {
00331             if ( !iGeoProfiles.Count())
00332                 {
00333                 aMenuPane->SetItemDimmed( EGeoProfilesOpen, ETrue );
00334                 aMenuPane->SetItemDimmed( EGeoProfilesDelete, ETrue );
00335                 }
00336             break;
00337             }
00338         default:
00339             {
00340             break;    
00341             }
00342         }
00343     }

void CGeoProfilesView::ProfileStatusChangedL  )  [virtual]
 

Inherited from MGeoProfilesEngineObserver

Implements MGeoProfilesEngineObserver.

Definition at line 349 of file geoprofilesview.cpp.

References iContainer, iEngine, iGeoProfiles, iLBModel, CGeoProfilesEngine::ListProfilesL(), SetCbaL(), CGeoProfilesContainer::UpdateL(), and CGeoProfilesLBModel::UpdateModel().

00350     {
00351     // Reload the profiles array
00352     iEngine->ListProfilesL( iGeoProfiles );
00353     iLBModel->UpdateModel( &iGeoProfiles );
00354     iContainer->UpdateL( *iLBModel );
00355     SetCbaL();
00356     }

void CGeoProfilesView::ConstructL  )  [private]
 

Second phase of the two phase constructor.

Definition at line 101 of file geoprofilesview.cpp.

References iEngine, iGeoProfiles, iLBModel, CGeoProfilesEngine::ListProfilesL(), CGeoProfilesLBModel::NewL(), CGeoProfilesEngine::NewL(), and SetCbaL().

00102     {
00103     BaseConstructL( R_GEOPROFILES_VIEW );
00104   
00105     iEngine = CGeoProfilesEngine::NewL( *this );
00106     
00107     // Fetch the list of currently available profiles
00108     iEngine->ListProfilesL( iGeoProfiles );
00109     
00110     // Allocate the List box view
00111     iLBModel = CGeoProfilesLBModel::NewL( &iGeoProfiles );
00112     
00113     // Set the Correct CBA
00114     SetCbaL();   
00115     }

void CGeoProfilesView::SetCbaL  )  [private]
 

Sets the Command button array based on the number of elements

Definition at line 362 of file geoprofilesview.cpp.

References iGeoProfiles.

Referenced by ConstructL(), and ProfileStatusChangedL().

00363     {
00364         if( Cba() )
00365             {
00366             if ( iGeoProfiles.Count())
00367                 {
00368                 Cba()->SetCommandSetL( R_GEOPROFILES_CBA );    
00369                 }
00370                 else
00371                     {
00372                     Cba()->SetCommandSetL( R_GEOPROFILES_CBA_EMPTY );        
00373                     }
00374                 Cba()->DrawDeferred();
00375             }       
00376     }


Member Data Documentation

CGeoProfilesContainer* CGeoProfilesView::iContainer [private]
 

GeoProfiles Container. Owns.

Definition at line 130 of file geoprofilesview.h.

Referenced by ContainerCommandL(), DoActivateL(), DoDeactivate(), ProfileStatusChangedL(), ScreenSizeChanged(), and ~CGeoProfilesView().

CGeoProfilesLBModel* CGeoProfilesView::iLBModel [private]
 

List box model

Definition at line 135 of file geoprofilesview.h.

Referenced by ConstructL(), ProfileStatusChangedL(), and ~CGeoProfilesView().


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

© Nokia 2009

Back to top