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 @@ ...@@ -32,6 +32,7 @@
#include <QStyleOptionViewItem> #include <QStyleOptionViewItem>
#include <QFontMetrics> #include <QFontMetrics>
#include <QPixmapCache> #include <QPixmapCache>
#include <QDrag>
#include "assert.h" #include "assert.h"
...@@ -309,6 +310,15 @@ QSize PlListViewItemDelegate::sizeHint ( const QStyleOptionViewItem & option, co ...@@ -309,6 +310,15 @@ QSize PlListViewItemDelegate::sizeHint ( const QStyleOptionViewItem & option, co
return QSize( 0, height ); 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 ) PlIconView::PlIconView( PLModel *model, QWidget *parent ) : QListView( parent )
{ {
PlIconViewItemDelegate *delegate = new PlIconViewItemDelegate( this ); PlIconViewItemDelegate *delegate = new PlIconViewItemDelegate( this );
...@@ -329,6 +339,11 @@ PlIconView::PlIconView( PLModel *model, QWidget *parent ) : QListView( parent ) ...@@ -329,6 +339,11 @@ PlIconView::PlIconView( PLModel *model, QWidget *parent ) : QListView( parent )
setItemDelegate( delegate ); setItemDelegate( delegate );
} }
void PlIconView::startDrag ( Qt::DropActions supportedActions )
{
plViewStartDrag( this, supportedActions );
}
PlListView::PlListView( PLModel *model, QWidget *parent ) : QListView( parent ) PlListView::PlListView( PLModel *model, QWidget *parent ) : QListView( parent )
{ {
setModel( model ); setModel( model );
...@@ -343,3 +358,14 @@ PlListView::PlListView( PLModel *model, QWidget *parent ) : QListView( parent ) ...@@ -343,3 +358,14 @@ PlListView::PlListView( PLModel *model, QWidget *parent ) : QListView( parent )
PlListViewItemDelegate *delegate = new PlListViewItemDelegate( this ); PlListViewItemDelegate *delegate = new PlListViewItemDelegate( this );
setItemDelegate( delegate ); setItemDelegate( delegate );
} }
void PlListView::startDrag ( Qt::DropActions supportedActions )
{
plViewStartDrag( this, supportedActions );
}
void PlTreeView::startDrag ( Qt::DropActions supportedActions )
{
plViewStartDrag( this, supportedActions );
}
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <QStyledItemDelegate> #include <QStyledItemDelegate>
#include <QListView> #include <QListView>
#include <QTreeView>
class QPainter; class QPainter;
class PLModel; class PLModel;
...@@ -67,6 +68,8 @@ class PlIconView : public QListView ...@@ -67,6 +68,8 @@ class PlIconView : public QListView
public: public:
PlIconView( PLModel *model, QWidget *parent = 0 ); PlIconView( PLModel *model, QWidget *parent = 0 );
private:
void startDrag ( Qt::DropActions supportedActions );
}; };
class PlListView : public QListView class PlListView : public QListView
...@@ -75,6 +78,16 @@ class PlListView : public QListView ...@@ -75,6 +78,16 @@ class PlListView : public QListView
public: public:
PlListView( PLModel *model, QWidget *parent = 0 ); 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 #endif
......
...@@ -289,7 +289,7 @@ void StandardPLPanel::createListView() ...@@ -289,7 +289,7 @@ void StandardPLPanel::createListView()
void StandardPLPanel::createTreeView() void StandardPLPanel::createTreeView()
{ {
/* Create and configure the QTreeView */ /* Create and configure the QTreeView */
treeView = new QTreeView; treeView = new PlTreeView;
treeView->setIconSize( QSize( 20, 20 ) ); treeView->setIconSize( QSize( 20, 20 ) );
treeView->setAlternatingRowColors( true ); 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