Dive d/l selection UI: fix more array access errors

The checked array is zero based, reflecting the rows shown.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-01-08 11:27:47 -08:00
parent 32824e8db8
commit d16bff13bb

View file

@ -570,7 +570,7 @@ QVariant DiveImportedModel::data(const QModelIndex &index, int role) const
} }
if (role == Qt::CheckStateRole) { if (role == Qt::CheckStateRole) {
if (index.column() == 0) if (index.column() == 0)
return checkStates[index.row() + firstIndex] ? Qt::Checked : Qt::Unchecked; return checkStates[index.row()] ? Qt::Checked : Qt::Unchecked;
} }
return QVariant(); return QVariant();
} }
@ -586,7 +586,7 @@ bool DiveImportedModel::setData(const QModelIndex &index, const QVariant &value,
if (role != Qt::CheckStateRole) if (role != Qt::CheckStateRole)
return false; return false;
checkStates[index.row() + firstIndex] = value.toBool(); checkStates[index.row()] = value.toBool();
dataChanged(index, index, QVector<int>() << Qt::CheckStateRole); dataChanged(index, index, QVector<int>() << Qt::CheckStateRole);
return true; return true;
} }