mpviewplugins/mpcollectionviewplugin/src/mpcollectioncontainerfactory.cpp
changeset 29 8192e5b5c935
parent 25 3ec52facab4d
child 32 c163ef0b758d
equal deleted inserted replaced
25:3ec52facab4d 29:8192e5b5c935
    22 #include "mpcollectioncontainer.h"
    22 #include "mpcollectioncontainer.h"
    23 #include "mpcollectioncontainerallsongs.h"
    23 #include "mpcollectioncontainerallsongs.h"
    24 #include "mpcollectioncontainerartists.h"
    24 #include "mpcollectioncontainerartists.h"
    25 #include "mpcollectioncontaineralbums.h"
    25 #include "mpcollectioncontaineralbums.h"
    26 #include "mpcollectioncontainerplaylists.h"
    26 #include "mpcollectioncontainerplaylists.h"
    27 #include "mpcollectioncontainergenres.h"
       
    28 #include "mptrace.h"
    27 #include "mptrace.h"
    29 
    28 
    30 /*!
    29 /*!
    31     \class MpCollectionContainerFactory
    30     \class MpCollectionContainerFactory
    32     \brief Music Player collection container factory.
    31     \brief Music Player collection container factory.
    75         mCurrentContainer->initialize();
    74         mCurrentContainer->initialize();
    76         connect( mCurrentContainer, SIGNAL(itemActivated(int)), mView, SLOT(openIndex(int)) );
    75         connect( mCurrentContainer, SIGNAL(itemActivated(int)), mView, SLOT(openIndex(int)) );
    77         connect( mCurrentContainer, SIGNAL(itemLongPressed(int, QPointF)), mView, SLOT(openContextMenu(int, QPointF)) );
    76         connect( mCurrentContainer, SIGNAL(itemLongPressed(int, QPointF)), mView, SLOT(openContextMenu(int, QPointF)) );
    78         break;
    77         break;
    79     case ECollectionContextArtists:
    78     case ECollectionContextArtists:
    80             if ( ( mCurrentContext != ECollectionContextArtistAlbums ) && ( mCurrentContext != ECollectionContextAlbumSongs) )
    79         if ( ( mCurrentContext != ECollectionContextArtistAlbums )
    81                 {
    80                && ( mCurrentContext != ECollectionContextArtistAlbumsTBone)
    82                 deleteCurrentContainer();
    81                && ( mCurrentContext != ECollectionContextArtistAllSongs) )
    83                 mCurrentContainer = new MpCollectionContainerArtists(mDocumentLoader);
    82             {
    84                 mCurrentContainer->initialize();
    83             deleteCurrentContainer();
    85                 connect( mCurrentContainer, SIGNAL(itemActivated(int)), mView, SLOT(openIndex(int)) );
    84             mCurrentContainer = new MpCollectionContainerArtists(mDocumentLoader);
    86                 connect( mCurrentContainer, SIGNAL(itemLongPressed(int, QPointF)), mView, SLOT(openContextMenu(int, QPointF)) );
    85             mCurrentContainer->initialize();
    87             }
    86             connect( mCurrentContainer, SIGNAL(itemActivated(int)), mView, SLOT(openIndex(int)) );
    88             break;
    87             connect( mCurrentContainer, SIGNAL(itemLongPressed(int, QPointF)), mView, SLOT(openContextMenu(int, QPointF)) );
       
    88             connect( mCurrentContainer, SIGNAL(findAlbumSongs(int)), mView, SLOT(findAlbumSongs(int)) );
       
    89             connect( mCurrentContainer, SIGNAL(playAlbumSongs(int, int)), mView, SLOT(playAlbumSongs(int, int)) );
       
    90         }
       
    91         break;
    89     case ECollectionContextAlbums:
    92     case ECollectionContextAlbums:
    90         if ( mCurrentContext != ECollectionContextAlbumSongs ) {
    93         if ( mCurrentContext != ECollectionContextAlbumsTBone ) {
    91             deleteCurrentContainer();
    94             deleteCurrentContainer();
    92             mCurrentContainer = new MpCollectionContainerAlbums(mDocumentLoader);
    95             mCurrentContainer = new MpCollectionContainerAlbums(mDocumentLoader);
    93             mCurrentContainer->initialize();
    96             mCurrentContainer->initialize();
    94             connect( mCurrentContainer, SIGNAL(itemActivated(int)), mView, SLOT(openIndex(int)) );
    97             connect( mCurrentContainer, SIGNAL(itemActivated(int)), mView, SLOT(openIndex(int)) );
    95             connect( mCurrentContainer, SIGNAL(itemLongPressed(int, QPointF)), mView, SLOT(openContextMenu(int, QPointF)) );
    98             connect( mCurrentContainer, SIGNAL(itemLongPressed(int, QPointF)), mView, SLOT(openContextMenu(int, QPointF)) );
       
    99             connect( mCurrentContainer, SIGNAL(findAlbumSongs(int)), mView, SLOT(findAlbumSongs(int)) );
       
   100             connect( mCurrentContainer, SIGNAL(playAlbumSongs(int, int)), mView, SLOT(playAlbumSongs(int, int)) );
    96         }
   101         }
    97         break;
   102         break;
    98     case ECollectionContextPlaylists:
   103     case ECollectionContextPlaylists:
    99         if ( mCurrentContext != ECollectionContextPlaylistSongs ) {
   104         if ( mCurrentContext != ECollectionContextPlaylistSongs ) {
   100             deleteCurrentContainer();
   105             deleteCurrentContainer();
   102             mCurrentContainer->initialize();
   107             mCurrentContainer->initialize();
   103             connect( mCurrentContainer, SIGNAL(itemActivated(int)), mView, SLOT(openIndex(int)) );
   108             connect( mCurrentContainer, SIGNAL(itemActivated(int)), mView, SLOT(openIndex(int)) );
   104             connect( mCurrentContainer, SIGNAL(itemLongPressed(int, QPointF)), mView, SLOT(openContextMenu(int, QPointF)) );
   109             connect( mCurrentContainer, SIGNAL(itemLongPressed(int, QPointF)), mView, SLOT(openContextMenu(int, QPointF)) );
   105         }
   110         }
   106         break;
   111         break;
   107     case ECollectionContextGenres:
       
   108         if ( mCurrentContext != ECollectionContextGenreSongs ) {
       
   109             deleteCurrentContainer();
       
   110             mCurrentContainer = new MpCollectionContainerGenres(mDocumentLoader);
       
   111             mCurrentContainer->initialize();
       
   112             connect( mCurrentContainer, SIGNAL(itemActivated(int)), mView, SLOT(openIndex(int)) );
       
   113             //connect( mCurrentContainer, SIGNAL(itemLongPressed(int, QPointF)), mView, SLOT(openContextMenu(int, QPointF)) );
       
   114         }
       
   115         break;
       
   116     case ECollectionContextAlbumSongs:
       
   117     case ECollectionContextArtistAlbums:
   112     case ECollectionContextArtistAlbums:
   118     case ECollectionContextArtistSongs:
   113     case ECollectionContextArtistAlbumsTBone:
       
   114     case ECollectionContextArtistAllSongs:
       
   115     case ECollectionContextAlbumsTBone:
   119     case ECollectionContextPlaylistSongs:
   116     case ECollectionContextPlaylistSongs:
   120     case ECollectionContextGenreSongs:
       
   121         // For this contexts, reuse the same container.
   117         // For this contexts, reuse the same container.
   122         break;
   118         break;
   123     }
   119     }
   124     TX_EXIT
   120     TX_EXIT
   125     mCurrentContext = context;
   121     mCurrentContext = context;
   136     case ECollectionContextAllSongs:
   132     case ECollectionContextAllSongs:
   137         delete static_cast<MpCollectionContainerAllSongs *>(mCurrentContainer);
   133         delete static_cast<MpCollectionContainerAllSongs *>(mCurrentContainer);
   138         break;
   134         break;
   139     case ECollectionContextArtists:
   135     case ECollectionContextArtists:
   140     case ECollectionContextArtistAlbums:
   136     case ECollectionContextArtistAlbums:
   141     case ECollectionContextArtistSongs:
   137     case ECollectionContextArtistAlbumsTBone:
       
   138     case ECollectionContextArtistAllSongs:
   142         delete static_cast<MpCollectionContainerArtists *>(mCurrentContainer);
   139         delete static_cast<MpCollectionContainerArtists *>(mCurrentContainer);
   143         break;
   140         break;
   144     case ECollectionContextAlbums:
   141     case ECollectionContextAlbums:
   145     case ECollectionContextAlbumSongs:
   142     case ECollectionContextAlbumsTBone:
   146         delete static_cast<MpCollectionContainerAlbums *>(mCurrentContainer);
   143         delete static_cast<MpCollectionContainerAlbums *>(mCurrentContainer);
   147         break;
   144         break;
   148     case ECollectionContextPlaylists:
   145     case ECollectionContextPlaylists:
   149     case ECollectionContextPlaylistSongs:
   146     case ECollectionContextPlaylistSongs:
   150         delete static_cast<MpCollectionContainerPlaylists *>(mCurrentContainer);
   147         delete static_cast<MpCollectionContainerPlaylists *>(mCurrentContainer);
   151         break;
   148         break;
   152     case ECollectionContextGenres:
       
   153     case ECollectionContextGenreSongs:
       
   154         delete static_cast<MpCollectionContainerGenres *>(mCurrentContainer);
       
   155         break;
       
   156     }
   149     }
   157     TX_EXIT
   150     TX_EXIT
   158 }
   151 }
   159 
   152