Commit 7c1dc4d1 authored by Jakob Leben's avatar Jakob Leben

Qt: use "no art" picture for drag-and-drop pixmap in all playlist views

This makes drag-and-drop easier, because drag-and-drop pixmap does not
cover the area under mouse cursor.
parent 55236712
......@@ -32,6 +32,7 @@
#include <QStyleOptionViewItem>
#include <QFontMetrics>
#include <QPixmapCache>
#include <QDrag>
#include "assert.h"
......@@ -309,6 +310,15 @@ QSize PlListViewItemDelegate::sizeHint ( const QStyleOptionViewItem & option, co
return QSize( 0, height );
}
static void plViewStartDrag( QAbstractItemView *view, const Qt::DropActions & supportedActions )
{
QDrag *drag = new QDrag( view );
drag->setPixmap( QPixmap( ":/noart64" ) );
drag->setMimeData( view->model()->mimeData(
view->selectionModel()->selectedIndexes() ) );
drag->exec( supportedActions );
}
PlIconView::PlIconView( PLModel *model, QWidget *parent ) : QListView( parent )
{
PlIconViewItemDelegate *delegate = new PlIconViewItemDelegate( this );
......@@ -329,6 +339,11 @@ PlIconView::PlIconView( PLModel *model, QWidget *parent ) : QListView( parent )
setItemDelegate( delegate );
}
void PlIconView::startDrag ( Qt::DropActions supportedActions )
{
plViewStartDrag( this, supportedActions );
}
PlListView::PlListView( PLModel *model, QWidget *parent ) : QListView( parent )
{
setModel( model );
......@@ -343,3 +358,14 @@ PlListView::PlListView( PLModel *model, QWidget *parent ) : QListView( parent )
PlListViewItemDelegate *delegate = new PlListViewItemDelegate( this );
setItemDelegate( delegate );
}
void PlListView::startDrag ( Qt::DropActions supportedActions )
{
plViewStartDrag( this, supportedActions );
}
void PlTreeView::startDrag ( Qt::DropActions supportedActions )
{
plViewStartDrag( this, supportedActions );
}
......@@ -26,6 +26,7 @@
#include <QStyledItemDelegate>
#include <QListView>
#include <QTreeView>
class QPainter;
class PLModel;
......@@ -67,6 +68,8 @@ class PlIconView : public QListView
public:
PlIconView( PLModel *model, QWidget *parent = 0 );
private:
void startDrag ( Qt::DropActions supportedActions );
};
class PlListView : public QListView
......@@ -75,6 +78,16 @@ class PlListView : public QListView
public:
PlListView( PLModel *model, QWidget *parent = 0 );
private:
void startDrag ( Qt::DropActions supportedActions );
};
class PlTreeView : public QTreeView
{
Q_OBJECT
private:
void startDrag ( Qt::DropActions supportedActions );
};
#endif
......
......@@ -289,7 +289,7 @@ void StandardPLPanel::createListView()
void StandardPLPanel::createTreeView()
{
/* Create and configure the QTreeView */
treeView = new QTreeView;
treeView = new PlTreeView;
treeView->setIconSize( QSize( 20, 20 ) );
treeView->setAlternatingRowColors( true );
......
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