Found during T215, rectify CIdentifier issues

* null/anonymous identifier
* CIdentifier can be linked with QObject and
* CIdentifier reflects name changes of QObject (UI components change name after ctor call)
This commit is contained in:
Klaus Basan
2018-01-02 19:43:16 +01:00
parent 2fab47a5d3
commit 26b5a6ce28
14 changed files with 99 additions and 68 deletions

View File

@@ -778,12 +778,6 @@ namespace BlackGui
}
}
const CIdentifier &CFlightPlanComponent::flightPlanIdentifier()
{
static const CIdentifier i(QStringLiteral("FLIGHTPLANCOMPONENT"));
return i;
}
void CFlightPlanComponent::initCompleters()
{
if (!sGui || !sGui->hasWebDataServices()) { return; }

View File

@@ -60,7 +60,7 @@ namespace BlackGui
QScopedPointer<Ui::CFlightPlanComponent> ui;
BlackMisc::Aviation::CFlightPlan m_flightPlan; //!< My flight plan
BlackMisc::Simulation::CAircraftModel m_model; //!< currently used model
BlackMisc::CIdentifier m_identifier; //!< Flightplan identifier
BlackMisc::CIdentifier m_identifier { "FlightPlanComponent", this }; //!< Flightplan identifier
BlackMisc::CDataReadOnly<BlackMisc::Simulation::Data::TLastModel> m_lastAircraftModel { this }; //!< recently used aircraft model
BlackMisc::CDataReadOnly<BlackMisc::Network::Data::TLastServer> m_lastServer { this }; //!< recently used server (VATSIM, other)
@@ -76,7 +76,7 @@ namespace BlackGui
static const QString &defaultTime() { static const QString t("00:00"); return t; }
//! Identifier
static const BlackMisc::CIdentifier &flightPlanIdentifier();
const BlackMisc::CIdentifier &flightPlanIdentifier() const { return m_identifier; }
//! Prefill with own aircraft data
void prefillWithOwnAircraftData();

View File

@@ -96,7 +96,7 @@ namespace BlackGui
void disableButtonBriefly();
QScopedPointer<Ui::CMainKeypadAreaComponent> ui;
BlackMisc::CIdentifier m_identifier { QStringLiteral("KEYPADAREACOMPONENT") };
BlackMisc::CIdentifier m_identifier { "MainKeypadAreaComponent", this };
};
} // namespace
} // namespace

View File

@@ -374,15 +374,6 @@ namespace BlackGui
}
}
CIdentifier CMappingComponent::mappingIdentifier()
{
if (m_identifier.getName().isEmpty())
{
m_identifier = CIdentifier(QStringLiteral("MAPPINGCOMPONENT"));
}
return m_identifier;
}
void CMappingComponent::updateRenderedAircraftView(bool forceUpdate)
{
m_updateTimer.start(); // restart

View File

@@ -137,7 +137,7 @@ namespace BlackGui
void connectionStatusChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to);
//! Identifier for data send from this component
BlackMisc::CIdentifier mappingIdentifier();
const BlackMisc::CIdentifier &mappingIdentifier() const { return m_identifier; }
//! Update simulated aircraft view
void updateRenderedAircraftView(bool forceUpdate = false);
@@ -151,7 +151,7 @@ namespace BlackGui
QTimer m_updateTimer { this };
BlackMisc::CTokenBucket m_bucket { 3, BlackMisc::PhysicalQuantities::CTime(5.0, BlackMisc::PhysicalQuantities::CTimeUnit::s()), 1};
Views::CCheckBoxDelegate *m_currentMappingsViewDelegate = nullptr; //! checkbox in view
BlackMisc::CIdentifier m_identifier;
BlackMisc::CIdentifier m_identifier { "MappingComponent", this };
};
} // namespace
} // namespace

View File

@@ -92,14 +92,10 @@ namespace BlackGui
{
switch (tab)
{
case TextMessagesAll:
return ui->tb_TextMessagesAll;
case TextMessagesCom1:
return ui->tb_TextMessagesCOM1;
case TextMessagesCom2:
return ui->tb_TextMessagesCOM2;
case TextMessagesUnicom:
return ui->tb_TextMessagesUnicom;
case TextMessagesAll: return ui->tb_TextMessagesAll;
case TextMessagesCom1: return ui->tb_TextMessagesCOM1;
case TextMessagesCom2: return ui->tb_TextMessagesCOM2;
case TextMessagesUnicom: return ui->tb_TextMessagesUnicom;
default:
Q_ASSERT_X(false, Q_FUNC_INFO, "Wrong index");
break;
@@ -120,7 +116,7 @@ namespace BlackGui
{
if (messages.isEmpty()) return;
const CSimulatedAircraft ownAircraft(this->getOwnAircraft());
const CTextMessageSettings msgSettings(this->m_messageSettings.getThreadLocal());
const CTextMessageSettings msgSettings(m_messageSettings.getThreadLocal());
for (const CTextMessage &message : messages)
{
@@ -193,14 +189,6 @@ namespace BlackGui
}
}
CIdentifier CTextMessageComponent::componentIdentifier()
{
if (m_identifier.getName().isEmpty())
m_identifier = CIdentifier(QStringLiteral("TEXTMESSAGECOMPONENT"));
return m_identifier;
}
void CTextMessageComponent::onChangedAircraftCockpit()
{
this->showCurrentFrequenciesFromCockpit();
@@ -214,7 +202,7 @@ namespace BlackGui
if (textMessage.isPrivateMessage())
{
// private message
CCallsign cs = textMessage.getSenderCallsign();
const CCallsign cs = textMessage.getSenderCallsign();
if (cs.isEmpty()) return false;
QWidget *tab = this->findTextMessageTabByName(cs.getStringAsSet());
if (!tab) { return false; }
@@ -292,12 +280,12 @@ namespace BlackGui
if (!textMessage.isPrivateMessage()) { return; }
const CCallsign cs = textMessage.wasSent() ? textMessage.getRecipientCallsign() : textMessage.getSenderCallsign();
if (cs.isEmpty()) { return; }
QWidget *tab = this->findTextMessageTabByCallsign(cs);
const QWidget *tab = this->findTextMessageTabByCallsign(cs);
if (!tab) { tab = this->addNewTextMessageTab(cs); }
Q_ASSERT_X(tab, Q_FUNC_INFO, "Missing tab");
CTextMessageTextEdit *textEdit = tab->findChild<CTextMessageTextEdit *>();
BLACK_VERIFY_X(textEdit, Q_FUNC_INFO, "Missing text edit");
if (!textEdit) { return; } // do not crash, though this situation could not happen
if (!textEdit) { return; } // do not crash, though this situation should not happen
textEdit->insertTextMessage(textMessage);
// sound

View File

@@ -56,7 +56,7 @@ namespace BlackGui
virtual ~CTextMessageComponent();
//! \copydoc CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea
virtual bool setParentDockWidgetInfoArea(BlackGui::CDockWidgetInfoArea *parentDockableWidget) override;
virtual bool setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget) override;
signals:
//! Message to be displayed in info window
@@ -80,8 +80,8 @@ namespace BlackGui
private:
QScopedPointer<Ui::CTextMessageComponent> ui;
BlackMisc::CIdentifier m_identifier;
BlackMisc::CSettingReadOnly<BlackGui::Settings::TextMessageSettings> m_messageSettings { this };
BlackMisc::CIdentifier m_identifier { "TextMessageComponent", this };
BlackMisc::CSettingReadOnly<Settings::TextMessageSettings> m_messageSettings { this };
//! Enum to widget
QWidget *getTabWidget(Tab tab) const;
@@ -124,7 +124,7 @@ namespace BlackGui
QString textMessageToCommand(const QString &enteredLine);
//! Identifier
BlackMisc::CIdentifier componentIdentifier();
const BlackMisc::CIdentifier &componentIdentifier() const { return m_identifier; }
//! Handle a text message entered
void handleEnteredTextMessage(const QString &textMessage);