From 1ba08e2fec619b105cb0d3d0718758bdcc9c7d87 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 6 Jan 2015 22:24:46 -0200 Subject: Make it possible to move from top to bottom Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/divelogimportdialog.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'qt-ui/divelogimportdialog.cpp') diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp index 632659cd2..7d165b892 100644 --- a/qt-ui/divelogimportdialog.cpp +++ b/qt-ui/divelogimportdialog.cpp @@ -103,6 +103,37 @@ void ColumnNameView::mousePressEvent(QMouseEvent *press) } } +void ColumnNameView::dragLeaveEvent(QDragLeaveEvent *leave) +{ + Q_UNUSED(leave); +} + +void ColumnNameView::dragEnterEvent(QDragEnterEvent *event) +{ + event->acceptProposedAction(); +} + +void ColumnNameView::dragMoveEvent(QDragMoveEvent *event) +{ + QModelIndex curr = indexAt(event->pos()); + if (!curr.isValid() || curr.row() != 0) + return; + event->acceptProposedAction(); +} + +void ColumnNameView::dropEvent(QDropEvent *event) +{ + const QMimeData *mimeData = event->mimeData(); + if (mimeData->data(subsurface_mimedata).count()) { + if (event->source() != this) { + event->acceptProposedAction(); + QVariant value = QString(mimeData->data(subsurface_mimedata)); + model()->insertRow(model()->rowCount()); + model()->setData(model()->index(model()->rowCount()-1, 0), value); + } + } +} + ColumnDropCSVView::ColumnDropCSVView(QWidget *parent) { setAcceptDrops(true); -- cgit v1.2.3-70-g09d2