From: tbaudier Date: Thu, 4 Oct 2018 12:32:55 +0000 (+0200) Subject: Merge branch 'drop_files' of https://github.com/m-pilia/vv into m-pilia-drop_files X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=8f42f40e826ecc4cc45e08ed41cc5596da74991c;hp=ae51e9bb80bdcd9468718a9473c1e9316cef2fd5;p=clitk.git Merge branch 'drop_files' of https://github.com/m-pilia/vv into m-pilia-drop_files --- diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 6a81732..30f7da5 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -18,6 +18,7 @@ It is distributed under dual licence #include #include +#include #include #include #include "QTreePushButton.h" @@ -132,6 +133,8 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() { setupUi(this); // this sets up the GUI + setAcceptDrops(true); // enable to drop into the window + setDicomClient(); //Qt::WindowFlags flags = windowFlags(); @@ -816,6 +819,25 @@ void vvMainWindow::OpenRecentImage() LoadImages(images, vvImageReader::IMAGE); } //------------------------------------------------------------------------------ +void vvMainWindow::dragEnterEvent(QDragEnterEvent *event) +{ + if (event->mimeData()->hasUrls()) { + event->acceptProposedAction(); + } +} +//------------------------------------------------------------------------------ +void vvMainWindow::dropEvent(QDropEvent *event) +{ + const QMimeData * mimeData = event->mimeData(); + if (!mimeData->hasUrls()) + return; + std::vector images; + for (auto const & url : mimeData->urls()) { + images.push_back(url.toLocalFile().toStdString()); + } + LoadImages(images, vvImageReader::IMAGE); +} +//------------------------------------------------------------------------------ //------------------------------------------------------------------------------ diff --git a/vv/vvMainWindow.h b/vv/vvMainWindow.h index 2be7e75..07f38e5 100644 --- a/vv/vvMainWindow.h +++ b/vv/vvMainWindow.h @@ -21,6 +21,7 @@ #include #include +#include #include "vtkVersion.h" #if (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 1) || VTK_MAJOR_VERSION >= 9 #include "ui_vvMainWindow.h" @@ -197,6 +198,10 @@ protected: void createRecentlyOpenedFilesMenu(); void updateRecentlyOpenedFilesMenu(const std::list &files); + // Drag and drop event handlers + virtual void dragEnterEvent(QDragEnterEvent *event); + virtual void dropEvent(QDropEvent *event); + private: //variables