diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2015-01-06 17:32:29 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-01-06 19:38:16 -0800 |
commit | f48065ac3c0c1f2dfdba099f6637df9c778756ab (patch) | |
tree | cbab7a4125411803b61ef155885375060966d9bf /qt-ui/divelogimportdialog.cpp | |
parent | 909be75113ef395e0a73eb8dd8698b101fd17cb2 (diff) | |
download | subsurface-f48065ac3c0c1f2dfdba099f6637df9c778756ab.tar.gz |
Do not accept drops from outside of subsurface
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/divelogimportdialog.cpp')
-rw-r--r-- | qt-ui/divelogimportdialog.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp index 539238560..16c713989 100644 --- a/qt-ui/divelogimportdialog.cpp +++ b/qt-ui/divelogimportdialog.cpp @@ -11,6 +11,8 @@ #include <QMimeData> #include <QFile> +static QString subsurface_mimedata = "subsurface/csvcolumns"; + const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::CSVApps[CSVAPPS] = { // time, depth, temperature, po2, cns, ndl, tts, stopdepth, pressure { "", }, @@ -88,14 +90,14 @@ void ColumnNameView::mousePressEvent(QMouseEvent *press) QDrag *drag = new QDrag(this); QMimeData *mimeData = new QMimeData; - mimeData->setText(atClick.data().toString()); + mimeData->setData(subsurface_mimedata, atClick.data().toByteArray()); model()->removeRow(atClick.row()); drag->setPixmap(pix); drag->setMimeData(mimeData); if (drag->exec() == Qt::IgnoreAction){ model()->insertRow(model()->rowCount()); QModelIndex idx = model()->index(model()->rowCount()-1, 0); - model()->setData(idx, mimeData->text()); + model()->setData(idx, mimeData->data(subsurface_mimedata)); } } @@ -105,20 +107,23 @@ void ColumnNameView::dragLeaveEvent(QDragLeaveEvent *leave) void ColumnNameView::dragEnterEvent(QDragEnterEvent *event) { - event->acceptProposedAction(); + if(event->mimeData()->data(subsurface_mimedata).count()) + event->acceptProposedAction(); } void ColumnNameView::dragMoveEvent(QDragMoveEvent *event) { - event->acceptProposedAction(); + if (event->mimeData()->data(subsurface_mimedata).count()) + event->acceptProposedAction(); } void ColumnNameView::dropEvent(QDropEvent *event) { const QMimeData *mimeData = event->mimeData(); - if (mimeData->hasText()) { + if (mimeData->data(subsurface_mimedata).count()) { + QVariant value = QString(mimeData->data(subsurface_mimedata)); model()->insertRow(model()->rowCount()); - model()->setData(model()->index(model()->rowCount()-1, 0), QVariant(mimeData->text())); + model()->setData(model()->index(model()->rowCount()-1, 0), value); } } @@ -153,8 +158,9 @@ void ColumnDropCSVView::dropEvent(QDropEvent *event) event->acceptProposedAction(); const QMimeData *mimeData = event->mimeData(); - if (mimeData->hasText()) { - model()->setData(curr, QVariant(mimeData->text())); + if (mimeData->data(subsurface_mimedata).count()) { + QVariant value = QString(mimeData->data(subsurface_mimedata)); + model()->setData(curr, value); } } |