mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 05:37:29 +02:00
Add flatcollection view
This commit is contained in:
committed by
Uwe L. Korn
parent
c029291312
commit
8214e954db
@@ -305,10 +305,13 @@ ViewManager::show( const Tomahawk::collection_ptr& collection )
|
|||||||
|
|
||||||
view->columnView()->proxyModel()->setStyle( PlayableProxyModel::Collection );
|
view->columnView()->proxyModel()->setStyle( PlayableProxyModel::Collection );
|
||||||
TreeModel* model = new TreeModel();
|
TreeModel* model = new TreeModel();
|
||||||
|
PlayableModel* flatModel = new PlayableModel();
|
||||||
|
|
||||||
view->setTreeModel( model );
|
view->setTreeModel( model );
|
||||||
|
view->setFlatModel( flatModel );
|
||||||
|
|
||||||
model->addCollection( collection );
|
model->addCollection( collection );
|
||||||
|
flatModel->appendTracks( collection );
|
||||||
setPage( view );
|
setPage( view );
|
||||||
|
|
||||||
if ( !collection.isNull() )
|
if ( !collection.isNull() )
|
||||||
|
@@ -48,14 +48,14 @@ FlexibleTreeView::FlexibleTreeView( QWidget* parent, QWidget* extraHeader )
|
|||||||
, m_modeHeader( new ModeHeader( this ) )
|
, m_modeHeader( new ModeHeader( this ) )
|
||||||
, m_columnView( new ColumnView() )
|
, m_columnView( new ColumnView() )
|
||||||
, m_treeView( new TreeView() )
|
, m_treeView( new TreeView() )
|
||||||
, m_trackView( 0 )
|
, m_trackView( new TrackView() )
|
||||||
, m_model( 0 )
|
, m_model( 0 )
|
||||||
|
, m_flatModel( 0 )
|
||||||
, m_temporary( false )
|
, m_temporary( false )
|
||||||
{
|
{
|
||||||
qRegisterMetaType< FlexibleTreeViewMode >( "FlexibleTreeViewMode" );
|
qRegisterMetaType< FlexibleTreeViewMode >( "FlexibleTreeViewMode" );
|
||||||
|
|
||||||
m_treeView->proxyModel()->setStyle( PlayableProxyModel::Collection );
|
m_treeView->proxyModel()->setStyle( PlayableProxyModel::Collection );
|
||||||
|
|
||||||
m_treeView->proxyModel()->setPlaylistInterface( m_columnView->proxyModel()->playlistInterface() );
|
m_treeView->proxyModel()->setPlaylistInterface( m_columnView->proxyModel()->playlistInterface() );
|
||||||
|
|
||||||
// m_trackView->setPlaylistInterface( m_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_columnView );
|
||||||
m_stack->addWidget( m_treeView );
|
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 ) ) );
|
connect( m_header, SIGNAL( filterTextChanged( QString ) ), SLOT( setFilter( QString ) ) );
|
||||||
|
|
||||||
@@ -182,7 +181,6 @@ FlexibleTreeView::setTreeModel( TreeModel* model )
|
|||||||
// m_trackView->setPlayableModel( model );
|
// m_trackView->setPlayableModel( model );
|
||||||
m_columnView->setTreeModel( model );
|
m_columnView->setTreeModel( model );
|
||||||
m_treeView->setTreeModel( model );
|
m_treeView->setTreeModel( model );
|
||||||
// m_gridView->setPlayableModel( model );
|
|
||||||
|
|
||||||
/* m_trackView->setSortingEnabled( false );
|
/* m_trackView->setSortingEnabled( false );
|
||||||
m_trackView->sortByColumn( -1 );
|
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
|
void
|
||||||
FlexibleTreeView::setCurrentMode( FlexibleTreeViewMode mode )
|
FlexibleTreeView::setCurrentMode( FlexibleTreeViewMode mode )
|
||||||
{
|
{
|
||||||
@@ -224,7 +243,7 @@ FlexibleTreeView::setCurrentMode( FlexibleTreeViewMode mode )
|
|||||||
|
|
||||||
case Albums:
|
case Albums:
|
||||||
{
|
{
|
||||||
// m_stack->setCurrentWidget( m_gridView );
|
m_stack->setCurrentWidget( m_trackView );
|
||||||
break;
|
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!
|
// 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_columnView->jumpToCurrentTrack() || b;
|
||||||
// b = m_trackView->jumpToCurrentTrack() || b;
|
b = m_trackView->jumpToCurrentTrack() || b;
|
||||||
b = m_treeView->jumpToCurrentTrack() || b;
|
b = m_treeView->jumpToCurrentTrack() || b;
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
@@ -284,8 +303,7 @@ FlexibleTreeView::setFilter( const QString& pattern )
|
|||||||
|
|
||||||
m_columnView->setFilter( pattern );
|
m_columnView->setFilter( pattern );
|
||||||
m_treeView->proxyModel()->setFilter( pattern );
|
m_treeView->proxyModel()->setFilter( pattern );
|
||||||
/* m_gridView->setFilter( pattern );
|
m_trackView->setFilter( pattern );
|
||||||
m_trackView->setFilter( pattern );*/
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -318,8 +336,7 @@ FlexibleTreeView::setEmptyTip( const QString& tip )
|
|||||||
{
|
{
|
||||||
m_columnView->setEmptyTip( tip );
|
m_columnView->setEmptyTip( tip );
|
||||||
m_treeView->setEmptyTip( tip );
|
m_treeView->setEmptyTip( tip );
|
||||||
/* m_gridView->setEmptyTip( tip );
|
m_trackView->setEmptyTip( tip );
|
||||||
m_trackView->setEmptyTip( tip );*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -31,6 +31,7 @@ class TrackView;
|
|||||||
class TreeView;
|
class TreeView;
|
||||||
class ColumnView;
|
class ColumnView;
|
||||||
class TreeModel;
|
class TreeModel;
|
||||||
|
class PlayableModel;
|
||||||
class ModeHeader;
|
class ModeHeader;
|
||||||
class PlaylistModel;
|
class PlaylistModel;
|
||||||
class FilterHeader;
|
class FilterHeader;
|
||||||
@@ -70,6 +71,7 @@ public:
|
|||||||
void setTrackView( TrackView* view );
|
void setTrackView( TrackView* view );
|
||||||
|
|
||||||
void setTreeModel( TreeModel* model );
|
void setTreeModel( TreeModel* model );
|
||||||
|
void setFlatModel( PlayableModel* model );
|
||||||
|
|
||||||
void setPixmap( const QPixmap& pixmap );
|
void setPixmap( const QPixmap& pixmap );
|
||||||
void setEmptyTip( const QString& tip );
|
void setEmptyTip( const QString& tip );
|
||||||
@@ -97,6 +99,7 @@ private:
|
|||||||
TrackView* m_trackView;
|
TrackView* m_trackView;
|
||||||
|
|
||||||
TreeModel* m_model;
|
TreeModel* m_model;
|
||||||
|
PlayableModel* m_flatModel;
|
||||||
QStackedWidget* m_stack;
|
QStackedWidget* m_stack;
|
||||||
|
|
||||||
FlexibleTreeViewMode m_mode;
|
FlexibleTreeViewMode m_mode;
|
||||||
|
@@ -904,20 +904,26 @@ PlayableModel::onDataChanged()
|
|||||||
void
|
void
|
||||||
PlayableModel::startLoading()
|
PlayableModel::startLoading()
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO;
|
|
||||||
Q_D( PlayableModel );
|
Q_D( PlayableModel );
|
||||||
|
if ( !d->loading )
|
||||||
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO;
|
||||||
d->loading = true;
|
d->loading = true;
|
||||||
emit loadingStarted();
|
emit loadingStarted();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlayableModel::finishLoading()
|
PlayableModel::finishLoading()
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO;
|
|
||||||
Q_D( PlayableModel );
|
Q_D( PlayableModel );
|
||||||
|
if ( d->loading )
|
||||||
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO;
|
||||||
d->loading = false;
|
d->loading = false;
|
||||||
emit loadingFinished();
|
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
|
void
|
||||||
PlayableModel::insertArtist( const Tomahawk::artist_ptr& artist, int row )
|
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
|
void
|
||||||
PlayableModel::setTitle( const QString& title )
|
PlayableModel::setTitle( const QString& title )
|
||||||
{
|
{
|
||||||
|
@@ -158,6 +158,7 @@ public slots:
|
|||||||
virtual void appendQuery( const Tomahawk::query_ptr& query );
|
virtual void appendQuery( const Tomahawk::query_ptr& query );
|
||||||
virtual void appendArtist( const Tomahawk::artist_ptr& artist );
|
virtual void appendArtist( const Tomahawk::artist_ptr& artist );
|
||||||
virtual void appendAlbum( const Tomahawk::album_ptr& album );
|
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 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 );
|
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 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 insertArtist( const Tomahawk::artist_ptr& artist, int row = 0 );
|
||||||
virtual void insertAlbum( const Tomahawk::album_ptr& album, 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 bool removeRows( int row, int count, const QModelIndex& parent = QModelIndex() );
|
||||||
virtual void remove( int row, bool moreToCome = false );
|
virtual void remove( int row, bool moreToCome = false );
|
||||||
@@ -191,6 +193,8 @@ private slots:
|
|||||||
void onPlaybackStarted( const Tomahawk::result_ptr result );
|
void onPlaybackStarted( const Tomahawk::result_ptr result );
|
||||||
void onPlaybackStopped();
|
void onPlaybackStopped();
|
||||||
|
|
||||||
|
void onTracksAdded( const QList< Tomahawk::query_ptr >& queries );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
Reference in New Issue
Block a user