selection: rename selectionChanged() to divesSelected()

The signals/slot names for dive selection changes were a mess.
Unify on divesSelected(). Firstly, selectionChanged() is a Qt
thing. Secondly, it is consistent with tripSelected().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2022-09-04 08:21:48 +02:00 committed by bstoeger
parent de2c4d93e0
commit 908da77863
6 changed files with 18 additions and 18 deletions

View file

@ -39,7 +39,7 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent),
setItemDelegateForColumn(DiveTripModelBase::RATING, new StarWidgetsDelegate(this)); setItemDelegateForColumn(DiveTripModelBase::RATING, new StarWidgetsDelegate(this));
MultiFilterSortModel *m = MultiFilterSortModel::instance(); MultiFilterSortModel *m = MultiFilterSortModel::instance();
setModel(m); setModel(m);
connect(m, &MultiFilterSortModel::selectionChanged, this, &DiveListView::diveSelectionChanged); connect(m, &MultiFilterSortModel::divesSelected, this, &DiveListView::divesSelectedSlot);
connect(m, &MultiFilterSortModel::tripSelected, this, &DiveListView::tripSelected); connect(m, &MultiFilterSortModel::tripSelected, this, &DiveListView::tripSelected);
connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &DiveListView::settingsChanged); connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &DiveListView::settingsChanged);
@ -225,7 +225,7 @@ void DiveListView::reset()
} }
// If items were selected, inform the selection model // If items were selected, inform the selection model
void DiveListView::diveSelectionChanged(const QVector<QModelIndex> &indices, QModelIndex currentDive, int currentDC) void DiveListView::divesSelectedSlot(const QVector<QModelIndex> &indices, QModelIndex currentDive, int currentDC)
{ {
// This is the entry point for programmatical selection changes. // This is the entry point for programmatical selection changes.
// Set a flag so that selection changes are not further processed, // Set a flag so that selection changes are not further processed,

View file

@ -52,7 +52,7 @@ slots:
void renumberDives(); void renumberDives();
void addDivesToTrip(); void addDivesToTrip();
void shiftTimes(); void shiftTimes();
void diveSelectionChanged(const QVector<QModelIndex> &indices, QModelIndex currentDive, int currentDC); void divesSelectedSlot(const QVector<QModelIndex> &indices, QModelIndex currentDive, int currentDC);
void tripSelected(QModelIndex trip, QModelIndex currentDive); void tripSelected(QModelIndex trip, QModelIndex currentDive);
private: private:
void rowsInserted(const QModelIndex &parent, int start, int end) override; void rowsInserted(const QModelIndex &parent, int start, int end) override;

View file

@ -682,7 +682,7 @@ DiveTripModelTree::DiveTripModelTree(QObject *parent) : DiveTripModelBase(parent
connect(&diveListNotifier, &DiveListNotifier::diveSiteChanged, this, &DiveTripModelTree::diveSiteChanged); connect(&diveListNotifier, &DiveListNotifier::diveSiteChanged, this, &DiveTripModelTree::diveSiteChanged);
connect(&diveListNotifier, &DiveListNotifier::divesMovedBetweenTrips, this, &DiveTripModelTree::divesMovedBetweenTrips); connect(&diveListNotifier, &DiveListNotifier::divesMovedBetweenTrips, this, &DiveTripModelTree::divesMovedBetweenTrips);
connect(&diveListNotifier, &DiveListNotifier::divesTimeChanged, this, &DiveTripModelTree::divesTimeChanged); connect(&diveListNotifier, &DiveListNotifier::divesTimeChanged, this, &DiveTripModelTree::divesTimeChanged);
connect(&diveListNotifier, &DiveListNotifier::divesSelected, this, &DiveTripModelTree::divesSelected); connect(&diveListNotifier, &DiveListNotifier::divesSelected, this, &DiveTripModelTree::divesSelectedSlot);
connect(&diveListNotifier, &DiveListNotifier::tripSelected, this, &DiveTripModelTree::tripSelected); connect(&diveListNotifier, &DiveListNotifier::tripSelected, this, &DiveTripModelTree::tripSelected);
connect(&diveListNotifier, &DiveListNotifier::tripChanged, this, &DiveTripModelTree::tripChanged); connect(&diveListNotifier, &DiveListNotifier::tripChanged, this, &DiveTripModelTree::tripChanged);
connect(&diveListNotifier, &DiveListNotifier::filterReset, this, &DiveTripModelTree::filterReset); connect(&diveListNotifier, &DiveListNotifier::filterReset, this, &DiveTripModelTree::filterReset);
@ -1370,7 +1370,7 @@ QModelIndex DiveTripModelTree::diveToIdx(const dive *d) const
} }
} }
void DiveTripModelTree::divesSelected(const QVector<dive *> &divesIn, dive *currentDive, int currentDC) void DiveTripModelTree::divesSelectedSlot(const QVector<dive *> &divesIn, dive *currentDive, int currentDC)
{ {
QVector <dive *> dives = visibleDives(divesIn); QVector <dive *> dives = visibleDives(divesIn);
@ -1382,7 +1382,7 @@ void DiveTripModelTree::divesSelected(const QVector<dive *> &divesIn, dive *curr
processByTrip(dives, [this, &indices] (dive_trip *trip, const QVector<dive *> &divesInTrip) processByTrip(dives, [this, &indices] (dive_trip *trip, const QVector<dive *> &divesInTrip)
{ divesSelectedTrip(trip, divesInTrip, indices); }); { divesSelectedTrip(trip, divesInTrip, indices); });
emit selectionChanged(indices, diveToIdx(currentDive), currentDC); emit divesSelected(indices, diveToIdx(currentDive), currentDC);
// The current dive has changed. Transform the current dive into an index and pass it on to the view. // The current dive has changed. Transform the current dive into an index and pass it on to the view.
currentChanged(currentDive); currentChanged(currentDive);
@ -1463,7 +1463,7 @@ DiveTripModelList::DiveTripModelList(QObject *parent) : DiveTripModelBase(parent
// Does nothing in list-view // Does nothing in list-view
//connect(&diveListNotifier, &DiveListNotifier::divesMovedBetweenTrips, this, &DiveTripModelList::divesMovedBetweenTrips); //connect(&diveListNotifier, &DiveListNotifier::divesMovedBetweenTrips, this, &DiveTripModelList::divesMovedBetweenTrips);
connect(&diveListNotifier, &DiveListNotifier::divesTimeChanged, this, &DiveTripModelList::divesTimeChanged); connect(&diveListNotifier, &DiveListNotifier::divesTimeChanged, this, &DiveTripModelList::divesTimeChanged);
connect(&diveListNotifier, &DiveListNotifier::divesSelected, this, &DiveTripModelList::divesSelected); connect(&diveListNotifier, &DiveListNotifier::divesSelected, this, &DiveTripModelList::divesSelectedSlot);
connect(&diveListNotifier, &DiveListNotifier::tripSelected, this, &DiveTripModelList::tripSelected); connect(&diveListNotifier, &DiveListNotifier::tripSelected, this, &DiveTripModelList::tripSelected);
connect(&diveListNotifier, &DiveListNotifier::filterReset, this, &DiveTripModelList::filterReset); connect(&diveListNotifier, &DiveListNotifier::filterReset, this, &DiveTripModelList::filterReset);
connect(&diveListNotifier, &DiveListNotifier::cylinderAdded, this, &DiveTripModelList::diveChanged); connect(&diveListNotifier, &DiveListNotifier::cylinderAdded, this, &DiveTripModelList::diveChanged);
@ -1659,7 +1659,7 @@ QModelIndex DiveTripModelList::diveToIdx(const dive *d) const
return createIndex(it - items.begin(), 0); return createIndex(it - items.begin(), 0);
} }
void DiveTripModelList::divesSelected(const QVector<dive *> &divesIn, dive *currentDive, int currentDC) void DiveTripModelList::divesSelectedSlot(const QVector<dive *> &divesIn, dive *currentDive, int currentDC)
{ {
QVector<dive *> dives = visibleDives(divesIn); QVector<dive *> dives = visibleDives(divesIn);
@ -1679,7 +1679,7 @@ void DiveTripModelList::divesSelected(const QVector<dive *> &divesIn, dive *curr
indices.append(createIndex(j, 0, noParent)); indices.append(createIndex(j, 0, noParent));
} }
emit selectionChanged(indices, diveToIdx(currentDive), currentDC); emit divesSelected(indices, diveToIdx(currentDive), currentDC);
// The current dive has changed. Transform the current dive into an index and pass it on to the view. // The current dive has changed. Transform the current dive into an index and pass it on to the view.
currentChanged(currentDive); currentChanged(currentDive);
@ -1697,7 +1697,7 @@ void DiveTripModelList::tripSelected(dive_trip *trip, dive *currentDive)
for (int i = 0; i < trip->dives.nr; ++i) for (int i = 0; i < trip->dives.nr; ++i)
dives.push_back(trip->dives.dives[i]); dives.push_back(trip->dives.dives[i]);
divesSelected(dives, currentDive, -1); divesSelectedSlot(dives, currentDive, -1);
} }
// Simple sorting helper for sorting against a criterium and if // Simple sorting helper for sorting against a criterium and if

View file

@ -84,7 +84,7 @@ signals:
// into QModelIndexes according to the current view (tree/list). Finally, the DiveListView transforms these // into QModelIndexes according to the current view (tree/list). Finally, the DiveListView transforms these
// indices into local indices according to current sorting/filtering and instructs the QSelectionModel to // indices into local indices according to current sorting/filtering and instructs the QSelectionModel to
// perform the appropriate actions. // perform the appropriate actions.
void selectionChanged(const QVector<QModelIndex> &indices, QModelIndex currentDive, int currentDC); void divesSelected(const QVector<QModelIndex> &indices, QModelIndex currentDive, int currentDC);
void tripSelected(QModelIndex trip, QModelIndex currentDive); void tripSelected(QModelIndex trip, QModelIndex currentDive);
protected: protected:
dive *oldCurrent; dive *oldCurrent;
@ -116,7 +116,7 @@ public slots:
void divesChanged(const QVector<dive *> &dives); void divesChanged(const QVector<dive *> &dives);
void diveChanged(dive *d); void diveChanged(dive *d);
void divesTimeChanged(timestamp_t delta, const QVector<dive *> &dives); void divesTimeChanged(timestamp_t delta, const QVector<dive *> &dives);
void divesSelected(const QVector<dive *> &dives, dive *currentDive, int currentDC); void divesSelectedSlot(const QVector<dive *> &dives, dive *currentDive, int currentDC);
void tripSelected(dive_trip *trip, dive *currentDive); void tripSelected(dive_trip *trip, dive *currentDive);
void tripChanged(dive_trip *trip, TripField); void tripChanged(dive_trip *trip, TripField);
void filterReset(); void filterReset();
@ -195,7 +195,7 @@ public slots:
void divesTimeChanged(timestamp_t delta, const QVector<dive *> &dives); void divesTimeChanged(timestamp_t delta, const QVector<dive *> &dives);
// Does nothing in list view. // Does nothing in list view.
//void divesMovedBetweenTrips(dive_trip *from, dive_trip *to, bool deleteFrom, bool createTo, const QVector<dive *> &dives); //void divesMovedBetweenTrips(dive_trip *from, dive_trip *to, bool deleteFrom, bool createTo, const QVector<dive *> &dives);
void divesSelected(const QVector<dive *> &dives, dive *currentDive, int currentDC); void divesSelectedSlot(const QVector<dive *> &dives, dive *currentDive, int currentDC);
void tripSelected(dive_trip *trip, dive *currentDive); void tripSelected(dive_trip *trip, dive *currentDive);
void filterReset(); void filterReset();

View file

@ -26,14 +26,14 @@ void MultiFilterSortModel::resetModel(DiveTripModelBase::Layout layout)
model.reset(new DiveTripModelList); model.reset(new DiveTripModelList);
setSourceModel(model.get()); setSourceModel(model.get());
connect(model.get(), &DiveTripModelBase::selectionChanged, this, &MultiFilterSortModel::selectionChangedSlot); connect(model.get(), &DiveTripModelBase::divesSelected, this, &MultiFilterSortModel::divesSelectedSlot);
connect(model.get(), &DiveTripModelBase::tripSelected, this, &MultiFilterSortModel::tripSelectedSlot); connect(model.get(), &DiveTripModelBase::tripSelected, this, &MultiFilterSortModel::tripSelectedSlot);
model->initSelection(); model->initSelection();
LocationInformationModel::instance()->update(); LocationInformationModel::instance()->update();
} }
// Translate selection into local indices and re-emit signal // Translate selection into local indices and re-emit signal
void MultiFilterSortModel::selectionChangedSlot(const QVector<QModelIndex> &indices, QModelIndex currentDive, int currentDC) void MultiFilterSortModel::divesSelectedSlot(const QVector<QModelIndex> &indices, QModelIndex currentDive, int currentDC)
{ {
QVector<QModelIndex> indicesLocal; QVector<QModelIndex> indicesLocal;
indicesLocal.reserve(indices.size()); indicesLocal.reserve(indices.size());
@ -43,7 +43,7 @@ void MultiFilterSortModel::selectionChangedSlot(const QVector<QModelIndex> &indi
indicesLocal.push_back(local); indicesLocal.push_back(local);
} }
emit selectionChanged(indicesLocal, mapFromSource(currentDive), currentDC); emit divesSelected(indicesLocal, mapFromSource(currentDive), currentDC);
} }
// Translate selection into local indices and re-emit signal // Translate selection into local indices and re-emit signal

View file

@ -18,10 +18,10 @@ public:
void resetModel(DiveTripModelBase::Layout layout); void resetModel(DiveTripModelBase::Layout layout);
signals: signals:
void selectionChanged(const QVector<QModelIndex> &indices, QModelIndex currentDive, int currentDC); void divesSelected(const QVector<QModelIndex> &indices, QModelIndex currentDive, int currentDC);
void tripSelected(QModelIndex trip, QModelIndex currentDive); void tripSelected(QModelIndex trip, QModelIndex currentDive);
private slots: private slots:
void selectionChangedSlot(const QVector<QModelIndex> &indices, QModelIndex currentDive, int currentDC); void divesSelectedSlot(const QVector<QModelIndex> &indices, QModelIndex currentDive, int currentDC);
void tripSelectedSlot(QModelIndex trip, QModelIndex currentDive); void tripSelectedSlot(QModelIndex trip, QModelIndex currentDive);
private: private:
MultiFilterSortModel(QObject *parent = 0); MultiFilterSortModel(QObject *parent = 0);