profilesservices/MediaFileList/Src/mediafiledialogstate.cpp
changeset 0 8c5d936e5675
equal deleted inserted replaced
-1:000000000000 0:8c5d936e5675
       
     1 /*
       
     2 * Copyright (c) 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:   Class used to deal with the items of the Main view
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include "mediafiledialogstate.h"
       
    24 #include "mediafiledialogutils.h"
       
    25 
       
    26 #include <mediafilelist.rsg>  // for .rss resource enums
       
    27 #include <StringLoader.h>
       
    28 
       
    29 
       
    30 
       
    31 /******************************************************************************
       
    32  * class TMFListItem
       
    33  ******************************************************************************/
       
    34 
       
    35 
       
    36 // -------------------------------------------------------------------------------
       
    37 // TMFListItem::TMFListItem
       
    38 //
       
    39 // -------------------------------------------------------------------------------
       
    40 //
       
    41 TMFListItem::TMFListItem()
       
    42  : iListIndex(KErrNotFound), iFolderId(KErrNotFound), iParentFolderId(KErrNotFound),
       
    43    iChildFolderId(KErrNotFound), iPersistent(ETrue),
       
    44    iHidden(EFalse), iIconId(EEIconEmpty), iChildIconId(EEIconEmpty),
       
    45    iUnknownCount(KErrNotFound)
       
    46 	 {
       
    47 	 }
       
    48 
       
    49 
       
    50 
       
    51 /******************************************************************************
       
    52  * class TMFCurrentItemInfo
       
    53  ******************************************************************************/
       
    54 
       
    55 
       
    56 // -------------------------------------------------------------------------------
       
    57 // TMFCurrentItemInfo::TMFCurrentItemInfo
       
    58 //
       
    59 // -------------------------------------------------------------------------------
       
    60 //
       
    61 void TMFCurrentItemInfo::Reset()
       
    62     {
       
    63     iIndexCheckNeeded = EFalse;
       
    64     iItemIndex = KErrNotFound;
       
    65     iMediaFileId = KErrNotFound;
       
    66     iFolderId = KErrNotFound;
       
    67     iFolderText = KNullDesC;
       
    68     }
       
    69 
       
    70 
       
    71 /******************************************************************************
       
    72  * class CMediaFileDialogState
       
    73  ******************************************************************************/
       
    74 
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CMediaFileDialogState::NewL
       
    78 //
       
    79 // -----------------------------------------------------------------------------
       
    80 CMediaFileDialogState* CMediaFileDialogState::NewL()
       
    81     {
       
    82     CMediaFileDialogState* self = new ( ELeave ) CMediaFileDialogState();
       
    83     CleanupStack::PushL( self );
       
    84     self->ConstructL();
       
    85     CleanupStack::Pop( self );
       
    86 
       
    87     return self;
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CMediaFileDialogState::CMediaFileDialogState
       
    92 // 
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 CMediaFileDialogState::CMediaFileDialogState()
       
    96 	{
       
    97 	iCurrentFolderId = EEFolderRoot;
       
    98 	iCurrentFolderIndex = 0;
       
    99 	iListPosition = KErrNotFound;
       
   100 	
       
   101     iQueryFolderId = EEFolderRoot;
       
   102     iQueryDirection = EEQueryDown;
       
   103     iQueryText = KNullDesC;
       
   104     iPreviousFolderId = KErrNotFound;
       
   105     iCurrentItemInfo.Reset();
       
   106     }
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // CMediaFileDialogState::ConstructL
       
   110 //
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 void CMediaFileDialogState::ConstructL()
       
   114     {
       
   115     AddPermanentItemsL();
       
   116     } 
       
   117 
       
   118 // ----------------------------------------------------------------------------
       
   119 // Destructor
       
   120 //
       
   121 // ----------------------------------------------------------------------------
       
   122 //
       
   123 CMediaFileDialogState::~CMediaFileDialogState()
       
   124     {
       
   125     iList.Close();
       
   126     }
       
   127 
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CMediaFileDialogState::Init
       
   131 //
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 void CMediaFileDialogState::Init()
       
   135     {
       
   136     // initialize non-persistent folders
       
   137     TInt count = iList.Count();
       
   138     for ( TInt i=0; i<count; i++ )
       
   139         {
       
   140         TMFListItem& item = iList[i];
       
   141         if ( !item.iPersistent )
       
   142             {
       
   143             item.iListIndex = KErrNotFound;
       
   144             item.iText = KNullDesC;
       
   145             item.iTitle = KNullDesC;
       
   146             }
       
   147         }
       
   148 
       
   149 	iCurrentFolderId = EEFolderRoot;
       
   150 	iCurrentFolderIndex = 0;
       
   151 	iListPosition = KErrNotFound;
       
   152   	
       
   153     iQueryFolderId = EEFolderRoot;
       
   154     iQueryDirection = EEQueryDown;
       
   155     iQueryText = KNullDesC;
       
   156     iPreviousFolderId = KErrNotFound;
       
   157     iCurrentItemInfo.Reset();
       
   158     }
       
   159 
       
   160 
       
   161 // -----------------------------------------------------------------------------
       
   162 // CMediaFileDialogState::HideRootFolder
       
   163 //
       
   164 // -----------------------------------------------------------------------------
       
   165 //
       
   166 void CMediaFileDialogState::HideRootFolder( TInt aFolderId, TBool aHidden,
       
   167                                             const TDesC& aText, TInt aIconId )
       
   168     {
       
   169     TInt index = IndexFromId( aFolderId );
       
   170     TMFListItem& item = iList[index];
       
   171     if ( item.iParentFolderId != EEFolderRoot )
       
   172         {
       
   173         return; // only root folders can be variated
       
   174         }
       
   175 
       
   176     item.iHidden = aHidden;
       
   177     if ( aText != KNullDesC )
       
   178         {
       
   179         TMFDialogUtil::StrCopy( item.iText, aText );
       
   180         }
       
   181     if ( aIconId != KErrNotFound )
       
   182         {
       
   183         item.iIconId = aIconId;
       
   184         }
       
   185     
       
   186     // update root folder indexes. Note that root folders must be
       
   187     // created in the same order they appear in UI (see AddPermanentItemsL).
       
   188     TInt listIndex = 0;
       
   189     TInt count = iList.Count();
       
   190     for ( TInt i=0; i<count; i++ )
       
   191         {
       
   192         TMFListItem& temp = iList[i];
       
   193         if ( temp.iParentFolderId == EEFolderRoot )
       
   194             {
       
   195             if ( !temp.iHidden )
       
   196                 {
       
   197                 temp.iListIndex = listIndex;
       
   198                 listIndex++;
       
   199                 }
       
   200             }
       
   201         }
       
   202     }
       
   203 
       
   204 
       
   205 // -----------------------------------------------------------------------------
       
   206 // CMediaFileDialogState::ResetUnknownCount
       
   207 //
       
   208 // -----------------------------------------------------------------------------
       
   209 //
       
   210 void CMediaFileDialogState::ResetUnknownCount()
       
   211     {
       
   212     SetUnknownCount( EEFolderArtistRoot, KErrNotFound );
       
   213     SetUnknownCount( EEFolderAlbumRoot, KErrNotFound );
       
   214     SetUnknownCount( EEFolderGenreRoot, KErrNotFound );
       
   215     SetUnknownCount( EEFolderComposerRoot, KErrNotFound );
       
   216     SetUnknownCount( EEFolderArtist, KErrNotFound );
       
   217     }
       
   218 
       
   219 
       
   220 // -----------------------------------------------------------------------------
       
   221 // CMediaFileDialogState::SetUnknownCount
       
   222 //
       
   223 // -----------------------------------------------------------------------------
       
   224 //
       
   225 void CMediaFileDialogState::SetUnknownCount( TInt aFolderId, TInt aCount )
       
   226     {
       
   227     TInt index = IndexFromId( aFolderId );
       
   228     TMFListItem& item = iList[index];
       
   229     item.iUnknownCount = aCount;
       
   230     }
       
   231 
       
   232 
       
   233 // -----------------------------------------------------------------------------
       
   234 // CMediaFileDialogState::UnknownCount
       
   235 //
       
   236 // -----------------------------------------------------------------------------
       
   237 //
       
   238 TInt CMediaFileDialogState::UnknownCount( TInt aFolderId )
       
   239     {
       
   240     TInt index = IndexFromId( aFolderId );
       
   241     TMFListItem& item = iList[index];
       
   242     return item.iUnknownCount;
       
   243     }
       
   244 
       
   245 
       
   246 // -----------------------------------------------------------------------------
       
   247 // CMediaFileDialogState::HideUnknownFolder
       
   248 //
       
   249 // -----------------------------------------------------------------------------
       
   250 //
       
   251 void CMediaFileDialogState::HideUnknownFolder( TInt aFolderId, TInt aUnknownCount )
       
   252     {
       
   253     TInt index = IndexFromId( aFolderId );
       
   254     TMFListItem& item = iList[index];
       
   255     
       
   256     item.iHidden = EFalse;
       
   257     if ( aUnknownCount < 1 )
       
   258         {
       
   259         item.iHidden = ETrue;
       
   260         }
       
   261     }
       
   262 
       
   263 
       
   264 // -----------------------------------------------------------------------------
       
   265 // CMediaFileDialogState::HideUnknownFolders
       
   266 //
       
   267 // -----------------------------------------------------------------------------
       
   268 //
       
   269 void CMediaFileDialogState::HideUnknownFolders()
       
   270     {
       
   271     TInt count = UnknownCount( EEFolderArtistRoot );
       
   272     HideUnknownFolder( EEFolderArtistUnknown, count );
       
   273     
       
   274     count = UnknownCount( EEFolderAlbumRoot );
       
   275     HideUnknownFolder( EEFolderAlbumUnknown, count );
       
   276 
       
   277     count = UnknownCount( EEFolderGenreRoot );
       
   278     HideUnknownFolder( EEFolderGenreUnknown, count );
       
   279 
       
   280     count = UnknownCount( EEFolderComposerRoot );
       
   281     HideUnknownFolder( EEFolderComposerUnknown, count );
       
   282     
       
   283     count = UnknownCount( EEFolderArtist );
       
   284     HideUnknownFolder( EEFolderArtistAlbumUnknown, count );
       
   285     }
       
   286 
       
   287 
       
   288 // -----------------------------------------------------------------------------
       
   289 // CMediaFileDialogState::SetUnknownFolderPosition
       
   290 //
       
   291 // -----------------------------------------------------------------------------
       
   292 //
       
   293 void CMediaFileDialogState::SetUnknownFolderPosition( TInt aQueryCount )
       
   294     {
       
   295     //
       
   296     // Unknown folder is the last list item (after query result items)
       
   297     //
       
   298     if ( iCurrentFolderId == EEFolderArtistRoot|| 
       
   299          iCurrentFolderId == EEFolderAlbumRoot ||
       
   300          iCurrentFolderId == EEFolderGenreRoot ||
       
   301          iCurrentFolderId == EEFolderComposerRoot ||
       
   302          iCurrentFolderId == EEFolderArtist )
       
   303         {
       
   304         SetListIndex( EEFolderArtistUnknown, aQueryCount );
       
   305         SetListIndex( EEFolderAlbumUnknown, aQueryCount );
       
   306         SetListIndex( EEFolderGenreUnknown, aQueryCount );
       
   307         SetListIndex( EEFolderComposerUnknown, aQueryCount );
       
   308     
       
   309         // folder EEFolderArtist has persistent "All" folder as a first item
       
   310         SetListIndex( EEFolderArtistAlbumUnknown, aQueryCount + 1 );
       
   311         }
       
   312     }
       
   313 
       
   314 
       
   315 // -----------------------------------------------------------------------------
       
   316 // CMediaFileDialogState::IndexFromId
       
   317 //
       
   318 // -----------------------------------------------------------------------------
       
   319 //
       
   320 TInt CMediaFileDialogState::IndexFromId( TInt aFolderId )
       
   321     {
       
   322     TInt index = KErrNotFound;
       
   323     
       
   324     TInt count = iList.Count();
       
   325     for (TInt i=0; i<count; i++)
       
   326         {
       
   327         TMFListItem& item = iList[i];
       
   328         if ( item.iFolderId == aFolderId )
       
   329             {
       
   330             index = i;
       
   331             break;
       
   332             }
       
   333         }
       
   334         
       
   335     __ASSERT_ALWAYS( index != KErrNotFound, Panic( KErrGeneral ) );
       
   336     
       
   337     return index;
       
   338     }
       
   339 
       
   340 
       
   341 // -----------------------------------------------------------------------------
       
   342 // CMediaFileDialogState::PersistentFolderCount
       
   343 //
       
   344 // Get count of persistent subfolders in folder aFolderId.
       
   345 // -----------------------------------------------------------------------------
       
   346 //
       
   347 TInt CMediaFileDialogState::PersistentFolderCount( TInt aFolderId )
       
   348     {
       
   349     TInt folderCount = 0;
       
   350     
       
   351     TInt count = iList.Count();
       
   352     for ( TInt i=0; i<count; i++ )
       
   353         {
       
   354         TMFListItem& item = iList[i];
       
   355         if ( item.iParentFolderId == aFolderId )
       
   356             {
       
   357             if ( item.iHidden )
       
   358                 {
       
   359                 continue;
       
   360                 }
       
   361             if ( item.iPersistent )
       
   362                 {
       
   363                 folderCount++;
       
   364                 }
       
   365             }
       
   366         }
       
   367 
       
   368     return folderCount;
       
   369     }
       
   370 
       
   371 
       
   372 // -----------------------------------------------------------------------------
       
   373 // CMediaFileDialogState::PersistentFolderCount
       
   374 //
       
   375 // -----------------------------------------------------------------------------
       
   376 //
       
   377 TInt CMediaFileDialogState::PersistentFolderCount()
       
   378     {
       
   379     return PersistentFolderCount( iCurrentFolderId );
       
   380     }
       
   381 
       
   382 
       
   383 // -----------------------------------------------------------------------------
       
   384 // CMediaFileDialogState::LeadingPersistentFolderCount
       
   385 //
       
   386 // -----------------------------------------------------------------------------
       
   387 //
       
   388 TInt CMediaFileDialogState::LeadingPersistentFolderCount()
       
   389     {
       
   390     // how many persisten folders in the beginning of list
       
   391     if ( iCurrentFolderId == EEFolderArtist )
       
   392         {
       
   393         return 1;
       
   394         }
       
   395         
       
   396     return 0;    
       
   397     }
       
   398 
       
   399 
       
   400 // -----------------------------------------------------------------------------
       
   401 // CMediaFileDialogState::CurrentItemIndex
       
   402 //
       
   403 // -----------------------------------------------------------------------------
       
   404 //
       
   405 TInt CMediaFileDialogState::CurrentItemIndex()
       
   406     {
       
   407     return iListPosition;
       
   408     }
       
   409 
       
   410 
       
   411 // -----------------------------------------------------------------------------
       
   412 // CMediaFileDialogState::SetCurrentItemIndex
       
   413 //
       
   414 // -----------------------------------------------------------------------------
       
   415 //
       
   416 void CMediaFileDialogState::SetCurrentItemIndex( TInt aIndex )
       
   417     {
       
   418     iListPosition = aIndex;
       
   419     }
       
   420 
       
   421 
       
   422 // -----------------------------------------------------------------------------
       
   423 // CMediaFileDialogState::PreviousFolderId
       
   424 //
       
   425 // -----------------------------------------------------------------------------
       
   426 //
       
   427 TInt CMediaFileDialogState::PreviousFolderId()
       
   428     {
       
   429     return iPreviousFolderId;
       
   430     }
       
   431 
       
   432 
       
   433 // -----------------------------------------------------------------------------
       
   434 // CMediaFileDialogState::GetCurrentItemInfo
       
   435 //
       
   436 // -----------------------------------------------------------------------------
       
   437 //
       
   438 TMFCurrentItemInfo& CMediaFileDialogState::CurrentItemInfo()
       
   439     {
       
   440     return iCurrentItemInfo;
       
   441     }
       
   442 
       
   443 
       
   444 // -----------------------------------------------------------------------------
       
   445 // CMediaFileDialogState::QueryDirection
       
   446 //
       
   447 // -----------------------------------------------------------------------------
       
   448 //
       
   449 TInt CMediaFileDialogState::QueryDirection()
       
   450     {
       
   451     return iQueryDirection;
       
   452     }
       
   453 
       
   454 
       
   455 // -----------------------------------------------------------------------------
       
   456 // CMediaFileDialogState::IsPersistent
       
   457 //
       
   458 // -----------------------------------------------------------------------------
       
   459 //
       
   460 TInt CMediaFileDialogState::IsPersistent( TInt aFolderId )
       
   461     {
       
   462     TInt index = IndexFromId( aFolderId );
       
   463 
       
   464     TMFListItem& item = iList[index];
       
   465     return item.iPersistent;
       
   466     }
       
   467 
       
   468 
       
   469 // -----------------------------------------------------------------------------
       
   470 // CMediaFileDialogState::SetListIndex
       
   471 //
       
   472 // -----------------------------------------------------------------------------
       
   473 //
       
   474 void CMediaFileDialogState::SetListIndex( TInt aFolderId, TInt aListIndex )
       
   475     {
       
   476     TInt count = iList.Count();
       
   477     for ( TInt i=0; i<count; i++ )
       
   478         {
       
   479         TMFListItem& item = iList[i];
       
   480         if ( item.iFolderId == aFolderId )
       
   481             {
       
   482             if ( item.iParentFolderId == EEFolderRoot || 
       
   483                  item.iParentFolderId == EEFolderMusic )
       
   484                 {
       
   485                 // root and music folder indexes cannot change after initialization
       
   486                 break;
       
   487                 }
       
   488             item.iListIndex = aListIndex;
       
   489             break;
       
   490             }
       
   491         }
       
   492     }
       
   493 
       
   494 
       
   495 // -----------------------------------------------------------------------------
       
   496 // CMediaFileDialogState::ListIndex
       
   497 //
       
   498 // -----------------------------------------------------------------------------
       
   499 //
       
   500 TInt CMediaFileDialogState::ListIndex( TInt aFolderId )
       
   501     {
       
   502     TInt count = iList.Count();
       
   503     for ( TInt i=0; i<count; i++ )
       
   504         {
       
   505         TMFListItem& item = iList[i];
       
   506         if ( item.iFolderId == aFolderId )
       
   507             {
       
   508             return item.iListIndex;
       
   509             }
       
   510         }
       
   511     
       
   512     return KErrNotFound;
       
   513     }
       
   514 
       
   515 
       
   516 // -----------------------------------------------------------------------------
       
   517 // CMediaFileDialogState::FindBoxNeeded
       
   518 //
       
   519 // -----------------------------------------------------------------------------
       
   520 //
       
   521 TBool CMediaFileDialogState::FindBoxNeeded()
       
   522     {
       
   523     //return ETrue;  // find box used in every folder
       
   524     
       
   525     
       
   526     if ( iCurrentFolderId == EEFolderSearch ||
       
   527          iCurrentFolderId == EEFolderRoot )
       
   528         {
       
   529         return ETrue; // these folders have find box
       
   530         }
       
   531     
       
   532     TMFListItem& currentFolder = iList[iCurrentFolderIndex];
       
   533     if ( currentFolder.iChildFolderId == EEFolderNone )
       
   534         {
       
   535         return ETrue; // folder contains audio or fideo files
       
   536         }
       
   537         
       
   538     return EFalse;
       
   539     }
       
   540 
       
   541 
       
   542 // -----------------------------------------------------------------------------
       
   543 // CMediaFileDialogState::QueryNeeded
       
   544 //
       
   545 // -----------------------------------------------------------------------------
       
   546 //
       
   547 TBool CMediaFileDialogState::QueryNeeded()
       
   548     {
       
   549     return QueryNeeded( iCurrentFolderId );
       
   550     }
       
   551 
       
   552 
       
   553 // -----------------------------------------------------------------------------
       
   554 // CMediaFileDialogState::QueryNeeded
       
   555 //
       
   556 // -----------------------------------------------------------------------------
       
   557 //
       
   558 TBool CMediaFileDialogState::QueryNeeded( TInt aFolderId )
       
   559     {
       
   560     if ( aFolderId == EEFolderRoot || aFolderId == EEFolderMusic )
       
   561         {
       
   562         return EFalse;
       
   563         }
       
   564     return ETrue;
       
   565     }
       
   566 
       
   567 
       
   568 // -----------------------------------------------------------------------------
       
   569 // CMediaFileDialogState::SetText
       
   570 //
       
   571 // -----------------------------------------------------------------------------
       
   572 //
       
   573 void CMediaFileDialogState::SetText( TInt aFolderId, const TDesC& aText )
       
   574     {
       
   575     TInt index = IndexFromId( aFolderId );
       
   576 
       
   577     TMFListItem& item = iList[index];
       
   578     
       
   579     // persistent folder data cannot change after initialization
       
   580     if ( !item.iPersistent )
       
   581         {
       
   582         TMFDialogUtil::StrCopy( item.iText, aText);
       
   583         }
       
   584     }
       
   585 
       
   586 
       
   587 // -----------------------------------------------------------------------------
       
   588 // CMediaFileDialogState::GetText
       
   589 //
       
   590 // -----------------------------------------------------------------------------
       
   591 //
       
   592 void CMediaFileDialogState::GetText( TInt aFolderId, TDes& aText )
       
   593     {
       
   594     aText = KNullDesC;
       
   595     
       
   596     TInt index = IndexFromId( aFolderId );
       
   597 
       
   598     TMFListItem& item = iList[index];
       
   599     TMFDialogUtil::StrCopy( aText, item.iText );
       
   600     }
       
   601 
       
   602 
       
   603 // -----------------------------------------------------------------------------
       
   604 // CMediaFileDialogState::GetSearchTitleL
       
   605 //
       
   606 // -----------------------------------------------------------------------------
       
   607 //
       
   608 void CMediaFileDialogState::GetSearchTitleL( TDes& aText, TInt aCount )
       
   609     {
       
   610     aText = KNullDesC;
       
   611     
       
   612     HBufC* hBuf = StringLoader::LoadLC( R_QTN_VIEW_SEARCH, aCount );
       
   613     TMFDialogUtil::StrCopy( aText, *hBuf );
       
   614     CleanupStack::PopAndDestroy( hBuf );
       
   615     }
       
   616 
       
   617 
       
   618 // -----------------------------------------------------------------------------
       
   619 // CMediaFileDialogState::GetSearchTitle
       
   620 //
       
   621 // -----------------------------------------------------------------------------
       
   622 //
       
   623 void CMediaFileDialogState::GetSearchTitle( TDes& aText, TInt aCount )
       
   624     {
       
   625     TRAP_IGNORE( GetSearchTitleL( aText, aCount ) );
       
   626     }
       
   627 
       
   628 
       
   629 // -----------------------------------------------------------------------------
       
   630 // CMediaFileDialogState::GetTitle
       
   631 //
       
   632 // -----------------------------------------------------------------------------
       
   633 //
       
   634 void CMediaFileDialogState::GetTitle( TInt aFolderId, TDes& aText )
       
   635     {
       
   636     aText = KNullDesC;
       
   637      
       
   638     TInt index = IndexFromId( aFolderId );
       
   639 
       
   640     TMFListItem& item = iList[index];
       
   641     TMFDialogUtil::StrCopy( aText, item.iTitle );
       
   642     }
       
   643 
       
   644 
       
   645 // -----------------------------------------------------------------------------
       
   646 // CMediaFileDialogState::SetTitle
       
   647 //
       
   648 // -----------------------------------------------------------------------------
       
   649 //
       
   650 void CMediaFileDialogState::SetTitle( TInt aFolderId, const TDesC& aText )
       
   651     {
       
   652     TInt index = IndexFromId( aFolderId );
       
   653 
       
   654     TMFListItem& item = iList[index];
       
   655     
       
   656     // persistent folder data cannot change after initialization
       
   657     if ( !item.iPersistent )
       
   658         {
       
   659         TMFDialogUtil::StrCopy( item.iTitle, aText);
       
   660         }
       
   661     }
       
   662 
       
   663 
       
   664 // -----------------------------------------------------------------------------
       
   665 // CMediaFileDialogState::CurrentFolder
       
   666 //
       
   667 // -----------------------------------------------------------------------------
       
   668 //
       
   669 TInt CMediaFileDialogState::CurrentFolder()
       
   670     {
       
   671     return iCurrentFolderId;
       
   672     }
       
   673 
       
   674 
       
   675 // -----------------------------------------------------------------------------
       
   676 // CMediaFileDialogState::SetCurrentFolder
       
   677 //
       
   678 // -----------------------------------------------------------------------------
       
   679 //
       
   680 void CMediaFileDialogState::SetCurrentFolder( TInt aFolderId )
       
   681     {
       
   682     iCurrentFolderIndex = IndexFromId( aFolderId );
       
   683     iCurrentFolderId = aFolderId;
       
   684     }
       
   685 
       
   686 
       
   687 // -----------------------------------------------------------------------------
       
   688 // CMediaFileDialogState::SetStateAfterQuery
       
   689 //
       
   690 // Set media file list state. This should be called after successful
       
   691 // database query.
       
   692 // -----------------------------------------------------------------------------
       
   693 //
       
   694 void CMediaFileDialogState::SetStateAfterQuery()
       
   695     {
       
   696     if ( iQueryDirection == EEQueryUpdate )
       
   697         {
       
   698         return;  // state does not change when updating
       
   699         }
       
   700     
       
   701     if ( iQueryDirection == EEQueryDown )
       
   702         {
       
   703         iListPosition = 0;
       
   704         }
       
   705     if ( iQueryDirection == EEQueryUp )
       
   706         {
       
   707         // set list position to folder that was closed
       
   708         TInt index = IndexFromId( iCurrentFolderId );
       
   709         TMFListItem& item = iList[index];
       
   710         iListPosition = item.iListIndex;
       
   711         }
       
   712     
       
   713     iPreviousFolderId = iCurrentFolderId;
       
   714     SetCurrentFolder( iQueryFolderId );
       
   715     }
       
   716 
       
   717 
       
   718 // -----------------------------------------------------------------------------
       
   719 // CMediaFileDialogState::SetQueryInfo
       
   720 //
       
   721 // -----------------------------------------------------------------------------
       
   722 //
       
   723 void CMediaFileDialogState::SetQueryInfo( TInt aQueryFolderId, const TDesC& aQueryText,
       
   724                                           TInt aQueryListPosition, TInt aQueryDirection )
       
   725     {
       
   726     if ( aQueryDirection == EEQueryUpdate )
       
   727         {
       
   728         iQueryDirection = aQueryDirection;
       
   729         return;
       
   730         }
       
   731     
       
   732     if ( aQueryDirection == EEQueryDown )
       
   733         {
       
   734         // folder/title updated even is query is not successful
       
   735         SetText( aQueryFolderId, aQueryText );
       
   736         SetTitle( aQueryFolderId, aQueryText );
       
   737         
       
   738         // set folder list position so that it can be restored
       
   739         // when folder is closed
       
   740         SetListIndex( aQueryFolderId, aQueryListPosition );
       
   741         }
       
   742        
       
   743     
       
   744     iQueryDirection = aQueryDirection;
       
   745     
       
   746     // new list position set after successful query
       
   747     iListPosition = aQueryListPosition;
       
   748     
       
   749     // iCurrentFolderId set after successful query
       
   750     iQueryFolderId = aQueryFolderId;
       
   751     }
       
   752 
       
   753 /*
       
   754 void CMediaFileDialogState::SetStateAfterQuery()
       
   755     {
       
   756     TInt previousCurrentFolderId = iCurrentFolderId;
       
   757     
       
   758     SetCurrentFolder( iQueryFolderId );
       
   759     
       
   760     if ( iQueryDirection == EEQueryDown )
       
   761         {
       
   762         SetListIndex( iQueryFolderId, iQueryListPosition );
       
   763         iListPosition = 0;
       
   764         }
       
   765     if ( iQueryDirection == EEQueryUp )
       
   766         {
       
   767         // set list position to folder that was closed
       
   768         TInt index = IndexFromId( previousCurrentFolderId );
       
   769         TMFListItem& item = iList[index];
       
   770         iListPosition = item.iListIndex;
       
   771         }
       
   772     }
       
   773 */
       
   774 
       
   775 
       
   776 
       
   777 /*
       
   778 void CMediaFileDialogState::SetQueryInfo( TInt aQueryFolderId, const TDesC& aQueryText,
       
   779                                           TInt aQueryListPosition, TInt aQueryDirection )
       
   780     {
       
   781     iQueryFolderId = aQueryFolderId;
       
   782     if ( aQueryDirection == EEQueryDown )
       
   783         {
       
   784         // folder/title updated even is query is not successful
       
   785         SetText( aQueryFolderId, aQueryText );
       
   786         SetTitle( aQueryFolderId, aQueryText );
       
   787         }
       
   788        
       
   789     iQueryListPosition = aQueryListPosition;
       
   790     iQueryDirection = aQueryDirection;
       
   791     
       
   792     iListPosition = aQueryListPosition; // updated after successful query
       
   793     }
       
   794 */
       
   795 
       
   796 // -----------------------------------------------------------------------------
       
   797 // CMediaFileDialogState::NextFolderDown
       
   798 //
       
   799 // -----------------------------------------------------------------------------
       
   800 //
       
   801 TInt CMediaFileDialogState::NextFolderDown( TInt aListIndex )
       
   802     {
       
   803     TInt folderId = FolderId( aListIndex );
       
   804     
       
   805     // folderId is KErrNotFound if list item is not a folder
       
   806     return folderId;
       
   807     }
       
   808 
       
   809 
       
   810 // -----------------------------------------------------------------------------
       
   811 // CMediaFileDialogState::NextFolderUp
       
   812 //
       
   813 // -----------------------------------------------------------------------------
       
   814 //
       
   815 TInt CMediaFileDialogState::NextFolderUp()
       
   816     {
       
   817     TMFListItem& item = iList[iCurrentFolderIndex];
       
   818     
       
   819     if ( item.iParentFolderId != KErrNotFound )
       
   820         {
       
   821         return item.iParentFolderId;
       
   822         }
       
   823         
       
   824     return KErrNotFound;
       
   825     }
       
   826 
       
   827 
       
   828 // -----------------------------------------------------------------------------
       
   829 // CMediaFileDialogState::QueryFolder
       
   830 //
       
   831 // -----------------------------------------------------------------------------
       
   832 //
       
   833 TInt CMediaFileDialogState::QueryFolder()
       
   834     {
       
   835     return iQueryFolderId;
       
   836     }
       
   837 
       
   838 
       
   839 // -----------------------------------------------------------------------------
       
   840 // CMediaFileDialogState::FolderId
       
   841 //
       
   842 // -----------------------------------------------------------------------------
       
   843 //
       
   844 TInt CMediaFileDialogState::FolderId( TInt aListIndex )
       
   845     {
       
   846     TBool persistent = EFalse;
       
   847     TInt icon = EEIconEmpty;
       
   848     TInt id = KErrNotFound;
       
   849     TBuf<KBufSize64> buf;
       
   850     GetFolderInfo( aListIndex, id, buf, persistent, icon );
       
   851     
       
   852     return id;
       
   853     }
       
   854 
       
   855 
       
   856 // -----------------------------------------------------------------------------
       
   857 // CMediaFileDialogState::FolderIndex
       
   858 //
       
   859 // -----------------------------------------------------------------------------
       
   860 //
       
   861 TInt CMediaFileDialogState::FolderIndex( TInt aListIndex )
       
   862     {
       
   863     if ( aListIndex < 0 )
       
   864         {
       
   865         return KErrNotFound;
       
   866         }
       
   867 
       
   868     TInt folderIndex = KErrNotFound;
       
   869     
       
   870     TInt count = iList.Count();
       
   871     for ( TInt i=0; i<count; i++ )
       
   872         {
       
   873         TMFListItem& item = iList[i];
       
   874         if ( item.iParentFolderId == iCurrentFolderId )
       
   875             {
       
   876             if ( item.iHidden )
       
   877                 {
       
   878                 continue;
       
   879                 }
       
   880             if ( item.iListIndex == aListIndex && item.iPersistent )
       
   881                 {
       
   882                 folderIndex = i;
       
   883                 break;
       
   884                 }
       
   885             }
       
   886         }
       
   887     
       
   888     return folderIndex;
       
   889     }
       
   890 
       
   891 
       
   892 // -----------------------------------------------------------------------------
       
   893 // CMediaFileDialogState::GetFolderInfo
       
   894 //
       
   895 // -----------------------------------------------------------------------------
       
   896 //
       
   897 void CMediaFileDialogState::GetFolderInfo( TInt aListIndex, TInt& aId, TDes& aText,
       
   898                                            TBool& aPersistent, TInt& aIconId )
       
   899     {
       
   900     aId = KErrNotFound;
       
   901     aText = KNullDesC;
       
   902     aPersistent = EFalse;
       
   903     aIconId = EEIconEmpty;
       
   904     
       
   905     TMFListItem& currentFolder = iList[iCurrentFolderIndex];
       
   906     if ( currentFolder.iChildFolderId == EEFolderNone )
       
   907         {
       
   908         // this is optimization and is based on the the fact that a folder
       
   909         // cannot contain both folder items and audio/video items.
       
   910         
       
   911         return; // not folder (item is audio or video file)
       
   912         }
       
   913     
       
   914     TInt index = FolderIndex( aListIndex );
       
   915     if ( index != KErrNotFound )
       
   916         {
       
   917         // get persistent folder info
       
   918         TMFListItem& item = iList[index];
       
   919         TMFDialogUtil::StrCopy( aText, item.iText );
       
   920         aId = item.iFolderId;
       
   921         aPersistent = ETrue;
       
   922         aIconId = item.iIconId;
       
   923         }
       
   924     else
       
   925         {
       
   926         // get non-persistent folder info.
       
   927         // folder text (eg album name) is in database
       
   928         aId = currentFolder.iChildFolderId;
       
   929         aIconId = currentFolder.iChildIconId;
       
   930         }
       
   931     }
       
   932 
       
   933 
       
   934 // -----------------------------------------------------------------------------
       
   935 // CMediaFileDialogState::EnableNullItemL
       
   936 //
       
   937 // -----------------------------------------------------------------------------
       
   938 //
       
   939 void CMediaFileDialogState::EnableNullItemL( TInt aFolderId, const TDesC& aText,
       
   940                                               TInt aIconId  )
       
   941     {
       
   942     HideRootFolder( aFolderId, EFalse, aText, aIconId );
       
   943     }
       
   944 
       
   945 
       
   946 
       
   947 // -----------------------------------------------------------------------------
       
   948 // CMediaFileDialogState::AddPermanentItemsL
       
   949 //
       
   950 //
       
   951 // Root
       
   952 //   Downloads
       
   953 //   Tones
       
   954 //     <tone1>
       
   955 //   Music
       
   956 //     All
       
   957 //     Artist
       
   958 //       <artist1>
       
   959 //       <artist2>
       
   960 //         All
       
   961 //         <album1>
       
   962 //         <album2>
       
   963 //         Unknown
       
   964 //       Unknown
       
   965 //     Album
       
   966 //       <album1>
       
   967 //         <song1>
       
   968 //       <album2>
       
   969 //       Unknown
       
   970 //         <song1>
       
   971 //         <song2>
       
   972 //     Genre
       
   973 //       Unknown
       
   974 //     Composer
       
   975 //       Unknown
       
   976 //   Videos
       
   977 //     <video1>
       
   978 //     <video2>
       
   979 //   Recordings
       
   980 //      <recording1>
       
   981 //      <recording2>
       
   982 //
       
   983 // -----------------------------------------------------------------------------
       
   984 //
       
   985 void CMediaFileDialogState::AddPermanentItemsL()
       
   986     {
       
   987     TMFListItem item;
       
   988     
       
   989     // Root
       
   990     item.iListIndex = 0;
       
   991     item.iFolderId = EEFolderRoot;
       
   992     item.iParentFolderId = KErrNotFound;
       
   993     item.iChildFolderId = KErrNotFound;
       
   994     item.iPersistent = ETrue;
       
   995     item.iHidden = EFalse;
       
   996     item.iIconId = KErrNotFound;
       
   997     item.iChildIconId = KErrNotFound;
       
   998     item.iUnknownCount = KErrNotFound;
       
   999     StringLoader::Load( item.iText, R_QTN_MEDIA_FILE_DIALOG_TITLE );
       
  1000     item.iTitle = KNullDesC;
       
  1001     User::LeaveIfError( iList.Append( item ) );
       
  1002 
       
  1003     // Downloads
       
  1004     item.iListIndex = 0;
       
  1005     item.iFolderId = EEFolderDownload;
       
  1006     item.iParentFolderId = EEFolderRoot;
       
  1007     item.iChildFolderId = EEFolderNone;
       
  1008     item.iPersistent = ETrue;
       
  1009     item.iHidden = EFalse;
       
  1010     item.iIconId = EEIconFolderDownload;
       
  1011     item.iChildIconId = EEIconEmpty;
       
  1012     item.iUnknownCount = KErrNotFound;
       
  1013     StringLoader::Load( item.iText, R_QTN_FOLDER_DOWNLOAD );
       
  1014     item.iTitle = KNullDesC;
       
  1015     User::LeaveIfError( iList.Append( item ) );
       
  1016 
       
  1017     // Tones
       
  1018     item.iListIndex = 1;
       
  1019     item.iFolderId = EEFolderTones;
       
  1020     item.iParentFolderId = EEFolderRoot;
       
  1021     item.iChildFolderId = EEFolderNone;
       
  1022     item.iPersistent = ETrue;
       
  1023     item.iHidden = EFalse;
       
  1024     item.iIconId = EEIconFolder;
       
  1025     item.iChildIconId = EEIconTone;
       
  1026     item.iUnknownCount = KErrNotFound;
       
  1027     StringLoader::Load( item.iText, R_QTN_FOLDER_TONES );
       
  1028     StringLoader::Load( item.iTitle, R_QTN_VIEW_TONES );
       
  1029     User::LeaveIfError( iList.Append( item ) );
       
  1030     
       
  1031     // Music
       
  1032     item.iListIndex = 2;
       
  1033     item.iFolderId = EEFolderMusic;
       
  1034     item.iParentFolderId = EEFolderRoot;
       
  1035     item.iChildFolderId = KErrNotFound;
       
  1036     item.iPersistent = ETrue;
       
  1037     item.iHidden = EFalse;
       
  1038     item.iIconId = EEIconFolder;
       
  1039     item.iChildIconId = KErrNotFound;
       
  1040     item.iUnknownCount = KErrNotFound;
       
  1041     StringLoader::Load( item.iText, R_QTN_FOLDER_MUSIC );
       
  1042     StringLoader::Load( item.iTitle, R_QTN_VIEW_MUSIC );
       
  1043     User::LeaveIfError( iList.Append( item ) );
       
  1044 
       
  1045     // Videos
       
  1046     item.iListIndex = 3;
       
  1047     item.iFolderId = EEFolderVideos;
       
  1048     item.iParentFolderId = EEFolderRoot;
       
  1049     item.iChildFolderId = EEFolderNone;
       
  1050     item.iPersistent = ETrue;
       
  1051     item.iHidden = EFalse;
       
  1052     item.iIconId = EEIconFolder;
       
  1053     item.iChildIconId = EEIconVideo;
       
  1054     item.iUnknownCount = KErrNotFound;
       
  1055     StringLoader::Load( item.iText, R_QTN_FOLDER_VIDEOS );
       
  1056     StringLoader::Load( item.iTitle, R_QTN_VIEW_VIDEOS );
       
  1057     User::LeaveIfError( iList.Append( item ) );
       
  1058     
       
  1059     // Recordings
       
  1060     item.iListIndex = 4;
       
  1061     item.iFolderId = EEFolderRecordings;
       
  1062     item.iParentFolderId = EEFolderRoot;
       
  1063     item.iChildFolderId = EEFolderNone;    
       
  1064     item.iPersistent = ETrue;
       
  1065     item.iHidden = EFalse;
       
  1066     item.iIconId = EEIconFolder;
       
  1067     item.iChildIconId = EEIconFolder;
       
  1068     item.iUnknownCount = KErrNotFound;
       
  1069     StringLoader::Load( item.iText, R_QTN_FOLDER_RECORDINGS );
       
  1070     StringLoader::Load( item.iTitle, R_QTN_VIEW_RECORDINGS );
       
  1071     User::LeaveIfError( iList.Append( item ) );
       
  1072 
       
  1073     // Null item one
       
  1074     item.iListIndex = 5;
       
  1075     item.iFolderId = EEFolderNullItemOne;
       
  1076     item.iParentFolderId = EEFolderRoot;
       
  1077     item.iChildFolderId = EEFolderNone;
       
  1078     item.iPersistent = ETrue;
       
  1079     item.iHidden = ETrue;  // by default not visible
       
  1080     item.iIconId = EEIconEmpty;
       
  1081     item.iChildIconId = KErrNotFound;
       
  1082     item.iUnknownCount = KErrNotFound;
       
  1083     item.iText = KNullDesC;
       
  1084     item.iTitle = KNullDesC;
       
  1085     User::LeaveIfError( iList.Append( item ) );
       
  1086     
       
  1087     // Null item two
       
  1088     item.iListIndex = 6;
       
  1089     item.iFolderId = EEFolderNullItemTwo;
       
  1090     item.iParentFolderId = EEFolderRoot;
       
  1091     item.iChildFolderId = KErrNotFound;
       
  1092     item.iPersistent = ETrue;
       
  1093     item.iHidden = ETrue;  // by default not visible
       
  1094     item.iIconId = EEIconEmpty;
       
  1095     item.iChildIconId = KErrNotFound;
       
  1096     item.iUnknownCount = KErrNotFound;
       
  1097     item.iText = KNullDesC;
       
  1098     item.iTitle = KNullDesC;
       
  1099     User::LeaveIfError( iList.Append( item ) );
       
  1100 
       
  1101     // Search
       
  1102     item.iListIndex = KErrNotFound;
       
  1103     item.iFolderId = EEFolderSearch;
       
  1104     item.iParentFolderId = EEFolderRoot;
       
  1105     item.iChildFolderId = EEFolderNone;    
       
  1106     item.iPersistent = ETrue;
       
  1107     item.iHidden = ETrue;  // visible only when search is used in root level
       
  1108     item.iIconId = EEIconEmpty;
       
  1109     item.iChildIconId = KErrNotFound;
       
  1110     item.iUnknownCount = KErrNotFound;
       
  1111     item.iText = KNullDesC;
       
  1112     item.iTitle = KNullDesC;
       
  1113 
       
  1114     //StringLoader::Load( item.iText, R_QTN_VIEW_SEARCH );
       
  1115     //StringLoader::Load( item.iTitle, R_QTN_VIEW_SEARCH );
       
  1116     User::LeaveIfError( iList.Append( item ) );
       
  1117 
       
  1118 
       
  1119     // Music Search
       
  1120     item.iListIndex = KErrNotFound;
       
  1121     item.iFolderId = EEFolderSearchMusic;
       
  1122     item.iParentFolderId = EEFolderMusic;
       
  1123     item.iChildFolderId = EEFolderNone;    
       
  1124     item.iPersistent = ETrue;
       
  1125     item.iHidden = ETrue;  // visible only when search is used in root level
       
  1126     item.iIconId = EEIconEmpty;
       
  1127     item.iChildIconId = KErrNotFound;
       
  1128     item.iUnknownCount = KErrNotFound;
       
  1129     item.iText = KNullDesC;
       
  1130     item.iTitle = KNullDesC;
       
  1131     User::LeaveIfError( iList.Append( item ) );
       
  1132 
       
  1133     // All music
       
  1134     item.iListIndex = 0;
       
  1135     item.iFolderId = EEFolderAllMusic;
       
  1136     item.iParentFolderId = EEFolderMusic;
       
  1137     item.iChildFolderId = EEFolderNone;    
       
  1138     item.iPersistent = ETrue;
       
  1139     item.iHidden = EFalse;
       
  1140     item.iIconId = EEIconFolder;
       
  1141     item.iChildIconId = EEIconMusic;
       
  1142     item.iUnknownCount = KErrNotFound;
       
  1143     StringLoader::Load( item.iText, R_QTN_FOLDER_ALL_MUSIC );
       
  1144     StringLoader::Load( item.iTitle, R_QTN_FOLDER_ALL_MUSIC );
       
  1145     User::LeaveIfError( iList.Append( item ) );
       
  1146     
       
  1147 
       
  1148     // Artist Root
       
  1149     item.iListIndex = 1;
       
  1150     item.iFolderId = EEFolderArtistRoot;
       
  1151     item.iParentFolderId = EEFolderMusic;
       
  1152     item.iChildFolderId = EEFolderArtist;
       
  1153     item.iPersistent = ETrue;
       
  1154     item.iHidden = EFalse;
       
  1155     item.iIconId = EEIconFolder;
       
  1156     item.iChildIconId = EEIconArtist;
       
  1157     item.iUnknownCount = KErrNotFound;
       
  1158     StringLoader::Load( item.iText, R_QTN_FOLDER_ARTIST );
       
  1159     StringLoader::Load( item.iTitle, R_QTN_VIEW_ARTIST );
       
  1160     User::LeaveIfError( iList.Append( item ) );
       
  1161 
       
  1162     // Album Root
       
  1163     item.iListIndex = 2;
       
  1164     item.iFolderId = EEFolderAlbumRoot;
       
  1165     item.iParentFolderId = EEFolderMusic;
       
  1166     item.iChildFolderId = EEFolderAlbum;
       
  1167     item.iPersistent = ETrue;
       
  1168     item.iHidden = EFalse;
       
  1169     item.iIconId = EEIconFolder;
       
  1170     item.iChildIconId = EEIconAlbum;
       
  1171     item.iUnknownCount = KErrNotFound;
       
  1172     StringLoader::Load( item.iText, R_QTN_FOLDER_ALBUM );
       
  1173     StringLoader::Load( item.iTitle, R_QTN_VIEW_ALBUM );
       
  1174     User::LeaveIfError( iList.Append( item ) );
       
  1175     
       
  1176     // Genre Root
       
  1177     item.iListIndex = 3;
       
  1178     item.iFolderId = EEFolderGenreRoot;
       
  1179     item.iParentFolderId = EEFolderMusic;
       
  1180     item.iChildFolderId = EEFolderGenre;
       
  1181     item.iPersistent = ETrue;
       
  1182     item.iHidden = EFalse;
       
  1183     item.iIconId = EEIconFolder;
       
  1184     item.iChildIconId = EEIconGenre;
       
  1185     item.iUnknownCount = KErrNotFound;
       
  1186     StringLoader::Load( item.iText, R_QTN_FOLDER_GENRE );
       
  1187     StringLoader::Load( item.iTitle, R_QTN_VIEW_GENRE );
       
  1188     User::LeaveIfError( iList.Append( item ) );
       
  1189     
       
  1190     // Composer Root
       
  1191     item.iListIndex = 4;
       
  1192     item.iFolderId = EEFolderComposerRoot;
       
  1193     item.iParentFolderId = EEFolderMusic;
       
  1194     item.iChildFolderId = EEFolderComposer;
       
  1195     item.iPersistent = ETrue;
       
  1196     item.iHidden = EFalse;
       
  1197     item.iIconId = EEIconFolder;
       
  1198     item.iChildIconId = EEIconComposer;
       
  1199     item.iUnknownCount = KErrNotFound;
       
  1200     StringLoader::Load( item.iText, R_QTN_FOLDER_COMPOSER );
       
  1201     StringLoader::Load( item.iTitle, R_QTN_VIEW_COMPOSER );
       
  1202     User::LeaveIfError( iList.Append( item ) );
       
  1203 
       
  1204     // Album ( represents some album under EEFolderAlbumRoot )
       
  1205     item.iListIndex = KErrNotFound;
       
  1206     item.iFolderId = EEFolderAlbum;
       
  1207     item.iParentFolderId = EEFolderAlbumRoot;
       
  1208     item.iChildFolderId = EEFolderNone;
       
  1209     item.iPersistent = EFalse;
       
  1210     item.iHidden = EFalse;
       
  1211     item.iIconId = EEIconAlbum;
       
  1212     item.iChildIconId = EEIconMusic;
       
  1213     item.iUnknownCount = KErrNotFound;
       
  1214     item.iText = KNullDesC;
       
  1215     item.iTitle = KNullDesC;
       
  1216     User::LeaveIfError( iList.Append( item ) );
       
  1217 
       
  1218     // Album Unknown ( all music files without album attribute )
       
  1219     item.iListIndex = KErrNotFound;
       
  1220     item.iFolderId = EEFolderAlbumUnknown;
       
  1221     item.iParentFolderId = EEFolderAlbumRoot;
       
  1222     item.iChildFolderId = EEFolderNone;
       
  1223     item.iPersistent = ETrue;
       
  1224     item.iHidden = EFalse;
       
  1225     item.iIconId = EEIconUnknown;
       
  1226     item.iChildIconId = EEIconMusic;
       
  1227     item.iUnknownCount = KErrNotFound;
       
  1228     StringLoader::Load( item.iText, R_QTN_UNKNOWN_ALBUM );
       
  1229     StringLoader::Load( item.iTitle, R_QTN_UNKNOWN_ALBUM );
       
  1230     User::LeaveIfError( iList.Append( item ) );
       
  1231     
       
  1232     // Genre ( represents some genre under EEFolderGenreRoot )
       
  1233     item.iListIndex = KErrNotFound;
       
  1234     item.iFolderId = EEFolderGenre;
       
  1235     item.iParentFolderId = EEFolderGenreRoot;
       
  1236     item.iChildFolderId = EEFolderNone;
       
  1237     item.iPersistent = EFalse;
       
  1238     item.iHidden = EFalse;
       
  1239     item.iIconId = EEIconGenre;
       
  1240     item.iChildIconId = EEIconMusic;
       
  1241     item.iUnknownCount = KErrNotFound;
       
  1242     item.iText = KNullDesC;
       
  1243     item.iTitle = KNullDesC;
       
  1244     User::LeaveIfError( iList.Append( item ) );
       
  1245 
       
  1246     // Genre Unknown ( all music files without genre attribute )
       
  1247     item.iListIndex = KErrNotFound;
       
  1248     item.iFolderId = EEFolderGenreUnknown;
       
  1249     item.iParentFolderId = EEFolderGenreRoot;
       
  1250     item.iChildFolderId = EEFolderNone;
       
  1251     item.iPersistent = ETrue;
       
  1252     item.iHidden = EFalse;
       
  1253     item.iIconId = EEIconUnknown;
       
  1254     item.iChildIconId = EEIconMusic;
       
  1255     item.iUnknownCount = KErrNotFound;
       
  1256     StringLoader::Load( item.iText, R_QTN_UNKNOWN_GENRE );
       
  1257     StringLoader::Load( item.iTitle, R_QTN_UNKNOWN_GENRE );
       
  1258     User::LeaveIfError( iList.Append( item ) );
       
  1259     
       
  1260     // Composer ( represents some composer under EEFolderComposerRoot )
       
  1261     item.iListIndex = KErrNotFound;
       
  1262     item.iFolderId = EEFolderComposer;
       
  1263     item.iParentFolderId = EEFolderComposerRoot;
       
  1264     item.iChildFolderId = EEFolderNone;
       
  1265     item.iPersistent = EFalse;
       
  1266     item.iHidden = EFalse;
       
  1267     item.iIconId = EEIconComposer;
       
  1268     item.iChildIconId = EEIconMusic;
       
  1269     item.iUnknownCount = KErrNotFound;
       
  1270     item.iText = KNullDesC;
       
  1271     item.iTitle = KNullDesC;
       
  1272     User::LeaveIfError( iList.Append( item ) );
       
  1273 
       
  1274     // Composer Unknown ( all music files without composer attribute )
       
  1275     item.iListIndex = KErrNotFound;
       
  1276     item.iFolderId = EEFolderComposerUnknown;
       
  1277     item.iParentFolderId = EEFolderComposerRoot;
       
  1278     item.iChildFolderId = EEFolderNone;
       
  1279     item.iPersistent = ETrue;
       
  1280     item.iHidden = EFalse;
       
  1281     item.iIconId = EEIconUnknown;
       
  1282     item.iChildIconId = EEIconMusic;
       
  1283     item.iUnknownCount = KErrNotFound;
       
  1284     StringLoader::Load( item.iText, R_QTN_UNKNOWN_COMPOSER );
       
  1285     StringLoader::Load( item.iTitle, R_QTN_UNKNOWN_COMPOSER );
       
  1286     User::LeaveIfError( iList.Append( item ) );
       
  1287 
       
  1288 
       
  1289 
       
  1290     //
       
  1291     // folders under Artist root
       
  1292     //
       
  1293     
       
  1294     // Artist (artist folder, folder name is artist name)
       
  1295     item.iListIndex = KErrNotFound;
       
  1296     item.iFolderId = EEFolderArtist;
       
  1297     item.iParentFolderId = EEFolderArtistRoot;
       
  1298     item.iChildFolderId = EEFolderArtistAlbum;
       
  1299     item.iPersistent = EFalse;
       
  1300     item.iHidden = EFalse;
       
  1301     item.iIconId = EEIconArtist;
       
  1302     item.iChildIconId = EEIconAlbum;
       
  1303     item.iUnknownCount = KErrNotFound;
       
  1304     item.iText = KNullDesC;
       
  1305     item.iTitle = KNullDesC;
       
  1306     User::LeaveIfError( iList.Append( item ) );
       
  1307 
       
  1308     // Artist all (all music files for one artist)
       
  1309     item.iListIndex = 0;
       
  1310     item.iFolderId = EEFolderArtistAll;
       
  1311     item.iParentFolderId = EEFolderArtist;
       
  1312     item.iChildFolderId = EEFolderNone;
       
  1313     item.iPersistent = ETrue;
       
  1314     item.iHidden = EFalse;
       
  1315     item.iIconId = EEIconFolder;
       
  1316     item.iChildIconId = EEIconMusic;
       
  1317     item.iUnknownCount = KErrNotFound;
       
  1318     StringLoader::Load( item.iText, R_QTN_FOLDER_ARTIST_ALL );
       
  1319     StringLoader::Load( item.iTitle, R_QTN_FOLDER_ARTIST_ALL );
       
  1320     User::LeaveIfError( iList.Append( item ) );
       
  1321 
       
  1322     // Artist album (one album, folder name is album name)
       
  1323     item.iListIndex = KErrNotFound;
       
  1324     item.iFolderId = EEFolderArtistAlbum;
       
  1325     item.iParentFolderId = EEFolderArtist;
       
  1326     item.iChildFolderId = EEFolderNone;
       
  1327     item.iPersistent = EFalse;
       
  1328     item.iHidden = EFalse;
       
  1329     item.iIconId = EEIconAlbum;
       
  1330     item.iChildIconId = EEIconMusic;
       
  1331     item.iUnknownCount = KErrNotFound;
       
  1332     item.iText = KNullDesC;
       
  1333     item.iTitle = KNullDesC;
       
  1334     User::LeaveIfError( iList.Append( item ) );
       
  1335 
       
  1336     // Artist album unknown (music files for one artist without album attribute)
       
  1337     item.iListIndex = KErrNotFound;
       
  1338     item.iFolderId = EEFolderArtistAlbumUnknown;
       
  1339     item.iParentFolderId = EEFolderArtist;
       
  1340     item.iChildFolderId = EEFolderNone;
       
  1341     item.iPersistent = ETrue;
       
  1342     item.iHidden = EFalse;
       
  1343     item.iIconId = EEIconUnknown;
       
  1344     item.iChildIconId = EEIconMusic;
       
  1345     item.iUnknownCount = KErrNotFound;
       
  1346     StringLoader::Load( item.iText, R_QTN_UNKNOWN_ALBUM );
       
  1347     StringLoader::Load( item.iTitle, R_QTN_UNKNOWN_ALBUM );
       
  1348     User::LeaveIfError( iList.Append( item ) );
       
  1349 
       
  1350     // Artist unknown (all music files without artist attribute)
       
  1351     item.iListIndex = KErrNotFound;
       
  1352     item.iFolderId = EEFolderArtistUnknown;
       
  1353     item.iParentFolderId = EEFolderArtistRoot;
       
  1354     item.iChildFolderId = EEFolderNone;
       
  1355     item.iPersistent = ETrue;
       
  1356     item.iHidden = EFalse;
       
  1357     item.iIconId = EEIconUnknown;
       
  1358     item.iChildIconId = EEIconMusic;
       
  1359     item.iUnknownCount = KErrNotFound;
       
  1360     StringLoader::Load( item.iText, R_QTN_UNKNOWN_ARTIST );
       
  1361     StringLoader::Load( item.iTitle, R_QTN_UNKNOWN_ARTIST );
       
  1362     User::LeaveIfError( iList.Append( item ) );
       
  1363     }
       
  1364 
       
  1365 
       
  1366 
       
  1367 // -----------------------------------------------------------------------------
       
  1368 // CMediaFileDialogState::Panic
       
  1369 //
       
  1370 // -----------------------------------------------------------------------------
       
  1371 //
       
  1372 void CMediaFileDialogState::Panic( TInt aReason ) 
       
  1373     {
       
  1374 	_LIT( KPanicCategory, "CMediaFileDialogState" );
       
  1375 	
       
  1376 	User::Panic( KPanicCategory, aReason ); 
       
  1377     }
       
  1378 
       
  1379 
       
  1380 // -----------------------------------------------------------------------------
       
  1381 // CMediaFileDialogState::PrintCurrentFolder (test code)
       
  1382 //
       
  1383 // -----------------------------------------------------------------------------
       
  1384 //
       
  1385 void CMediaFileDialogState::PrintCurrentFolder()
       
  1386     {
       
  1387 	TBuf<KBufSize128> buf;
       
  1388 	
       
  1389 	GetFolderTypeText( buf, iCurrentFolderId );
       
  1390 	User::InfoPrint( buf );
       
  1391     }
       
  1392 		
       
  1393 		
       
  1394 // -----------------------------------------------------------------------------
       
  1395 // CMediaFileDialogState::GetFolderTypeText (test code)
       
  1396 //
       
  1397 // -----------------------------------------------------------------------------
       
  1398 //
       
  1399 void CMediaFileDialogState::GetFolderTypeText(TDes& aText, TInt aType)
       
  1400     {
       
  1401 	switch (aType)
       
  1402 		{
       
  1403 		case EEFolderRoot:
       
  1404 			aText = _L("EFolderRoot");
       
  1405 			break;
       
  1406 		case EEFolderTones:
       
  1407 			aText = _L("EFolderTones");
       
  1408 			break;
       
  1409 		case EEFolderMusic:
       
  1410 			aText = _L("EFolderMusic");
       
  1411 			break;
       
  1412 		case EEFolderVideos:
       
  1413 			aText = _L("EFolderVideos");
       
  1414 			break;
       
  1415 		case EEFolderRecordings:
       
  1416 			aText = _L("EFolderRecordings");
       
  1417 			break;
       
  1418         case EEFolderSearch:
       
  1419             aText = _L("EEFolderSearch");
       
  1420             break;
       
  1421 
       
  1422 		case EEFolderRecent:
       
  1423 			aText = _L("EFolderRecent");
       
  1424 			break;
       
  1425 		
       
  1426 
       
  1427 		case EEFolderArtistRoot:
       
  1428 			aText = _L("EFolderArtistRoot");
       
  1429 			break;
       
  1430 		case EEFolderArtist:
       
  1431 			aText = _L("EFolderArtist");
       
  1432 			break;
       
  1433 		case EEFolderArtistUnknown:
       
  1434 			aText = _L("EFolderArtistUnknown");
       
  1435 			break;
       
  1436 		case EEFolderArtistAll:
       
  1437 			aText = _L("EEFolderArtistAll");
       
  1438 	        break;
       
  1439     	case EEFolderArtistAlbum:
       
  1440 			aText = _L("EEFolderArtistAlbum");
       
  1441 			break;
       
  1442 		case EEFolderArtistAlbumUnknown:
       
  1443 			aText = _L("EEFolderArtistAlbumUnknown");
       
  1444 			break;
       
  1445 
       
  1446 
       
  1447 		case EEFolderAllMusic:
       
  1448 			aText = _L("EFolderAllMusic");
       
  1449 			break;
       
  1450 
       
  1451 		case EEFolderAlbumRoot:
       
  1452 			aText = _L("EFolderAlbumRoot");
       
  1453 			break;
       
  1454 		case EEFolderAlbum:
       
  1455 			aText = _L("EFolderAlbum");
       
  1456 			break;
       
  1457 		case EEFolderAlbumUnknown:
       
  1458 			aText = _L("EFolderAlbumUnknown");
       
  1459 			break;
       
  1460 			
       
  1461 		case EEFolderGenreRoot:
       
  1462 			aText = _L("EFolderGenreRoot");
       
  1463 			break;
       
  1464 		case EEFolderGenre:
       
  1465 			aText = _L("EFolderGenre");
       
  1466 			break;
       
  1467 		case EEFolderGenreUnknown:
       
  1468 			aText = _L("EFolderGenreUnknown");
       
  1469 			break;
       
  1470 			
       
  1471 		case EEFolderComposerRoot:
       
  1472 			aText = _L("EFolderComposerRoot");
       
  1473 			break;
       
  1474 		case EEFolderComposer:
       
  1475 			aText = _L("EFolderComposer");
       
  1476 			break;
       
  1477 		case EEFolderComposerUnknown:
       
  1478 			aText = _L("EFolderComposerUnknown");
       
  1479 			break;
       
  1480 			
       
  1481 		case EEFolderUnknown:
       
  1482 			aText = _L("EFolderUnknown");
       
  1483 			break;
       
  1484 
       
  1485 		case EEFolderNone:
       
  1486 			aText = _L("EFolderNone");
       
  1487 			break;
       
  1488 
       
  1489 		default:
       
  1490 			aText = _L("### unknown ###");
       
  1491 			break;
       
  1492 		}
       
  1493     }
       
  1494 
       
  1495 
       
  1496 
       
  1497 
       
  1498 
       
  1499 
       
  1500 
       
  1501 //  End of File