mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-01-19 15:37:01 +01:00
* Clean up ViewManager.
This commit is contained in:
parent
2bb7f91e7d
commit
d73cd9479c
@ -25,7 +25,6 @@
|
||||
#include "audio/AudioEngine.h"
|
||||
#include "context/ContextWidget.h"
|
||||
#include "infobar/InfoBar.h"
|
||||
#include "topbar/TopBar.h"
|
||||
|
||||
#include "FlexibleView.h"
|
||||
#include "TreeModel.h"
|
||||
@ -79,7 +78,6 @@ ViewManager::ViewManager( QObject* parent )
|
||||
, m_topLovedWidget( 0 )
|
||||
, m_recentPlaysWidget( 0 )
|
||||
, m_currentPage( 0 )
|
||||
, m_currentMode( PlaylistModes::Tree )
|
||||
, m_loaded( false )
|
||||
{
|
||||
s_instance = this;
|
||||
@ -101,10 +99,6 @@ ViewManager::ViewManager( QObject* parent )
|
||||
m_superCollectionView->setShowModes( false );
|
||||
// m_superCollectionView->proxyModel()->setShowOfflineResults( false );
|
||||
|
||||
m_superGridView = new GridView();
|
||||
m_superAlbumModel = new AlbumModel( m_superGridView );
|
||||
m_superGridView->setPlayableModel( m_superAlbumModel );
|
||||
|
||||
m_stack->setContentsMargins( 0, 0, 0, 0 );
|
||||
m_widget->setContentsMargins( 0, 0, 0, 0 );
|
||||
m_widget->layout()->setContentsMargins( 0, 0, 0, 0 );
|
||||
@ -274,81 +268,32 @@ ViewManager::show( const Tomahawk::query_ptr& query )
|
||||
Tomahawk::ViewPage*
|
||||
ViewManager::show( const Tomahawk::collection_ptr& collection )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << m_currentMode;
|
||||
m_currentCollection = collection;
|
||||
ViewPage* shown = 0;
|
||||
if ( m_currentMode == PlaylistModes::Flat )
|
||||
|
||||
TreeView* view;
|
||||
if ( !m_treeViews.contains( collection ) || m_treeViews.value( collection ).isNull() )
|
||||
{
|
||||
/* CollectionView* view;
|
||||
if ( !m_collectionViews.contains( collection ) || m_collectionViews.value( collection ).isNull() )
|
||||
{
|
||||
view = new CollectionView();
|
||||
CollectionFlatModel* model = new CollectionFlatModel();
|
||||
view->setPlayableModel( model );
|
||||
view = new TreeView();
|
||||
view->proxyModel()->setStyle( PlayableProxyModel::Collection );
|
||||
TreeModel* model = new TreeModel();
|
||||
view->setTreeModel( model );
|
||||
|
||||
model->addCollection( collection );
|
||||
|
||||
m_collectionViews.insert( collection, view );
|
||||
}
|
||||
if ( collection && collection->source()->isLocal() )
|
||||
view->setEmptyTip( tr( "After you have scanned your music collection you will find your tracks right here." ) );
|
||||
else
|
||||
{
|
||||
view = m_collectionViews.value( collection ).data();
|
||||
}
|
||||
view->setEmptyTip( tr( "This collection is empty." ) );
|
||||
|
||||
shown = view;
|
||||
setPage( view );*/
|
||||
model->addCollection( collection );
|
||||
|
||||
m_treeViews.insert( collection, view );
|
||||
}
|
||||
else
|
||||
{
|
||||
view = m_treeViews.value( collection ).data();
|
||||
}
|
||||
|
||||
if ( m_currentMode == PlaylistModes::Tree )
|
||||
{
|
||||
TreeView* view;
|
||||
if ( !m_treeViews.contains( collection ) || m_treeViews.value( collection ).isNull() )
|
||||
{
|
||||
view = new TreeView();
|
||||
view->proxyModel()->setStyle( PlayableProxyModel::Collection );
|
||||
TreeModel* model = new TreeModel();
|
||||
view->setTreeModel( model );
|
||||
|
||||
if ( collection && collection->source()->isLocal() )
|
||||
view->setEmptyTip( tr( "After you have scanned your music collection you will find your tracks right here." ) );
|
||||
else
|
||||
view->setEmptyTip( tr( "This collection is empty." ) );
|
||||
|
||||
model->addCollection( collection );
|
||||
|
||||
m_treeViews.insert( collection, view );
|
||||
}
|
||||
else
|
||||
{
|
||||
view = m_treeViews.value( collection ).data();
|
||||
}
|
||||
|
||||
shown = view;
|
||||
setPage( view );
|
||||
}
|
||||
|
||||
if ( m_currentMode == PlaylistModes::Album )
|
||||
{
|
||||
GridView* aview;
|
||||
if ( !m_collectionGridViews.contains( collection ) || m_collectionGridViews.value( collection ).isNull() )
|
||||
{
|
||||
aview = new GridView();
|
||||
AlbumModel* amodel = new AlbumModel( aview );
|
||||
aview->setPlayableModel( amodel );
|
||||
amodel->addCollection( collection );
|
||||
|
||||
m_collectionGridViews.insert( collection, aview );
|
||||
}
|
||||
else
|
||||
{
|
||||
aview = m_collectionGridViews.value( collection ).data();
|
||||
}
|
||||
|
||||
shown = aview;
|
||||
setPage( aview );
|
||||
}
|
||||
|
||||
return shown;
|
||||
setPage( view );
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@ -397,26 +342,9 @@ ViewManager::showSuperCollection()
|
||||
|
||||
m_superCollectionModel->setTitle( tr( "SuperCollection" ) );
|
||||
m_superCollectionModel->setDescription( tr( "Combined libraries of all your online friends" ) );
|
||||
m_superAlbumModel->setTitle( tr( "All available albums" ) );
|
||||
|
||||
ViewPage* shown = 0;
|
||||
if ( m_currentMode == PlaylistModes::Tree )
|
||||
{
|
||||
shown = m_superCollectionView;
|
||||
setPage( m_superCollectionView );
|
||||
}
|
||||
else if ( m_currentMode == PlaylistModes::Flat )
|
||||
{
|
||||
shown = m_superCollectionView;
|
||||
setPage( m_superCollectionView );
|
||||
}
|
||||
else if ( m_currentMode == PlaylistModes::Album )
|
||||
{
|
||||
shown = m_superGridView;
|
||||
setPage( m_superGridView );
|
||||
}
|
||||
|
||||
return shown;
|
||||
setPage( m_superCollectionView );
|
||||
return m_superCollectionView;
|
||||
}
|
||||
|
||||
|
||||
@ -501,48 +429,6 @@ ViewManager::showRecentPlaysPage()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ViewManager::setTableMode()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
m_currentMode = PlaylistModes::Flat;
|
||||
|
||||
if ( isSuperCollectionVisible() )
|
||||
showSuperCollection();
|
||||
else
|
||||
show( m_currentCollection );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ViewManager::setTreeMode()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
m_currentMode = PlaylistModes::Tree;
|
||||
|
||||
if ( isSuperCollectionVisible() )
|
||||
showSuperCollection();
|
||||
else
|
||||
show( m_currentCollection );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ViewManager::setAlbumMode()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
m_currentMode = PlaylistModes::Album;
|
||||
|
||||
if ( isSuperCollectionVisible() )
|
||||
showSuperCollection();
|
||||
else
|
||||
show( m_currentCollection );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ViewManager::setFilter( const QString& filter )
|
||||
{
|
||||
@ -759,13 +645,9 @@ ViewManager::updateView()
|
||||
SIGNAL( shuffleModeChanged( bool ) ) );
|
||||
|
||||
m_infobar->setFilter( currentPage()->filter() );
|
||||
}
|
||||
|
||||
if ( currentPage()->showStatsBar() && currentPlaylistInterface() )
|
||||
{
|
||||
emit repeatModeChanged( currentPlaylistInterface()->repeatMode() );
|
||||
emit shuffleModeChanged( currentPlaylistInterface()->shuffled() );
|
||||
emit modeChanged( currentPlaylistInterface()->viewMode() );
|
||||
}
|
||||
|
||||
/* if ( currentPage()->queueVisible() )
|
||||
@ -773,8 +655,6 @@ ViewManager::updateView()
|
||||
else
|
||||
hideQueue();*/
|
||||
|
||||
emit statsAvailable( currentPage()->showStatsBar() );
|
||||
emit modesAvailable( currentPage()->showModes() );
|
||||
emit filterAvailable( currentPage()->showFilter() );
|
||||
|
||||
/* if ( !currentPage()->showStatsBar() && !currentPage()->showModes() && !currentPage()->showFilter() )
|
||||
@ -784,7 +664,6 @@ ViewManager::updateView()
|
||||
|
||||
m_infobar->setVisible( currentPage()->showInfoBar() );
|
||||
m_infobar->setCaption( currentPage()->title() );
|
||||
|
||||
m_infobar->setUpdaters( currentPage()->updaters() );
|
||||
|
||||
switch( currentPage()->descriptionType() )
|
||||
@ -988,27 +867,11 @@ ViewManager::dynamicPlaylistForInterface( Tomahawk::playlistinterface_ptr interf
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::collection_ptr
|
||||
ViewManager::collectionForInterface( Tomahawk::playlistinterface_ptr interface ) const
|
||||
{
|
||||
foreach ( QWeakPointer<GridView> view, m_collectionGridViews.values() )
|
||||
{
|
||||
if ( view.data()->playlistInterface() == interface )
|
||||
{
|
||||
return m_collectionGridViews.key( view );
|
||||
}
|
||||
}
|
||||
|
||||
return collection_ptr();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ViewManager::isSuperCollectionVisible() const
|
||||
{
|
||||
return ( currentPage() != 0 &&
|
||||
( currentPage()->playlistInterface() == m_superCollectionView->playlistInterface() ||
|
||||
currentPage()->playlistInterface() == m_superGridView->playlistInterface() ) );
|
||||
( currentPage()->playlistInterface() == m_superCollectionView->playlistInterface() ) );
|
||||
}
|
||||
|
||||
|
||||
@ -1021,19 +884,6 @@ ViewManager::showCurrentTrack()
|
||||
{
|
||||
setPage( page );
|
||||
page->jumpToCurrentTrack();
|
||||
|
||||
// reset the correct mode, if the user has changed it since
|
||||
|
||||
if ( dynamic_cast< TrackView* >( page ) )
|
||||
m_currentMode = PlaylistModes::Flat;
|
||||
else if ( dynamic_cast< GridView* >( page ) )
|
||||
m_currentMode = PlaylistModes::Album;
|
||||
else if ( dynamic_cast< TreeView* >( page ) )
|
||||
m_currentMode = PlaylistModes::Tree;
|
||||
else
|
||||
return;
|
||||
|
||||
emit modeChanged( (PlaylistModes::ViewMode)m_currentMode );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,6 @@ class TreeModel;
|
||||
class TrackView;
|
||||
class SourceInfoWidget;
|
||||
class InfoBar;
|
||||
class TopBar;
|
||||
class TrackInfoWidget;
|
||||
class NewReleasesWidget;
|
||||
class WelcomeWidget;
|
||||
@ -113,10 +112,7 @@ signals:
|
||||
void repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode mode );
|
||||
void shuffleModeChanged( bool enabled );
|
||||
|
||||
void statsAvailable( bool b );
|
||||
void modesAvailable( bool b );
|
||||
void filterAvailable( bool b );
|
||||
void modeChanged( Tomahawk::PlaylistModes::ViewMode mode );
|
||||
|
||||
void playClicked();
|
||||
void pauseClicked();
|
||||
@ -159,10 +155,6 @@ public slots:
|
||||
void showQueue() { emit showQueueRequested(); }
|
||||
void hideQueue() { emit hideQueueRequested(); }
|
||||
|
||||
void setTreeMode();
|
||||
void setTableMode();
|
||||
void setAlbumMode();
|
||||
|
||||
void setRepeatMode( Tomahawk::PlaylistModes::RepeatMode mode );
|
||||
void setShuffled( bool enabled );
|
||||
|
||||
@ -189,7 +181,6 @@ private:
|
||||
|
||||
Tomahawk::playlist_ptr playlistForInterface( Tomahawk::playlistinterface_ptr plInterface ) const;
|
||||
Tomahawk::dynplaylist_ptr dynamicPlaylistForInterface( Tomahawk::playlistinterface_ptr plInterface ) const;
|
||||
Tomahawk::collection_ptr collectionForInterface( Tomahawk::playlistinterface_ptr plInterface ) const;
|
||||
|
||||
QWidget* m_widget;
|
||||
InfoBar* m_infobar;
|
||||
@ -197,8 +188,6 @@ private:
|
||||
QStackedWidget* m_stack;
|
||||
AnimatedSplitter* m_splitter;
|
||||
|
||||
AlbumModel* m_superAlbumModel;
|
||||
GridView* m_superGridView;
|
||||
TreeModel* m_superCollectionModel;
|
||||
TreeView* m_superCollectionView;
|
||||
QueueView* m_queue;
|
||||
@ -212,7 +201,6 @@ private:
|
||||
|
||||
QHash< Tomahawk::dynplaylist_ptr, QWeakPointer<Tomahawk::DynamicWidget> > m_dynamicWidgets;
|
||||
QHash< Tomahawk::collection_ptr, QWeakPointer<TreeView> > m_treeViews;
|
||||
QHash< Tomahawk::collection_ptr, QWeakPointer<GridView> > m_collectionGridViews;
|
||||
QHash< Tomahawk::artist_ptr, QWeakPointer<ArtistInfoWidget> > m_artistViews;
|
||||
QHash< Tomahawk::album_ptr, QWeakPointer<AlbumInfoWidget> > m_albumViews;
|
||||
QHash< Tomahawk::query_ptr, QWeakPointer<TrackInfoWidget> > m_trackViews;
|
||||
@ -224,7 +212,6 @@ private:
|
||||
Tomahawk::ViewPage* m_currentPage;
|
||||
|
||||
Tomahawk::collection_ptr m_currentCollection;
|
||||
int m_currentMode;
|
||||
|
||||
QTimer m_filterTimer;
|
||||
QString m_filter;
|
||||
|
Loading…
x
Reference in New Issue
Block a user