diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2015-01-06 23:30:46 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-01-06 19:38:56 -0800 |
commit | 9511ee029403c7e49989b49889d159f45d859770 (patch) | |
tree | f1d54b352a597a1323a22a76f4bd74c990aaa02d | |
parent | a96e0e1ec11722fadebe61fe3c87f2d9991843ff (diff) | |
download | subsurface-9511ee029403c7e49989b49889d159f45d859770.tar.gz |
Do not allow the drop target to erase an old column
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-ui/divelogimportdialog.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
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<ColumnNameResult*>(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<ColumnNameResult*>(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(); } } |