From 3b37844708d0bcbac3dbec86a44d6dfff69639a0 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 2 Mar 2016 04:41:36 -0800 Subject: Add helper functions to identify the position of a dive in the dive list Signed-off-by: Dirk Hohndel --- qt-models/divelistmodel.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'qt-models/divelistmodel.cpp') diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index bef2c5158..7e1844f3e 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -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()) -- cgit v1.2.3-70-g09d2