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>
This commit is contained in:
Tomaz Canabrava 2015-01-06 23:30:46 -02:00 committed by Dirk Hohndel
parent a96e0e1ec1
commit 9511ee0294

View file

@ -163,18 +163,23 @@ void ColumnDropCSVView::dropEvent(QDropEvent *event)
if (!curr.isValid() || curr.row() != 0) if (!curr.isValid() || curr.row() != 0)
return; return;
event->acceptProposedAction();
const QMimeData *mimeData = event->mimeData(); const QMimeData *mimeData = event->mimeData();
if (mimeData->data(subsurface_mimedata).count()) { if (!mimeData->data(subsurface_mimedata).count())
if (event->source() != this) { return;
QVariant value = QString(mimeData->data(subsurface_mimedata));
model()->setData(curr, value); if (event->source() == this ) {
} else { QString value_old = QString(mimeData->data(subsurface_mimedata));
QString value_old = QString(mimeData->data(subsurface_mimedata)); QString value_new = curr.data().toString();
QString value_new = curr.data().toString(); ColumnNameResult *m = qobject_cast<ColumnNameResult*>(model());
ColumnNameResult *m = qobject_cast<ColumnNameResult*>(model()); m->swapValues(value_old, value_new);
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();
} }
} }