[vlc-commits] commit: qt4: allow dnd to file-input on convert-dialog (Ilkka Ollakka )

git at videolan.org git at videolan.org
Mon Jun 14 10:26:34 CEST 2010


vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Mon Jun 14 11:26:18 2010 +0300| [b68fb123875dbc0038bb551769f1ce1a1f68b8a7] | committer: Ilkka Ollakka 

qt4: allow dnd to file-input on convert-dialog

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b68fb123875dbc0038bb551769f1ce1a1f68b8a7
---

 modules/gui/qt4/components/open_panels.cpp |   42 ++++++++++++++++++++++++++++
 modules/gui/qt4/components/open_panels.hpp |    5 +++
 2 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/modules/gui/qt4/components/open_panels.cpp b/modules/gui/qt4/components/open_panels.cpp
index 148a7b1..61c397f 100644
--- a/modules/gui/qt4/components/open_panels.cpp
+++ b/modules/gui/qt4/components/open_panels.cpp
@@ -47,6 +47,7 @@
 #include <QScrollArea>
 #include <QUrl>
 #include <QStringListModel>
+#include <QDropEvent>
 
 
 #define I_DEVICE_TOOLTIP \
@@ -65,6 +66,8 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     /* Classic UI Setup */
     ui.setupUi( this );
 
+    setAcceptDrops( true );
+
     /* Set Filters for file selection */
 /*    QString fileTypes = "";
     ADD_FILTER_MEDIA( fileTypes );
@@ -166,6 +169,45 @@ FileOpenPanel::~FileOpenPanel()
         getSettings()->setValue( "file-dialog-state", dialogBox->saveState() );
 }
 
+void FileOpenPanel::dragEnterEvent( QDragEnterEvent *event )
+{
+    event->acceptProposedAction();
+}
+
+void FileOpenPanel::dragMoveEvent( QDragMoveEvent *event )
+{
+    event->acceptProposedAction();
+}
+
+void FileOpenPanel::dragLeaveEvent( QDragLeaveEvent *event )
+{
+    event->accept();
+}
+
+void FileOpenPanel::dropEvent( QDropEvent *event )
+{
+    if( event->possibleActions() & Qt::CopyAction )
+       event->setDropAction( Qt::CopyAction );
+    else
+        return;
+
+    const QMimeData *mimeData = event->mimeData();
+    foreach( const QUrl &url, mimeData->urls() )
+    {
+        if( url.isValid() )
+        {
+            QListWidgetItem *item = new QListWidgetItem(
+                                         toNativeSeparators( url.toLocalFile() ),
+                                         ui.fileListWidg );
+            item->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled );
+            ui.fileListWidg->addItem( item );
+        }
+    }
+    updateMRL();
+    updateButtons();
+    event->accept();
+}
+
 void FileOpenPanel::browseFile()
 {
     QStringList files = QFileDialog::getOpenFileNames( this, qtr( "Select one or multiple files" ), p_intf->p_sys->filepath) ;
diff --git a/modules/gui/qt4/components/open_panels.hpp b/modules/gui/qt4/components/open_panels.hpp
index 4d2d05b..2999b5b 100644
--- a/modules/gui/qt4/components/open_panels.hpp
+++ b/modules/gui/qt4/components/open_panels.hpp
@@ -62,6 +62,7 @@ class QWidget;
 class QLineEdit;
 class QString;
 class QStringListModel;
+class QEvent;
 
 class OpenPanel: public QWidget
 {
@@ -114,6 +115,10 @@ protected:
         }
         return false;
     }
+    virtual void dropEvent( QDropEvent *);
+    virtual void dragEnterEvent( QDragEnterEvent * );
+    virtual void dragMoveEvent( QDragMoveEvent * );
+    virtual void dragLeaveEvent( QDragLeaveEvent * );
 private:
     Ui::OpenFile ui;
     FileOpenBox *dialogBox;



More information about the vlc-commits mailing list