[vlc-devel] [PATCH] Qt4: Make playlist window drag&drop to current selected PLSelItem (updated)

Edward Wang edward.c.wang at compdigitec.com
Sat Dec 31 03:58:12 CET 2011


This patch updated to latest git will make playlist window drag and drop to current selection (either media library or playlist). This should make it somewhat more user friendly because it drops into where the user expects it to.

Fixes #4873
Thanks,
	Edward Wang


---
 modules/gui/qt4/components/playlist/playlist.cpp |    9 ++++++---
 modules/gui/qt4/components/playlist/playlist.hpp |    2 ++
 modules/gui/qt4/components/playlist/selector.cpp |    5 +++++
 modules/gui/qt4/components/playlist/selector.hpp |    1 +
 modules/gui/qt4/main_interface.cpp               |   15 ++++++++++++---
 modules/gui/qt4/main_interface.hpp               |    3 ++-
 6 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/playlist.cpp b/modules/gui/qt4/components/playlist/playlist.cpp
index 661f376..a0eb4cd 100644
--- a/modules/gui/qt4/components/playlist/playlist.cpp
+++ b/modules/gui/qt4/components/playlist/playlist.cpp
@@ -63,8 +63,8 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
     leftSplitter = new QSplitter( Qt::Vertical, this );
 
     /* Source Selector */
-    PLSelector *selector = new PLSelector( this, p_intf );
-    leftSplitter->addWidget( selector);
+    selector = new PLSelector( this, p_intf );
+    leftSplitter->addWidget( selector );
 
     /* Create a Container for the Art Label
        in order to have a beautiful resizing for the selector above it */
@@ -211,8 +211,11 @@ PlaylistWidget::~PlaylistWidget()
 
 void PlaylistWidget::dropEvent( QDropEvent *event )
 {
+    if( !( selector->getCurrentItemCategory() == IS_PL ||
+           selector->getCurrentItemCategory() == IS_ML ) ) return;
+
     if( p_intf->p_sys->p_mi )
-        p_intf->p_sys->p_mi->dropEventPlay( event, false );
+        p_intf->p_sys->p_mi->dropEventPlay( event, false, (selector->getCurrentItemCategory() == IS_PL) );
 }
 void PlaylistWidget::dragEnterEvent( QDragEnterEvent *event )
 {
diff --git a/modules/gui/qt4/components/playlist/playlist.hpp b/modules/gui/qt4/components/playlist/playlist.hpp
index 7172f95..7d10eb6 100644
--- a/modules/gui/qt4/components/playlist/playlist.hpp
+++ b/modules/gui/qt4/components/playlist/playlist.hpp
@@ -46,6 +46,7 @@ class QSignalMapper;
 class SearchLineEdit;
 class QModelIndex;
 class QStackedWidget;
+class PLSelector;
 
 class PlaylistWidget : public QWidget
 {
@@ -61,6 +62,7 @@ private:
     QSplitter            *leftSplitter;
     QSplitter            *split;
     StandardPLPanel      *mainView;
+    PLSelector           *selector;
 
     QAction *viewActions[ 4 /* StandardPLPanel::VIEW_COUNT*/ ];
 
diff --git a/modules/gui/qt4/components/playlist/selector.cpp b/modules/gui/qt4/components/playlist/selector.cpp
index bb64382..693d454 100644
--- a/modules/gui/qt4/components/playlist/selector.cpp
+++ b/modules/gui/qt4/components/playlist/selector.cpp
@@ -534,6 +534,11 @@ void PLSelector::getCurrentSelectedItem( int* type, QString *string)
     *string = currentItem()->data( 0, NAME_ROLE ).toString();
 }
 
+int PLSelector::getCurrentItemCategory()
+{
+    return currentItem()->data( 0, SPECIAL_ROLE ).toInt();
+}
+
 void PLSelector::wheelEvent( QWheelEvent *e )
 {
     // Accept this event in order to prevent unwanted volume up/down changes
diff --git a/modules/gui/qt4/components/playlist/selector.hpp b/modules/gui/qt4/components/playlist/selector.hpp
index 7657fa2..21d2977 100644
--- a/modules/gui/qt4/components/playlist/selector.hpp
+++ b/modules/gui/qt4/components/playlist/selector.hpp
@@ -117,6 +117,7 @@ public:
     virtual ~PLSelector();
 
     void getCurrentSelectedItem( int *type, QString *name );
+    int getCurrentItemCategory();
 
 protected:
     virtual void drawBranches ( QPainter *, const QRect &, const QModelIndex & ) const;
diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp
index 0e88231..19c65a8 100644
--- a/modules/gui/qt4/main_interface.cpp
+++ b/modules/gui/qt4/main_interface.cpp
@@ -1192,7 +1192,16 @@ void MainInterface::dropEvent(QDropEvent *event)
     dropEventPlay( event, true );
 }
 
-void MainInterface::dropEventPlay( QDropEvent *event, bool b_play )
+/**
+ * dropEventPlay
+ *
+ * Event called if something is dropped onto a VLC window
+ * \param event the event in question
+ * \param b_play whether to play the file immediately
+ * \param b_playlist true to add to playlist, false to add to media library
+ * \return nothing
+ */
+void MainInterface::dropEventPlay( QDropEvent *event, bool b_play, bool b_playlist )
 {
     if( event->possibleActions() & ( Qt::CopyAction | Qt::MoveAction ) )
        event->setDropAction( Qt::CopyAction );
@@ -1221,7 +1230,7 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play )
             QString mrl = toURI( url.toEncoded().constData() );
             playlist_Add( THEPL, qtu(mrl), NULL,
                           PLAYLIST_APPEND | (first ? PLAYLIST_GO: PLAYLIST_PREPARSE),
-                          PLAYLIST_END, true, pl_Unlocked );
+                          PLAYLIST_END, b_playlist, pl_Unlocked );
             first = false;
             RecentsMRL::getInstance( p_intf )->addRecent( mrl );
         }
@@ -1236,7 +1245,7 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play )
         QString mrl = toURI( mimeData->text() );
         playlist_Add( THEPL, qtu(mrl), NULL,
                       PLAYLIST_APPEND | (first ? PLAYLIST_GO: PLAYLIST_PREPARSE),
-                      PLAYLIST_END, true, pl_Unlocked );
+                      PLAYLIST_END, b_playlist, pl_Unlocked );
     }
     event->accept();
 }
diff --git a/modules/gui/qt4/main_interface.hpp b/modules/gui/qt4/main_interface.hpp
index 87e04d5..142d092 100644
--- a/modules/gui/qt4/main_interface.hpp
+++ b/modules/gui/qt4/main_interface.hpp
@@ -88,7 +88,8 @@ public:
     bool isInterfaceFullScreen() { return b_interfaceFullScreen; }
 
 protected:
-    void dropEventPlay( QDropEvent *, bool);
+    void dropEventPlay( QDropEvent* event, bool b_play ) { dropEventPlay(event, b_play, true); }
+    void dropEventPlay( QDropEvent *, bool, bool );
 #ifdef WIN32
     virtual bool winEvent( MSG *, long * );
 #endif
-- 
1.7.5.4




More information about the vlc-devel mailing list