mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
list models: include current dive in selection signal
After sending a selection-change signal, there follows a current dive changed signal. Combine these two into a single signal, since usually the current dive is changed when the selection is changed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
832398180c
commit
9ccb940a1b
8 changed files with 23 additions and 48 deletions
|
@ -530,7 +530,7 @@ static ShownChange updateShownAll()
|
|||
return res;
|
||||
}
|
||||
|
||||
void DiveTripModelBase::currentChanged()
|
||||
void DiveTripModelBase::currentChanged(dive *currentDive)
|
||||
{
|
||||
// On Desktop we use a signal to forward current-dive changed, on mobile we use ROLE_CURRENT.
|
||||
// TODO: Unify - use the role for both.
|
||||
|
@ -540,21 +540,12 @@ void DiveTripModelBase::currentChanged()
|
|||
QModelIndex oldIdx = diveToIdx(oldCurrent);
|
||||
dataChanged(oldIdx, oldIdx, roles);
|
||||
}
|
||||
if (current_dive && oldCurrent != current_dive) {
|
||||
QModelIndex newIdx = diveToIdx(current_dive);
|
||||
if (currentDive && oldCurrent != currentDive) {
|
||||
QModelIndex newIdx = diveToIdx(currentDive);
|
||||
dataChanged(newIdx, newIdx, roles);
|
||||
}
|
||||
#else
|
||||
if (oldCurrent == current_dive)
|
||||
return;
|
||||
if (current_dive) {
|
||||
QModelIndex newIdx = diveToIdx(current_dive);
|
||||
emit currentDiveChanged(newIdx);
|
||||
} else {
|
||||
emit currentDiveChanged(QModelIndex());
|
||||
}
|
||||
#endif
|
||||
oldCurrent = current_dive;
|
||||
oldCurrent = currentDive;
|
||||
}
|
||||
|
||||
// Find a range of matching elements in a vector.
|
||||
|
@ -1378,7 +1369,7 @@ QModelIndex DiveTripModelTree::diveToIdx(const dive *d) const
|
|||
}
|
||||
}
|
||||
|
||||
void DiveTripModelTree::divesSelected(const QVector<dive *> &divesIn)
|
||||
void DiveTripModelTree::divesSelected(const QVector<dive *> &divesIn, dive *currentDive)
|
||||
{
|
||||
QVector <dive *> dives = visibleDives(divesIn);
|
||||
|
||||
|
@ -1390,10 +1381,10 @@ void DiveTripModelTree::divesSelected(const QVector<dive *> &divesIn)
|
|||
processByTrip(dives, [this, &indices] (dive_trip *trip, const QVector<dive *> &divesInTrip)
|
||||
{ divesSelectedTrip(trip, divesInTrip, indices); });
|
||||
|
||||
emit selectionChanged(indices);
|
||||
emit selectionChanged(indices, diveToIdx(currentDive));
|
||||
|
||||
// The current dive has changed. Transform the current dive into an index and pass it on to the view.
|
||||
currentChanged();
|
||||
currentChanged(currentDive);
|
||||
}
|
||||
|
||||
void DiveTripModelTree::divesSelectedTrip(dive_trip *trip, const QVector<dive *> &dives, QVector<QModelIndex> &indices)
|
||||
|
@ -1648,7 +1639,7 @@ QModelIndex DiveTripModelList::diveToIdx(const dive *d) const
|
|||
return createIndex(it - items.begin(), 0);
|
||||
}
|
||||
|
||||
void DiveTripModelList::divesSelected(const QVector<dive *> &divesIn)
|
||||
void DiveTripModelList::divesSelected(const QVector<dive *> &divesIn, dive *currentDive)
|
||||
{
|
||||
QVector<dive *> dives = visibleDives(divesIn);
|
||||
|
||||
|
@ -1668,10 +1659,10 @@ void DiveTripModelList::divesSelected(const QVector<dive *> &divesIn)
|
|||
indices.append(createIndex(j, 0, noParent));
|
||||
}
|
||||
|
||||
emit selectionChanged(indices);
|
||||
emit selectionChanged(indices, diveToIdx(currentDive));
|
||||
|
||||
// The current dive has changed. Transform the current dive into an index and pass it on to the view.
|
||||
currentChanged();
|
||||
currentChanged(currentDive);
|
||||
}
|
||||
|
||||
// Simple sorting helper for sorting against a criterium and if
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue