mpdata/src/mpmpxcollectiondata.cpp
branchRCL_3
changeset 25 14979e23cb5e
equal deleted inserted replaced
24:26a1709b9fec 25:14979e23cb5e
       
     1 /*
       
     2 * Copyright (c) 2009 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: Music Player collection data.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "mpmpxcollectiondata.h"
       
    19 #include "mpmpxcollectiondata_p.h"
       
    20 
       
    21 /*!
       
    22     \class MpMpxCollectionData
       
    23     \brief Music Player collection data.
       
    24 
       
    25     Collection data provides access to collection data needed by the view.
       
    26     Every item of data can be accessed via an index and its details by specifying
       
    27     the data type of the selected data item.
       
    28 */
       
    29 
       
    30 /*!
       
    31     \enum MpMpxCollectionData::DataType
       
    32 
       
    33     This enum defines available data types.
       
    34  */
       
    35 
       
    36 /*!
       
    37     \fn void contextChanged( TCollectionContext context )
       
    38 
       
    39     This signal is emitted when a new data set is available and the
       
    40     collection context is changed.
       
    41 
       
    42     \sa setMpxMedia()
       
    43  */
       
    44 
       
    45 /*!
       
    46     \fn void dataChanged()
       
    47 
       
    48     This signal is emitted when a new data set is available within the
       
    49     same context. This can happen after operations like delete and several
       
    50     playlist related operations (save, rearrange, remove).
       
    51 
       
    52     \sa setMpxMedia()
       
    53  */
       
    54 
       
    55 /*!
       
    56     \fn void dataChanged( int fromIndex, int toIndex )
       
    57 
       
    58     This signal is emitted when a new data set is available within the
       
    59     same context. This can happen during an incremental open operation,
       
    60     if the view accesses a range of data that doesn't have final data
       
    61     (i.e. Unknown). This signal is emitted upon completion of incremental
       
    62     open operation, if such unavailable range was accessed.
       
    63 
       
    64     \sa setMpxMedia()
       
    65  */
       
    66 
       
    67 /*!
       
    68     \fn void albumDataChanged()
       
    69 
       
    70     This signal is specific to views with TBone. This signal is emitted when
       
    71     a new data set is available for the list section of the TBone. Currently,
       
    72     the only operation that can trigger this is the delete operation.
       
    73 
       
    74     \sa setMpxMedia()
       
    75  */
       
    76 
       
    77 /*!
       
    78     \fn void refreshAlbumSongs()
       
    79 
       
    80     This signal is specific to views with TBone. This signal is emitted when
       
    81     album song data is available (for the list section of the TBone), upon
       
    82     completion of MpEngine's findAlbumSongs() operation.
       
    83 
       
    84     \sa setAlbumContent()
       
    85  */
       
    86 
       
    87 /*!
       
    88  Constructs the collection data.
       
    89  */
       
    90 MpMpxCollectionData::MpMpxCollectionData( QObject *parent )
       
    91     : QObject(parent)
       
    92 {
       
    93     d_ptr = new MpMpxCollectionDataPrivate(this);
       
    94 }
       
    95 
       
    96 /*!
       
    97  Destructs the collection data.
       
    98  */
       
    99 MpMpxCollectionData::~MpMpxCollectionData()
       
   100 {
       
   101     delete d_ptr;
       
   102 }
       
   103 
       
   104 /*!
       
   105  Returns the current collection context.
       
   106  /sa setContext()
       
   107  */
       
   108 TCollectionContext MpMpxCollectionData::context() const
       
   109 {
       
   110     return d_ptr->context();
       
   111 }
       
   112 
       
   113 /*!
       
   114  Returns the number of data entries.
       
   115  */
       
   116 int MpMpxCollectionData::count() const
       
   117 {
       
   118     return d_ptr->count();
       
   119 }
       
   120 
       
   121 /*!
       
   122  Returns the \a title of the collection data based on the current context.
       
   123  */
       
   124 QString MpMpxCollectionData::collectionTitle() const
       
   125 {
       
   126     return d_ptr->collectionTitle();
       
   127 }
       
   128 
       
   129 /*!
       
   130  Returns the data for the specified \a index and \a type.
       
   131  */
       
   132 QString MpMpxCollectionData::itemData( int index, MpMpxCollectionData::DataType type ) const
       
   133 {
       
   134     return d_ptr->itemData(index, type);
       
   135 }
       
   136 
       
   137 /*!
       
   138  Returns if the current container is of type 'Auto playlist'.
       
   139  */
       
   140 bool MpMpxCollectionData::isAutoPlaylist()
       
   141 {
       
   142     return d_ptr->isAutoPlaylist();
       
   143 }
       
   144 
       
   145 /*!
       
   146  Returns if the item specified by \a index is of type 'Auto playlist'.
       
   147  */
       
   148 bool MpMpxCollectionData::isAutoPlaylist( int index )
       
   149 {
       
   150     return d_ptr->isAutoPlaylist(index);
       
   151 }
       
   152 
       
   153 /*!
       
   154  Returns the count of the items contained within item specified by \a index.
       
   155  */
       
   156 int MpMpxCollectionData::itemCount( int index )
       
   157 {
       
   158     return d_ptr->itemCount(index);
       
   159 }
       
   160 
       
   161 /*!
       
   162  Returns the current container id.
       
   163  */
       
   164 int MpMpxCollectionData::containerId()
       
   165 {
       
   166     return d_ptr->containerId();
       
   167 }
       
   168 
       
   169 /*!
       
   170  Returns id of the item specified by \a index
       
   171  */
       
   172 int MpMpxCollectionData::itemId( int index )
       
   173 {
       
   174     return d_ptr->itemId(index);
       
   175 }
       
   176 
       
   177 /*!
       
   178  Returns id of the album song specified by \a index
       
   179  */
       
   180 int MpMpxCollectionData::albumSongId( int index )
       
   181 {
       
   182     return d_ptr->albumSongId( index );
       
   183 }
       
   184 
       
   185 /*!
       
   186  Removes item specified by \a index, also internally caches the item for drag
       
   187  and drop operations.
       
   188  
       
   189  \sa testCachedItem() insertCachedItem()
       
   190  */
       
   191 void MpMpxCollectionData::removeItem( int index )
       
   192 {
       
   193     d_ptr->removeItem( index );
       
   194 }
       
   195 
       
   196 /*!
       
   197  Test wether the cached item matches \a itemId.
       
   198  \sa removeItem() insertCachedItem()
       
   199  */
       
   200 bool MpMpxCollectionData::testCachedItem( int itemId )
       
   201 {
       
   202     return d_ptr->testCachedItem( itemId );
       
   203 }
       
   204 
       
   205 /*!
       
   206  Inserts the cached item in the location specified by \a index
       
   207  \sa removeItem() testCachedItem()
       
   208  */
       
   209 void MpMpxCollectionData::insertCachedItem(int index)
       
   210 {
       
   211     d_ptr->insertCachedItem( index );
       
   212 }
       
   213 
       
   214 /*!
       
   215  Sets the current album in focus. Also, triggers refreshAlbumSongs() signal
       
   216  if data contains album songs already and returns true. Otherwise, function
       
   217  returns false.
       
   218  */
       
   219 bool MpMpxCollectionData::setCurrentAlbum( int index )
       
   220 {
       
   221     return d_ptr->setCurrentAlbum( index );
       
   222 }
       
   223 
       
   224 /*!
       
   225  Returns the current album index.
       
   226  \sa setCurrentAlbum()
       
   227  */
       
   228 int MpMpxCollectionData::currentAlbumIndex() const
       
   229 {
       
   230     return d_ptr->currentAlbumIndex();
       
   231 }
       
   232 
       
   233 /*!
       
   234  Returns the number of songs in the current album.
       
   235  */
       
   236 int MpMpxCollectionData::albumSongsCount() const
       
   237 {
       
   238     return d_ptr->albumSongsCount();
       
   239 }
       
   240 
       
   241 /*!
       
   242  Returns the data for the specified \a index and \a type in the current album.
       
   243  Currently supported data types are: Title and Uri. All others will return
       
   244 
       
   245  empty string.
       
   246 
       
   247  \sa setCurrentAlbum()
       
   248  */
       
   249 QString MpMpxCollectionData::albumSongData( int index, MpMpxCollectionData::DataType type ) const
       
   250 {
       
   251     return d_ptr->albumSongData( index, type );
       
   252 }
       
   253 
       
   254 /*!
       
   255  Returns item property for the specified \a index and \a type in the current item.
       
   256  Currently supported data types are: Corrupted and DrmExpired. All others will return
       
   257  false bool.
       
   258  */
       
   259 
       
   260 bool MpMpxCollectionData::hasItemProperty( int index, MpMpxCollectionData:: DataProperty type ) const
       
   261 {
       
   262     return d_ptr->hasItemProperty( index, type );
       
   263 }
       
   264 
       
   265 /*!
       
   266  Returns item property for the specified \a index and \a type in the current album.
       
   267  Currently supported data types are: Corrupted and DrmExpired. All others will return
       
   268  false bool.
       
   269  */
       
   270 bool MpMpxCollectionData::hasAlbumSongProperty( int index, MpMpxCollectionData:: DataProperty type ) const
       
   271 {
       
   272     return d_ptr->hasAlbumSongProperty( index, type);
       
   273 }
       
   274 
       
   275 /*!
       
   276  Sets the media \a entries from the MPX framework. The \a reopen flag indicates
       
   277  whether the new media is a result of reopenCollection() operation in the MpEngine.
       
   278  Internal usage only from MpEngine.
       
   279  */
       
   280 void MpMpxCollectionData::setMpxMedia( const CMPXMedia& entries, bool reopen )
       
   281 {
       
   282     d_ptr->setMpxMedia(entries, reopen);
       
   283 }
       
   284 
       
   285 /*!
       
   286  Called when collection was opened with incremental open. This indicates that the
       
   287  media received in setMpxMedia() has an update.
       
   288  */
       
   289 void MpMpxCollectionData::incrementalOpenUpdate()
       
   290 {
       
   291     d_ptr->incrementalOpenUpdate();
       
   292 }
       
   293 
       
   294 /*!
       
   295  Returns the container media from the MPX framework.
       
   296  Internal usage only from MpEngine.
       
   297 
       
   298  \sa setMpxMedia()
       
   299  */
       
   300 const CMPXMedia& MpMpxCollectionData::containerMedia()
       
   301 {
       
   302     return d_ptr->containerMedia();
       
   303 }
       
   304 
       
   305 /*!
       
   306  Sets the context.
       
   307  Used to fake open() and back() in T-Bone supporting views.
       
   308  Used to force the context for Media Wall view.
       
   309  */
       
   310 void MpMpxCollectionData::setContext( TCollectionContext context )
       
   311 {
       
   312     d_ptr->setContext( context );
       
   313 }
       
   314 
       
   315 /*!
       
   316  Sets the media \a albumContent from the MPX framework.
       
   317  Internal usage only from MpEngine.
       
   318  Album songs have been populated. Notify the change by emitting
       
   319  refreshAlbumSongs() signal.
       
   320 
       
   321  \sa setCurrentAlbum()
       
   322  */
       
   323 void MpMpxCollectionData::setAlbumContent( const CMPXMedia& albumContent )
       
   324 {
       
   325     d_ptr->setAlbumContent(albumContent);
       
   326 }
       
   327 
       
   328 /*!
       
   329  Returns the index of the item with \a ItemUniqueId.
       
   330  Only supported for ECollectionContextAlbumsMediaWall.
       
   331 
       
   332  \sa setContext()
       
   333  */
       
   334 int MpMpxCollectionData::itemIndex( int itemUniqueId )
       
   335 {
       
   336     return d_ptr->itemIndex( itemUniqueId );
       
   337 }
       
   338 
       
   339 /*!
       
   340  Returns the index within the album data for the song with \a songUniqueId.
       
   341 
       
   342  */
       
   343 int MpMpxCollectionData::albumSongIndex( int songUniqueId )
       
   344 {
       
   345     return d_ptr->albumSongIndex( songUniqueId );
       
   346 }
       
   347 
       
   348 /*!
       
   349  Returns the list of index for the song with \a songUniqueId. 
       
   350  A list is returned due to playlist can contain the same song 
       
   351  multiple times.
       
   352 
       
   353  */
       
   354 QList<int>  MpMpxCollectionData::songIndex( int songUniqueId )
       
   355 {
       
   356     return d_ptr->songIndex( songUniqueId );
       
   357 }
       
   358 
       
   359 /*!
       
   360  Set model index \a index as corrupted.  
       
   361 
       
   362  */
       
   363 void MpMpxCollectionData::setCorruptValue( QModelIndex index, bool tBone )
       
   364 {
       
   365     d_ptr->setCorruptValue( index, tBone );
       
   366 }
       
   367 
       
   368 /*!
       
   369  Set the reloadAlbumContent variable to \a reloadAlbum
       
   370 
       
   371  */
       
   372 void MpMpxCollectionData::setReloadAlbumContent( bool reloadAlbum )
       
   373 {
       
   374     d_ptr->setReloadAlbumContent( reloadAlbum );
       
   375 }
       
   376