From bf390f592ad389b214c57214e533bd058f587a61 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 16 Oct 2017 13:00:47 +0200 Subject: [PATCH] Ref T171, formatting of some existing completers * private slots -> private * this->m_ -> m_ * removed unused utility function (model string completer) --- .../aircraftmodelstringcompleter.cpp | 44 ++++++++----------- .../components/aircraftmodelstringcompleter.h | 18 +++----- src/blackgui/components/colorselector.cpp | 34 +++++++------- src/blackgui/components/colorselector.h | 15 +++---- .../components/dbairlineicaoselectorbase.cpp | 20 ++++----- .../components/dbairlineicaoselectorbase.h | 6 +-- .../dbairlinenameselectorcomponent.h | 1 - .../components/dbcountryselectorcomponent.cpp | 36 +++++++-------- .../components/dbcountryselectorcomponent.h | 20 ++++----- .../dbdistributorselectorcomponent.cpp | 26 +++++------ .../dbdistributorselectorcomponent.h | 22 +++++----- 11 files changed, 111 insertions(+), 131 deletions(-) diff --git a/src/blackgui/components/aircraftmodelstringcompleter.cpp b/src/blackgui/components/aircraftmodelstringcompleter.cpp index 832ccc81d..8c3d7d6da 100644 --- a/src/blackgui/components/aircraftmodelstringcompleter.cpp +++ b/src/blackgui/components/aircraftmodelstringcompleter.cpp @@ -35,19 +35,19 @@ namespace BlackGui ui->setupUi(this); ui->le_modelString->setValidator(new CUpperCaseValidator(ui->le_modelString)); - connect(ui->le_modelString, &QLineEdit::editingFinished, this, &CAircraftModelStringCompleter::ps_textChanged); - connect(sGui->getWebDataServices(), &CWebDataServices::swiftDbModelsRead, this, &CAircraftModelStringCompleter::ps_swiftModelDataRead); - connect(ui->rb_Db, &QRadioButton::clicked, this, &CAircraftModelStringCompleter::ps_initGui); - connect(ui->rb_ModelSet, &QRadioButton::clicked, this, &CAircraftModelStringCompleter::ps_initGui); - connect(ui->rb_OwnModels, &QRadioButton::clicked, this, &CAircraftModelStringCompleter::ps_initGui); + connect(ui->le_modelString, &QLineEdit::editingFinished, this, &CAircraftModelStringCompleter::onTextChanged); + connect(sGui->getWebDataServices(), &CWebDataServices::swiftDbModelsRead, this, &CAircraftModelStringCompleter::onSwiftModelDataRead); + connect(ui->rb_Db, &QRadioButton::clicked, this, &CAircraftModelStringCompleter::initGui); + connect(ui->rb_ModelSet, &QRadioButton::clicked, this, &CAircraftModelStringCompleter::initGui); + connect(ui->rb_OwnModels, &QRadioButton::clicked, this, &CAircraftModelStringCompleter::initGui); if (sGui->getIContextSimulator()) { - connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CAircraftModelStringCompleter::ps_simulatorConnected); + connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CAircraftModelStringCompleter::onSimulatorConnected); const CSimulatorInfo sim(sGui->getIContextSimulator()->getSimulatorPluginInfo().getSimulator()); if (sim.isSingleSimulator()) { - this->m_modelCaches.setCurrentSimulator(sim); + m_modelCaches.setCurrentSimulator(sim); } else { @@ -109,56 +109,48 @@ namespace BlackGui CompleterSourceFlag sourceWithData = None; if (ui->rb_Db->isChecked()) { - if (this->m_currentSourceWithData == DB) { return; } + if (m_currentSourceWithData == DB) { return; } modelStrings = sGui->getWebDataServices()->getModelCompleterStrings(); if (!modelStrings.isEmpty()) { sourceWithData = DB; } } else if (ui->rb_ModelSet->isChecked()) { - if (this->m_currentSourceWithData == ModelSet) { return; } + if (m_currentSourceWithData == ModelSet) { return; } modelStrings = sGui->getIContextSimulator()->getModelSetCompleterStrings(true); if (!modelStrings.isEmpty()) { sourceWithData = ModelSet; } } else if (ui->rb_OwnModels->isChecked()) { - if (this->m_currentSourceWithData == OwnModels) { return; } - modelStrings = this->m_modelCaches.getCurrentCachedModels().toCompleterStrings(); + if (m_currentSourceWithData == OwnModels) { return; } + modelStrings = m_modelCaches.getCurrentCachedModels().toCompleterStrings(); if (!modelStrings.isEmpty()) { sourceWithData = OwnModels; } } - this->m_currentSourceWithData = sourceWithData; + m_currentSourceWithData = sourceWithData; ui->le_modelString->setCompleter(new QCompleter(modelStrings, this)); ui->le_modelString->setPlaceholderText(QString("model strings (%1)").arg(modelStrings.size())); } - void CAircraftModelStringCompleter::setCompleterParameters(QCompleter *completer) - { - completer->setCaseSensitivity(Qt::CaseInsensitive); - completer->setWrapAround(true); - completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel); - completer->setCompletionMode(QCompleter::InlineCompletion); - } - - void CAircraftModelStringCompleter::ps_textChanged() + void CAircraftModelStringCompleter::onTextChanged() { emit this->modelStringChanged(); } - void CAircraftModelStringCompleter::ps_initGui() + void CAircraftModelStringCompleter::initGui() { this->setCompleter(); } - void CAircraftModelStringCompleter::ps_simulatorConnected(int status) + void CAircraftModelStringCompleter::onSimulatorConnected(int status) { // reinit because sim changed Q_UNUSED(status); - this->ps_initGui(); + this->initGui(); } - void CAircraftModelStringCompleter::ps_swiftModelDataRead() + void CAircraftModelStringCompleter::onSwiftModelDataRead() { - this->ps_initGui(); + this->initGui(); } } // ns } // ns diff --git a/src/blackgui/components/aircraftmodelstringcompleter.h b/src/blackgui/components/aircraftmodelstringcompleter.h index 3804db741..f01288264 100644 --- a/src/blackgui/components/aircraftmodelstringcompleter.h +++ b/src/blackgui/components/aircraftmodelstringcompleter.h @@ -47,7 +47,7 @@ namespace BlackGui explicit CAircraftModelStringCompleter(QWidget *parent = nullptr); //! Destructor - ~CAircraftModelStringCompleter(); + virtual ~CAircraftModelStringCompleter(); //! The model string QString getModelString() const; @@ -78,21 +78,17 @@ namespace BlackGui //! Set the completer void setCompleter(); - //! How completer behaves - static void setCompleterParameters(QCompleter *completer); - - private slots: - //! Value has been changed - void ps_textChanged(); - //! Init the GUI - void ps_initGui(); + void initGui(); + + //! Value has been changed + void onTextChanged(); //! Simulator connected - void ps_simulatorConnected(int status); + void onSimulatorConnected(int status); //! All swift data have been read - void ps_swiftModelDataRead(); + void onSwiftModelDataRead(); private: QScopedPointer ui; diff --git a/src/blackgui/components/colorselector.cpp b/src/blackgui/components/colorselector.cpp index 1ad08406f..4fc1f9d99 100644 --- a/src/blackgui/components/colorselector.cpp +++ b/src/blackgui/components/colorselector.cpp @@ -48,16 +48,16 @@ namespace BlackGui ui->setupUi(this); ui->tb_ColorDialog->setIcon(CIcons::color16()); this->setAcceptDrops(true); - connect(ui->tb_ColorDialog, &QToolButton::clicked, this, &CColorSelector::ps_colorDialog); - connect(ui->le_Color, &QLineEdit::editingFinished, this, &CColorSelector::ps_returnPressed); - connect(ui->le_Color, &QLineEdit::returnPressed, this, &CColorSelector::ps_returnPressed); + connect(ui->tb_ColorDialog, &QToolButton::clicked, this, &CColorSelector::colorDialog); + connect(ui->le_Color, &QLineEdit::editingFinished, this, &CColorSelector::onReturnPressed); + connect(ui->le_Color, &QLineEdit::returnPressed, this, &CColorSelector::onReturnPressed); QCompleter *completer = new QCompleter(QColor::colorNames(), this); completer->setCaseSensitivity(Qt::CaseInsensitive); completer->setMaxVisibleItems(10); completer->setCompletionMode(QCompleter::PopupCompletion); ui->le_Color->setCompleter(completer); - connect(completer, static_cast(&QCompleter::activated), this, &CColorSelector::ps_colorName); + connect(completer, static_cast(&QCompleter::activated), this, &CColorSelector::setColorByName); } CColorSelector::~CColorSelector() { } @@ -129,24 +129,24 @@ namespace BlackGui if (mime->hasColor()) { - QColor color = qvariant_cast(event->mimeData()->colorData()); + const QColor color = qvariant_cast(event->mimeData()->colorData()); if (!color.isValid()) { return; } this->setColor(color); } else if (CGuiUtility::hasSwiftVariantMimeType(mime)) { - CVariant valueVariant(CGuiUtility::fromSwiftDragAndDropData(mime)); + const CVariant valueVariant(CGuiUtility::fromSwiftDragAndDropData(mime)); if (valueVariant.isValid()) { if (valueVariant.canConvert()) { - CRgbColor rgb(valueVariant.value()); + const CRgbColor rgb(valueVariant.value()); if (!rgb.isValid()) { return; } this->setColor(rgb); } else if (valueVariant.canConvert()) { - QColor qColor(valueVariant.value()); + const QColor qColor(valueVariant.value()); if (!qColor.isValid()) { return; } this->setColor(qColor); } @@ -154,12 +154,12 @@ namespace BlackGui } else if (mime->hasText()) { - QString t = mime->text(); + const QString t = mime->text(); if (t.isEmpty()) { return; } if (!t.contains("{")) { // we assume a color string, not an object (because there are no {}) - CRgbColor c(t); + const CRgbColor c(t); if (!c.isValid()) { return; } this->setColor(c); } @@ -169,7 +169,7 @@ namespace BlackGui void CColorSelector::mousePressEvent(QMouseEvent *event) { if (!event || event->button() != Qt::LeftButton) { QFrame::mousePressEvent(event); } - CRgbColor c(this->getColor()); + const CRgbColor c(this->getColor()); if (!c.isValid()) { return; } QDrag *drag = new QDrag(this); @@ -183,7 +183,7 @@ namespace BlackGui Q_UNUSED(dropAction); } - void CColorSelector::ps_colorDialog() + void CColorSelector::colorDialog() { QColor q = this->getColor().toQColor(); if (!q.isValid()) { q = m_lastColor.toQColor(); } @@ -192,26 +192,26 @@ namespace BlackGui this->setColor(newColor); } - void CColorSelector::ps_returnPressed() + void CColorSelector::onReturnPressed() { - CRgbColor color = this->getColor(); + const CRgbColor color = this->getColor(); if (color.isValid()) { this->setColor(color); } } - void CColorSelector::ps_colorName(const QString &colorName) + void CColorSelector::setColorByName(const QString &colorName) { if (colorName.isEmpty()) { return; } - CRgbColor c(colorName, true); + const CRgbColor c(colorName, true); if (c.isValid()) { this->setColor(c); } } void CColorSelector::resetToLastValidColor() { if (!m_lastColor.isValid()) { return; } - this->setColor(this->m_lastColor); + this->setColor(m_lastColor); } } // ns } // ns diff --git a/src/blackgui/components/colorselector.h b/src/blackgui/components/colorselector.h index 73e79b891..7b5e581fa 100644 --- a/src/blackgui/components/colorselector.h +++ b/src/blackgui/components/colorselector.h @@ -83,22 +83,21 @@ namespace BlackGui //! For dragging the color virtual void mousePressEvent(QMouseEvent *event) override; - private slots: + private: //! Open up a color dilaog - void ps_colorDialog(); + void colorDialog(); //! Enter pressed - void ps_returnPressed(); + void onReturnPressed(); //! Set color by color name - void ps_colorName(const QString &colorName); - - private: - QScopedPointer ui; - BlackMisc::CRgbColor m_lastColor; + void setColorByName(const QString &colorName); //! Reset to last valid color void resetToLastValidColor(); + + QScopedPointer ui; + BlackMisc::CRgbColor m_lastColor; }; } // ns } // ns diff --git a/src/blackgui/components/dbairlineicaoselectorbase.cpp b/src/blackgui/components/dbairlineicaoselectorbase.cpp index c5d70170e..5c9436768 100644 --- a/src/blackgui/components/dbairlineicaoselectorbase.cpp +++ b/src/blackgui/components/dbairlineicaoselectorbase.cpp @@ -42,7 +42,7 @@ namespace BlackGui this->setAcceptDrops(true); this->setAcceptedMetaTypeIds({qMetaTypeId(), qMetaTypeId()}); - connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbAirlineIcaoSelectorBase::ps_codesRead); + connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbAirlineIcaoSelectorBase::onCodesRead); // when we already have data, init completers. This can not be done directly in the // constructor due to virtual functions @@ -51,7 +51,7 @@ namespace BlackGui { QTimer::singleShot(500, [this, c]() { - this->ps_codesRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadFinished, c); + this->onCodesRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadFinished, c); }); } } @@ -64,13 +64,13 @@ namespace BlackGui if (icao == m_currentIcao) { return false; } if (icao.isLoadedFromDb()) { - this->m_currentIcao = icao; + m_currentIcao = icao; } else { - this->m_currentIcao = sGui->getWebDataServices()->smartAirlineIcaoSelector(icao); + m_currentIcao = sGui->getWebDataServices()->smartAirlineIcaoSelector(icao); } - emit changedAirlineIcao(this->m_currentIcao); + emit changedAirlineIcao(m_currentIcao); return true; } @@ -134,7 +134,7 @@ namespace BlackGui } } - void CDbAirlineIcaoSelectorBase::ps_codesRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count) + void CDbAirlineIcaoSelectorBase::onCodesRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count) { if (!sGui) { return; } if (entity.testFlag(CEntityFlags::AirlineIcaoEntity) && readState == CEntityFlags::ReadFinished) @@ -143,19 +143,19 @@ namespace BlackGui { QCompleter *c = this->createCompleter(); Q_ASSERT_X(c, Q_FUNC_INFO, "missing converter"); - connect(c, static_cast(&QCompleter::activated), this, &CDbAirlineIcaoSelectorBase::ps_completerActivated); + connect(c, static_cast(&QCompleter::activated), this, &CDbAirlineIcaoSelectorBase::onCompleterActivated); m_completer.reset(c); // deletes any old completer } else { - this->m_completer.reset(nullptr); + m_completer.reset(nullptr); } } } - void CDbAirlineIcaoSelectorBase::ps_completerActivated(const QString &icaoString) + void CDbAirlineIcaoSelectorBase::onCompleterActivated(const QString &icaoString) { - int dbKey = CDatastoreUtility::extractIntegerKey(icaoString); + const int dbKey = CDatastoreUtility::extractIntegerKey(icaoString); if (dbKey < 0) { return; } this->setAirlineIcao(dbKey); } diff --git a/src/blackgui/components/dbairlineicaoselectorbase.h b/src/blackgui/components/dbairlineicaoselectorbase.h index 18608443e..6fed9c7c5 100644 --- a/src/blackgui/components/dbairlineicaoselectorbase.h +++ b/src/blackgui/components/dbairlineicaoselectorbase.h @@ -90,12 +90,12 @@ namespace BlackGui QScopedPointer m_completer; //!< completer used BlackMisc::Aviation::CAirlineIcaoCode m_currentIcao; //!< current ICAO object - private slots: + private: //! Airlines have been read - void ps_codesRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState readState, int count); + void onCodesRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState readState, int count); //! Data have been changed - void ps_completerActivated(const QString &icaoString); + void onCompleterActivated(const QString &icaoString); }; } // ns } // ns diff --git a/src/blackgui/components/dbairlinenameselectorcomponent.h b/src/blackgui/components/dbairlinenameselectorcomponent.h index 6e96b92e9..e7a82829e 100644 --- a/src/blackgui/components/dbairlinenameselectorcomponent.h +++ b/src/blackgui/components/dbairlinenameselectorcomponent.h @@ -23,7 +23,6 @@ class QCompleter; class QWidget; namespace Ui { class CDbAirlineNameSelectorComponent; } - namespace BlackGui { namespace Components diff --git a/src/blackgui/components/dbcountryselectorcomponent.cpp b/src/blackgui/components/dbcountryselectorcomponent.cpp index 6b8932bee..3cb32348b 100644 --- a/src/blackgui/components/dbcountryselectorcomponent.cpp +++ b/src/blackgui/components/dbcountryselectorcomponent.cpp @@ -46,20 +46,18 @@ namespace BlackGui this->setAcceptDrops(true); this->setAcceptedMetaTypeIds({qMetaTypeId(), qMetaTypeId()}); - connect(ui->le_CountryIso, &QLineEdit::returnPressed, this, &CDbCountrySelectorComponent::ps_dataChanged); - connect(ui->le_CountryName, &QLineEdit::returnPressed, this, &CDbCountrySelectorComponent::ps_dataChanged); - connect(ui->le_CountryIso, &QLineEdit::editingFinished, this, &CDbCountrySelectorComponent::ps_dataChanged); - connect(ui->le_CountryName, &QLineEdit::returnPressed, this, &CDbCountrySelectorComponent::ps_dataChanged); + connect(ui->le_CountryIso, &QLineEdit::returnPressed, this, &CDbCountrySelectorComponent::onDataChanged); + connect(ui->le_CountryName, &QLineEdit::returnPressed, this, &CDbCountrySelectorComponent::onDataChanged); + connect(ui->le_CountryIso, &QLineEdit::editingFinished, this, &CDbCountrySelectorComponent::onDataChanged); + connect(ui->le_CountryName, &QLineEdit::returnPressed, this, &CDbCountrySelectorComponent::onDataChanged); ui->le_CountryIso->setValidator(new CUpperCaseValidator(this)); - connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbCountrySelectorComponent::ps_CountriesRead); - this->ps_CountriesRead(CEntityFlags::DistributorEntity, CEntityFlags::ReadFinished, sGui->getWebDataServices()->getCountriesCount()); + connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbCountrySelectorComponent::onCountriesRead); + this->onCountriesRead(CEntityFlags::DistributorEntity, CEntityFlags::ReadFinished, sGui->getWebDataServices()->getCountriesCount()); } CDbCountrySelectorComponent::~CDbCountrySelectorComponent() - { - // - } + { } void CDbCountrySelectorComponent::setCountry(const BlackMisc::CCountry &country) { @@ -75,15 +73,15 @@ namespace BlackGui void CDbCountrySelectorComponent::setCountry(const QString &isoCode) { - CCountry c(sGui->getWebDataServices()->getCountryForIsoCode(isoCode)); + const CCountry c(sGui->getWebDataServices()->getCountryForIsoCode(isoCode)); this->setCountry(c); } BlackMisc::CCountry CDbCountrySelectorComponent::getCountry() const { if (!sGui) { return CCountry(); } - QString iso(ui->le_CountryIso->text().trimmed().toUpper()); - QString name(ui->le_CountryName->text().trimmed()); + const QString iso(ui->le_CountryIso->text().trimmed().toUpper()); + const QString name(ui->le_CountryName->text().trimmed()); if (CCountry::isValidIsoCode(iso)) { return sGui->getWebDataServices()->getCountryForIsoCode(iso); @@ -138,25 +136,25 @@ namespace BlackGui void CDbCountrySelectorComponent::dropEvent(QDropEvent *event) { if (!event || !acceptDrop(event->mimeData())) { return; } - CVariant valueVariant(toCVariant(event->mimeData())); + const CVariant valueVariant(toCVariant(event->mimeData())); if (valueVariant.isValid()) { if (valueVariant.canConvert()) { - CCountry country(valueVariant.value()); + const CCountry country(valueVariant.value()); if (!country.hasIsoCode()) { return; } this->setCountry(country); } else if (valueVariant.canConvert()) { - CCountryList countries(valueVariant.value()); + const CCountryList countries(valueVariant.value()); if (countries.isEmpty()) { return; } this->setCountry(countries.front()); } } } - void CDbCountrySelectorComponent::ps_CountriesRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count) + void CDbCountrySelectorComponent::onCountriesRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count) { if (!sGui) { return; } if (entity.testFlag(CEntityFlags::DistributorEntity) && readState == CEntityFlags::ReadFinished) @@ -167,7 +165,7 @@ namespace BlackGui c->setCaseSensitivity(Qt::CaseInsensitive); c->setCompletionMode(QCompleter::PopupCompletion); c->setMaxVisibleItems(10); - connect(c, static_cast(&QCompleter::activated), this, &CDbCountrySelectorComponent::ps_completerActivated); + connect(c, static_cast(&QCompleter::activated), this, &CDbCountrySelectorComponent::onCompleterActivated); ui->le_CountryName->setCompleter(c); this->m_completerCountryNames.reset(c); // deletes any old completer @@ -179,7 +177,7 @@ namespace BlackGui } } - void CDbCountrySelectorComponent::ps_dataChanged() + void CDbCountrySelectorComponent::onDataChanged() { if (!sGui) { return; } QObject *sender = this->sender(); @@ -201,7 +199,7 @@ namespace BlackGui } } - void CDbCountrySelectorComponent::ps_completerActivated(const QString &countryName) + void CDbCountrySelectorComponent::onCompleterActivated(const QString &countryName) { ui->le_CountryName->setText(countryName); this->setCountry(sGui->getWebDataServices()->getCountryForName(countryName)); diff --git a/src/blackgui/components/dbcountryselectorcomponent.h b/src/blackgui/components/dbcountryselectorcomponent.h index 5876fec35..52b823c45 100644 --- a/src/blackgui/components/dbcountryselectorcomponent.h +++ b/src/blackgui/components/dbcountryselectorcomponent.h @@ -30,7 +30,6 @@ class QDropEvent; class QWidget; namespace Ui { class CDbCountrySelectorComponent; } - namespace BlackGui { namespace Components @@ -86,17 +85,16 @@ namespace BlackGui //! \copydoc QWidget::dropEvent virtual void dropEvent(QDropEvent *event) override; - private slots: - //! Countries have been read - void ps_CountriesRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState readState, int count); - - //! Data have been changed - void ps_dataChanged(); - - //! Data have been changed - void ps_completerActivated(const QString &countryName); - private: + //! Countries have been read + void onCountriesRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState readState, int count); + + //! Data have been changed + void onDataChanged(); + + //! Data have been changed + void onCompleterActivated(const QString &countryName); + QScopedPointer ui; QScopedPointer m_completerCountryNames; BlackMisc::CCountry m_currentCountry; diff --git a/src/blackgui/components/dbdistributorselectorcomponent.cpp b/src/blackgui/components/dbdistributorselectorcomponent.cpp index 5fa02a620..061cdb0de 100644 --- a/src/blackgui/components/dbdistributorselectorcomponent.cpp +++ b/src/blackgui/components/dbdistributorselectorcomponent.cpp @@ -51,13 +51,13 @@ namespace BlackGui this->setAcceptedMetaTypeIds({qMetaTypeId(), qMetaTypeId()}); ui->le_Distributor->setValidator(new CUpperCaseValidator(this)); - bool c = connect(ui->le_Distributor, &QLineEdit::returnPressed, this, &CDbDistributorSelectorComponent::ps_dataChanged); + bool c = connect(ui->le_Distributor, &QLineEdit::returnPressed, this, &CDbDistributorSelectorComponent::onDataChanged); Q_ASSERT_X(c, Q_FUNC_INFO, "Missing connect"); - c = connect(sApp->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbDistributorSelectorComponent::ps_distributorsRead); + c = connect(sApp->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbDistributorSelectorComponent::onDistributorsRead); Q_ASSERT_X(c, Q_FUNC_INFO, "Missing connect"); Q_UNUSED(c); - this->ps_distributorsRead(CEntityFlags::DistributorEntity, CEntityFlags::ReadFinished, sApp->getWebDataServices()->getDistributorsCount()); + this->onDistributorsRead(CEntityFlags::DistributorEntity, CEntityFlags::ReadFinished, sApp->getWebDataServices()->getDistributorsCount()); } CDbDistributorSelectorComponent::~CDbDistributorSelectorComponent() @@ -67,7 +67,7 @@ namespace BlackGui void CDbDistributorSelectorComponent::setDistributor(const CDistributor &distributor) { - QString key(distributor.getDbKey()); + const QString key(distributor.getDbKey()); if (key.isEmpty()) { return; } if (distributor != m_currentDistributor) { @@ -80,7 +80,7 @@ namespace BlackGui void CDbDistributorSelectorComponent::setDistributor(const QString &distributorKeyOrAlias) { QString keyOrAlias(distributorKeyOrAlias.toUpper().trimmed()); - if (this->m_currentDistributor.matchesKeyOrAlias(keyOrAlias)) { return; } + if (m_currentDistributor.matchesKeyOrAlias(keyOrAlias)) { return; } CDistributor d(sGui->getWebDataServices()->getDistributors().findByKeyOrAlias(keyOrAlias)); if (d.hasCompleteData()) { @@ -96,11 +96,11 @@ namespace BlackGui CDistributor CDbDistributorSelectorComponent::getDistributor() const { if (!sGui) { return CDistributor(); } - QString distributorKeyOrAlias(ui->le_Distributor->text().trimmed().toUpper()); + const QString distributorKeyOrAlias(ui->le_Distributor->text().trimmed().toUpper()); if (distributorKeyOrAlias.isEmpty()) { return CDistributor(); } - if (this->m_currentDistributor.matchesKeyOrAlias(distributorKeyOrAlias)) { return this->m_currentDistributor; } + if (m_currentDistributor.matchesKeyOrAlias(distributorKeyOrAlias)) { return m_currentDistributor; } - CDistributor d(sGui->getWebDataServices()->getDistributors().findByKey(distributorKeyOrAlias)); + const CDistributor d(sGui->getWebDataServices()->getDistributors().findByKey(distributorKeyOrAlias)); if (d.hasValidDbKey()) { // for some reason we have a new distributor here @@ -169,7 +169,7 @@ namespace BlackGui } } - void CDbDistributorSelectorComponent::ps_distributorsRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count) + void CDbDistributorSelectorComponent::onDistributorsRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count) { if (!sGui) { return; } if (entity.testFlag(CEntityFlags::DistributorEntity) && readState == CEntityFlags::ReadFinished) @@ -181,7 +181,7 @@ namespace BlackGui c->setCaseSensitivity(Qt::CaseInsensitive); c->setCompletionMode(QCompleter::PopupCompletion); c->setMaxVisibleItems(10); - connect(c, static_cast(&QCompleter::activated), this, &CDbDistributorSelectorComponent::ps_completerActivated); + connect(c, static_cast(&QCompleter::activated), this, &CDbDistributorSelectorComponent::onCompleterActivated); ui->le_Distributor->setCompleter(c); m_completerDistributors.reset(c); // deletes any old completer @@ -189,13 +189,13 @@ namespace BlackGui } else { - this->m_completerDistributors.reset(nullptr); + m_completerDistributors.reset(nullptr); this->setReadOnly(true); } } } - void CDbDistributorSelectorComponent::ps_dataChanged() + void CDbDistributorSelectorComponent::onDataChanged() { if (!sGui) { return; } QString keyOrAlias(ui->le_Distributor->text().trimmed().toUpper()); @@ -204,7 +204,7 @@ namespace BlackGui this->setDistributor(d); } - void CDbDistributorSelectorComponent::ps_completerActivated(const QString &distributorKeyOrAlias) + void CDbDistributorSelectorComponent::onCompleterActivated(const QString &distributorKeyOrAlias) { this->setDistributor(distributorKeyOrAlias); } diff --git a/src/blackgui/components/dbdistributorselectorcomponent.h b/src/blackgui/components/dbdistributorselectorcomponent.h index 442c324e1..7c106a72a 100644 --- a/src/blackgui/components/dbdistributorselectorcomponent.h +++ b/src/blackgui/components/dbdistributorselectorcomponent.h @@ -31,7 +31,6 @@ class QDropEvent; class QWidget; namespace Ui { class CDbDistributorSelectorComponent; } - namespace BlackGui { namespace Components @@ -50,7 +49,7 @@ namespace BlackGui explicit CDbDistributorSelectorComponent(QWidget *parent = nullptr); //! Destructor - ~CDbDistributorSelectorComponent(); + virtual ~CDbDistributorSelectorComponent(); //! Current distributor void setDistributor(const BlackMisc::Simulation::CDistributor &distributor); @@ -90,17 +89,16 @@ namespace BlackGui //! \copydoc QWidget::dropEvent virtual void dropEvent(QDropEvent *event) override; - private slots: - //! Distributors have been read - void ps_distributorsRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState readState, int count); - - //! Data have been changed - void ps_dataChanged(); - - //! Data have been changed - void ps_completerActivated(const QString &distributorKeyOrAlias); - private: + //! Distributors have been read + void onDistributorsRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState readState, int count); + + //! Data have been changed + void onDataChanged(); + + //! Data have been changed + void onCompleterActivated(const QString &distributorKeyOrAlias); + QScopedPointer ui; QScopedPointer m_completerDistributors; QMetaObject::Connection m_signalConnection;