[vlc-commits] commit: Qt: use "no art" picture for drag-and-drop pixmap in all playlist views (Jakob Leben )
git at videolan.org
git at videolan.org
Wed Mar 10 11:50:23 CET 2010
vlc | branch: master | Jakob Leben <jleben at videolan.org> | Wed Mar 10 11:47:06 2010 +0100| [7c1dc4d12af7caf300ed6e591faf71efed2f71a9] | committer: 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.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7c1dc4d12af7caf300ed6e591faf71efed2f71a9
---
modules/gui/qt4/components/playlist/icon_view.cpp | 26 ++++++++++++++++++++
modules/gui/qt4/components/playlist/icon_view.hpp | 13 ++++++++++
.../gui/qt4/components/playlist/standardpanel.cpp | 2 +-
3 files changed, 40 insertions(+), 1 deletions(-)
diff --git a/modules/gui/qt4/components/playlist/icon_view.cpp b/modules/gui/qt4/components/playlist/icon_view.cpp
index f60ce0e..290300a 100644
--- a/modules/gui/qt4/components/playlist/icon_view.cpp
+++ b/modules/gui/qt4/components/playlist/icon_view.cpp
@@ -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 );
+}
+
diff --git a/modules/gui/qt4/components/playlist/icon_view.hpp b/modules/gui/qt4/components/playlist/icon_view.hpp
index 27b704f..b5cc433 100644
--- a/modules/gui/qt4/components/playlist/icon_view.hpp
+++ b/modules/gui/qt4/components/playlist/icon_view.hpp
@@ -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
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index bc31e5a..1cef8f4 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -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 );
More information about the vlc-commits
mailing list