summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-mobile/qmlmanager.cpp8
-rw-r--r--qt-mobile/qmlmanager.h1
-rw-r--r--qt-models/divelistmodel.cpp10
-rw-r--r--qt-models/divelistmodel.h1
4 files changed, 20 insertions, 0 deletions
diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp
index 9a0a97f65..39b02e6a9 100644
--- a/qt-mobile/qmlmanager.cpp
+++ b/qt-mobile/qmlmanager.cpp
@@ -882,6 +882,14 @@ void QMLManager::showMap(const QString& location)
}
}
+// where in the QML dive list is that dive?
+int QMLManager::getIndex(const QString &diveId)
+{
+ int dive_id = diveId.toInt();
+ int idx = DiveListModel::instance()->getDiveIdx(dive_id);
+ return idx;
+}
+
QString QMLManager::getNumber(const QString& diveId)
{
int dive_id = diveId.toInt();
diff --git a/qt-mobile/qmlmanager.h b/qt-mobile/qmlmanager.h
index 41ca2271f..17fe699e4 100644
--- a/qt-mobile/qmlmanager.h
+++ b/qt-mobile/qmlmanager.h
@@ -103,6 +103,7 @@ public slots:
void finishSetup();
void openLocalThenRemote(QString url);
void showMap(const QString& location);
+ int getIndex(const QString& diveId);
QString getNumber(const QString& diveId);
QString getDate(const QString& diveId);
QString getCurrentPosition();
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();