From 9511ee029403c7e49989b49889d159f45d859770 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 6 Jan 2015 23:30:46 -0200 Subject: Do not allow the drop target to erase an old column Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/divelogimportdialog.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp index 37a86bfb2..4fb9b30d2 100644 --- a/qt-ui/divelogimportdialog.cpp +++ b/qt-ui/divelogimportdialog.cpp @@ -163,18 +163,23 @@ void ColumnDropCSVView::dropEvent(QDropEvent *event) if (!curr.isValid() || curr.row() != 0) return; - event->acceptProposedAction(); const QMimeData *mimeData = event->mimeData(); - if (mimeData->data(subsurface_mimedata).count()) { - if (event->source() != this) { - QVariant value = QString(mimeData->data(subsurface_mimedata)); - model()->setData(curr, value); - } else { - QString value_old = QString(mimeData->data(subsurface_mimedata)); - QString value_new = curr.data().toString(); - ColumnNameResult *m = qobject_cast(model()); - m->swapValues(value_old, value_new); - } + if (!mimeData->data(subsurface_mimedata).count()) + return; + + if (event->source() == this ) { + QString value_old = QString(mimeData->data(subsurface_mimedata)); + QString value_new = curr.data().toString(); + ColumnNameResult *m = qobject_cast(model()); + m->swapValues(value_old, value_new); + event->acceptProposedAction(); + return; + } + + if (curr.data().toString().isEmpty()) { + QVariant value = QString(mimeData->data(subsurface_mimedata)); + model()->setData(curr, value); + event->acceptProposedAction(); } } -- cgit v1.2.3-70-g09d2