mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +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)
|
QString QMLManager::getNumber(const QString& diveId)
|
||||||
{
|
{
|
||||||
int dive_id = diveId.toInt();
|
int dive_id = diveId.toInt();
|
||||||
|
|
|
@ -103,6 +103,7 @@ public slots:
|
||||||
void finishSetup();
|
void finishSetup();
|
||||||
void openLocalThenRemote(QString url);
|
void openLocalThenRemote(QString url);
|
||||||
void showMap(const QString& location);
|
void showMap(const QString& location);
|
||||||
|
int getIndex(const QString& diveId);
|
||||||
QString getNumber(const QString& diveId);
|
QString getNumber(const QString& diveId);
|
||||||
QString getDate(const QString& diveId);
|
QString getDate(const QString& diveId);
|
||||||
QString getCurrentPosition();
|
QString getCurrentPosition();
|
||||||
|
|
|
@ -91,6 +91,16 @@ int DiveListModel::getDiveId(int idx) const
|
||||||
return m_dives[idx]->id();
|
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
|
QVariant DiveListModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if(index.row() < 0 || index.row() > m_dives.count())
|
if(index.row() < 0 || index.row() > m_dives.count())
|
||||||
|
|
|
@ -38,6 +38,7 @@ public:
|
||||||
void clear();
|
void clear();
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
int getDiveId(int idx) const;
|
int getDiveId(int idx) const;
|
||||||
|
int getDiveIdx(int id) const;
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||||
QHash<int, QByteArray> roleNames() const;
|
QHash<int, QByteArray> roleNames() const;
|
||||||
QString startAddDive();
|
QString startAddDive();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue