swift
Loading...
Searching...
No Matches
atcstationview.cpp
1// SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#include <QFlags>
7#include <QtGlobal>
8
10#include "gui/menus/menuaction.h"
13#include "misc/icons.h"
14
15using namespace swift::config;
16using namespace swift::misc;
17using namespace swift::misc::aviation;
18using namespace swift::gui::models;
19using namespace swift::gui::menus;
20
21namespace swift::gui::views
22{
24 {
25 this->standardInit(new CAtcStationListModel(CAtcStationListModel::StationsOnline, this));
27 }
28
30 {
31 Q_ASSERT(m_model);
32 m_model->setStationMode(stationMode);
33 this->setSortIndicator();
34 }
35
37 {
38 m_model->changedAtcStationConnectionStatus(station, added);
39
40 // resize the first, rest will be resized with normal updates
41 if (this->rowCount() == 1)
42 {
44 }
45 }
46
48 {
49 menuActions.addMenuCom();
51 {
52 if (m_debugActions.isEmpty())
53 {
54 m_debugActions = QList<QAction *>({ nullptr, nullptr });
55 }
56 m_debugActions[0] = menuActions.addAction(m_debugActions[0], CIcons::tableSheet16(),
57 "Test: 1k ATC online stations", CMenuAction::pathClientCom(),
58 { this, &CAtcStationView::emitTestRequest1kAtcOnlineDummies });
59 m_debugActions[1] = menuActions.addAction(m_debugActions[1], CIcons::tableSheet16(),
60 "Test: 3k ATC online stations", CMenuAction::pathClientCom(),
61 { this, &CAtcStationView::emitTestRequest3kAtcOnlineDummies });
62 }
63
64 if (this->hasSelection())
65 {
66 if (m_actions.isEmpty())
67 {
68 m_actions = QList<QAction *>({ nullptr, nullptr, nullptr, nullptr, nullptr });
69 }
70
71 m_actions[0] = menuActions.addAction(m_actions[0], CIcons::appCockpit16(), "Tune in COM1 (active)",
73 { this, [this]() { tuneInAtc(CComSystem::Com1, true); } });
74 m_actions[1] = menuActions.addAction(m_actions[1], CIcons::appCockpit16(), "Tune in COM2 (active)",
76 { this, [this]() { tuneInAtc(CComSystem::Com2, true); } });
77 m_actions[2] = menuActions.addAction(m_actions[2], CIcons::appCockpit16(), "Tune in COM1 (standby)",
79 { this, [this]() { tuneInAtc(CComSystem::Com1, false); } });
80 m_actions[3] = menuActions.addAction(m_actions[3], CIcons::appCockpit16(), "Tune in COM2 (standby)",
82 { this, [this]() { tuneInAtc(CComSystem::Com2, false); } });
83 m_actions[4] =
84 menuActions.addAction(m_actions[4], CIcons::appTextMessages16(), "Show text messages",
85 CMenuAction::pathClientCom(), { this, &CAtcStationView::requestTextMessage });
86 }
87 CViewBase::customMenu(menuActions);
88 }
89
90 void CAtcStationView::tuneInAtc(const misc::aviation::CComSystem::ComUnit unit, const bool active)
91 {
92 const CAtcStation s(this->selectedObject());
93 if (s.getCallsign().isEmpty())
94 {
95 return;
96 }
97 emit this->requestComFrequency(s.getFrequency(), unit, active);
98 }
99
100 void CAtcStationView::requestTextMessage()
101 {
102 const CAtcStation s(this->selectedObject());
103 if (s.getCallsign().isEmpty())
104 {
105 return;
106 }
107 emit this->requestTextMessageWidget(s.getCallsign());
108 }
109} // namespace swift::gui::views
static constexpr bool isDebugBuild()
Debug build?
static const QString & pathClientCom()
Client COM related.
Definition menuaction.h:209
Bunch of CMenuAction objects.
Definition menuaction.h:384
CMenuAction addMenuCom()
Add COM model menu.
CMenuAction addAction(const CMenuAction &menuAction)
Add menu action.
void setStationMode(swift::gui::models::CAtcStationListModel::AtcStationMode stationMode)
Set station mode.
void requestComFrequency(const swift::misc::physical_quantities::CFrequency &frequency, swift::misc::aviation::CComSystem::ComUnit unit, bool active)
Request COM frequency.
void customMenu(swift::gui::menus::CMenuActions &menuActions)
Method creating the menu.
void requestTextMessageWidget(const swift::misc::aviation::CCallsign &callsign)
Request a text message to.
CAtcStationView(QWidget *parent=nullptr)
Constructor.
void changedAtcStationConnectionStatus(const swift::misc::aviation::CAtcStation &station, bool added)
Used to quickly update single station (better response for the user).
void customMenu(menus::CMenuActions &menuActions)
Method creating the menu.
Definition viewbase.cpp:785
Menu m_menus
Default menu settings.
Definition viewbase.h:603
virtual void fullResizeToContents()
Full resizing to content, might be slow.
@ MenuClear
allow clearing the view via menu
Definition viewbase.h:120
@ MenuRefresh
allow refreshing the view via menu
Definition viewbase.h:122
bool hasSelection() const
Selection (selected rows).
static const QPixmap & appCockpit16()
Application cockpit.
static const QPixmap & appTextMessages16()
Application text messages.
static const QPixmap & tableSheet16()
Table sheet.
Value object encapsulating information about an ATC station.
Definition atcstation.h:38
Models to be used with views, mainly QTableView.
Views, mainly QTableView.
Free functions in swift::misc.
QObject * parent() const const