Cleanup: make "struct dive *" and "struct dive_trip *" Qt metatypes

Just as we did for pointer to struct dive_site, make pointers to
struct dive and struct dive_trip "Qt metatypes". This means that
they can be passed through QVariants without taking a detour via
void *.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-11-22 08:06:07 +01:00 committed by Dirk Hohndel
parent fba6ec5ad5
commit 9e565e3552
4 changed files with 33 additions and 29 deletions

View file

@ -51,7 +51,7 @@ QVariant DiveTripModel::tripData(const dive_trip *trip, int column, int role)
bool oneDayTrip=true;
if (role == TRIP_ROLE)
return QVariant::fromValue<void *>((void *)trip); // Not nice: casting away a const
return QVariant::fromValue(const_cast<dive_trip *>(trip)); // Not nice: casting away a const
if (role == Qt::DisplayRole) {
switch (column) {
@ -248,7 +248,7 @@ QVariant DiveTripModel::diveData(const struct dive *d, int column, int role)
case STAR_ROLE:
return d->rating;
case DIVE_ROLE:
return QVariant::fromValue<void *>((void *)d); // Not nice: casting away a const
return QVariant::fromValue(const_cast<dive *>(d)); // Not nice: casting away a const
case DIVE_IDX:
return get_divenr(d);
case SELECTED_ROLE: