1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-18 23:09:42 +01:00

Add flatcollection view

This commit is contained in:
Christian Muehlhaeuser 2014-07-16 04:19:50 +01:00 committed by Uwe L. Korn
parent c029291312
commit 8214e954db
5 changed files with 76 additions and 17 deletions

View File

@ -305,10 +305,13 @@ ViewManager::show( const Tomahawk::collection_ptr& collection )
view->columnView()->proxyModel()->setStyle( PlayableProxyModel::Collection );
TreeModel* model = new TreeModel();
PlayableModel* flatModel = new PlayableModel();
view->setTreeModel( model );
view->setFlatModel( flatModel );
model->addCollection( collection );
flatModel->appendTracks( collection );
setPage( view );
if ( !collection.isNull() )

View File

@ -48,14 +48,14 @@ FlexibleTreeView::FlexibleTreeView( QWidget* parent, QWidget* extraHeader )
, m_modeHeader( new ModeHeader( this ) )
, m_columnView( new ColumnView() )
, m_treeView( new TreeView() )
, m_trackView( 0 )
, m_trackView( new TrackView() )
, m_model( 0 )
, m_flatModel( 0 )
, m_temporary( false )
{
qRegisterMetaType< FlexibleTreeViewMode >( "FlexibleTreeViewMode" );
m_treeView->proxyModel()->setStyle( PlayableProxyModel::Collection );
m_treeView->proxyModel()->setPlaylistInterface( m_columnView->proxyModel()->playlistInterface() );
// m_trackView->setPlaylistInterface( m_playlistInterface );
@ -93,8 +93,7 @@ FlexibleTreeView::FlexibleTreeView( QWidget* parent, QWidget* extraHeader )
m_stack->addWidget( m_columnView );
m_stack->addWidget( m_treeView );
/* m_stack->addWidget( m_gridView );
m_stack->addWidget( m_trackView );*/
m_stack->addWidget( m_trackView );
connect( m_header, SIGNAL( filterTextChanged( QString ) ), SLOT( setFilter( QString ) ) );
@ -182,7 +181,6 @@ FlexibleTreeView::setTreeModel( TreeModel* model )
// m_trackView->setPlayableModel( model );
m_columnView->setTreeModel( model );
m_treeView->setTreeModel( model );
// m_gridView->setPlayableModel( model );
/* m_trackView->setSortingEnabled( false );
m_trackView->sortByColumn( -1 );
@ -195,6 +193,27 @@ FlexibleTreeView::setTreeModel( TreeModel* model )
}
void
FlexibleTreeView::setFlatModel( PlayableModel* model )
{
if ( m_flatModel )
{
// disconnect( m_flatModel, SIGNAL( changed() ), this, SLOT( onModelChanged() ) );
delete m_flatModel;
}
m_flatModel = model;
m_trackView->setPlayableModel( model );
m_trackView->setSortingEnabled( true );
m_trackView->sortByColumn( 0 );
/* connect( model, SIGNAL( changed() ), SLOT( onModelChanged() ), Qt::UniqueConnection );
onModelChanged();*/
}
void
FlexibleTreeView::setCurrentMode( FlexibleTreeViewMode mode )
{
@ -224,7 +243,7 @@ FlexibleTreeView::setCurrentMode( FlexibleTreeViewMode mode )
case Albums:
{
// m_stack->setCurrentWidget( m_gridView );
m_stack->setCurrentWidget( m_trackView );
break;
}
}
@ -270,7 +289,7 @@ FlexibleTreeView::jumpToCurrentTrack()
// note: the order of comparison is important here, if we'd write "b || foo" then foo will not be executed if b is already true!
b = m_columnView->jumpToCurrentTrack() || b;
// b = m_trackView->jumpToCurrentTrack() || b;
b = m_trackView->jumpToCurrentTrack() || b;
b = m_treeView->jumpToCurrentTrack() || b;
return b;
@ -284,8 +303,7 @@ FlexibleTreeView::setFilter( const QString& pattern )
m_columnView->setFilter( pattern );
m_treeView->proxyModel()->setFilter( pattern );
/* m_gridView->setFilter( pattern );
m_trackView->setFilter( pattern );*/
m_trackView->setFilter( pattern );
return true;
}
@ -318,8 +336,7 @@ FlexibleTreeView::setEmptyTip( const QString& tip )
{
m_columnView->setEmptyTip( tip );
m_treeView->setEmptyTip( tip );
/* m_gridView->setEmptyTip( tip );
m_trackView->setEmptyTip( tip );*/
m_trackView->setEmptyTip( tip );
}

View File

@ -31,6 +31,7 @@ class TrackView;
class TreeView;
class ColumnView;
class TreeModel;
class PlayableModel;
class ModeHeader;
class PlaylistModel;
class FilterHeader;
@ -70,6 +71,7 @@ public:
void setTrackView( TrackView* view );
void setTreeModel( TreeModel* model );
void setFlatModel( PlayableModel* model );
void setPixmap( const QPixmap& pixmap );
void setEmptyTip( const QString& tip );
@ -97,6 +99,7 @@ private:
TrackView* m_trackView;
TreeModel* m_model;
PlayableModel* m_flatModel;
QStackedWidget* m_stack;
FlexibleTreeViewMode m_mode;

View File

@ -904,20 +904,26 @@ PlayableModel::onDataChanged()
void
PlayableModel::startLoading()
{
tDebug() << Q_FUNC_INFO;
Q_D( PlayableModel );
d->loading = true;
emit loadingStarted();
if ( !d->loading )
{
tDebug() << Q_FUNC_INFO;
d->loading = true;
emit loadingStarted();
}
}
void
PlayableModel::finishLoading()
{
tDebug() << Q_FUNC_INFO;
Q_D( PlayableModel );
d->loading = false;
emit loadingFinished();
if ( d->loading )
{
tDebug() << Q_FUNC_INFO;
d->loading = false;
emit loadingFinished();
}
}
@ -1000,6 +1006,13 @@ PlayableModel::appendTracks( const QList< Tomahawk::track_ptr >& tracks, const Q
}
void
PlayableModel::appendTracks( const Tomahawk::collection_ptr& collection )
{
insertTracks( collection, rowCount( QModelIndex() ) );
}
void
PlayableModel::insertArtist( const Tomahawk::artist_ptr& artist, int row )
{
@ -1053,6 +1066,25 @@ PlayableModel::insertQueries( const QList< Tomahawk::query_ptr >& queries, int r
}
void
PlayableModel::insertTracks( const Tomahawk::collection_ptr& collection, int row )
{
Tomahawk::TracksRequest* req = collection->requestTracks( Tomahawk::album_ptr() );
connect( dynamic_cast< QObject* >( req ), SIGNAL( tracks( QList< Tomahawk::query_ptr > ) ),
this, SLOT( onTracksAdded( QList< Tomahawk::query_ptr > ) ), Qt::UniqueConnection );
req->enqueue();
// connect( collection.data(), SIGNAL( changed() ), SLOT( onCollectionChanged() ), Qt::UniqueConnection );
}
void
PlayableModel::onTracksAdded( const QList< Tomahawk::query_ptr >& queries )
{
appendQueries( queries );
}
void
PlayableModel::setTitle( const QString& title )
{

View File

@ -158,6 +158,7 @@ public slots:
virtual void appendQuery( const Tomahawk::query_ptr& query );
virtual void appendArtist( const Tomahawk::artist_ptr& artist );
virtual void appendAlbum( const Tomahawk::album_ptr& album );
virtual void appendTracks( const Tomahawk::collection_ptr& collection );
virtual void insertQueries( const QList< Tomahawk::query_ptr >& queries, int row = 0, const QList< Tomahawk::PlaybackLog >& logs = QList< Tomahawk::PlaybackLog >() );
virtual void insertArtists( const QList< Tomahawk::artist_ptr >& artists, int row = 0 );
@ -165,6 +166,7 @@ public slots:
virtual void insertQuery( const Tomahawk::query_ptr& query, int row = 0, const Tomahawk::PlaybackLog& log = Tomahawk::PlaybackLog() );
virtual void insertArtist( const Tomahawk::artist_ptr& artist, int row = 0 );
virtual void insertAlbum( const Tomahawk::album_ptr& album, int row = 0 );
virtual void insertTracks( const Tomahawk::collection_ptr& collection, int row = 0 );
virtual bool removeRows( int row, int count, const QModelIndex& parent = QModelIndex() );
virtual void remove( int row, bool moreToCome = false );
@ -191,6 +193,8 @@ private slots:
void onPlaybackStarted( const Tomahawk::result_ptr result );
void onPlaybackStopped();
void onTracksAdded( const QList< Tomahawk::query_ptr >& queries );
private:
void init();
template <typename T>