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

* Reload playlist when a new revision is available.

This commit is contained in:
Christian Muehlhaeuser
2010-10-23 04:33:47 +02:00
parent fc6b3d3595
commit 0f9772e17a
5 changed files with 25 additions and 5 deletions

View File

@@ -16,7 +16,6 @@ CollectionFlatModel::CollectionFlatModel( QObject* parent )
CollectionFlatModel::~CollectionFlatModel() CollectionFlatModel::~CollectionFlatModel()
{ {
delete m_rootItem;
} }

View File

@@ -16,7 +16,6 @@ PlaylistModel::PlaylistModel( QObject* parent )
PlaylistModel::~PlaylistModel() PlaylistModel::~PlaylistModel()
{ {
delete m_rootItem;
} }
@@ -44,8 +43,16 @@ PlaylistModel::headerData( int section, Qt::Orientation orientation, int role )
void void
PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist ) 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; 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; PlItem* plitem;
QList<plentry_ptr> entries = playlist->entries(); QList<plentry_ptr> entries = playlist->entries();
@@ -77,3 +84,12 @@ PlaylistModel::onDataChanged()
// emit itemSizeChanged( p->index ); // emit itemSizeChanged( p->index );
emit dataChanged( p->index, p->index.sibling( p->index.row(), columnCount() - 1 ) ); 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 );
}

View File

@@ -42,6 +42,8 @@ signals:
private slots: private slots:
void onDataChanged(); void onDataChanged();
void onRevisionLoaded( Tomahawk::PlaylistRevision revision );
private: private:
Tomahawk::playlist_ptr m_playlist; Tomahawk::playlist_ptr m_playlist;
}; };

View File

@@ -9,6 +9,9 @@ using namespace Tomahawk;
PlItem::~PlItem() PlItem::~PlItem()
{ {
qDeleteAll( children );
if ( parent )
parent->children.removeOne( this ); parent->children.removeOne( this );
} }

View File

@@ -13,7 +13,7 @@ Q_OBJECT
public: public:
explicit TrackModel( QObject* parent = 0 ); explicit TrackModel( QObject* parent = 0 );
~TrackModel(); virtual ~TrackModel();
virtual QModelIndex index( int row, int column, const QModelIndex& parent ) const; virtual QModelIndex index( int row, int column, const QModelIndex& parent ) const;
virtual QModelIndex parent( const QModelIndex& child ) const; virtual QModelIndex parent( const QModelIndex& child ) const;