[vlc-devel] commit: Qt: ooops, fix deleting playlist items by key press (Jakob Leben )
git version control
git at videolan.org
Fri Feb 12 21:36:56 CET 2010
vlc | branch: master | Jakob Leben <jleben at videolan.org> | Fri Feb 12 21:35:18 2010 +0100| [d4e7c32a73fb230a21c505d9a34d6efe95d95978] | committer: Jakob Leben
Qt: ooops, fix deleting playlist items by key press
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d4e7c32a73fb230a21c505d9a34d6efe95d95978
---
.../gui/qt4/components/playlist/standardpanel.cpp | 35 +++++++++++---------
.../gui/qt4/components/playlist/standardpanel.hpp | 5 +--
2 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index 010b520..b2a664c 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -288,17 +288,25 @@ void StandardPLPanel::browseInto( )
QModelIndex() );
}
-/* Delete and Suppr key remove the selection
- FilterKey function and code function */
-void StandardPLPanel::keyPressEvent( QKeyEvent *e )
+void StandardPLPanel::wheelEvent( QWheelEvent *e )
{
- switch( e->key() )
+ // Accept this event in order to prevent unwanted volume up/down changes
+ e->accept();
+}
+
+bool StandardPLPanel::eventFilter ( QObject * watched, QEvent * event )
+{
+ 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_Back )
+ {
+ deleteSelection();
+ return true;
+ }
}
+ return false;
}
void StandardPLPanel::deleteSelection()
@@ -316,7 +324,7 @@ void StandardPLPanel::createIconView()
this, popupPlView( const QPoint & ) );
CONNECT( iconView, activated( const QModelIndex & ),
this, activate( const QModelIndex & ) );
-
+ iconView->installEventFilter( this );
layout->addWidget( iconView, 1, 0, 1, -1 );
}
@@ -328,7 +336,7 @@ void StandardPLPanel::createListView()
this, popupPlView( const QPoint & ) );
CONNECT( listView, activated( const QModelIndex & ),
this, activate( const QModelIndex & ) );
-
+ listView->installEventFilter( this );
layout->addWidget( listView, 1, 0, 1, -1 );
}
@@ -380,6 +388,7 @@ void StandardPLPanel::createTreeView()
this, popupSelectColumn( QPoint ) );
CONNECT( treeView, customContextMenuRequested( const QPoint & ),
this, popupPlView( const QPoint & ) );
+ treeView->installEventFilter( this );
/* SignalMapper for columns */
selectColumnsSigMapper = new QSignalMapper( this );
@@ -447,12 +456,6 @@ void StandardPLPanel::cycleViews()
assert( 0 );
}
-void StandardPLPanel::wheelEvent( QWheelEvent *e )
-{
- // Accept this event in order to prevent unwanted volume up/down changes
- e->accept();
-}
-
void StandardPLPanel::activate( const QModelIndex &index )
{
if( model->hasChildren( index ) )
diff --git a/modules/gui/qt4/components/playlist/standardpanel.hpp b/modules/gui/qt4/components/playlist/standardpanel.hpp
index d234130..1983d60 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.hpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.hpp
@@ -60,9 +60,6 @@ public:
protected:
friend class PlaylistWidget;
- virtual void keyPressEvent( QKeyEvent *e );
- virtual void wheelEvent( QWheelEvent *e );
-
PLModel *model;
private:
enum {
@@ -99,6 +96,8 @@ private:
void createTreeView();
void createIconView();
void createListView();
+ void wheelEvent( QWheelEvent *e );
+ bool eventFilter ( QObject * watched, QEvent * event );
public slots:
void setRoot( playlist_item_t * );
More information about the vlc-devel
mailing list