summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-ui/divelogimportdialog.cpp31
-rw-r--r--qt-ui/divelogimportdialog.h4
2 files changed, 35 insertions, 0 deletions
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);
diff --git a/qt-ui/divelogimportdialog.h b/qt-ui/divelogimportdialog.h
index 29ceedf7d..7e43434cd 100644
--- a/qt-ui/divelogimportdialog.h
+++ b/qt-ui/divelogimportdialog.h
@@ -50,6 +50,10 @@ public:
ColumnNameView(QWidget *parent);
protected:
void mousePressEvent(QMouseEvent *press);
+ void dragLeaveEvent(QDragLeaveEvent *leave);
+ void dragEnterEvent(QDragEnterEvent *event);
+ void dragMoveEvent(QDragMoveEvent *event);
+ void dropEvent(QDropEvent *event);
private:
int currentDraggedIndex;
};