From 5c8f7d410cd46c399667028fa7a605ca35911153 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 21 May 2021 16:38:08 -0500 Subject: [PATCH] refactor: qt deprecations, pt 1 (#1707) * refactor: use QMultiMap in DetailsDialog::onRemoveTrackerClicked() * refactor: use 'QWindowFlags = {}' in BaseDialog Fixes deprecated use: > ../qt/BaseDialog.h:16:59: warning: 'QFlags' is deprecated: Use default constructor instead [-Wdeprecated-declarations] * refactor: remove empty string in string_view ctor Fixes readability-redundant-string-init warning: > ../qt/Prefs.cc:379:20: error: redundant string initialization [readability-redundant-string-init,-warnings-as-errors] > auto constexpr SessionUsername = std::string_view { "" }; > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- qt/BaseDialog.h | 2 +- qt/DetailsDialog.cc | 4 ++-- qt/Prefs.cc | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/qt/BaseDialog.h b/qt/BaseDialog.h index d719d1cea..30c1e65bf 100644 --- a/qt/BaseDialog.h +++ b/qt/BaseDialog.h @@ -13,7 +13,7 @@ class BaseDialog : public QDialog { public: - BaseDialog(QWidget* parent = nullptr, Qt::WindowFlags flags = 0) : + BaseDialog(QWidget* parent = nullptr, Qt::WindowFlags flags = {}) : QDialog(parent, flags) { setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); diff --git a/qt/DetailsDialog.cc b/qt/DetailsDialog.cc index faa88e3a3..2c37e2a12 100644 --- a/qt/DetailsDialog.cc +++ b/qt/DetailsDialog.cc @@ -1368,12 +1368,12 @@ void DetailsDialog::onRemoveTrackerClicked() // make a map of torrentIds to announce URLs to remove QItemSelectionModel* selection_model = ui_.trackersView->selectionModel(); QModelIndexList selected_rows = selection_model->selectedRows(); - QMap torrent_id_to_tracker_ids; + QMultiMap torrent_id_to_tracker_ids; for (QModelIndex const& i : selected_rows) { auto const inf = ui_.trackersView->model()->data(i, TrackerModel::TrackerRole).value(); - torrent_id_to_tracker_ids.insertMulti(inf.torrent_id, inf.st.id); + torrent_id_to_tracker_ids.insert(inf.torrent_id, inf.st.id); } // batch all of a tracker's torrents into one command diff --git a/qt/Prefs.cc b/qt/Prefs.cc index b364b19da..1f1345fa6 100644 --- a/qt/Prefs.cc +++ b/qt/Prefs.cc @@ -375,8 +375,8 @@ void Prefs::initDefaults(tr_variant* d) const { auto constexpr FilterMode = std::string_view { "all" }; auto constexpr SessionHost = std::string_view { "localhost" }; - auto constexpr SessionPassword = std::string_view { "" }; - auto constexpr SessionUsername = std::string_view { "" }; + auto constexpr SessionPassword = std::string_view {}; + auto constexpr SessionUsername = std::string_view {}; auto constexpr SortMode = std::string_view { "sort-by-name" }; auto constexpr SoundCommand = std::string_view { "canberra-gtk-play -i complete-download -d 'transmission torrent downloaded'" };