1
0
Fork 0
mirror of https://github.com/subsurface/subsurface.git synced 2025-02-19 22:16:15 +00:00

Add helper to remove dive from model

I tried various things to do this from QML but it just doesn't seem to
work at all. So I gave up and instead added a trivial helper function.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2016-01-29 06:25:13 -08:00
parent 957f03f2a4
commit 9f7ecbb53e
4 changed files with 19 additions and 1 deletions

View file

@ -556,6 +556,11 @@ QString QMLManager::addDive()
return DiveListModel::instance()->startAddDive(); return DiveListModel::instance()->startAddDive();
} }
void QMLManager::addDiveAborted(int id)
{
DiveListModel::instance()->removeDiveById(id);
}
QString QMLManager::getCurrentPosition() QString QMLManager::getCurrentPosition()
{ {
return locationProvider->currentPosition(); return locationProvider->currentPosition();

View file

@ -77,6 +77,7 @@ public slots:
void saveChanges(); void saveChanges();
QString addDive(); QString addDive();
void addDiveAborted(int id);
void applyGpsData(); void applyGpsData();
void sendGpsData(); void sendGpsData();
void downloadGpsData(); void downloadGpsData();

View file

@ -52,6 +52,16 @@ void DiveListModel::removeDive(int i)
endRemoveRows(); endRemoveRows();
} }
void DiveListModel::removeDiveById(int id)
{
for (int i = 0; i < rowCount(); i++) {
if (m_dives.at(i)->id() == id) {
removeDive(i);
return;
}
}
}
void DiveListModel::updateDive(int i, dive *d) void DiveListModel::updateDive(int i, dive *d)
{ {
DiveObjectHelper *newDive = new DiveObjectHelper(d); DiveObjectHelper *newDive = new DiveObjectHelper(d);
@ -125,6 +135,7 @@ DiveListModel *DiveListModel::instance()
return m_instance; return m_instance;
} }
DiveObjectHelper* DiveListModel::at(int i){ DiveObjectHelper* DiveListModel::at(int i)
{
return m_dives.at(i); return m_dives.at(i);
} }

View file

@ -33,6 +33,7 @@ public:
void addDive(dive *d); void addDive(dive *d);
void insertDive(int i, DiveObjectHelper *newDive); void insertDive(int i, DiveObjectHelper *newDive);
void removeDive(int i); void removeDive(int i);
void removeDiveById(int id);
void updateDive(int i, dive *d); void updateDive(int i, dive *d);
void clear(); void clear();
int rowCount(const QModelIndex &parent = QModelIndex()) const; int rowCount(const QModelIndex &parent = QModelIndex()) const;