|
Nokia N97 SDK Example Applications Guide |
#include <CCEGroupView.h>
Inheritance diagram for CCEGroupView:

Definition at line 45 of file CCEGroupView.h.
Public Member Functions |
|
| virtual | ~CCEGroupView () |
| void | HandleCommandL (TInt aCommand) |
| TUid | Id () const |
| void | DoActivateL (const TVwsViewId &aPrevViewId, TUid aCustomMessageId, const TDesC8 &aCustomMessage) |
| void | DoDeactivate () |
| void | HandleClientRectChange () |
| void | DynInitMenuPaneL (TInt aResourceId, CEikMenuPane *aMenuPane) |
Static Public Member Functions |
|
| static CCEGroupView * | NewL (MCLFContentListingEngine *aEngine, MCLFItemListModel *aModel, CCEOperationObserver *aObserver) |
| static CCEGroupView * | NewLC (MCLFContentListingEngine *aEngine, MCLFItemListModel *aModel, CCEOperationObserver *aObserver) |
Private Member Functions |
|
| CCEGroupView (MCLFContentListingEngine *aEngine, MCLFItemListModel *aModel, CCEOperationObserver *aObserver) | |
| void | ConstructL () |
| void | GroupListItemsL (const TCEGrouping aGroupingState) |
| void | NoMusicFilesFoundL () |
| void | PopulateListBoxL (const TCLFDefaultFieldId aFieldId) |
Private Attributes |
|
| CCEGroupContainer * | iContainer |
| MCLFContentListingEngine * | iEngine |
| MCLFItemListModel * | iModel |
| CCEOperationObserver * | iObserver |
| CCECustomGrouper * | iArtistGrouper |
| CCEPostFilter * | iPostFilter |
| CCEWaitNote * | iWaitNote |
| CActiveSchedulerWait | iWait |
| TCEGrouping | iGrouping |
|
|
Destructor. Definition at line 101 of file CCEGroupView.cpp. References iArtistGrouper, iContainer, iPostFilter, and iWaitNote. 00102 { 00103 delete iWaitNote; 00104 delete iArtistGrouper; 00105 delete iPostFilter; 00106 00107 if( iContainer ) 00108 { 00109 AppUi()->RemoveFromStack( iContainer ); 00110 delete iContainer; 00111 } 00112 }
|
|
||||||||||||||||
|
C++ default constructor.
Definition at line 46 of file CCEGroupView.cpp. Referenced by NewLC(). 00049 : iEngine( aEngine ), 00050 iModel( aModel ), 00051 iObserver( aObserver ), 00052 iGrouping( ECENoGrouping ) 00053 { 00054 }
|
|
||||||||||||||||
|
Creates and returns a new instance of this class.
Definition at line 74 of file CCEGroupView.cpp. References NewLC(). 00077 { 00078 CCEGroupView* self = 00079 CCEGroupView::NewLC( aEngine, aModel, aObserver ); 00080 CleanupStack::Pop( self ); 00081 return self; 00082 }
|
|
||||||||||||||||
|
Creates and returns a new instance of this class. The returned object is left on the cleanup stack.
Definition at line 89 of file CCEGroupView.cpp. References CCEGroupView(). Referenced by CCEAppUi::ConstructL(), and NewL(). 00092 { 00093 CCEGroupView* self = 00094 new (ELeave) CCEGroupView( aEngine, aModel, aObserver ); 00095 CleanupStack::PushL( self ); 00096 self->ConstructL(); 00097 return self; 00098 }
|
|
|
Symbian 2nd phase constructor. Definition at line 61 of file CCEGroupView.cpp. References iWaitNote, and CCEWaitNote::NewL(). 00062 { 00063 BaseConstructL( R_CE_GROUP_VIEW ); 00064 00065 // Create a wait note 00066 iWaitNote = CCEWaitNote::NewL(); 00067 }
|
|
|
From CAknView. Handle user's commands. Definition at line 119 of file CCEGroupView.cpp. References CCEWaitNote::CloseWaitNoteL(), iObserver, CCEOperationObserver::IsRefreshOngoing(), iWait, iWaitNote, and CCEWaitNote::OpenWaitNoteL(). 00120 { 00121 // Diplay a wait note if user tries to do something while refresh operation 00122 // of the list model has not finished yet. 00123 if( iObserver->IsRefreshOngoing() ) 00124 { 00125 // View the wait note 00126 iWaitNote->OpenWaitNoteL( R_CE_WAIT_NOTE ); 00127 00128 // Wait for the refresh operation to complete. Operation Observer will 00129 // stop this wait when the refresh operation has compeleted. 00130 iWait.Start(); 00131 00132 // Close the wait note 00133 iWaitNote->CloseWaitNoteL(); 00134 } 00135 00136 switch( aCommand ) 00137 { 00138 case ECECmdGroupByAllMusicFiles: 00139 { 00140 // Reset grouping state 00141 iGrouping = ECENoGrouping; 00142 00143 // Group items in the list model 00144 GroupListItemsL( ECEGroupedByAll ); 00145 00146 // Reset the list box 00147 iContainer->ResetListBoxL(); 00148 00149 if( iModel->ItemCount() <= 0 ) 00150 { 00151 NoMusicFilesFoundL(); 00152 break; 00153 } 00154 00155 // Load "all files" list item from the resource and add it to 00156 // the list box if there are music files in the model 00157 HBufC* defaultAllFilesItem = StringLoader::LoadLC( 00158 R_CE_GROUP_ALL_FILES_ITEM ); 00159 iContainer->AppendListBoxItemL( *defaultAllFilesItem ); 00160 CleanupStack::PopAndDestroy( defaultAllFilesItem ); 00161 00162 // Focus the topmost item of the list box 00163 iContainer->SetCurrentItemIndex( 0 ); 00164 break; 00165 } 00166 00167 case ECECmdGroupByAlbum: 00168 { 00169 // Reset the grouping state 00170 iGrouping = ECENoGrouping; 00171 00172 // Group items in the list model 00173 GroupListItemsL( ECEGroupedByAlbum ); 00174 00175 if( iModel->ItemCount() <= 0 ) 00176 { 00177 NoMusicFilesFoundL(); 00178 } 00179 00180 // Re-generate the list box with album names 00181 PopulateListBoxL( ECLFFieldIdAlbum ); 00182 00183 // Focus the topmost item of the list box 00184 iContainer->SetCurrentItemIndex( 0 ); 00185 break; 00186 } 00187 00188 case ECECmdGroupByArtist: 00189 { 00190 // Reset the grouping state 00191 iGrouping = ECENoGrouping; 00192 00193 // Group items in the list model 00194 GroupListItemsL( ECEGroupedByArtist ); 00195 00196 // Remove custom grouper from the model 00197 iModel->SetCustomGrouper( NULL ); 00198 00199 if( iModel->ItemCount() <= 0 ) 00200 { 00201 NoMusicFilesFoundL(); 00202 } 00203 00204 // Re-generate the list box with artist names 00205 PopulateListBoxL( ECLFFieldIdArtist ); 00206 00207 // Select the topmost item from the list box 00208 iContainer->SetCurrentItemIndex( 0 ); 00209 break; 00210 } 00211 00212 case ECECmdSelect: 00213 case ECECmdOpen: 00214 { 00215 // Prepare to get all music files to the model 00216 iModel->SetGroupingStyle( ECLFNoGrouping ); 00217 iModel->SetCustomGrouper( NULL ); 00218 iModel->SetPostFilter( NULL ); 00219 00220 // Delete old post filter if any 00221 if( iPostFilter ) 00222 { 00223 delete iPostFilter; 00224 iPostFilter = NULL; 00225 } 00226 00227 // Check the grouping state of the application 00228 // The list is grouped by .. 00229 // .. all files 00230 if( iGrouping == ECEGroupedByAll ) 00231 { 00232 // Do nothing, because the model has been prepared to get 00233 // all music files on the refresh. 00234 } 00235 00236 // .. albums 00237 else if( iGrouping == ECEGroupedByAlbum ) 00238 { 00239 // Which album is selected 00240 TInt selectedAlbum( iContainer->CurrentItemIndex() ); 00241 00242 // Get name of the album 00243 TPtrC nameOfAlbum; 00244 TInt error( iModel->Item( selectedAlbum ).GetField( 00245 ECLFFieldIdAlbum, nameOfAlbum ) ); 00246 User::LeaveIfError( error ); 00247 00248 // Create and activate a post filter for album filtering 00249 // so that the model will contain only sound files 00250 // from selected album 00251 iPostFilter = 00252 CCEPostFilter::NewL( ECLFFieldIdAlbum, nameOfAlbum ); 00253 iModel->SetPostFilter( iPostFilter ); 00254 } 00255 00256 // .. artists 00257 else if( iGrouping == ECEGroupedByArtist ) 00258 { 00259 // Which artist is selected 00260 TInt selectedArtist( iContainer->CurrentItemIndex() ); 00261 00262 // Get name of the artist 00263 TPtrC nameOfArtist; 00264 TInt error( iModel->Item( selectedArtist ).GetField( 00265 ECLFFieldIdArtist, nameOfArtist ) ); 00266 User::LeaveIfError( error ); 00267 00268 // Create and activate a post filter for album filtering 00269 // so that the model will contain only sound files 00270 // from selected artist 00271 iPostFilter = 00272 CCEPostFilter::NewL( ECLFFieldIdArtist, nameOfArtist ); 00273 iModel->SetPostFilter( iPostFilter ); 00274 } 00275 00276 // .. files have not been grouped yet 00277 else 00278 { 00279 return; 00280 } 00281 00282 // Refresh the model and activate the music files view 00283 iModel->RefreshL( ECLFRefreshAll ); 00284 AppUi()->ActivateLocalViewL( KCEMusicViewId ); 00285 break; 00286 } 00287 00288 default: 00289 { 00290 AppUi()->HandleCommandL( aCommand ); 00291 break; 00292 } 00293 } 00294 }
|
|
|
From CAknView. Get Id of the view. Definition at line 301 of file CCEGroupView.cpp.
|
|
||||||||||||||||
|
From CAknView. Activate the view. Definition at line 311 of file CCEGroupView.cpp. References CCEGroupContainer::ConstructL(), iContainer, iModel, iObserver, iWait, and CCEOperationObserver::PrepareForRefresh(). 00314 { 00315 // Create a container and refresh the list model for Group view in the 00316 // first activate 00317 if( !iContainer ) 00318 { 00319 iContainer = new (ELeave) CCEGroupContainer( this ); 00320 iContainer->SetMopParent( this ); 00321 iContainer->ConstructL(); 00322 00323 // Send reference of CActiveSchedulerWait to the CLF Operation Observer 00324 iObserver->PrepareForRefresh( iWait ); 00325 00326 // Call refresh to get all music files from the file system to the model 00327 iModel->RefreshL(); 00328 00329 // At this point, other initialization operations can be done as the 00330 // list model refresh is an asychronous operation. 00331 } 00332 00333 AppUi()->AddToViewStackL( *this, iContainer ); 00334 00335 // Group files, if they were grouped when the view was deactivated 00336 if( iGrouping != ECENoGrouping ) 00337 { 00338 GroupListItemsL( iGrouping ); 00339 } 00340 }
|
|
|
From CAknView. Deactivate the view. Definition at line 347 of file CCEGroupView.cpp. References iContainer. 00348 { 00349 if( iContainer ) 00350 { 00351 AppUi()->RemoveFromStack( iContainer ); 00352 } 00353 }
|
|
|
From CAknView. Handle change of rect. Definition at line 360 of file CCEGroupView.cpp. References iContainer. 00361 { 00362 if( iContainer ) 00363 { 00364 iContainer->SetRect( iAvkonAppUi->ClientRect() ); 00365 } 00366 }
|
|
||||||||||||
|
From CAknView. Dim items of the menu pane. Definition at line 373 of file CCEGroupView.cpp. References CCEGroupContainer::CurrentItemIndex(), and iContainer. 00375 { 00376 // Dim open-option from the options-menu 00377 // if there are no items in the list box 00378 if( aResourceId == R_CE_GROUP_VIEW_MENUPANE ) 00379 { 00380 if( iContainer->CurrentItemIndex() < 0 ) 00381 { 00382 aMenuPane->SetItemDimmed( ECECmdOpen, ETrue ); 00383 } 00384 } 00385 }
|
|
|
Group items in the list model if they were grouped when the view was deactivated. For example, files are grouped when you switch back from music view to group view.
Definition at line 393 of file CCEGroupView.cpp. References iModel. 00394 { 00395 // Remove existing post filter and sorting style from the model 00396 iModel->SetPostFilter( NULL ); 00397 iModel->SetSortingStyle( NULL ); 00398 00399 switch( aGroupingState ) 00400 { 00401 case ECENoGrouping: 00402 { 00403 break; 00404 } 00405 00406 case ECEGroupedByAll: 00407 { 00408 // Remove grouping 00409 iModel->SetGroupingStyle( ECLFNoGrouping ); 00410 break; 00411 } 00412 00413 case ECEGroupedByAlbum: 00414 { 00415 // Set album grouping 00416 iModel->SetGroupingStyle( ECLFMusicAlbumGrouping ); 00417 break; 00418 } 00419 00420 case ECEGroupedByArtist: 00421 { 00422 // Delete old and create new custom grouper for artist grouping 00423 if( iArtistGrouper ) 00424 { 00425 delete iArtistGrouper; 00426 iArtistGrouper = NULL; 00427 } 00428 00429 iArtistGrouper = CCECustomGrouper::NewL( ECLFFieldIdArtist ); 00430 iModel->SetCustomGrouper( iArtistGrouper ); 00431 break; 00432 } 00433 } 00434 00435 // Refresh the model 00436 iModel->RefreshL( ECLFRefreshAll ); 00437 00438 // Set new grouping state if items were found 00439 if( iModel->ItemCount() > 0 ) 00440 { 00441 iGrouping = aGroupingState; 00442 } 00443 else 00444 { 00445 iGrouping = ECENoGrouping; 00446 } 00447 }
|
|
|
Show user a warning note that no music files were found for selected grouping option. Definition at line 454 of file CCEGroupView.cpp. 00455 { 00456 HBufC* noteText = StringLoader::LoadLC( R_CE_NO_MUSIC_FILES_FOUND ); 00457 CAknWarningNote* note = new (ELeave) CAknWarningNote; 00458 note->ExecuteLD( *noteText ); 00459 CleanupStack::PopAndDestroy( noteText ); 00460 }
|
|
|
List all files from the list model to the list box.
Definition at line 467 of file CCEGroupView.cpp. References CCEGroupContainer::AppendListBoxItemL(), iContainer, iModel, and CCEGroupContainer::ResetListBoxL(). 00468 { 00469 // Reset the list box 00470 iContainer->ResetListBoxL(); 00471 00472 // Add all items to the list box 00473 TInt countItems( iModel->ItemCount() ); 00474 for( TInt i = 0; i < countItems; ++i ) 00475 { 00476 // Get value of requested field and add item to the list box 00477 TPtrC fieldValue; 00478 TInt error( iModel->Item( i ).GetField( aFieldId, fieldValue ) ); 00479 00480 if( error == KErrNone ) 00481 { 00482 iContainer->AppendListBoxItemL( fieldValue ); 00483 } 00484 } 00485 }
|
|
© Nokia 2009 |