[vlc-devel] commit: Qt: fix deleting playlist items by key press (Jakob Leben )

git version control git at videolan.org
Sat Feb 13 10:51:50 CET 2010


vlc | branch: 1.0-bugfix | Jakob Leben <jleben at videolan.org> | Sat Feb 13 10:49:32 2010 +0100| [4934f4791e99228ad784df671adb46e28b66a835] | committer: Jakob Leben 

Qt: fix deleting playlist items by key press

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4934f4791e99228ad784df671adb46e28b66a835
---

 modules/gui/qt4/components/playlist/panels.hpp     |    3 +-
 .../gui/qt4/components/playlist/standardpanel.cpp  |   21 +++++++++++--------
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/panels.hpp b/modules/gui/qt4/components/playlist/panels.hpp
index 6876f0c..3ad2128 100644
--- a/modules/gui/qt4/components/playlist/panels.hpp
+++ b/modules/gui/qt4/components/playlist/panels.hpp
@@ -67,8 +67,6 @@ public:
                      playlist_t *,playlist_item_t * );
     virtual ~StandardPLPanel();
 protected:
-    virtual void keyPressEvent( QKeyEvent *e );
-protected:
     PLModel *model;
     friend class PlaylistWidget;
 private:
@@ -76,6 +74,7 @@ private:
     QPushButton *repeatButton, *randomButton, *addButton, *gotoPlayingButton;
     int currentRootId;
     QSignalMapper *ContextUpdateMapper;
+    bool eventFilter ( QObject * watched, QEvent * event );
 public slots:
     void removeItem( int );
     virtual void setRoot( int );
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index ca421c6..50344ce 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -103,6 +103,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
              this, handleExpansion( const QModelIndex& ) );
     CONNECT( model, columnsChanged( int ),
             this, checkSortingIndicator( int ) );
+    view->installEventFilter( this );
 
     currentRootId = -1;
     CONNECT( parent, rootChanged( int ), this, setCurrentRootId( int ) );
@@ -360,18 +361,20 @@ void StandardPLPanel::removeItem( int i_id )
     model->removeItem( i_id );
 }
 
-/* Delete and Suppr key remove the selection
-   FilterKey function and code function */
-void StandardPLPanel::keyPressEvent( QKeyEvent *e )
+bool StandardPLPanel::eventFilter ( QObject * watched, QEvent * event )
 {
-    switch( e->key() )
+    if (event->type() == QEvent::KeyPress)
     {
-    case Qt::Key_Back:
-    case Qt::Key_Delete:
-        deleteSelection();
-        break;
+        QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
+        if( keyEvent->key() == Qt::Key_Delete ||
+            keyEvent->key() == Qt::Key_Backspace )
+        {
+            deleteSelection();
+            return true;
+        }
     }
-}
+    return false;
+ }
 
 void StandardPLPanel::deleteSelection()
 {




More information about the vlc-devel mailing list