From 7ab3479a343067c991c380d8a7d943d28714181d Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 25 Jul 2019 01:41:09 +0800 Subject: [PATCH] Replace static_cast by qOverload --- src/base/bittorrent/session.cpp | 2 +- src/base/net/smtp.cpp | 2 +- src/gui/addnewtorrentdialog.cpp | 2 +- src/gui/advancedsettings.cpp | 6 +++--- src/gui/mainwindow.cpp | 26 ++++++++++++------------- src/gui/optionsdialog.cpp | 2 +- src/gui/properties/propertieswidget.cpp | 2 +- src/gui/properties/proptabbar.cpp | 2 +- src/gui/properties/speedwidget.cpp | 2 +- src/gui/rss/automatedrssdownloader.cpp | 2 +- src/gui/scanfoldersdelegate.cpp | 2 +- src/gui/search/searchjobwidget.cpp | 14 ++++++------- src/gui/search/searchwidget.cpp | 4 ++-- src/gui/speedlimitdialog.cpp | 2 +- src/gui/transferlistfilterswidget.cpp | 7 +++---- src/gui/updownratiodialog.cpp | 2 +- 16 files changed, 39 insertions(+), 40 deletions(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 1e32ac752..b23ea3d57 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -3570,7 +3570,7 @@ void Session::configureDeferred() if (!m_deferredConfigureScheduled) { #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) QMetaObject::invokeMethod(this - , static_cast(&Session::configure) + , qOverload<>(&Session::configure) , Qt::QueuedConnection); #else QMetaObject::invokeMethod(this, "configure", Qt::QueuedConnection); diff --git a/src/base/net/smtp.cpp b/src/base/net/smtp.cpp index 1e009069a..444f12f53 100644 --- a/src/base/net/smtp.cpp +++ b/src/base/net/smtp.cpp @@ -113,7 +113,7 @@ Smtp::Smtp(QObject *parent) connect(m_socket, &QIODevice::readyRead, this, &Smtp::readyRead); connect(m_socket, &QAbstractSocket::disconnected, this, &QObject::deleteLater); - connect(m_socket, static_cast(&QAbstractSocket::error) + connect(m_socket, qOverload(&QAbstractSocket::error) , this, &Smtp::error); // Test hmacMD5 function (http://www.faqs.org/rfcs/rfc2202.html) diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index eb5a02a3b..00a0d1ffc 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -612,7 +612,7 @@ void AddNewTorrentDialog::setupTreeview() m_contentDelegate = new PropListDelegate(nullptr); m_ui->contentTreeView->setItemDelegate(m_contentDelegate); connect(m_ui->contentTreeView, &QAbstractItemView::clicked, m_ui->contentTreeView - , static_cast(&QAbstractItemView::edit)); + , qOverload(&QAbstractItemView::edit)); connect(m_ui->contentTreeView, &QWidget::customContextMenuRequested, this, &AddNewTorrentDialog::displayContentTreeMenu); // List files in torrent diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index c2d78fd46..58e2ccb4c 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -137,11 +137,11 @@ AdvancedSettings::AdvancedSettings(QWidget *parent) setSelectionMode(QAbstractItemView::NoSelection); setEditTriggers(QAbstractItemView::NoEditTriggers); // Signals - connect(&m_spinBoxCache, static_cast(&QSpinBox::valueChanged) + connect(&m_spinBoxCache, qOverload(&QSpinBox::valueChanged) , this, &AdvancedSettings::updateCacheSpinSuffix); - connect(&m_comboBoxInterface, static_cast(&QComboBox::currentIndexChanged) + connect(&m_comboBoxInterface, qOverload(&QComboBox::currentIndexChanged) , this, &AdvancedSettings::updateInterfaceAddressCombo); - connect(&m_spinBoxSaveResumeDataInterval, static_cast(&QSpinBox::valueChanged) + connect(&m_spinBoxSaveResumeDataInterval, qOverload(&QSpinBox::valueChanged) , this, &AdvancedSettings::updateSaveResumeDataIntervalSuffix); // Load settings loadAdvancedSettings(); diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 1fe353c81..1275c6116 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -253,10 +253,12 @@ MainWindow::MainWindow(QWidget *parent) connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackersRemoved, m_transferListFiltersWidget, &TransferListFiltersWidget::removeTrackers); connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerlessStateChanged, m_transferListFiltersWidget, &TransferListFiltersWidget::changeTrackerless); - using Func = void (TransferListFiltersWidget::*)(BitTorrent::TorrentHandle *const, const QString &); - connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerSuccess, m_transferListFiltersWidget, static_cast(&TransferListFiltersWidget::trackerSuccess)); - connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerError, m_transferListFiltersWidget, static_cast(&TransferListFiltersWidget::trackerError)); - connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerWarning, m_transferListFiltersWidget, static_cast(&TransferListFiltersWidget::trackerWarning)); + connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerSuccess + , m_transferListFiltersWidget, qOverload(&TransferListFiltersWidget::trackerSuccess)); + connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerError + , m_transferListFiltersWidget, qOverload(&TransferListFiltersWidget::trackerError)); + connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerWarning + , m_transferListFiltersWidget, qOverload(&TransferListFiltersWidget::trackerWarning)); #ifdef Q_OS_MAC // Increase top spacing to avoid tab overlapping @@ -856,17 +858,15 @@ void MainWindow::createKeyboardShortcuts() m_ui->actionCloseWindow->setVisible(false); #endif - QShortcut *switchTransferShortcut = new QShortcut(Qt::ALT + Qt::Key_1, this); + const auto *switchTransferShortcut = new QShortcut(Qt::ALT + Qt::Key_1, this); connect(switchTransferShortcut, &QShortcut::activated, this, &MainWindow::displayTransferTab); - - using Func = void (MainWindow::*)(); - QShortcut *switchSearchShortcut = new QShortcut(Qt::ALT + Qt::Key_2, this); - connect(switchSearchShortcut, &QShortcut::activated, this, static_cast(&MainWindow::displaySearchTab)); - QShortcut *switchRSSShortcut = new QShortcut(Qt::ALT + Qt::Key_3, this); - connect(switchRSSShortcut, &QShortcut::activated, this, static_cast(&MainWindow::displayRSSTab)); - QShortcut *switchExecutionLogShortcut = new QShortcut(Qt::ALT + Qt::Key_4, this); + const auto *switchSearchShortcut = new QShortcut(Qt::ALT + Qt::Key_2, this); + connect(switchSearchShortcut, &QShortcut::activated, this, qOverload<>(&MainWindow::displaySearchTab)); + const auto *switchRSSShortcut = new QShortcut(Qt::ALT + Qt::Key_3, this); + connect(switchRSSShortcut, &QShortcut::activated, this, qOverload<>(&MainWindow::displayRSSTab)); + const auto *switchExecutionLogShortcut = new QShortcut(Qt::ALT + Qt::Key_4, this); connect(switchExecutionLogShortcut, &QShortcut::activated, this, &MainWindow::displayExecutionLogTab); - QShortcut *switchSearchFilterShortcut = new QShortcut(QKeySequence::Find, m_transferListWidget); + const auto *switchSearchFilterShortcut = new QShortcut(QKeySequence::Find, m_transferListWidget); connect(switchSearchFilterShortcut, &QShortcut::activated, this, &MainWindow::focusSearchFilter); m_ui->actionDocumentation->setShortcut(QKeySequence::HelpContents); diff --git a/src/gui/optionsdialog.cpp b/src/gui/optionsdialog.cpp index 232d102c6..aaaf01e16 100644 --- a/src/gui/optionsdialog.cpp +++ b/src/gui/optionsdialog.cpp @@ -341,7 +341,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) connect(m_ui->comboEncryption, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton); connect(m_ui->checkMaxRatio, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->checkMaxRatio, &QAbstractButton::toggled, this, &ThisType::toggleComboRatioLimitAct); - connect(m_ui->spinMaxRatio, static_cast(&QDoubleSpinBox::valueChanged), + connect(m_ui->spinMaxRatio, qOverload(&QDoubleSpinBox::valueChanged), this, &ThisType::enableApplyButton); connect(m_ui->comboRatioLimitAct, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton); connect(m_ui->checkMaxSeedingMinutes, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index 87c28d93f..0757c429e 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -97,7 +97,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent) // SIGNAL/SLOTS connect(m_ui->filesList, &QAbstractItemView::clicked - , m_ui->filesList, static_cast(&QAbstractItemView::edit)); + , m_ui->filesList, qOverload(&QAbstractItemView::edit)); connect(m_ui->selectAllButton, &QPushButton::clicked, m_propListModel, &TorrentContentFilterModel::selectAll); connect(m_ui->selectNoneButton, &QPushButton::clicked, m_propListModel, &TorrentContentFilterModel::selectNone); connect(m_ui->filesList, &QWidget::customContextMenuRequested, this, &PropertiesWidget::displayFilesListMenu); diff --git a/src/gui/properties/proptabbar.cpp b/src/gui/properties/proptabbar.cpp index 150799425..67bbf9137 100644 --- a/src/gui/properties/proptabbar.cpp +++ b/src/gui/properties/proptabbar.cpp @@ -100,7 +100,7 @@ PropTabBar::PropTabBar(QWidget *parent) addWidget(speedButton); m_btnGroup->addButton(speedButton, SpeedTab); // SIGNAL/SLOT - connect(m_btnGroup, static_cast(&QButtonGroup::buttonClicked) + connect(m_btnGroup, qOverload(&QButtonGroup::buttonClicked) , this, &PropTabBar::setCurrentIndex); // Disable buttons focus for (QAbstractButton *btn : asConst(m_btnGroup->buttons())) diff --git a/src/gui/properties/speedwidget.cpp b/src/gui/properties/speedwidget.cpp index 761cb17ee..804a35bc4 100644 --- a/src/gui/properties/speedwidget.cpp +++ b/src/gui/properties/speedwidget.cpp @@ -75,7 +75,7 @@ SpeedWidget::SpeedWidget(PropertiesWidget *parent) m_periodCombobox->addItem(tr("12 Hours")); m_periodCombobox->addItem(tr("24 Hours")); - connect(m_periodCombobox, static_cast(&QComboBox::currentIndexChanged) + connect(m_periodCombobox, qOverload(&QComboBox::currentIndexChanged) , this, &SpeedWidget::onPeriodChange); m_graphsMenu = new QMenu(this); diff --git a/src/gui/rss/automatedrssdownloader.cpp b/src/gui/rss/automatedrssdownloader.cpp index 5e173f757..8bd505e8f 100644 --- a/src/gui/rss/automatedrssdownloader.cpp +++ b/src/gui/rss/automatedrssdownloader.cpp @@ -113,7 +113,7 @@ AutomatedRssDownloader::AutomatedRssDownloader(QWidget *parent) connect(m_ui->checkRegex, &QCheckBox::stateChanged, this, &AutomatedRssDownloader::updateMustLineValidity); connect(m_ui->checkRegex, &QCheckBox::stateChanged, this, &AutomatedRssDownloader::updateMustNotLineValidity); connect(m_ui->checkSmart, &QCheckBox::stateChanged, this, &AutomatedRssDownloader::handleRuleDefinitionChanged); - connect(m_ui->spinIgnorePeriod, static_cast(&QSpinBox::valueChanged) + connect(m_ui->spinIgnorePeriod, qOverload(&QSpinBox::valueChanged) , this, &AutomatedRssDownloader::handleRuleDefinitionChanged); connect(m_ui->listFeeds, &QListWidget::itemChanged, this, &AutomatedRssDownloader::handleFeedCheckStateChange); diff --git a/src/gui/scanfoldersdelegate.cpp b/src/gui/scanfoldersdelegate.cpp index 344a6e675..136df25c2 100644 --- a/src/gui/scanfoldersdelegate.cpp +++ b/src/gui/scanfoldersdelegate.cpp @@ -67,7 +67,7 @@ QWidget *ScanFoldersDelegate::createEditor(QWidget *parent, const QStyleOptionVi editor->addItem(index.data().toString()); } - connect(editor, static_cast(&QComboBox::currentIndexChanged) + connect(editor, qOverload(&QComboBox::currentIndexChanged) , this, &ScanFoldersDelegate::comboboxIndexChanged); return editor; } diff --git a/src/gui/search/searchjobwidget.cpp b/src/gui/search/searchjobwidget.cpp index 9378751f5..fdc1f566b 100644 --- a/src/gui/search/searchjobwidget.cpp +++ b/src/gui/search/searchjobwidget.cpp @@ -135,23 +135,23 @@ SearchJobWidget::SearchJobWidget(SearchHandler *searchHandler, QWidget *parent) m_ui->horizontalLayout->insertWidget(0, m_lineEditSearchResultsFilter); connect(m_lineEditSearchResultsFilter, &LineEdit::textChanged, this, &SearchJobWidget::filterSearchResults); - connect(m_ui->filterMode, static_cast(&QComboBox::currentIndexChanged) + connect(m_ui->filterMode, qOverload(&QComboBox::currentIndexChanged) , this, &SearchJobWidget::updateFilter); connect(m_ui->minSeeds, &QAbstractSpinBox::editingFinished, this, &SearchJobWidget::updateFilter); - connect(m_ui->minSeeds, static_cast(&QSpinBox::valueChanged) + connect(m_ui->minSeeds, qOverload(&QSpinBox::valueChanged) , this, &SearchJobWidget::updateFilter); connect(m_ui->maxSeeds, &QAbstractSpinBox::editingFinished, this, &SearchJobWidget::updateFilter); - connect(m_ui->maxSeeds, static_cast(&QSpinBox::valueChanged) + connect(m_ui->maxSeeds, qOverload(&QSpinBox::valueChanged) , this, &SearchJobWidget::updateFilter); connect(m_ui->minSize, &QAbstractSpinBox::editingFinished, this, &SearchJobWidget::updateFilter); - connect(m_ui->minSize, static_cast(&QDoubleSpinBox::valueChanged) + connect(m_ui->minSize, qOverload(&QDoubleSpinBox::valueChanged) , this, &SearchJobWidget::updateFilter); connect(m_ui->maxSize, &QAbstractSpinBox::editingFinished, this, &SearchJobWidget::updateFilter); - connect(m_ui->maxSize, static_cast(&QDoubleSpinBox::valueChanged) + connect(m_ui->maxSize, qOverload(&QDoubleSpinBox::valueChanged) , this, &SearchJobWidget::updateFilter); - connect(m_ui->minSizeUnit, static_cast(&QComboBox::currentIndexChanged) + connect(m_ui->minSizeUnit, qOverload(&QComboBox::currentIndexChanged) , this, &SearchJobWidget::updateFilter); - connect(m_ui->maxSizeUnit, static_cast(&QComboBox::currentIndexChanged) + connect(m_ui->maxSizeUnit, qOverload(&QComboBox::currentIndexChanged) , this, &SearchJobWidget::updateFilter); connect(m_ui->resultsBrowser, &QAbstractItemView::doubleClicked, this, &SearchJobWidget::onItemDoubleClicked); diff --git a/src/gui/search/searchwidget.cpp b/src/gui/search/searchwidget.cpp index b0345a436..c731f997e 100644 --- a/src/gui/search/searchwidget.cpp +++ b/src/gui/search/searchwidget.cpp @@ -132,9 +132,9 @@ SearchWidget::SearchWidget(MainWindow *mainWindow) connect(m_ui->lineEditSearchPattern, &LineEdit::returnPressed, m_ui->searchButton, &QPushButton::click); connect(m_ui->lineEditSearchPattern, &LineEdit::textEdited, this, &SearchWidget::searchTextEdited); - connect(m_ui->selectPlugin, static_cast(&QComboBox::currentIndexChanged) + connect(m_ui->selectPlugin, qOverload(&QComboBox::currentIndexChanged) , this, &SearchWidget::selectMultipleBox); - connect(m_ui->selectPlugin, static_cast(&QComboBox::currentIndexChanged) + connect(m_ui->selectPlugin, qOverload(&QComboBox::currentIndexChanged) , this, &SearchWidget::fillCatCombobox); const auto focusSearchHotkey = new QShortcut(QKeySequence::Find, this); diff --git a/src/gui/speedlimitdialog.cpp b/src/gui/speedlimitdialog.cpp index 29c9b2cee..6ca1cf5b8 100644 --- a/src/gui/speedlimitdialog.cpp +++ b/src/gui/speedlimitdialog.cpp @@ -39,7 +39,7 @@ SpeedLimitDialog::SpeedLimitDialog(QWidget *parent) // Connect to slots connect(m_ui->bandwidthSlider, &QSlider::valueChanged, this, &SpeedLimitDialog::updateSpinValue); - connect(m_ui->spinBandwidth, static_cast(&QSpinBox::valueChanged) + connect(m_ui->spinBandwidth, qOverload(&QSpinBox::valueChanged) , this, &SpeedLimitDialog::updateSliderValue); Utils::Gui::resize(this); diff --git a/src/gui/transferlistfilterswidget.cpp b/src/gui/transferlistfilterswidget.cpp index 051a664f1..5e17ba8f6 100644 --- a/src/gui/transferlistfilterswidget.cpp +++ b/src/gui/transferlistfilterswidget.cpp @@ -652,12 +652,11 @@ TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferLi connect(trackerLabel, &QCheckBox::toggled, m_trackerFilters, &TrackerFiltersList::toggleFilter); connect(trackerLabel, &QCheckBox::toggled, pref, &Preferences::setTrackerFilterState); - using Func = void (TransferListFiltersWidget::*)(const QString&, const QString&); - connect(this, static_cast(&TransferListFiltersWidget::trackerSuccess) + connect(this, qOverload(&TransferListFiltersWidget::trackerSuccess) , m_trackerFilters, &TrackerFiltersList::trackerSuccess); - connect(this, static_cast(&TransferListFiltersWidget::trackerError) + connect(this, qOverload(&TransferListFiltersWidget::trackerError) , m_trackerFilters, &TrackerFiltersList::trackerError); - connect(this, static_cast(&TransferListFiltersWidget::trackerWarning) + connect(this, qOverload(&TransferListFiltersWidget::trackerWarning) , m_trackerFilters, &TrackerFiltersList::trackerWarning); } diff --git a/src/gui/updownratiodialog.cpp b/src/gui/updownratiodialog.cpp index 4bd27bda4..39f288c34 100644 --- a/src/gui/updownratiodialog.cpp +++ b/src/gui/updownratiodialog.cpp @@ -69,7 +69,7 @@ UpDownRatioDialog::UpDownRatioDialog(bool useDefault, qreal initialRatioValue, m_ui->timeSpinBox->setMaximum(maxTimeValue); m_ui->timeSpinBox->setValue(initialTimeValue); - connect(m_ui->buttonGroup, static_cast(&QButtonGroup::buttonClicked) + connect(m_ui->buttonGroup, qOverload(&QButtonGroup::buttonClicked) , this, &UpDownRatioDialog::handleRatioTypeChanged); connect(m_ui->checkMaxRatio, &QCheckBox::toggled, this, &UpDownRatioDialog::enableRatioSpin); connect(m_ui->checkMaxTime, &QCheckBox::toggled, this, &UpDownRatioDialog::enableTimeSpin);