From 908da778632579433da33a6c0aa452550d38905e Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 4 Sep 2022 08:21:48 +0200 Subject: [PATCH] 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 --- desktop-widgets/divelistview.cpp | 4 ++-- desktop-widgets/divelistview.h | 2 +- qt-models/divetripmodel.cpp | 14 +++++++------- qt-models/divetripmodel.h | 6 +++--- qt-models/filtermodels.cpp | 6 +++--- qt-models/filtermodels.h | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index 29ffc2b0c..ff8abb1df 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -39,7 +39,7 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), setItemDelegateForColumn(DiveTripModelBase::RATING, new StarWidgetsDelegate(this)); MultiFilterSortModel *m = MultiFilterSortModel::instance(); setModel(m); - connect(m, &MultiFilterSortModel::selectionChanged, this, &DiveListView::diveSelectionChanged); + connect(m, &MultiFilterSortModel::divesSelected, this, &DiveListView::divesSelectedSlot); connect(m, &MultiFilterSortModel::tripSelected, this, &DiveListView::tripSelected); connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &DiveListView::settingsChanged); @@ -225,7 +225,7 @@ void DiveListView::reset() } // If items were selected, inform the selection model -void DiveListView::diveSelectionChanged(const QVector &indices, QModelIndex currentDive, int currentDC) +void DiveListView::divesSelectedSlot(const QVector &indices, QModelIndex currentDive, int currentDC) { // This is the entry point for programmatical selection changes. // Set a flag so that selection changes are not further processed, diff --git a/desktop-widgets/divelistview.h b/desktop-widgets/divelistview.h index 0590e2574..2d458b801 100644 --- a/desktop-widgets/divelistview.h +++ b/desktop-widgets/divelistview.h @@ -52,7 +52,7 @@ slots: void renumberDives(); void addDivesToTrip(); void shiftTimes(); - void diveSelectionChanged(const QVector &indices, QModelIndex currentDive, int currentDC); + void divesSelectedSlot(const QVector &indices, QModelIndex currentDive, int currentDC); void tripSelected(QModelIndex trip, QModelIndex currentDive); private: void rowsInserted(const QModelIndex &parent, int start, int end) override; diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp index 913193798..d1631e4b0 100644 --- a/qt-models/divetripmodel.cpp +++ b/qt-models/divetripmodel.cpp @@ -682,7 +682,7 @@ DiveTripModelTree::DiveTripModelTree(QObject *parent) : DiveTripModelBase(parent connect(&diveListNotifier, &DiveListNotifier::diveSiteChanged, this, &DiveTripModelTree::diveSiteChanged); connect(&diveListNotifier, &DiveListNotifier::divesMovedBetweenTrips, this, &DiveTripModelTree::divesMovedBetweenTrips); 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::tripChanged, this, &DiveTripModelTree::tripChanged); connect(&diveListNotifier, &DiveListNotifier::filterReset, this, &DiveTripModelTree::filterReset); @@ -1370,7 +1370,7 @@ QModelIndex DiveTripModelTree::diveToIdx(const dive *d) const } } -void DiveTripModelTree::divesSelected(const QVector &divesIn, dive *currentDive, int currentDC) +void DiveTripModelTree::divesSelectedSlot(const QVector &divesIn, dive *currentDive, int currentDC) { QVector dives = visibleDives(divesIn); @@ -1382,7 +1382,7 @@ void DiveTripModelTree::divesSelected(const QVector &divesIn, dive *curr processByTrip(dives, [this, &indices] (dive_trip *trip, const QVector &divesInTrip) { 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. currentChanged(currentDive); @@ -1463,7 +1463,7 @@ DiveTripModelList::DiveTripModelList(QObject *parent) : DiveTripModelBase(parent // Does nothing in list-view //connect(&diveListNotifier, &DiveListNotifier::divesMovedBetweenTrips, this, &DiveTripModelList::divesMovedBetweenTrips); 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::filterReset, this, &DiveTripModelList::filterReset); connect(&diveListNotifier, &DiveListNotifier::cylinderAdded, this, &DiveTripModelList::diveChanged); @@ -1659,7 +1659,7 @@ QModelIndex DiveTripModelList::diveToIdx(const dive *d) const return createIndex(it - items.begin(), 0); } -void DiveTripModelList::divesSelected(const QVector &divesIn, dive *currentDive, int currentDC) +void DiveTripModelList::divesSelectedSlot(const QVector &divesIn, dive *currentDive, int currentDC) { QVector dives = visibleDives(divesIn); @@ -1679,7 +1679,7 @@ void DiveTripModelList::divesSelected(const QVector &divesIn, dive *curr 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. currentChanged(currentDive); @@ -1697,7 +1697,7 @@ void DiveTripModelList::tripSelected(dive_trip *trip, dive *currentDive) for (int i = 0; i < trip->dives.nr; ++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 diff --git a/qt-models/divetripmodel.h b/qt-models/divetripmodel.h index d9899c2db..2fc55a510 100644 --- a/qt-models/divetripmodel.h +++ b/qt-models/divetripmodel.h @@ -84,7 +84,7 @@ signals: // 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 // perform the appropriate actions. - void selectionChanged(const QVector &indices, QModelIndex currentDive, int currentDC); + void divesSelected(const QVector &indices, QModelIndex currentDive, int currentDC); void tripSelected(QModelIndex trip, QModelIndex currentDive); protected: dive *oldCurrent; @@ -116,7 +116,7 @@ public slots: void divesChanged(const QVector &dives); void diveChanged(dive *d); void divesTimeChanged(timestamp_t delta, const QVector &dives); - void divesSelected(const QVector &dives, dive *currentDive, int currentDC); + void divesSelectedSlot(const QVector &dives, dive *currentDive, int currentDC); void tripSelected(dive_trip *trip, dive *currentDive); void tripChanged(dive_trip *trip, TripField); void filterReset(); @@ -195,7 +195,7 @@ public slots: void divesTimeChanged(timestamp_t delta, const QVector &dives); // Does nothing in list view. //void divesMovedBetweenTrips(dive_trip *from, dive_trip *to, bool deleteFrom, bool createTo, const QVector &dives); - void divesSelected(const QVector &dives, dive *currentDive, int currentDC); + void divesSelectedSlot(const QVector &dives, dive *currentDive, int currentDC); void tripSelected(dive_trip *trip, dive *currentDive); void filterReset(); diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp index 74340939c..c4bcdeaf9 100644 --- a/qt-models/filtermodels.cpp +++ b/qt-models/filtermodels.cpp @@ -26,14 +26,14 @@ void MultiFilterSortModel::resetModel(DiveTripModelBase::Layout layout) model.reset(new DiveTripModelList); 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); model->initSelection(); LocationInformationModel::instance()->update(); } // Translate selection into local indices and re-emit signal -void MultiFilterSortModel::selectionChangedSlot(const QVector &indices, QModelIndex currentDive, int currentDC) +void MultiFilterSortModel::divesSelectedSlot(const QVector &indices, QModelIndex currentDive, int currentDC) { QVector indicesLocal; indicesLocal.reserve(indices.size()); @@ -43,7 +43,7 @@ void MultiFilterSortModel::selectionChangedSlot(const QVector &indi 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 diff --git a/qt-models/filtermodels.h b/qt-models/filtermodels.h index 5c87fad3e..bae29932b 100644 --- a/qt-models/filtermodels.h +++ b/qt-models/filtermodels.h @@ -18,10 +18,10 @@ public: void resetModel(DiveTripModelBase::Layout layout); signals: - void selectionChanged(const QVector &indices, QModelIndex currentDive, int currentDC); + void divesSelected(const QVector &indices, QModelIndex currentDive, int currentDC); void tripSelected(QModelIndex trip, QModelIndex currentDive); private slots: - void selectionChangedSlot(const QVector &indices, QModelIndex currentDive, int currentDC); + void divesSelectedSlot(const QVector &indices, QModelIndex currentDive, int currentDC); void tripSelectedSlot(QModelIndex trip, QModelIndex currentDive); private: MultiFilterSortModel(QObject *parent = 0);