}
-// Doesn't go through lyxfunc, so we need to update the
-// layout choice etc. ourselves
-bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & ev_in)
+bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & ev)
{
- // e.g. Qt mouse press when no buffer
- if (!available())
- return false;
+ switch (ev.action) {
+ case LFUN_MOUSE_PRESS:
+ case LFUN_MOUSE_MOTION:
+ case LFUN_MOUSE_RELEASE:
+ case LFUN_MOUSE_DOUBLE:
+ case LFUN_MOUSE_TRIPLE:
+ {
+ // We pass those directly to the Bufferview, since
+ // otherwise selection handling breaks down
- screen().hideCursor();
+ // Doesn't go through lyxfunc, so we need to update
+ // the layout choice etc. ourselves
- // Make sure that the cached BufferView is correct.
- FuncRequest ev = ev_in;
- ev.setView(bv_);
+ // e.g. Qt mouse press when no buffer
+ if (!available())
+ return false;
- bool const res = dispatch(ev);
+ screen().hideCursor();
- // see workAreaKeyPress
- cursor_timeout.restart();
- screen().showCursor(*bv_);
+ bool const res = dispatch(ev);
+
+ // see workAreaKeyPress
+ cursor_timeout.restart();
+ screen().showCursor(*bv_);
- // FIXME: we should skip these when selecting
- bv_->owner()->updateLayoutChoice();
- bv_->owner()->updateToolbar();
- bv_->fitCursor();
+ // FIXME: we should skip these when selecting
+ owner_->updateLayoutChoice();
+ owner_->updateToolbar();
+ fitCursor();
- // slight hack: this is only called currently when
- // we clicked somewhere, so we force through the display
- // of the new status here.
- bv_->owner()->clearMessage();
+ // slight hack: this is only called currently when we
+ // clicked somewhere, so we force through the display
+ // of the new status here.
+ owner_->clearMessage();
- return res;
+ return res;
+ }
+ default:
+ owner_->dispatch(ev);
+ return true;
+ }
}
#include <config.h>
-#include "debug.h"
-#include "LyXView.h"
-#include "version.h" // lyx_version
-
-#include "support/filetools.h" // LibFileSearch
-#include "support/lstrings.h"
-#include "support/LAssert.h"
-
#include "QWorkArea.h"
+#include "debug.h"
+#include "lfuns.h"
#include "qt_helpers.h"
#include "lcolorcache.h"
#include <qapplication.h>
#include <qevent.h>
+#include <qdragobject.h>
#include <qpainter.h>
#include <qmainwindow.h>
#include <qlayout.h>
#include <X11/Xlib.h>
#endif
-#include <cmath>
#include <cctype>
using std::endl;
-using std::abs;
-using std::hex;
-
QWorkArea::QWorkArea(int, int, int, int)
: WorkArea(), QWidget(qApp->mainWidget()), painter_(*this)
(static_cast<QMainWindow*>(qApp->mainWidget()))->setCentralWidget(this);
setFocusProxy(content_);
+ setAcceptDrops(true);
content_->show();
#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)
+ dispatch(FuncRequest(LFUN_FILE_OPEN, fromqstr(*i)));
+ }
+}