model = new PLModel( p_playlist, p_intf, p_root, this );
/* Create and configure the QTreeView */
- view = new QVLCTreeView;
+ view = new QTreeView;
view->setModel( model );
view2 = NULL;
view->setAcceptDrops( true );
view->setDropIndicatorShown( true );
+ installEventFilter( view );
/* Saved Settings */
getSettings()->beginGroup("Playlist");
if( getSettings()->contains( "headerStateV2" ) )
/* Connections for the TreeView */
CONNECT( view, activated( const QModelIndex& ) ,
model,activateItem( const QModelIndex& ) );
- CONNECT( view, rightClicked( QModelIndex , QPoint ),
- this, doPopup( QModelIndex, QPoint ) );
CONNECT( view->header(), customContextMenuRequested( const QPoint & ),
this, popupSelectColumn( QPoint ) );
CONNECT( model, currentChanged( const QModelIndex& ),
view2->setViewMode( QListView::IconMode );
view2->setMovement( QListView::Snap );
layout->addWidget( view2, 1, 0, 1, -1 );
+ installEventFilter( view2 );
}
view->hide();
view2->show();
view2->hide();
view->show();
}
+}
+bool StandardPLPanel::eventFilter( QObject *obj, QEvent *event )
+{
+ QAbstractItemView *view = qobject_cast<QAbstractItemView *>(obj);
+ if( !view ) return false;
+ switch( event->type() )
+ {
+ case QEvent::MouseButtonPress:
+ {
+ QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
+ if( mouseEvent->button() & Qt::RightButton )
+ {
+ QModelIndex index = view->indexAt(
+ QPoint( mouseEvent->x(), mouseEvent->y() ) );
+ doPopup( index, QCursor::pos() );
+ return true;
+ }
+ else if( mouseEvent->button() & Qt::LeftButton )
+ {
+ if( !view->indexAt( QPoint( mouseEvent->x(),
+ mouseEvent->y() ) ).isValid() )
+ view->clearSelection();
+ }
+ // view->mousePressEvent( mouseEvent );
+ }
+ return true;
+ case QEvent::MouseButtonRelease:
+ {
+ QMouseEvent *mouseEvent2 = static_cast<QMouseEvent *>(event);
+ if( mouseEvent2->button() & Qt::RightButton )
+ return false; /* Do NOT forward to QTreeView!! */
+ // view->mouseReleaseEvent( mouseEvent );
+ return true;
+ }
+ default:
+ return false;
+ }
+ return true;
}
virtual void keyPressEvent( QKeyEvent *e );
+ bool eventFilter(QObject *obj, QEvent *event);
+
PLModel *model;
private:
intf_thread_t *p_intf;
int currentRootId;
QSignalMapper *selectColumnsSigMapper;
+ void doPopup( QModelIndex index, QPoint point );
public slots:
void removeItem( int );
virtual void setRoot( playlist_item_t * );
void deleteSelection();
void handleExpansion( const QModelIndex& );
void gotoPlayingItem();
- void doPopup( QModelIndex index, QPoint point );
void search( const QString& searchText );
void popupAdd();
void popupSelectColumn( QPoint );
QIcon::Mode iconMode;
};
-/*****************************************************************
- * Custom views
- *****************************************************************/
-#include <QMouseEvent>
-#include <QTreeView>
-#include <QCursor>
-#include <QPoint>
-#include <QModelIndex>
-
-/**
- Special QTreeView that can emit rightClicked()
- */
-class QVLCTreeView : public QTreeView
-{
- Q_OBJECT;
-public:
- void mouseReleaseEvent( QMouseEvent* e )
- {
- if( e->button() & Qt::RightButton )
- return; /* Do NOT forward to QTreeView!! */
- QTreeView::mouseReleaseEvent( e );
- }
-
- void mousePressEvent( QMouseEvent* e )
- {
- if( e->button() & Qt::RightButton )
- {
- QModelIndex index = indexAt( QPoint( e->x(), e->y() ) );
- if( index.isValid() )
- setSelection( visualRect( index ), QItemSelectionModel::ClearAndSelect );
- emit rightClicked( index, QCursor::pos() );
- return;
- }
- if( e->button() & Qt::LeftButton )
- {
- if( !indexAt( QPoint( e->x(), e->y() ) ).isValid() )
- clearSelection();
- }
- QTreeView::mousePressEvent( e );
- }
-
-signals:
- void rightClicked( QModelIndex, QPoint );
-};
-
/* VLC Key/Wheel hotkeys interactions */
class QKeyEvent;
class QWheelEvent;
+class QInputEvent;
int qtKeyModifiersToVLC( QInputEvent* e );
int qtEventToVLCKey( QKeyEvent *e );