diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-11-16 18:41:47 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-11-16 20:19:55 -0800 |
commit | 4f9526ef8122f3496ee0ead986fcc10c500e0584 (patch) | |
tree | 29c6c838928c03bb47a404f3ff0c889a25bc7869 /qt-ui/models.cpp | |
parent | c1a05fd03443ac9604684fa22a7efd5172bd2ffc (diff) | |
download | subsurface-4f9526ef8122f3496ee0ead986fcc10c500e0584.tar.gz |
Fix wrong handling of Dive Table, and revert some wrong changes.
This patch just reverts some wrong changes that I'v done on a
past commit ( sorry ) and correctly handles the selectDive,
by using a IDX instead of the dive pointer, as dirk told me
it's extremely error-prone since the pointer can change.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/models.cpp')
-rw-r--r-- | qt-ui/models.cpp | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index dd69e45c2..2e4a0860e 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -989,6 +989,9 @@ QVariant DiveItem::data(int column, int role) const if (role == DiveTripModel::DIVE_ROLE) retVal = QVariant::fromValue<void*>(dive); + if(role == DiveTripModel::DIVE_IDX){ + retVal = get_divenr(dive); + } return retVal; } @@ -1198,23 +1201,6 @@ QVariant DiveComputerModel::data(const QModelIndex& index, int role) const return ret; } -void DiveTripModel::deleteSelectedDives() -{ - // after a dive is deleted the ones following it move forward in the dive_table - // so instead of using the for_each_dive macro I'm using an explicit for loop - // to make this easier to understand - beginRemoveRows(index(0,0), 0, rowCount()-1); - for (int i = 0; i < dive_table.nr; i++) { - struct dive *d = get_dive(i); - if (!d->selected) - continue; - delete_single_dive(i); - i--; // so the next dive isn't skipped... it's now #i - } - endRemoveRows(); - setupModelData(); -} - int DiveComputerModel::rowCount(const QModelIndex& parent) const { return numRows; |