[vlc-devel] commit: Qt: return playlist model and views to "now playing" root if current root is deleted (Jakob Leben )
git version control
git at videolan.org
Wed Feb 10 11:07:50 CET 2010
vlc | branch: master | Jakob Leben <jleben at videolan.org> | Wed Feb 10 08:27:42 2010 +0100| [790811343ae90c501aabd1a40ec375659fd415f2] | committer: Jakob Leben
Qt: return playlist model and views to "now playing" root if current root is deleted
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=790811343ae90c501aabd1a40ec375659fd415f2
---
.../gui/qt4/components/playlist/playlist_model.cpp | 9 ++++++---
.../gui/qt4/components/playlist/playlist_model.hpp | 1 +
.../gui/qt4/components/playlist/standardpanel.cpp | 6 ++++++
.../gui/qt4/components/playlist/standardpanel.hpp | 16 +++++++++-------
4 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index d2fba6f..6c6272f 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -700,9 +700,6 @@ void PLModel::removeItem( PLItem *item )
if( item->i_id == i_cached_id ) i_cached_id = -1;
i_cached_input_id = -1;
- if(item == rootItem)
- rootItem = NULL;
-
if( item->parentItem ) {
int i = item->parentItem->children.indexOf( item );
beginRemoveRows( index( item->parentItem, 0), i, i );
@@ -712,6 +709,12 @@ void PLModel::removeItem( PLItem *item )
}
else delete item;
+ if(item == rootItem)
+ {
+ rootItem = NULL;
+ rebuild( p_playlist->p_playing );
+ emit rootChanged();
+ }
}
/* This function must be entered WITH the playlist lock */
diff --git a/modules/gui/qt4/components/playlist/playlist_model.hpp b/modules/gui/qt4/components/playlist/playlist_model.hpp
index 9e36847..cb5e68c 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.hpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.hpp
@@ -150,6 +150,7 @@ private:
signals:
void currentChanged( const QModelIndex& );
+ void rootChanged();
public slots:
void activateItem( const QModelIndex &index );
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index d26cc64..4d073a4 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -79,6 +79,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
locationBar = new LocationBar( model );
layout->addWidget( locationBar, 0, 0 );
+ CONNECT( model, rootChanged(), locationBar, setRootIndex() );
/* A Spacer and the search possibilities */
layout->setColumnStretch( 1, 10 );
@@ -499,6 +500,11 @@ void LocationBar::setIndex( const QModelIndex &index )
}
}
+void LocationBar::setRootIndex()
+{
+ setIndex( QModelIndex() );
+}
+
void LocationBar::invoke( int i_id )
{
QModelIndex index = model->index( i_id, 0 );
diff --git a/modules/gui/qt4/components/playlist/standardpanel.hpp b/modules/gui/qt4/components/playlist/standardpanel.hpp
index dd868b2..dd5aebf 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.hpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.hpp
@@ -118,6 +118,8 @@ public:
void setIndex( const QModelIndex & );
signals:
void invoked( const QModelIndex & );
+public slots:
+ void setRootIndex();
private slots:
void invoke( int i_item_id );
private:
@@ -129,13 +131,13 @@ private:
class LocationButton : public QPushButton
{
- public:
- LocationButton( const QString &, bool bold, bool arrow );
- private:
- void paintEvent ( QPaintEvent * event );
- QSize sizeHint() const;
- QFontMetrics *metrics;
- bool b_arrow;
+public:
+ LocationButton( const QString &, bool bold, bool arrow );
+private:
+ void paintEvent ( QPaintEvent * event );
+ QSize sizeHint() const;
+ QFontMetrics *metrics;
+ bool b_arrow;
};
#endif
More information about the vlc-devel
mailing list