1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-07 06:36:55 +02:00

* Use FlexibleTreeViews for showing collections.

This commit is contained in:
Christian Muehlhaeuser
2013-06-12 06:21:04 +02:00
parent 5e3bdd51c2
commit e3302a1365
2 changed files with 17 additions and 11 deletions

View File

@@ -26,11 +26,13 @@
#include "infobar/InfoBar.h" #include "infobar/InfoBar.h"
#include "playlist/FlexibleView.h" #include "playlist/FlexibleView.h"
#include "playlist/FlexibleTreeView.h"
#include "playlist/TreeModel.h" #include "playlist/TreeModel.h"
#include "playlist/PlaylistModel.h" #include "playlist/PlaylistModel.h"
#include "playlist/PlaylistView.h" #include "playlist/PlaylistView.h"
#include "playlist/PlayableProxyModel.h" #include "playlist/PlayableProxyModel.h"
#include "playlist/PlayableModel.h" #include "playlist/PlayableModel.h"
#include "playlist/ColumnView.h"
#include "playlist/TreeView.h" #include "playlist/TreeView.h"
#include "playlist/TreeWidget.h" #include "playlist/TreeWidget.h"
#include "playlist/GridView.h" #include "playlist/GridView.h"
@@ -309,28 +311,31 @@ ViewManager::show( const Tomahawk::collection_ptr& collection )
{ {
m_currentCollection = collection; m_currentCollection = collection;
TreeWidget* widget; FlexibleTreeView* view;
if ( !m_treeWidgets.contains( collection ) || m_treeWidgets.value( collection ).isNull() ) if ( !m_collectionViews.contains( collection ) || m_collectionViews.value( collection ).isNull() )
{ {
widget = new TreeWidget(); view = new FlexibleTreeView();
widget->view()->proxyModel()->setStyle( PlayableProxyModel::Collection );
view->columnView()->proxyModel()->setStyle( PlayableProxyModel::Collection );
TreeModel* model = new TreeModel(); TreeModel* model = new TreeModel();
widget->view()->setTreeModel( model );
view->setTreeModel( model );
if ( !collection.isNull() ) if ( !collection.isNull() )
widget->view()->setEmptyTip( collection->emptyText() ); view->setEmptyTip( collection->emptyText() );
model->addCollection( collection ); model->addCollection( collection );
setPage( view );
m_treeWidgets.insert( collection, widget ); m_collectionViews.insert( collection, view );
} }
else else
{ {
widget = m_treeWidgets.value( collection ).data(); view = m_collectionViews.value( collection ).data();
} }
setPage( widget ); setPage( view );
return widget; return view;
} }

View File

@@ -41,6 +41,7 @@ class TreeWidget;
class CollectionModel; class CollectionModel;
class ContextWidget; class ContextWidget;
class FlexibleView; class FlexibleView;
class FlexibleTreeView;
class PlaylistModel; class PlaylistModel;
class PlaylistView; class PlaylistView;
class TrackProxyModel; class TrackProxyModel;
@@ -200,7 +201,7 @@ private:
QList< Tomahawk::collection_ptr > m_superCollections; QList< Tomahawk::collection_ptr > m_superCollections;
QHash< Tomahawk::dynplaylist_ptr, QPointer<Tomahawk::DynamicWidget> > m_dynamicWidgets; QHash< Tomahawk::dynplaylist_ptr, QPointer<Tomahawk::DynamicWidget> > m_dynamicWidgets;
QHash< Tomahawk::collection_ptr, QPointer<TreeWidget> > m_treeWidgets; QHash< Tomahawk::collection_ptr, QPointer<FlexibleTreeView> > m_collectionViews;
QHash< Tomahawk::artist_ptr, QPointer<ArtistInfoWidget> > m_artistViews; QHash< Tomahawk::artist_ptr, QPointer<ArtistInfoWidget> > m_artistViews;
QHash< Tomahawk::album_ptr, QPointer<AlbumInfoWidget> > m_albumViews; QHash< Tomahawk::album_ptr, QPointer<AlbumInfoWidget> > m_albumViews;
QHash< Tomahawk::query_ptr, QPointer<TrackInfoWidget> > m_trackViews; QHash< Tomahawk::query_ptr, QPointer<TrackInfoWidget> > m_trackViews;