Using qOverload, removing static_cast workaround.

This commit is contained in:
Mat Sutcliffe
2018-12-25 14:08:02 +00:00
parent 1403926d3d
commit f48a411f43
14 changed files with 20 additions and 22 deletions

View File

@@ -59,9 +59,9 @@ namespace BlackGui
ui->cb_SetupAudioLoopback->setChecked(sGui->getIContextAudio()->isAudioLoopbackEnabled()); ui->cb_SetupAudioLoopback->setChecked(sGui->getIContextAudio()->isAudioLoopbackEnabled());
// the connects depend on initAudioDeviceLists // the connects depend on initAudioDeviceLists
c = connect(ui->cb_SetupAudioInputDevice, static_cast<void (QComboBox::*)(int)> (&QComboBox::currentIndexChanged), this, &CAudioSetupComponent::onAudioDeviceSelected); c = connect(ui->cb_SetupAudioInputDevice, qOverload<int>(&QComboBox::currentIndexChanged), this, &CAudioSetupComponent::onAudioDeviceSelected);
Q_ASSERT(c); Q_ASSERT(c);
c = connect(ui->cb_SetupAudioOutputDevice, static_cast<void (QComboBox::*)(int)> (&QComboBox::currentIndexChanged), this, &CAudioSetupComponent::onAudioDeviceSelected); c = connect(ui->cb_SetupAudioOutputDevice, qOverload<int>(&QComboBox::currentIndexChanged), this, &CAudioSetupComponent::onAudioDeviceSelected);
Q_ASSERT(c); Q_ASSERT(c);
// context // context

View File

@@ -39,7 +39,7 @@ namespace BlackGui
c = connect(ui->hs_Volume, &QSlider::valueChanged, this, &CAudioVolumeComponent::ps_changeOutputVolumeFromSlider); c = connect(ui->hs_Volume, &QSlider::valueChanged, this, &CAudioVolumeComponent::ps_changeOutputVolumeFromSlider);
Q_ASSERT(c); Q_ASSERT(c);
Q_UNUSED(c); Q_UNUSED(c);
c = connect(ui->sb_Volume, static_cast<void (QSpinBox::*)(int)> (&QSpinBox::valueChanged), this, &CAudioVolumeComponent::ps_changeOutputVolumeFromSpinBox); c = connect(ui->sb_Volume, qOverload<int>(&QSpinBox::valueChanged), this, &CAudioVolumeComponent::ps_changeOutputVolumeFromSpinBox);
Q_ASSERT(c); Q_ASSERT(c);
Q_UNUSED(c); Q_UNUSED(c);
c = connect(ui->pb_Volume100, &QPushButton::clicked, this, &CAudioVolumeComponent::ps_setVolume100); c = connect(ui->pb_Volume100, &QPushButton::clicked, this, &CAudioVolumeComponent::ps_setVolume100);

View File

@@ -57,7 +57,7 @@ namespace BlackGui
completer->setMaxVisibleItems(10); completer->setMaxVisibleItems(10);
completer->setCompletionMode(QCompleter::PopupCompletion); completer->setCompletionMode(QCompleter::PopupCompletion);
ui->le_Color->setCompleter(completer); ui->le_Color->setCompleter(completer);
connect(completer, static_cast<void (QCompleter::*)(const QString &)>(&QCompleter::activated), this, &CColorSelector::setColorByName); connect(completer, qOverload<const QString &>(&QCompleter::activated), this, &CColorSelector::setColorByName);
} }
CColorSelector::~CColorSelector() { } CColorSelector::~CColorSelector() { }

View File

@@ -201,7 +201,7 @@ namespace BlackGui
c->setCompletionMode(QCompleter::PopupCompletion); c->setCompletionMode(QCompleter::PopupCompletion);
c->setMaxVisibleItems(10); c->setMaxVisibleItems(10);
c->popup()->setMinimumWidth(175); c->popup()->setMinimumWidth(175);
connect(c, static_cast<void (QCompleter::*)(const QString &)>(&QCompleter::activated), this, &CDbAircraftIcaoSelectorComponent::onCompleterActivated); connect(c, qOverload<const QString &>(&QCompleter::activated), this, &CDbAircraftIcaoSelectorComponent::onCompleterActivated);
ui->le_Aircraft->setCompleter(c); ui->le_Aircraft->setCompleter(c);
m_completerIcaoDescription.reset(c); // deletes any old completer m_completerIcaoDescription.reset(c); // deletes any old completer

View File

@@ -141,7 +141,7 @@ namespace BlackGui
{ {
QCompleter *c = this->createCompleter(); QCompleter *c = this->createCompleter();
Q_ASSERT_X(c, Q_FUNC_INFO, "missing converter"); Q_ASSERT_X(c, Q_FUNC_INFO, "missing converter");
connect(c, static_cast<void (QCompleter::*)(const QString &)>(&QCompleter::activated), this, &CDbAirlineIcaoSelectorBase::onCompleterActivated); connect(c, qOverload<const QString &>(&QCompleter::activated), this, &CDbAirlineIcaoSelectorBase::onCompleterActivated);
m_completer.reset(c); // deletes any old completer m_completer.reset(c); // deletes any old completer
} }
else else

View File

@@ -165,7 +165,7 @@ namespace BlackGui
c->setCaseSensitivity(Qt::CaseInsensitive); c->setCaseSensitivity(Qt::CaseInsensitive);
c->setCompletionMode(QCompleter::PopupCompletion); c->setCompletionMode(QCompleter::PopupCompletion);
c->setMaxVisibleItems(10); c->setMaxVisibleItems(10);
connect(c, static_cast<void (QCompleter::*)(const QString &)>(&QCompleter::activated), this, &CDbCountrySelectorComponent::onCompleterActivated); connect(c, qOverload<const QString &>(&QCompleter::activated), this, &CDbCountrySelectorComponent::onCompleterActivated);
ui->le_CountryName->setCompleter(c); ui->le_CountryName->setCompleter(c);
m_completerCountryNames.reset(c); // deletes any old completer m_completerCountryNames.reset(c); // deletes any old completer

View File

@@ -184,7 +184,7 @@ namespace BlackGui
c->setCaseSensitivity(Qt::CaseInsensitive); c->setCaseSensitivity(Qt::CaseInsensitive);
c->setCompletionMode(QCompleter::PopupCompletion); c->setCompletionMode(QCompleter::PopupCompletion);
c->setMaxVisibleItems(10); c->setMaxVisibleItems(10);
connect(c, static_cast<void (QCompleter::*)(const QString &)>(&QCompleter::activated), this, &CDbDistributorSelectorComponent::onCompleterActivated); connect(c, qOverload<const QString &>(&QCompleter::activated), this, &CDbDistributorSelectorComponent::onCompleterActivated);
ui->le_Distributor->setCompleter(c); ui->le_Distributor->setCompleter(c);
m_completerDistributors.reset(c); // deletes any old completer m_completerDistributors.reset(c); // deletes any old completer

View File

@@ -196,7 +196,7 @@ namespace BlackGui
c->setCaseSensitivity(Qt::CaseInsensitive); c->setCaseSensitivity(Qt::CaseInsensitive);
c->setCompletionMode(QCompleter::PopupCompletion); c->setCompletionMode(QCompleter::PopupCompletion);
c->setMaxVisibleItems(10); c->setMaxVisibleItems(10);
connect(c, static_cast<void (QCompleter::*)(const QString &)>(&QCompleter::activated), this, &CDbLiverySelectorComponent::onCompleterActivated); connect(c, qOverload<const QString &>(&QCompleter::activated), this, &CDbLiverySelectorComponent::onCompleterActivated);
ui->le_Livery->setCompleter(c); ui->le_Livery->setCompleter(c);
m_completerLiveries.reset(c); // deletes any old completer m_completerLiveries.reset(c); // deletes any old completer

View File

@@ -100,7 +100,7 @@ namespace BlackGui
connect(ui->pb_Accept, &QPushButton::clicked, this, &CHotkeyDialog::accept); connect(ui->pb_Accept, &QPushButton::clicked, this, &CHotkeyDialog::accept);
connect(ui->pb_Cancel, &QPushButton::clicked, this, &CHotkeyDialog::reject); connect(ui->pb_Cancel, &QPushButton::clicked, this, &CHotkeyDialog::reject);
connect(ui->tv_Actions->selectionModel(), &QItemSelectionModel::selectionChanged, this, &CHotkeyDialog::changeSelectedAction); connect(ui->tv_Actions->selectionModel(), &QItemSelectionModel::selectionChanged, this, &CHotkeyDialog::changeSelectedAction);
connect(ui->cb_Identifier, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &CHotkeyDialog::changeApplicableMachine); connect(ui->cb_Identifier, qOverload<int>(&QComboBox::currentIndexChanged), this, &CHotkeyDialog::changeApplicableMachine);
if (sGui) if (sGui)
{ {
@@ -116,7 +116,7 @@ namespace BlackGui
CKeySelectionBox::CKeySelectionBox(QWidget *parent) : CHorizontalComboBox(parent) CKeySelectionBox::CKeySelectionBox(QWidget *parent) : CHorizontalComboBox(parent)
{ {
connect(this, static_cast<void(CKeySelectionBox::*)(int)>(&CKeySelectionBox::currentIndexChanged), this, &CKeySelectionBox::updateSelectedIndex); connect(this, qOverload<int>(&CKeySelectionBox::currentIndexChanged), this, &CKeySelectionBox::updateSelectedIndex);
} }
void CKeySelectionBox::setSelectedIndex(int index) void CKeySelectionBox::setSelectedIndex(int index)

View File

@@ -35,8 +35,8 @@ namespace BlackGui
ui->cb_SelcalPairs1->setStyleSheet("combobox-popup: 0;"); ui->cb_SelcalPairs1->setStyleSheet("combobox-popup: 0;");
ui->cb_SelcalPairs2->setStyleSheet("combobox-popup: 0;"); ui->cb_SelcalPairs2->setStyleSheet("combobox-popup: 0;");
connect(ui->cb_SelcalPairs1, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &CSelcalCodeSelector::selcalIndexChanged); connect(ui->cb_SelcalPairs1, qOverload<int>(&QComboBox::currentIndexChanged), this, &CSelcalCodeSelector::selcalIndexChanged);
connect(ui->cb_SelcalPairs2, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &CSelcalCodeSelector::selcalIndexChanged); connect(ui->cb_SelcalPairs2, qOverload<int>(&QComboBox::currentIndexChanged), this, &CSelcalCodeSelector::selcalIndexChanged);
} }
CSelcalCodeSelector::~CSelcalCodeSelector() CSelcalCodeSelector::~CSelcalCodeSelector()

View File

@@ -38,7 +38,7 @@ namespace BlackGui
// Widget style // Widget style
connect(ui->hs_SettingsGuiOpacity, &QSlider::valueChanged, this, &CSettingsGuiComponent::changedWindowsOpacity); connect(ui->hs_SettingsGuiOpacity, &QSlider::valueChanged, this, &CSettingsGuiComponent::changedWindowsOpacity);
connect(ui->cb_SettingsGuiWidgetStyle, static_cast<void(QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged), connect(ui->cb_SettingsGuiWidgetStyle, qOverload<const QString &>(&QComboBox::currentIndexChanged),
this, &CSettingsGuiComponent::widgetStyleChanged); this, &CSettingsGuiComponent::widgetStyleChanged);
// selection // selection

View File

@@ -197,8 +197,7 @@ namespace BlackGui
void CWeatherComponent::setupConnections() void CWeatherComponent::setupConnections()
{ {
// UI connections // UI connections
connect(ui->cb_weatherScenario, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), connect(ui->cb_weatherScenario, qOverload<int>(&QComboBox::currentIndexChanged), this, &CWeatherComponent::setWeatherScenario);
this, &CWeatherComponent::setWeatherScenario);
connect(m_coordinateDialog.data(), &CCoordinateDialog::changedCoordinate, this, &CWeatherComponent::updateWeatherInformation); connect(m_coordinateDialog.data(), &CCoordinateDialog::changedCoordinate, this, &CWeatherComponent::updateWeatherInformation);
connect(ui->cb_UseOwnAcftPosition, &QCheckBox::toggled, this, &CWeatherComponent::toggleUseOwnAircraftPosition); connect(ui->cb_UseOwnAcftPosition, &QCheckBox::toggled, this, &CWeatherComponent::toggleUseOwnAircraftPosition);
connect(&m_weatherUpdateTimer, &QTimer::timeout, this, &CWeatherComponent::updateWeatherInformation); connect(&m_weatherUpdateTimer, &QTimer::timeout, this, &CWeatherComponent::updateWeatherInformation);

View File

@@ -129,8 +129,7 @@ namespace BlackGui
signalMapperToggleFloating->setMapping(toggleFloatingMenuAction, i); signalMapperToggleFloating->setMapping(toggleFloatingMenuAction, i);
} }
// new syntax not yet possible because of overloaded signal c = connect(signalMapperToggleFloating, qOverload<int>(&QSignalMapper::mapped), this, &CInfoArea::toggleFloatingByIndex);
c = connect(signalMapperToggleFloating, static_cast<void (QSignalMapper::*)(int)>(&QSignalMapper::mapped), this, &CInfoArea::toggleFloatingByIndex);
BLACK_VERIFY_X(c, Q_FUNC_INFO, "Cannot connect mapper"); // do not make that shutdown reason in a release build BLACK_VERIFY_X(c, Q_FUNC_INFO, "Cannot connect mapper"); // do not make that shutdown reason in a release build
menu->addMenu(subMenuDisplay); menu->addMenu(subMenuDisplay);

View File

@@ -28,8 +28,8 @@ namespace BlackGui
QVBoxLayout *layout = new QVBoxLayout; QVBoxLayout *layout = new QVBoxLayout;
setLayout(layout); setLayout(layout);
connect(m_detailsButtonMapper, static_cast<void (QSignalMapper::*)(const QString &)>(&QSignalMapper::mapped), this, &CPluginSelector::pluginDetailsRequested); connect(m_detailsButtonMapper, qOverload<const QString &>(&QSignalMapper::mapped), this, &CPluginSelector::pluginDetailsRequested);
connect(m_configButtonMapper, static_cast<void (QSignalMapper::*)(const QString &)>(&QSignalMapper::mapped), this, &CPluginSelector::pluginConfigRequested); connect(m_configButtonMapper, qOverload<const QString &>(&QSignalMapper::mapped), this, &CPluginSelector::pluginConfigRequested);
} }
void CPluginSelector::addPlugin(const QString &identifier, const QString &name, bool hasConfig, bool enabled) void CPluginSelector::addPlugin(const QString &identifier, const QString &name, bool hasConfig, bool enabled)
@@ -62,13 +62,13 @@ namespace BlackGui
{ {
QPushButton *config = new QPushButton("..."); QPushButton *config = new QPushButton("...");
m_configButtonMapper->setMapping(config, identifier); m_configButtonMapper->setMapping(config, identifier);
connect(config, &QPushButton::clicked, m_configButtonMapper, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map)); connect(config, &QPushButton::clicked, m_configButtonMapper, qOverload<>(&QSignalMapper::map));
pw->layout()->addWidget(config); pw->layout()->addWidget(config);
} }
QPushButton *details = new QPushButton("?"); QPushButton *details = new QPushButton("?");
m_detailsButtonMapper->setMapping(details, identifier); m_detailsButtonMapper->setMapping(details, identifier);
connect(details, &QPushButton::clicked, m_detailsButtonMapper, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map)); connect(details, &QPushButton::clicked, m_detailsButtonMapper, qOverload<>(&QSignalMapper::map));
pw->layout()->addWidget(details); pw->layout()->addWidget(details);
layout->setStretch(0, 1); layout->setStretch(0, 1);