diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index 71ac3bb1e6ca47b297da0b22fe59c1ec1ec08d02..7484b29e34543e03c5b91b66958aa5f23a904927 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -122,6 +122,9 @@ WatchWindow::WatchWindow(Type type, QWidget *parent) setIndentation(indentation() * 9/10); setUniformRowHeights(true); setItemDelegate(new WatchDelegate(this)); + setDragEnabled(true); + setAcceptDrops(true); + setDropIndicatorShown(true); connect(this, SIGNAL(expanded(QModelIndex)), this, SLOT(expandNode(QModelIndex))); @@ -161,6 +164,35 @@ void WatchWindow::keyPressEvent(QKeyEvent *ev) QTreeView::keyPressEvent(ev); } +void WatchWindow::dragEnterEvent(QDragEnterEvent *ev) +{ + //QTreeView::dragEnterEvent(ev); + if (ev->mimeData()->hasFormat("text/plain")) { + ev->setDropAction(Qt::CopyAction); + ev->accept(); + } +} + +void WatchWindow::dragMoveEvent(QDragMoveEvent *ev) +{ + //QTreeView::dragMoveEvent(ev); + if (ev->mimeData()->hasFormat("text/plain")) { + ev->setDropAction(Qt::CopyAction); + ev->accept(); + } +} + +void WatchWindow::dropEvent(QDropEvent *ev) +{ + if (ev->mimeData()->hasFormat("text/plain")) { + theDebuggerAction(WatchExpression)->trigger(ev->mimeData()->text()); + //ev->acceptProposedAction(); + ev->setDropAction(Qt::CopyAction); + ev->accept(); + } + //QTreeView::dropEvent(ev); +} + void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) { QMenu menu; diff --git a/src/plugins/debugger/watchwindow.h b/src/plugins/debugger/watchwindow.h index 715507f8b16df9cef441cebd960581a11e02d9e4..adf4e06347e99268b29355a8822c527a2bd2f9e3 100644 --- a/src/plugins/debugger/watchwindow.h +++ b/src/plugins/debugger/watchwindow.h @@ -64,6 +64,10 @@ private: void keyPressEvent(QKeyEvent *ev); void contextMenuEvent(QContextMenuEvent *ev); + void dragEnterEvent(QDragEnterEvent *ev); + void dropEvent(QDropEvent *ev); + void dragMoveEvent(QDragMoveEvent *ev); + void editItem(const QModelIndex &idx); void reset(); /* reimpl */