mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 05:37:29 +02:00
* Clean up ViewManager.
This commit is contained in:
@@ -25,7 +25,6 @@
|
|||||||
#include "audio/AudioEngine.h"
|
#include "audio/AudioEngine.h"
|
||||||
#include "context/ContextWidget.h"
|
#include "context/ContextWidget.h"
|
||||||
#include "infobar/InfoBar.h"
|
#include "infobar/InfoBar.h"
|
||||||
#include "topbar/TopBar.h"
|
|
||||||
|
|
||||||
#include "FlexibleView.h"
|
#include "FlexibleView.h"
|
||||||
#include "TreeModel.h"
|
#include "TreeModel.h"
|
||||||
@@ -79,7 +78,6 @@ ViewManager::ViewManager( QObject* parent )
|
|||||||
, m_topLovedWidget( 0 )
|
, m_topLovedWidget( 0 )
|
||||||
, m_recentPlaysWidget( 0 )
|
, m_recentPlaysWidget( 0 )
|
||||||
, m_currentPage( 0 )
|
, m_currentPage( 0 )
|
||||||
, m_currentMode( PlaylistModes::Tree )
|
|
||||||
, m_loaded( false )
|
, m_loaded( false )
|
||||||
{
|
{
|
||||||
s_instance = this;
|
s_instance = this;
|
||||||
@@ -101,10 +99,6 @@ ViewManager::ViewManager( QObject* parent )
|
|||||||
m_superCollectionView->setShowModes( false );
|
m_superCollectionView->setShowModes( false );
|
||||||
// m_superCollectionView->proxyModel()->setShowOfflineResults( 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_stack->setContentsMargins( 0, 0, 0, 0 );
|
||||||
m_widget->setContentsMargins( 0, 0, 0, 0 );
|
m_widget->setContentsMargins( 0, 0, 0, 0 );
|
||||||
m_widget->layout()->setContentsMargins( 0, 0, 0, 0 );
|
m_widget->layout()->setContentsMargins( 0, 0, 0, 0 );
|
||||||
@@ -274,33 +268,8 @@ ViewManager::show( const Tomahawk::query_ptr& query )
|
|||||||
Tomahawk::ViewPage*
|
Tomahawk::ViewPage*
|
||||||
ViewManager::show( const Tomahawk::collection_ptr& collection )
|
ViewManager::show( const Tomahawk::collection_ptr& collection )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << m_currentMode;
|
|
||||||
m_currentCollection = collection;
|
m_currentCollection = collection;
|
||||||
ViewPage* shown = 0;
|
|
||||||
if ( m_currentMode == PlaylistModes::Flat )
|
|
||||||
{
|
|
||||||
/* CollectionView* view;
|
|
||||||
if ( !m_collectionViews.contains( collection ) || m_collectionViews.value( collection ).isNull() )
|
|
||||||
{
|
|
||||||
view = new CollectionView();
|
|
||||||
CollectionFlatModel* model = new CollectionFlatModel();
|
|
||||||
view->setPlayableModel( model );
|
|
||||||
|
|
||||||
model->addCollection( collection );
|
|
||||||
|
|
||||||
m_collectionViews.insert( collection, view );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
view = m_collectionViews.value( collection ).data();
|
|
||||||
}
|
|
||||||
|
|
||||||
shown = view;
|
|
||||||
setPage( view );*/
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_currentMode == PlaylistModes::Tree )
|
|
||||||
{
|
|
||||||
TreeView* view;
|
TreeView* view;
|
||||||
if ( !m_treeViews.contains( collection ) || m_treeViews.value( collection ).isNull() )
|
if ( !m_treeViews.contains( collection ) || m_treeViews.value( collection ).isNull() )
|
||||||
{
|
{
|
||||||
@@ -323,32 +292,8 @@ ViewManager::show( const Tomahawk::collection_ptr& collection )
|
|||||||
view = m_treeViews.value( collection ).data();
|
view = m_treeViews.value( collection ).data();
|
||||||
}
|
}
|
||||||
|
|
||||||
shown = view;
|
|
||||||
setPage( view );
|
setPage( view );
|
||||||
}
|
return 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -397,26 +342,9 @@ ViewManager::showSuperCollection()
|
|||||||
|
|
||||||
m_superCollectionModel->setTitle( tr( "SuperCollection" ) );
|
m_superCollectionModel->setTitle( tr( "SuperCollection" ) );
|
||||||
m_superCollectionModel->setDescription( tr( "Combined libraries of all your online friends" ) );
|
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 );
|
setPage( m_superCollectionView );
|
||||||
}
|
return 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -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
|
void
|
||||||
ViewManager::setFilter( const QString& filter )
|
ViewManager::setFilter( const QString& filter )
|
||||||
{
|
{
|
||||||
@@ -759,13 +645,9 @@ ViewManager::updateView()
|
|||||||
SIGNAL( shuffleModeChanged( bool ) ) );
|
SIGNAL( shuffleModeChanged( bool ) ) );
|
||||||
|
|
||||||
m_infobar->setFilter( currentPage()->filter() );
|
m_infobar->setFilter( currentPage()->filter() );
|
||||||
}
|
|
||||||
|
|
||||||
if ( currentPage()->showStatsBar() && currentPlaylistInterface() )
|
|
||||||
{
|
|
||||||
emit repeatModeChanged( currentPlaylistInterface()->repeatMode() );
|
emit repeatModeChanged( currentPlaylistInterface()->repeatMode() );
|
||||||
emit shuffleModeChanged( currentPlaylistInterface()->shuffled() );
|
emit shuffleModeChanged( currentPlaylistInterface()->shuffled() );
|
||||||
emit modeChanged( currentPlaylistInterface()->viewMode() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if ( currentPage()->queueVisible() )
|
/* if ( currentPage()->queueVisible() )
|
||||||
@@ -773,8 +655,6 @@ ViewManager::updateView()
|
|||||||
else
|
else
|
||||||
hideQueue();*/
|
hideQueue();*/
|
||||||
|
|
||||||
emit statsAvailable( currentPage()->showStatsBar() );
|
|
||||||
emit modesAvailable( currentPage()->showModes() );
|
|
||||||
emit filterAvailable( currentPage()->showFilter() );
|
emit filterAvailable( currentPage()->showFilter() );
|
||||||
|
|
||||||
/* if ( !currentPage()->showStatsBar() && !currentPage()->showModes() && !currentPage()->showFilter() )
|
/* if ( !currentPage()->showStatsBar() && !currentPage()->showModes() && !currentPage()->showFilter() )
|
||||||
@@ -784,7 +664,6 @@ ViewManager::updateView()
|
|||||||
|
|
||||||
m_infobar->setVisible( currentPage()->showInfoBar() );
|
m_infobar->setVisible( currentPage()->showInfoBar() );
|
||||||
m_infobar->setCaption( currentPage()->title() );
|
m_infobar->setCaption( currentPage()->title() );
|
||||||
|
|
||||||
m_infobar->setUpdaters( currentPage()->updaters() );
|
m_infobar->setUpdaters( currentPage()->updaters() );
|
||||||
|
|
||||||
switch( currentPage()->descriptionType() )
|
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
|
bool
|
||||||
ViewManager::isSuperCollectionVisible() const
|
ViewManager::isSuperCollectionVisible() const
|
||||||
{
|
{
|
||||||
return ( currentPage() != 0 &&
|
return ( currentPage() != 0 &&
|
||||||
( currentPage()->playlistInterface() == m_superCollectionView->playlistInterface() ||
|
( currentPage()->playlistInterface() == m_superCollectionView->playlistInterface() ) );
|
||||||
currentPage()->playlistInterface() == m_superGridView->playlistInterface() ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1021,19 +884,6 @@ ViewManager::showCurrentTrack()
|
|||||||
{
|
{
|
||||||
setPage( page );
|
setPage( page );
|
||||||
page->jumpToCurrentTrack();
|
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 TrackView;
|
||||||
class SourceInfoWidget;
|
class SourceInfoWidget;
|
||||||
class InfoBar;
|
class InfoBar;
|
||||||
class TopBar;
|
|
||||||
class TrackInfoWidget;
|
class TrackInfoWidget;
|
||||||
class NewReleasesWidget;
|
class NewReleasesWidget;
|
||||||
class WelcomeWidget;
|
class WelcomeWidget;
|
||||||
@@ -113,10 +112,7 @@ signals:
|
|||||||
void repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode mode );
|
void repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode mode );
|
||||||
void shuffleModeChanged( bool enabled );
|
void shuffleModeChanged( bool enabled );
|
||||||
|
|
||||||
void statsAvailable( bool b );
|
|
||||||
void modesAvailable( bool b );
|
|
||||||
void filterAvailable( bool b );
|
void filterAvailable( bool b );
|
||||||
void modeChanged( Tomahawk::PlaylistModes::ViewMode mode );
|
|
||||||
|
|
||||||
void playClicked();
|
void playClicked();
|
||||||
void pauseClicked();
|
void pauseClicked();
|
||||||
@@ -159,10 +155,6 @@ public slots:
|
|||||||
void showQueue() { emit showQueueRequested(); }
|
void showQueue() { emit showQueueRequested(); }
|
||||||
void hideQueue() { emit hideQueueRequested(); }
|
void hideQueue() { emit hideQueueRequested(); }
|
||||||
|
|
||||||
void setTreeMode();
|
|
||||||
void setTableMode();
|
|
||||||
void setAlbumMode();
|
|
||||||
|
|
||||||
void setRepeatMode( Tomahawk::PlaylistModes::RepeatMode mode );
|
void setRepeatMode( Tomahawk::PlaylistModes::RepeatMode mode );
|
||||||
void setShuffled( bool enabled );
|
void setShuffled( bool enabled );
|
||||||
|
|
||||||
@@ -189,7 +181,6 @@ private:
|
|||||||
|
|
||||||
Tomahawk::playlist_ptr playlistForInterface( Tomahawk::playlistinterface_ptr plInterface ) const;
|
Tomahawk::playlist_ptr playlistForInterface( Tomahawk::playlistinterface_ptr plInterface ) const;
|
||||||
Tomahawk::dynplaylist_ptr dynamicPlaylistForInterface( 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;
|
QWidget* m_widget;
|
||||||
InfoBar* m_infobar;
|
InfoBar* m_infobar;
|
||||||
@@ -197,8 +188,6 @@ private:
|
|||||||
QStackedWidget* m_stack;
|
QStackedWidget* m_stack;
|
||||||
AnimatedSplitter* m_splitter;
|
AnimatedSplitter* m_splitter;
|
||||||
|
|
||||||
AlbumModel* m_superAlbumModel;
|
|
||||||
GridView* m_superGridView;
|
|
||||||
TreeModel* m_superCollectionModel;
|
TreeModel* m_superCollectionModel;
|
||||||
TreeView* m_superCollectionView;
|
TreeView* m_superCollectionView;
|
||||||
QueueView* m_queue;
|
QueueView* m_queue;
|
||||||
@@ -212,7 +201,6 @@ private:
|
|||||||
|
|
||||||
QHash< Tomahawk::dynplaylist_ptr, QWeakPointer<Tomahawk::DynamicWidget> > m_dynamicWidgets;
|
QHash< Tomahawk::dynplaylist_ptr, QWeakPointer<Tomahawk::DynamicWidget> > m_dynamicWidgets;
|
||||||
QHash< Tomahawk::collection_ptr, QWeakPointer<TreeView> > m_treeViews;
|
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::artist_ptr, QWeakPointer<ArtistInfoWidget> > m_artistViews;
|
||||||
QHash< Tomahawk::album_ptr, QWeakPointer<AlbumInfoWidget> > m_albumViews;
|
QHash< Tomahawk::album_ptr, QWeakPointer<AlbumInfoWidget> > m_albumViews;
|
||||||
QHash< Tomahawk::query_ptr, QWeakPointer<TrackInfoWidget> > m_trackViews;
|
QHash< Tomahawk::query_ptr, QWeakPointer<TrackInfoWidget> > m_trackViews;
|
||||||
@@ -224,7 +212,6 @@ private:
|
|||||||
Tomahawk::ViewPage* m_currentPage;
|
Tomahawk::ViewPage* m_currentPage;
|
||||||
|
|
||||||
Tomahawk::collection_ptr m_currentCollection;
|
Tomahawk::collection_ptr m_currentCollection;
|
||||||
int m_currentMode;
|
|
||||||
|
|
||||||
QTimer m_filterTimer;
|
QTimer m_filterTimer;
|
||||||
QString m_filter;
|
QString m_filter;
|
||||||
|
Reference in New Issue
Block a user