swift
flightplandialog.cpp
1 // SPDX-FileCopyrightText: Copyright (C) 2019 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
4 #include "flightplandialog.h"
5 
6 #include "ui_flightplandialog.h"
7 
9 #include "gui/guiapplication.h"
11 
12 using namespace swift::misc::aviation;
13 using namespace swift::core::context;
14 using namespace swift::gui::components;
15 
16 namespace swift::gui::views
17 {
18  CFlightPlanDialog::CFlightPlanDialog(QWidget *parent) : QDialog(parent), ui(new Ui::CFlightPlanDialog)
19  {
20  ui->setupUi(this);
21  this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
22 
23  connect(ui->pb_LoadFlightPlan, &QPushButton::clicked, this, &CFlightPlanDialog::loadFp);
24  connect(ui->comp_CallsignCompleter, &CCallsignCompleter::validCallsignEnteredDigest, this,
25  &CFlightPlanDialog::loadFp);
26  }
27 
29 
31  {
32  if (callsign.isEmpty()) { return; }
33  if (!sGui || sGui->isShuttingDown() || !sGui->getIContextNetwork()) { return; }
35  ui->te_FlightPlan->setText(fp.asHTML(true));
36  ui->comp_CallsignCompleter->setCallsign(callsign);
37  this->setDialogTitle(callsign);
38  this->exec();
39  }
40 
41  void CFlightPlanDialog::setDialogTitle(const CCallsign &callsign)
42  {
43  if (callsign.isEmpty())
44  {
45  this->setWindowTitle("Flight plan");
46  return;
47  }
48  this->setWindowTitle("Flight plan for " + callsign.asString());
49  }
50 
51  void CFlightPlanDialog::loadFp()
52  {
53  const CCallsign cs = ui->comp_CallsignCompleter->getCallsign(false);
54  this->showFlightPlan(cs);
55  }
56 
57 } // namespace swift::gui::views
const context::IContextNetwork * getIContextNetwork() const
Direct access to contexts if a CCoreFacade has been initialized.
bool isShuttingDown() const
Is application shutting down?
virtual swift::misc::aviation::CFlightPlan loadFlightPlanFromNetwork(const swift::misc::aviation::CCallsign &callsign) const =0
Load flight plan (from network)
Flight plan as dialog, also meant for other callsigns.
void showFlightPlan(const swift::misc::aviation::CCallsign &callsign)
Show a particular callsign flight plan.
Value object encapsulating information of a callsign.
Definition: callsign.h:30
const QString & asString() const
Get callsign (normalized)
Definition: callsign.h:96
bool isEmpty() const
Is empty?
Definition: callsign.h:63
Value object for a flight plan.
Definition: flightplan.h:148
QString asHTML(bool i18n=false) const
As HTML.
Definition: flightplan.cpp:309
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
High level reusable GUI components.
Definition: aboutdialog.cpp:13
Views, mainly QTableView.