From 314d8a645b740b1adc2358501e7f1e391dbbd08d Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sun, 25 Nov 2018 22:13:15 +0000 Subject: [PATCH] Replace deprecated Qt algorithms with C++ Standard Library equivalents --- Configuration.cpp | 8 ++++---- models/FrequencyList.cpp | 14 +++++--------- models/StationList.cpp | 13 ++++--------- widgets/mainwindow.cpp | 5 +++-- 4 files changed, 16 insertions(+), 24 deletions(-) diff --git a/Configuration.cpp b/Configuration.cpp index a75cacc68..bf57206b2 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -2279,10 +2279,10 @@ void Configuration::impl::delete_selected_macros (QModelIndexList selected_rows) { // sort in reverse row order so that we can delete without changing // indices underneath us - qSort (selected_rows.begin (), selected_rows.end (), [] (QModelIndex const& lhs, QModelIndex const& rhs) - { - return rhs.row () < lhs.row (); // reverse row ordering - }); + std::sort (selected_rows.begin (), selected_rows.end (), [] (QModelIndex const& lhs, QModelIndex const& rhs) + { + return rhs.row () < lhs.row (); // reverse row ordering + }); // now delete them Q_FOREACH (auto index, selected_rows) diff --git a/models/FrequencyList.cpp b/models/FrequencyList.cpp index e50afe2a4..55844bdfa 100644 --- a/models/FrequencyList.cpp +++ b/models/FrequencyList.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -350,14 +351,6 @@ bool FrequencyList_v2::remove (Item f) return m_->removeRow (row); } -namespace -{ - bool row_is_higher (QModelIndex const& lhs, QModelIndex const& rhs) - { - return lhs.row () > rhs.row (); - } -} - bool FrequencyList_v2::removeDisjointRows (QModelIndexList rows) { bool result {true}; @@ -371,7 +364,10 @@ bool FrequencyList_v2::removeDisjointRows (QModelIndexList rows) } // reverse sort by row - qSort (rows.begin (), rows.end (), row_is_higher); + std::sort (rows.begin (), rows.end (), [] (QModelIndex const& lhs, QModelIndex const& rhs) + { + return rhs.row () < lhs.row (); // reverse row ordering + }); Q_FOREACH (auto index, rows) { if (result && !m_->removeRow (index.row ())) diff --git a/models/StationList.cpp b/models/StationList.cpp index cfd629ede..eeeb4d607 100644 --- a/models/StationList.cpp +++ b/models/StationList.cpp @@ -139,14 +139,6 @@ bool StationList::remove (Station s) return removeRow (row); } -namespace -{ - bool row_is_higher (QModelIndex const& lhs, QModelIndex const& rhs) - { - return lhs.row () > rhs.row (); - } -} - bool StationList::removeDisjointRows (QModelIndexList rows) { bool result {true}; @@ -160,7 +152,10 @@ bool StationList::removeDisjointRows (QModelIndexList rows) } // reverse sort by row - qSort (rows.begin (), rows.end (), row_is_higher); + std::sort (rows.begin (), rows.end (), [] (QModelIndex const& lhs, QModelIndex const& rhs) + { + return rhs.row () < lhs.row (); // reverse row ordering + }); Q_FOREACH (auto index, rows) { if (result && !m_->removeRow (index.row ())) diff --git a/widgets/mainwindow.cpp b/widgets/mainwindow.cpp index e0788a8f9..895569942 100644 --- a/widgets/mainwindow.cpp +++ b/widgets/mainwindow.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -7923,9 +7924,9 @@ QString MainWindow::sortHoundCalls(QString t, int isort, int max_dB) if(isort>1) { if(bReverse) { - qSort(list.begin(),list.end(),qGreater()); + std::sort (list.begin (), list.end (), std::greater ()); } else { - qSort(list.begin(),list.end()); + std::sort (list.begin (), list.end ()); } }