6 #include "ui_aircraftpartscomponent.h"
16 using namespace swift::misc::aviation;
17 using namespace swift::misc::network;
18 using namespace swift::misc::math;
19 using namespace swift::misc::physical_quantities;
20 using namespace swift::misc::simulation;
22 using namespace swift::core::context;
26 CAircraftPartsComponent::CAircraftPartsComponent(QWidget *parent)
31 ui->editor_AircraftParts->showSetButton(
false);
32 connect(ui->pb_SendAircraftPartsGui, &QPushButton::released,
this, &CAircraftPartsComponent::sendAircraftParts);
33 connect(ui->pb_SendAircraftPartsJson, &QPushButton::released,
this,
34 &CAircraftPartsComponent::sendAircraftParts);
35 connect(ui->pb_CurrentParts, &QPushButton::released,
this, &CAircraftPartsComponent::setCurrentParts);
36 connect(ui->pb_OwnParts, &QPushButton::released,
this, &CAircraftPartsComponent::displayOwnParts);
37 connect(ui->pb_RequestFromNetwork, &QPushButton::released,
this,
38 &CAircraftPartsComponent::requestPartsFromNetwork);
39 connect(ui->pb_DisplayLog, &QPushButton::released,
this, &CAircraftPartsComponent::displayLogInSimulator);
41 &CAircraftPartsComponent::onCallsignChanged);
43 ui->comp_RemoteAircraftCompleter->addOwnCallsign(
true);
53 ui->comp_RemoteAircraftCompleter->setCallsign(callsign);
54 this->onCallsignChanged();
57 void CAircraftPartsComponent::sendAircraftParts()
67 const CCallsign callsign(ui->comp_RemoteAircraftCompleter->getCallsign(
true));
68 if (callsign.isEmpty())
83 static const QString question(
"'%1' does not support parts, enable parts for it?");
84 const QMessageBox::StandardButton reply = QMessageBox::question(
85 this,
"No parts supported", question.arg(callsign.asString()), QMessageBox::Yes | QMessageBox::No);
86 if (reply != QMessageBox::Yes) {
return; }
92 const bool json = (QObject::sender() == ui->pb_SendAircraftPartsJson);
93 const CAircraftParts parts = json ? ui->editor_AircraftParts->getAircraftPartsFromJson() :
94 ui->editor_AircraftParts->getAircraftPartsFromGui();
95 ui->editor_AircraftParts->setAircraftParts(parts);
97 ui->tb_History->setToolTip(
"");
98 const bool incremental = ui->cb_AircraftPartsIncremental->isChecked();
103 void CAircraftPartsComponent::setCurrentParts()
106 const CCallsign callsign(ui->comp_RemoteAircraftCompleter->getCallsign());
107 if (callsign.isEmpty()) {
return; }
117 ui->editor_AircraftParts->setAircraftParts(parts);
118 ui->tb_History->setToolTip(history.
toHtml());
121 void CAircraftPartsComponent::requestPartsFromNetwork()
126 const CCallsign callsign(ui->comp_RemoteAircraftCompleter->getCallsign(
true));
127 if (callsign.isEmpty())
132 ui->pb_RequestFromNetwork->setEnabled(
false);
134 CLogMessage(
this).
info(u
"Request aircraft config for '%1'") << callsign.asString();
137 const QPointer<CAircraftPartsComponent> myself(
this);
139 if (!myself) {
return; }
140 ui->pb_CurrentParts->click();
141 ui->pb_RequestFromNetwork->setEnabled(
true);
145 void CAircraftPartsComponent::onCallsignChanged()
147 this->setCurrentParts();
148 emit this->
callsignChanged(ui->comp_RemoteAircraftCompleter->getCallsign());
151 void CAircraftPartsComponent::displayOwnParts()
159 ui->comp_RemoteAircraftCompleter->setCallsign(cs);
160 ui->editor_AircraftParts->setAircraftParts(parts);
163 void CAircraftPartsComponent::displayLogInSimulator()
167 const CCallsign callsign(ui->comp_RemoteAircraftCompleter->getCallsign(
true));
168 if (callsign.isEmpty())
175 const QString dotCmd(
".drv pos " + callsign.asString());
const context::IContextOwnAircraft * getIContextOwnAircraft() const
Direct access to contexts if a CCoreFacade has been initialized.
const context::IContextNetwork * getIContextNetwork() const
Direct access to contexts if a CCoreFacade has been initialized.
bool isShuttingDown() const
Is application shutting down?
const context::IContextSimulator * getIContextSimulator() const
Direct access to contexts if a CCoreFacade has been initialized.
virtual bool parseCommandLine(const QString &commandLine, const swift::misc::CIdentifier &originator)=0
Parse a given command line.
virtual swift::misc::CStatusMessageList getAircraftPartsHistory(const swift::misc::aviation::CCallsign &callsign) const =0
Get aircraft parts history.
virtual bool setOtherClient(const swift::misc::network::CClient &client)=0
Set client for given callsign.
virtual swift::misc::aviation::CAircraftPartsList getRemoteAircraftParts(const swift::misc::aviation::CCallsign &callsign) const =0
Get remote aircraft parts.
virtual swift::misc::network::CClientList getClientsForCallsigns(const swift::misc::aviation::CCallsignSet &callsigns) const =0
Clients for given callsign, e.g. to test/fetch direct aircraft model.
virtual void testRequestAircraftConfig(const swift::misc::aviation::CCallsign &callsign)=0
Request parts for callsign (from another client)
virtual void testAddAircraftParts(const swift::misc::aviation::CCallsign &callsign, const swift::misc::aviation::CAircraftParts &parts, bool incremental)=0
Inject aircraft parts for testing.
virtual bool isConnected() const =0
Network connected?
virtual swift::misc::simulation::CSimulatedAircraft getOwnAircraft() const =0
Get own aircraft.
Allows to display and manipulate parts.
virtual ~CAircraftPartsComponent()
Dtor.
void setCallsign(const swift::misc::aviation::CCallsign &callsign)
Set selected callsign.
void callsignChanged(const swift::misc::aviation::CCallsign &callsign)
Currently used callsign.
void validCallsignEnteredDigest()
Changed callsign entered.
Value object encapsulating information identifying a component of a modular distributed swift process...
Class for emitting a log message.
Derived & validationError(const char16_t(&format)[N])
Set the severity to error, providing a format string, and adding the validation category.
Derived & info(const char16_t(&format)[N])
Set the severity to info, providing a format string.
const_reference frontOrDefault() const
Access the first element, or a default-initialized value if the sequence is empty.
bool isEmpty() const
Synonym for empty.
Streamable status message, e.g.
Status messages, e.g. from Core -> GUI.
QString toHtml(const CPropertyIndexList &indexes=simpleHtmlOutput()) const
Specialized version to convert to HTML.
OBJ latestObject() const
Latest object.
Value object encapsulating information of aircraft's parts.
Value object encapsulating a list of aircraft parts.
Value object encapsulating information of a callsign.
bool isEmpty() const
Is empty?
bool hasAircraftPartsCapability() const
Supports aircraft parts?
void addCapability(Capability capability)
Add capability.
const aviation::CCallsign & getCallsign() const
Callsign used with other client.
Comprehensive information of an aircraft.
const aviation::CCallsign & getCallsign() const
Get callsign.
const aviation::CAircraftParts & getParts() const
Get aircraft parts.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
Backend services of the swift project, like dealing with the network or the simulators.
High level reusable GUI components.
Free functions in swift::misc.
auto singleShot(int msec, QObject *target, F &&task)
Starts a single-shot timer which will call a task in the thread of the given object when it times out...