summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2016-03-02 04:41:36 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-03-02 04:46:26 -0800
commit3b37844708d0bcbac3dbec86a44d6dfff69639a0 (patch)
treedb4674939cf3312662ae0eaa959cb6291a8d5462 /qt-models
parentb275e604c13004427e37cc1f42139d2f412158f2 (diff)
downloadsubsurface-3b37844708d0bcbac3dbec86a44d6dfff69639a0.tar.gz
Add helper functions to identify the position of a dive in the dive list
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/divelistmodel.cpp10
-rw-r--r--qt-models/divelistmodel.h1
2 files changed, 11 insertions, 0 deletions
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())
diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h
index fd703c14a..aae3bfc74 100644
--- a/qt-models/divelistmodel.h
+++ b/qt-models/divelistmodel.h
@@ -38,6 +38,7 @@ public:
void clear();
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int getDiveId(int idx) const;
+ int getDiveIdx(int id) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
QHash<int, QByteArray> roleNames() const;
QString startAddDive();