diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2015-01-06 23:20:54 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-01-06 19:38:50 -0800 |
commit | a96e0e1ec11722fadebe61fe3c87f2d9991843ff (patch) | |
tree | 41a49dd603b8589166ebcba50d8c93b3cc3193a2 /qt-ui/divelogimportdialog.cpp | |
parent | 6746b73d85e0160d64862ada43effec0515e92b4 (diff) | |
download | subsurface-a96e0e1ec11722fadebe61fe3c87f2d9991843ff.tar.gz |
Fix moving columns
Qt has a very bad habit of getting the inner widget instead of the outer
one.
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 | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp index fae2d3987..37a86bfb2 100644 --- a/qt-ui/divelogimportdialog.cpp +++ b/qt-ui/divelogimportdialog.cpp @@ -175,7 +175,6 @@ void ColumnDropCSVView::dropEvent(QDropEvent *event) ColumnNameResult *m = qobject_cast<ColumnNameResult*>(model()); m->swapValues(value_old, value_new); } - } } @@ -187,15 +186,15 @@ ColumnNameResult::ColumnNameResult(QObject *parent) : QAbstractTableModel(parent void ColumnNameResult::swapValues(const QString &one, const QString &other) { int firstIndex = columnNames.indexOf(one); int secondIndex = columnNames.indexOf(other); - columnNames[firstIndex] = other; - columnNames[secondIndex] = one; - dataChanged(index(0,0), index(0, columnCount()-1)); + setData(index(0, firstIndex), QVariant(other), Qt::EditRole); + setData(index(0, secondIndex), QVariant(one), Qt::EditRole); } bool ColumnNameResult::setData(const QModelIndex &index, const QVariant &value, int role) { - if (!index.isValid() || index.row() != 0) + if (!index.isValid() || index.row() != 0) { return false; + } if (role == Qt::EditRole) { columnNames[index.column()] = value.toString(); dataChanged(index, index); @@ -275,7 +274,12 @@ void ColumnDropCSVView::mousePressEvent(QMouseEvent *press) drag->setPixmap(pix); drag->setMimeData(mimeData); if (drag->exec() != Qt::IgnoreAction){ - if (drag->target() != drag->source()) { + QObject *target = drag->target(); + if (target->objectName() == "qt_scrollarea_viewport") + target = target->parent(); + + + if (target != drag->source()) { model()->setData(atClick, QString()); } } |