I plan to apply this patch to 1.3.4cvs. This is already applied to
1.4.0cvs. Did anybody try drag and drop of .lyx files with 1.4.0cvs?
Did it work as expected?

JMarc

Index: src/BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.322
diff -u -p -r1.322 BufferView_pimpl.C
--- src/BufferView_pimpl.C	23 Jan 2003 16:23:35 -0000	1.322
+++ src/BufferView_pimpl.C	4 Dec 2003 16:50:11 -0000
@@ -93,6 +93,7 @@ unsigned int const saved_positions_num =
 // (Lgb)
 
 boost::signals::connection dispatchcon;
+boost::signals::connection viewdispatchcon;
 boost::signals::connection timecon;
 boost::signals::connection doccon;
 boost::signals::connection resizecon;
@@ -119,6 +120,8 @@ BufferView::Pimpl::Pimpl(BufferView * bv
 		.connect(boost::bind(&BufferView::Pimpl::workAreaResize, this));
 	dispatchcon = workarea().dispatch
 		.connect(boost::bind(&BufferView::Pimpl::dispatch, this, _1));
+	viewdispatchcon = workarea().viewDispatch
+		.connect(boost::bind(&BufferView::Pimpl::viewDispatch, this, _1));
 	kpresscon = workarea().workAreaKeyPress
 		.connect(boost::bind(&BufferView::Pimpl::workAreaKeyPress, this, _1, _2));
 	selectioncon = workarea().selectionRequested
@@ -912,6 +915,13 @@ void BufferView::Pimpl::MenuInsertLyXFil
 #endif
 		owner_->message(STRCONV(str.str()));
 	}
+}
+
+
+bool BufferView::Pimpl::viewDispatch(FuncRequest const & ev)
+{
+		owner_->dispatch(ev);
+		return true;
 }
 
 
Index: src/BufferView_pimpl.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.h,v
retrieving revision 1.81
diff -u -p -r1.81 BufferView_pimpl.h
--- src/BufferView_pimpl.h	21 Oct 2002 00:15:48 -0000	1.81
+++ src/BufferView_pimpl.h	4 Dec 2003 16:50:11 -0000
@@ -102,6 +102,9 @@ struct BufferView::Pimpl : public boost:
 	void updateInset(Inset * inset, bool mark_dirty);
 	///
 	bool dispatch(FuncRequest const & ev);
+	///
+	bool viewDispatch(FuncRequest const & ev);
+
 private:
 	///
 	friend class BufferView;
Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.1021.2.23
diff -u -p -r1.1021.2.23 ChangeLog
--- src/ChangeLog	20 Nov 2003 14:13:03 -0000	1.1021.2.23
+++ src/ChangeLog	4 Dec 2003 16:50:13 -0000
@@ -1,3 +1,8 @@
+2003-12-04  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
+
+	* BufferView_pimpl.C (viewDispatch): new method, called by the qt
+	drag-and-drop code.
+
 2003-11-19  Angus Leeming  <[EMAIL PROTECTED]>
 
 	* lyxtextclass.C (LyXTextClass): fix warning about variable
Index: src/frontends/WorkArea.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/WorkArea.h,v
retrieving revision 1.17
diff -u -p -r1.17 WorkArea.h
--- src/frontends/WorkArea.h	21 Oct 2002 17:38:07 -0000	1.17
+++ src/frontends/WorkArea.h	4 Dec 2003 16:50:13 -0000
@@ -72,6 +72,8 @@ public:
 	boost::signal2<void, LyXKeySymPtr, key_modifier::state> workAreaKeyPress;
 	/// some mouse event
 	boost::signal1<void, FuncRequest> dispatch;
+	/// used by drag-and-drop
+	boost::signal1<bool, FuncRequest> viewDispatch;
 	/// emitted when an X client has requested our selection
 	boost::signal0<void> selectionRequested;
 	/// emitted when another X client has stolen our selection
Index: src/frontends/qt2/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/ChangeLog,v
retrieving revision 1.389.2.39
diff -u -p -r1.389.2.39 ChangeLog
--- src/frontends/qt2/ChangeLog	19 Nov 2003 16:32:49 -0000	1.389.2.39
+++ src/frontends/qt2/ChangeLog	4 Dec 2003 16:50:13 -0000
@@ -1,3 +1,9 @@
+2003-12-04  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
+
+	* QWorkArea.C (QWorkArea):
+	(dragEnterEvent):
+	(dropEvent): add support for drag and drop of URIs
+
 2003-11-14  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
 
 	* ui/QMathDialogBase.ui: remove mention of \frac in tooltip, since
Index: src/frontends/qt2/QWorkArea.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QWorkArea.C,v
retrieving revision 1.11
diff -u -p -r1.11 QWorkArea.C
--- src/frontends/qt2/QWorkArea.C	17 Dec 2002 20:37:10 -0000	1.11
+++ src/frontends/qt2/QWorkArea.C	4 Dec 2003 16:50:13 -0000
@@ -27,6 +27,7 @@
 
 #include <qapplication.h>
 #include <qevent.h>
+#include <qdragobject.h>
 #include <qpainter.h>
 #include <qmainwindow.h>
 #include <qlayout.h>
@@ -53,6 +54,7 @@ QWorkArea::QWorkArea(int, int, int, int)
 	(static_cast<QMainWindow*>(qApp->mainWidget()))->setCentralWidget(this);
 
 	setFocusProxy(content_);
+	setAcceptDrops(true);
 
 	content_->show();
 
@@ -143,4 +145,25 @@ void QWorkArea::putClipboard(string cons
 	QApplication::clipboard()->setSelectionMode(true);
 #endif
 	QApplication::clipboard()->setText(toqstr(str));
+}
+
+
+void QWorkArea::dragEnterEvent(QDragEnterEvent * event)
+{
+	event->accept(QUriDrag::canDecode(event));
+}
+
+
+void QWorkArea::dropEvent(QDropEvent* event)
+{
+	QStringList files;
+
+	if (QUriDrag::decodeLocalFiles(event, files)) {
+		lyxerr[Debug::GUI] << "QWorkArea::dropEvent: got URIs!"
+				   << endl;
+		for (QStringList::Iterator i = files.begin();
+		     i!=files.end(); ++i)
+			viewDispatch(FuncRequest(LFUN_FILE_OPEN, fromqstr(*i)));
+//			lyxerr << "got file: " << fromqstr(*i) << endl;
+	}
 }
Index: src/frontends/qt2/QWorkArea.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QWorkArea.h,v
retrieving revision 1.8
diff -u -p -r1.8 QWorkArea.h
--- src/frontends/qt2/QWorkArea.h	20 Oct 2002 01:48:28 -0000	1.8
+++ src/frontends/qt2/QWorkArea.h	4 Dec 2003 16:50:13 -0000
@@ -56,6 +56,11 @@ public:
 	///
 	virtual void putClipboard(string const &) const;
 
+	///
+	virtual void dragEnterEvent(QDragEnterEvent * event);
+	///
+	virtual void dropEvent(QDropEvent* event);
+
 	/// get the pixmap we paint on to
 	QPixmap * getPixmap() const { return content_->pixmap(); }
 

Reply via email to