예제 #1
0
// ----------------------------------------------------------------------------
// Add array items in aSrc into sorted array aDest if the item is not in
// the aDest yet
// ----------------------------------------------------------------------------
//
EXPORT_C void MPXUser::MergeArray(const MDesCArray& aSrc, CDesCArray& aDest)
    {
    for (TInt i=aSrc.MdcaCount(); --i>=0 ;)
        {
        ////ignore leave when insert the same item
        TRAP_IGNORE(aDest.InsertIsqL(aSrc.MdcaPoint(i)));
        }
    }
// -----------------------------------------------------------------------------
// CCLFDefaultOperation::DoMusicAlbumGroupingL
// -----------------------------------------------------------------------------
//
void CCLFDefaultOperation::DoMusicAlbumGroupingL(
    const TArray<MCLFItem*>& aSourceList,
    RPointerArray<MCLFItem>& aGroupedList )
{
    CleanupResetAndDestroyPushL( aGroupedList );

    CDesCArray* tempAlbumNameArray =
        new (ELeave) CDesCArraySeg( KCLFGroupedItemArrayGranularity );
    CleanupStack::PushL( tempAlbumNameArray );

    const TInt count( aSourceList.Count() );
    for( TInt i = 0 ; i < count ; ++i )
    {
        const MCLFItem* item = aSourceList[i];
        TPtrC albumName;
        if( item->GetField( ECLFFieldIdAlbum, albumName ) == KErrNone )
        {
            TInt pos( 0 );
            if( tempAlbumNameArray->FindIsq( albumName, pos ) )
            {
                // not found
                tempAlbumNameArray->InsertIsqL( albumName );

                // make new item
                MCLFModifiableItem* newItem =
                    ContentListingFactory::NewModifiableItemLC();
                newItem->AddFieldL( ECLFFieldIdAlbum, albumName );
                iGroupedItemList.AppendL( newItem );    // takes ownership
                CleanupStack::Pop(); // newItem

                TPtrC artistName;
                if( item->GetField( ECLFFieldIdArtist, artistName ) == KErrNone )
                {
                    newItem->AddFieldL( ECLFFieldIdArtist, artistName );
                }

                // add new item to grouper list
                aGroupedList.AppendL( newItem );
            }
        }
    }
    CleanupStack::PopAndDestroy( tempAlbumNameArray );

    CleanupStack::Pop( &aGroupedList );
}