diff options
-rw-r--r-- | qt-mobile/qmlmanager.cpp | 5 | ||||
-rw-r--r-- | qt-mobile/qmlmanager.h | 1 | ||||
-rw-r--r-- | qt-models/divelistmodel.cpp | 13 | ||||
-rw-r--r-- | qt-models/divelistmodel.h | 1 |
4 files changed, 19 insertions, 1 deletions
diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp index ab06cd941..f71e15100 100644 --- a/qt-mobile/qmlmanager.cpp +++ b/qt-mobile/qmlmanager.cpp @@ -556,6 +556,11 @@ QString QMLManager::addDive() return DiveListModel::instance()->startAddDive(); } +void QMLManager::addDiveAborted(int id) +{ + DiveListModel::instance()->removeDiveById(id); +} + QString QMLManager::getCurrentPosition() { return locationProvider->currentPosition(); diff --git a/qt-mobile/qmlmanager.h b/qt-mobile/qmlmanager.h index eb225a6cf..bb8bb693d 100644 --- a/qt-mobile/qmlmanager.h +++ b/qt-mobile/qmlmanager.h @@ -77,6 +77,7 @@ public slots: void saveChanges(); QString addDive(); + void addDiveAborted(int id); void applyGpsData(); void sendGpsData(); void downloadGpsData(); diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index 114745fe7..9ddf05dbc 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -52,6 +52,16 @@ void DiveListModel::removeDive(int i) 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) { DiveObjectHelper *newDive = new DiveObjectHelper(d); @@ -125,6 +135,7 @@ DiveListModel *DiveListModel::instance() return m_instance; } -DiveObjectHelper* DiveListModel::at(int i){ +DiveObjectHelper* DiveListModel::at(int i) +{ return m_dives.at(i); } diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h index 675619640..fd703c14a 100644 --- a/qt-models/divelistmodel.h +++ b/qt-models/divelistmodel.h @@ -33,6 +33,7 @@ public: void addDive(dive *d); void insertDive(int i, DiveObjectHelper *newDive); void removeDive(int i); + void removeDiveById(int id); void updateDive(int i, dive *d); void clear(); int rowCount(const QModelIndex &parent = QModelIndex()) const; |