Add helper functions to identify the position of a dive in the dive list

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2016-03-02 04:41:36 -08:00
parent b275e604c1
commit 3b37844708
4 changed files with 20 additions and 0 deletions

View file

@ -91,6 +91,16 @@ int DiveListModel::getDiveId(int idx) const
return m_dives[idx]->id();
}
int DiveListModel::getDiveIdx(int id) const
{
int i;
for (i = 0; i < m_dives.count(); i++) {
if (m_dives.at(i)->id() == id)
return i;
}
return -1;
}
QVariant DiveListModel::data(const QModelIndex &index, int role) const
{
if(index.row() < 0 || index.row() > m_dives.count())