mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-20 06:45:27 +00:00
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:
parent
a96e0e1ec1
commit
9511ee0294
1 changed files with 16 additions and 11 deletions
|
@ -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 {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue