mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-19 23:41:51 +02:00
* Reload playlist when a new revision is available.
This commit is contained in:
parent
fc6b3d3595
commit
0f9772e17a
@ -16,7 +16,6 @@ CollectionFlatModel::CollectionFlatModel( QObject* parent )
|
||||
|
||||
CollectionFlatModel::~CollectionFlatModel()
|
||||
{
|
||||
delete m_rootItem;
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,7 +16,6 @@ PlaylistModel::PlaylistModel( QObject* parent )
|
||||
|
||||
PlaylistModel::~PlaylistModel()
|
||||
{
|
||||
delete m_rootItem;
|
||||
}
|
||||
|
||||
|
||||
@ -44,8 +43,16 @@ PlaylistModel::headerData( int section, Qt::Orientation orientation, int role )
|
||||
void
|
||||
PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist )
|
||||
{
|
||||
if ( !m_playlist.isNull() )
|
||||
disconnect( m_playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), this, SLOT( onRevisionLoaded( Tomahawk::PlaylistRevision ) ) );
|
||||
|
||||
emit beginRemoveRows( QModelIndex(), 0, rowCount( QModelIndex() ) - 1 );
|
||||
delete m_rootItem;
|
||||
m_rootItem = new PlItem();
|
||||
emit endRemoveRows();
|
||||
|
||||
m_playlist = playlist;
|
||||
// connect( playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), SLOT( onRevisionLoaded( Tomahawk::PlaylistRevision ) ) );
|
||||
connect( playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), SLOT( onRevisionLoaded( Tomahawk::PlaylistRevision ) ) );
|
||||
|
||||
PlItem* plitem;
|
||||
QList<plentry_ptr> entries = playlist->entries();
|
||||
@ -77,3 +84,12 @@ PlaylistModel::onDataChanged()
|
||||
// emit itemSizeChanged( p->index );
|
||||
emit dataChanged( p->index, p->index.sibling( p->index.row(), columnCount() - 1 ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistModel::onRevisionLoaded( Tomahawk::PlaylistRevision revision )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
loadPlaylist( m_playlist );
|
||||
}
|
||||
|
@ -42,6 +42,8 @@ signals:
|
||||
private slots:
|
||||
void onDataChanged();
|
||||
|
||||
void onRevisionLoaded( Tomahawk::PlaylistRevision revision );
|
||||
|
||||
private:
|
||||
Tomahawk::playlist_ptr m_playlist;
|
||||
};
|
||||
|
@ -9,7 +9,10 @@ using namespace Tomahawk;
|
||||
|
||||
PlItem::~PlItem()
|
||||
{
|
||||
parent->children.removeOne( this );
|
||||
qDeleteAll( children );
|
||||
|
||||
if ( parent )
|
||||
parent->children.removeOne( this );
|
||||
}
|
||||
|
||||
|
||||
|
@ -13,7 +13,7 @@ Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TrackModel( QObject* parent = 0 );
|
||||
~TrackModel();
|
||||
virtual ~TrackModel();
|
||||
|
||||
virtual QModelIndex index( int row, int column, const QModelIndex& parent ) const;
|
||||
virtual QModelIndex parent( const QModelIndex& child ) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user