mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +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:
parent
957f03f2a4
commit
9f7ecbb53e
4 changed files with 19 additions and 1 deletions
|
@ -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();
|
||||
|
|
|
@ -77,6 +77,7 @@ public slots:
|
|||
|
||||
void saveChanges();
|
||||
QString addDive();
|
||||
void addDiveAborted(int id);
|
||||
void applyGpsData();
|
||||
void sendGpsData();
|
||||
void downloadGpsData();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue