mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: replace dive_site::dives by an std::vector<>
Since this is now in C++, we don't have to use our crazy TABLE_* macros. This contains a logic change: the dives associated to a dive site are now unsorted. The old code was subtly buggy: dives were added in a sorted manner, but when the dive was edited the list was not resorted. Very unlikely that this leads to a serious problem, still not good. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
3f8b4604be
commit
801b5d50b2
12 changed files with 39 additions and 45 deletions
|
|
@ -62,9 +62,9 @@ void DiveSiteListView::diveSiteClicked(const QModelIndex &index)
|
|||
MainWindow::instance()->editDiveSite(ds);
|
||||
break;
|
||||
case LocationInformationModel::REMOVE:
|
||||
if (ds->dives.nr > 0 &&
|
||||
if (!ds->dives.empty() &&
|
||||
QMessageBox::warning(this, tr("Delete dive site?"),
|
||||
tr("This dive site has %n dive(s). Do you really want to delete it?\n", "", ds->dives.nr),
|
||||
tr("This dive site has %n dive(s). Do you really want to delete it?\n", "", ds->dives.size()),
|
||||
QMessageBox::Yes|QMessageBox::No) == QMessageBox::No)
|
||||
return;
|
||||
Command::deleteDiveSites(QVector<dive_site *>{ds});
|
||||
|
|
|
|||
|
|
@ -1410,7 +1410,7 @@ void MainWindow::on_actionImportDiveSites_triggered()
|
|||
}
|
||||
// The imported dive sites still have pointers to imported dives - remove them
|
||||
for (int i = 0; i < log.sites->nr; ++i)
|
||||
log.sites->dive_sites[i]->dives.nr = 0;
|
||||
log.sites->dive_sites[i]->dives.clear();
|
||||
|
||||
QString source = fileNames.size() == 1 ? fileNames[0] : tr("multiple files");
|
||||
|
||||
|
|
|
|||
|
|
@ -480,7 +480,7 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem
|
|||
} else {
|
||||
int distanceMeters = get_distance(&ds->location, ¤tLocation);
|
||||
QString distance = distance_string(distanceMeters);
|
||||
int nr = nr_of_dives_at_dive_site(ds);
|
||||
size_t nr = nr_of_dives_at_dive_site(*ds);
|
||||
bottomText += tr(" (~%1 away").arg(distance);
|
||||
bottomText += tr(", %n dive(s) here)", "", nr);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue