mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
implement basic drag-and-drop support in qt
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7508 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
cd75cc4376
commit
9a747c4130
@ -955,37 +955,49 @@ void BufferView::Pimpl::trackChanges()
|
||||
}
|
||||
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
2003-08-05 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||
|
||||
* BufferView_pimpl.C (workAreaDispatch): change to use
|
||||
LyXView::dispatch instead of BufferView::Pimpl::dispatch for lfuns
|
||||
that are no mouse related.
|
||||
|
||||
2003-08-05 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
|
@ -1,3 +1,9 @@
|
||||
2003-08-05 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||
|
||||
* QWorkArea.C (QWorkArea):
|
||||
(dragEnterEvent):
|
||||
(dropEvent): add support for drag and drop of URIs
|
||||
|
||||
2003-08-03 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||
|
||||
* ui/moc/Makefile.am (INCLUDES): forgot to use QT_INCLUDES
|
||||
|
@ -11,20 +11,15 @@
|
||||
#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>
|
||||
@ -34,13 +29,9 @@
|
||||
#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)
|
||||
@ -51,6 +42,7 @@ QWorkArea::QWorkArea(int, int, int, int)
|
||||
(static_cast<QMainWindow*>(qApp->mainWidget()))->setCentralWidget(this);
|
||||
|
||||
setFocusProxy(content_);
|
||||
setAcceptDrops(true);
|
||||
|
||||
content_->show();
|
||||
|
||||
@ -142,3 +134,23 @@ void QWorkArea::putClipboard(string const & str) const
|
||||
#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)));
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,10 @@ public:
|
||||
virtual string const getClipboard() const;
|
||||
///
|
||||
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(); }
|
||||
|
Loading…
Reference in New Issue
Block a user