]> git.lyx.org Git - lyx.git/commitdiff
Transfer Drag&Drop handling from GuiWorkArea to GuiView.
authorAbdelrazak Younes <younes@lyx.org>
Tue, 14 Aug 2007 13:14:47 +0000 (13:14 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Tue, 14 Aug 2007 13:14:47 +0000 (13:14 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19556 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiView.h
src/frontends/qt4/GuiWorkArea.cpp
src/frontends/qt4/GuiWorkArea.h

index acbab7d2c2299dee8431bf3c81d5427b3b14cacb..3c6fb19fd3bab6c73737b5f8e471feb33421fe0d 100644 (file)
 #include "support/filetools.h"
 #include "support/convert.h"
 #include "support/lstrings.h"
+#include "support/os.h"
 
+#include "Buffer.h"
 #include "BufferView.h"
 #include "BufferList.h"
+#include "callback.h"
 #include "debug.h"
 #include "FuncRequest.h"
-#include "callback.h"
-#include "LyXRC.h"
 #include "LyX.h"
-#include "Session.h"
 #include "LyXFunc.h"
+#include "LyXRC.h"
 #include "MenuBackend.h"
-#include "Buffer.h"
-#include "BufferList.h"
+#include "Session.h"
 
 #include <QAction>
 #include <QApplication>
 #include <QCloseEvent>
+#include <QDesktopWidget>
+#include <QDragEnterEvent>
+#include <QDropEvent>
+#include <QHBoxLayout>
+#include <QList>
+#include <QMimeData>
 #include <QPixmap>
+#include <QPushButton>
 #include <QStatusBar>
 #include <QToolBar>
 #include <QTabBar>
-#include <QDesktopWidget>
+#include <QUrl>
 #include <QVBoxLayout>
-#include <QHBoxLayout>
-#include <QPushButton>
 
 
 #include <boost/bind.hpp>
@@ -222,6 +227,9 @@ GuiView::GuiView(int id)
        if (!iconname.empty())
                setWindowIcon(QPixmap(toqstr(iconname.absFilename())));
 #endif
+
+       // For Drag&Drop.
+       setAcceptDrops(true);
 }
 
 
@@ -320,6 +328,33 @@ void GuiView::closeEvent(QCloseEvent * close_event)
 }
 
 
+void GuiView::dragEnterEvent(QDragEnterEvent * event)
+{
+       if (event->mimeData()->hasUrls())
+               event->accept();
+       /// \todo Ask lyx-devel is this is enough:
+       /// if (event->mimeData()->hasFormat("text/plain"))
+       ///     event->acceptProposedAction();
+}
+
+
+void GuiView::dropEvent(QDropEvent* event)
+{
+       QList<QUrl> files = event->mimeData()->urls();
+       if (files.isEmpty())
+               return;
+
+       LYXERR(Debug::GUI) << BOOST_CURRENT_FUNCTION
+               << " got URLs!" << endl;
+       for (int i = 0; i!=files.size(); ++i) {
+               string const file = support::os::internal_path(fromqstr(
+                       files.at(i).toLocalFile()));
+               if (!file.empty())
+                       dispatch(FuncRequest(LFUN_FILE_OPEN, file));
+       }
+}
+
+
 void GuiView::saveGeometry()
 {
        static bool done = false;
index 2d8d172eee6354da7e0f125773c374ae5cf73b97..ad22ddf463e48274dc9745307b4ff4a4f020b274 100644 (file)
@@ -117,6 +117,11 @@ protected:
        virtual void moveEvent(QMoveEvent * e);
 
 private:
+       ///
+       void dragEnterEvent(QDragEnterEvent * ev);
+       ///
+       void dropEvent(QDropEvent * ev);
+
        /// focus the command buffer widget
        void focus_command_widget();
 
index a6c08b1eff58539c6c5d3127bc4835201189ca5c..b9c0a9dab8a78284b644c9f1a9e524c84dd1ef16 100644 (file)
 #include "QKeySymbol.h"
 #include "qt_helpers.h"
 
-#include "LyXView.h"
+#include "frontends/LyXView.h"
 
 #include "BufferView.h"
-#include "rowpainter.h"
+#include "Color.h"
 #include "debug.h"
 #include "FuncRequest.h"
-#include "Color.h"
-#include "version.h"
 #include "LyXRC.h"
+#include "rowpainter.h"
+#include "version.h"
 
 #include "support/filetools.h" // LibFileSearch
-#include "support/os.h"
 #include "support/convert.h"
 
 #include "graphics/GraphicsImage.h"
 #include "graphics/GraphicsLoader.h"
 
+#include <QInputContext>
 #include <QLayout>
 #include <QMainWindow>
-#include <QMimeData>
-#include <QUrl>
-#include <QDragEnterEvent>
 #include <QPainter>
 #include <QScrollBar>
 #include <QTimer>
-#include <QInputContext>
 
 #include <boost/bind.hpp>
 #include <boost/current_function.hpp>
@@ -63,9 +59,6 @@ int const CursorWidth = 1;
 using std::endl;
 using std::string;
 
-namespace os = lyx::support::os;
-
-
 namespace lyx {
 
 using support::FileName;
@@ -271,31 +264,6 @@ void GuiWorkArea::adjustViewWithScrollBar(int)
 }
 
 
-void GuiWorkArea::dragEnterEvent(QDragEnterEvent * event)
-{
-       if (event->mimeData()->hasUrls())
-               event->accept();
-       /// \todo Ask lyx-devel is this is enough:
-       /// if (event->mimeData()->hasFormat("text/plain"))
-       ///     event->acceptProposedAction();
-}
-
-
-void GuiWorkArea::dropEvent(QDropEvent* event)
-{
-       QList<QUrl> files = event->mimeData()->urls();
-       if (files.isEmpty())
-               return;
-
-       LYXERR(Debug::GUI) << "GuiWorkArea::dropEvent: got URIs!" << endl;
-       for (int i = 0; i!=files.size(); ++i) {
-               string const file = os::internal_path(fromqstr(files.at(i).toLocalFile()));
-               if (!file.empty())
-                       dispatch(FuncRequest(LFUN_FILE_OPEN, file));
-       }
-}
-
-
 void GuiWorkArea::focusInEvent(QFocusEvent * /*event*/)
 {
        // No need to do anything if we didn't change views...
index f64ed84cae6da033371faec2b37b17fd7b2ae484..09ba83c6d1bfe820d8a2ad66387f07ad16bc822d 100644 (file)
@@ -117,10 +117,6 @@ public:
 private:
        void doGreyOut(QLPainter & pain);
        ///
-       void dragEnterEvent(QDragEnterEvent * ev);
-       ///
-       void dropEvent(QDropEvent * ev);
-       ///
        void focusInEvent(QFocusEvent *);
        ///
        void focusOutEvent(QFocusEvent *);