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

git version control git at videolan.org
Sun Feb 14 04:13:58 CET 2010


vlc/vlc-1.0 | branch: master | Jakob Leben <jleben at videolan.org> | Sat Feb 13 10:49:32 2010 +0100| [34447939f2afc254c1262e1573842dcda7243d3f] | committer: Jean-Baptiste Kempf 

Qt: fix deleting playlist items by key press

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.0.git/?a=commit;h=34447939f2afc254c1262e1573842dcda7243d3f
---

 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