mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
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:
parent
b275e604c1
commit
3b37844708
4 changed files with 20 additions and 0 deletions
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue