diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2015-01-06 15:26:19 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-01-06 19:37:23 -0800 |
commit | 6149004f4763d8b55fd59542813126341dd34fb5 (patch) | |
tree | 930474a1286c043fee73ffb6727fd8aa0776368f /qt-ui/divelogimportdialog.cpp | |
parent | 81f2ee589246556271aae73f2dcbaba019b18207 (diff) | |
download | subsurface-6149004f4763d8b55fd59542813126341dd34fb5.tar.gz |
Remove the string from the model while dragging
We are not correctly readding it yet - be patient.
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 | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp index 9db910661..7e2a2a22d 100644 --- a/qt-ui/divelogimportdialog.cpp +++ b/qt-ui/divelogimportdialog.cpp @@ -34,12 +34,18 @@ bool ColumnNameProvider::insertRows(int row, int count, const QModelIndex &paren bool ColumnNameProvider::removeRows(int row, int count, const QModelIndex &parent) { - qDebug() << "Calling"; + beginRemoveRows(QModelIndex(), row, row); + columnNames.removeAt(row); + qDebug() << "Removing row" << row; + endRemoveRows(); } bool ColumnNameProvider::setData(const QModelIndex &index, const QVariant &value, int role) { - + if (role == Qt::EditRole) { + columnNames[index.row()] = value.toString(); + } + dataChanged(index, index); } QVariant ColumnNameProvider::data(const QModelIndex &index, int role) const @@ -75,29 +81,35 @@ void ColumnNameView::mousePressEvent(QMouseEvent *press) QDrag *drag = new QDrag(this); QMimeData *mimeData = new QMimeData; mimeData->setText(atClick.data().toString()); + model()->removeRow(atClick.row()); drag->setMimeData(mimeData); drag->exec(); - currentDraggedIndex = atClick.row(); + } void ColumnNameView::dragLeaveEvent(QDragLeaveEvent *leave) { - model()->removeRow(currentDraggedIndex); + } void ColumnNameView::dragEnterEvent(QDragEnterEvent *event) { - + event->acceptProposedAction(); } void ColumnNameView::dragMoveEvent(QDragMoveEvent *event) { - + event->acceptProposedAction(); } void ColumnNameView::dropEvent(QDropEvent *event) { - + const QMimeData *mimeData = event->mimeData(); + if (mimeData->hasText()) { + model()->insertRow(model()->rowCount()); + model()->setData(model()->index(model()->rowCount()-1, 0), QVariant(mimeData->text())); + qDebug() << "model -> rowcount() " << model()->rowCount(); + } } |