Commit d4e7c32a authored by Jakob Leben's avatar Jakob Leben

Qt: ooops, fix deleting playlist items by key press

parent b5c4baa4
...@@ -288,17 +288,25 @@ void StandardPLPanel::browseInto( ) ...@@ -288,17 +288,25 @@ void StandardPLPanel::browseInto( )
QModelIndex() ); QModelIndex() );
} }
/* Delete and Suppr key remove the selection void StandardPLPanel::wheelEvent( QWheelEvent *e )
FilterKey function and code function */
void StandardPLPanel::keyPressEvent( QKeyEvent *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: QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
case Qt::Key_Delete: if( keyEvent->key() == Qt::Key_Delete ||
deleteSelection(); keyEvent->key() == Qt::Key_Back )
break; {
deleteSelection();
return true;
}
} }
return false;
} }
void StandardPLPanel::deleteSelection() void StandardPLPanel::deleteSelection()
...@@ -316,7 +324,7 @@ void StandardPLPanel::createIconView() ...@@ -316,7 +324,7 @@ void StandardPLPanel::createIconView()
this, popupPlView( const QPoint & ) ); this, popupPlView( const QPoint & ) );
CONNECT( iconView, activated( const QModelIndex & ), CONNECT( iconView, activated( const QModelIndex & ),
this, activate( const QModelIndex & ) ); this, activate( const QModelIndex & ) );
iconView->installEventFilter( this );
layout->addWidget( iconView, 1, 0, 1, -1 ); layout->addWidget( iconView, 1, 0, 1, -1 );
} }
...@@ -328,7 +336,7 @@ void StandardPLPanel::createListView() ...@@ -328,7 +336,7 @@ void StandardPLPanel::createListView()
this, popupPlView( const QPoint & ) ); this, popupPlView( const QPoint & ) );
CONNECT( listView, activated( const QModelIndex & ), CONNECT( listView, activated( const QModelIndex & ),
this, activate( const QModelIndex & ) ); this, activate( const QModelIndex & ) );
listView->installEventFilter( this );
layout->addWidget( listView, 1, 0, 1, -1 ); layout->addWidget( listView, 1, 0, 1, -1 );
} }
...@@ -380,6 +388,7 @@ void StandardPLPanel::createTreeView() ...@@ -380,6 +388,7 @@ void StandardPLPanel::createTreeView()
this, popupSelectColumn( QPoint ) ); this, popupSelectColumn( QPoint ) );
CONNECT( treeView, customContextMenuRequested( const QPoint & ), CONNECT( treeView, customContextMenuRequested( const QPoint & ),
this, popupPlView( const QPoint & ) ); this, popupPlView( const QPoint & ) );
treeView->installEventFilter( this );
/* SignalMapper for columns */ /* SignalMapper for columns */
selectColumnsSigMapper = new QSignalMapper( this ); selectColumnsSigMapper = new QSignalMapper( this );
...@@ -447,12 +456,6 @@ void StandardPLPanel::cycleViews() ...@@ -447,12 +456,6 @@ void StandardPLPanel::cycleViews()
assert( 0 ); 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 ) void StandardPLPanel::activate( const QModelIndex &index )
{ {
if( model->hasChildren( index ) ) if( model->hasChildren( index ) )
......
...@@ -60,9 +60,6 @@ public: ...@@ -60,9 +60,6 @@ public:
protected: protected:
friend class PlaylistWidget; friend class PlaylistWidget;
virtual void keyPressEvent( QKeyEvent *e );
virtual void wheelEvent( QWheelEvent *e );
PLModel *model; PLModel *model;
private: private:
enum { enum {
...@@ -99,6 +96,8 @@ private: ...@@ -99,6 +96,8 @@ private:
void createTreeView(); void createTreeView();
void createIconView(); void createIconView();
void createListView(); void createListView();
void wheelEvent( QWheelEvent *e );
bool eventFilter ( QObject * watched, QEvent * event );
public slots: public slots:
void setRoot( playlist_item_t * ); void setRoot( playlist_item_t * );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment