diff --git a/src/playlistview.cpp b/src/playlistview.cpp index d7ea76d1d..cb6021c2d 100644 --- a/src/playlistview.cpp +++ b/src/playlistview.cpp @@ -77,9 +77,15 @@ void PlaylistView::setItemDelegates(Library* library) { setItemDelegateForColumn(Playlist::Column_DateModified, new DateItemDelegate(this)); } -void PlaylistView::setModel(QAbstractItemModel *model) { - QTreeView::setModel(model); +void PlaylistView::setModel(QAbstractItemModel *m) { + if (model()) + disconnect(model(), 0, this, 0); + + QTreeView::setModel(m); LoadGeometry(); + + Playlist* playlist = qobject_cast(m); + connect(playlist, SIGNAL(CurrentSongChanged(Song)), SLOT(MaybeAutoscroll())); } void PlaylistView::LoadGeometry() { @@ -348,12 +354,6 @@ void PlaylistView::InhibitAutoscrollTimeout() { inhibit_autoscroll_ = false; } -void PlaylistView::dataChanged(const QModelIndex& topleft, - const QModelIndex& bottomright) { - QTreeView::dataChanged(topleft, bottomright); - MaybeAutoscroll(); -} - void PlaylistView::MaybeAutoscroll() { Playlist* playlist = qobject_cast(model()); Q_ASSERT(playlist); diff --git a/src/playlistview.h b/src/playlistview.h index 4a000e315..a438f9e3f 100644 --- a/src/playlistview.h +++ b/src/playlistview.h @@ -56,19 +56,16 @@ class PlaylistView : public QTreeView { void mousePressEvent(QMouseEvent *event); void scrollContentsBy(int dx, int dy); - protected slots: - void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); - private slots: void LoadGeometry(); void SaveGeometry(); void GlowIntensityChanged(); void InhibitAutoscrollTimeout(); + void MaybeAutoscroll(); private: void ReloadBarPixmaps(); QList LoadBarPixmap(const QString& filename); - void MaybeAutoscroll(); private: static const char* kSettingsGroup;