11#include "gui/menus/menuaction.h"
18using namespace swift::misc::aviation;
35 if (!this->stationModel())
39 this->stationModel()->changedAtcStationConnectionStatus(station, added);
44 if (!this->stationModel())
49 this->stationModel()->updateContainer(stations);
55 if (!this->stationModel())
59 this->stationModel()->clear();
66 if (this->stationModel())
68 this->stationModel()->setColumns(columns);
74 void CAtcStationTreeView::fullResizeToContentsImpl()
91 CAtcStationTreeModel *CAtcStationTreeView::stationModel()
96 CAtcStation CAtcStationTreeView::selectedObject()
const
99 return this->selectedObject(index);
102 CAtcStation CAtcStationTreeView::selectedObject(
const QModelIndex &index)
const
105 const QString callsign = data.
toString();
106 const CAtcStationTreeModel *
model = this->stationModel();
111 return model->container().findFirstByCallsign(CCallsign(callsign, CCallsign::Atc));
114 QString CAtcStationTreeView::suffixForIndex(
const QModelIndex &index)
116 const QVariant data = this->
model()->
data(index);
120 void CAtcStationTreeView::onExpanded(
const QModelIndex &index)
126 void CAtcStationTreeView::onSelected(
const QItemSelection &selected,
const QItemSelection &deselected)
128 Q_UNUSED(deselected);
133 const CAtcStation atcStation = this->selectedObject(selected.
indexes().front());
141 void CAtcStationTreeView::customMenu(
const QPoint &point)
143 if (!this->stationModel())
147 if (this->stationModel()->container().
isEmpty())
152 auto *menu =
new QMenu(
this);
168 menu->addAction(com1);
169 menu->addAction(com2);
170 menu->addAction(com1_stby);
171 menu->addAction(com2_stby);
172 menu->addAction(text);
173 menu->addSeparator();
179 void CAtcStationTreeView::storeState()
184 const QModelIndex i = this->
model()->
index(row, 0);
186 const QString suffix = this->suffixForIndex(i);
187 m_expanded.insert(suffix,
expanded);
191 void CAtcStationTreeView::restoreState()
195 const QModelIndex i = this->
model()->
index(row, 0);
196 const QString suffix = this->suffixForIndex(i);
197 const bool expanded = m_expanded.value(suffix,
true);
204 const CAtcStation s(this->selectedObject());
205 if (s.getCallsign().isEmpty())
212 void CAtcStationTreeView::requestTextMessage()
214 const CAtcStation s(this->selectedObject());
215 if (s.getCallsign().isEmpty())
COverlayMessagesTreeView(QWidget *parent=nullptr)
Constructor.
void requestComFrequency(const swift::misc::physical_quantities::CFrequency &frequency, swift::misc::aviation::CComSystem::ComUnit unit, bool active)
Request COM frequency.
CAtcStationTreeView(QWidget *parent=nullptr)
Constructor.
void objectSelected(const swift::misc::aviation::CAtcStation &station)
This object has been selected.
bool isEmpty() const
Empty.
void updateContainer(const swift::misc::aviation::CAtcStationList &stations)
Update container.
void requestTextMessageWidget(const swift::misc::aviation::CCallsign &callsign)
Request a text message to.
void fullResizeToContents()
Resize all columns.
void changedAtcStationConnectionStatus(const swift::misc::aviation::CAtcStation &station, bool added)
Used to quickly update single station (better response for the user).
void setColumns(const models::CColumns &columns)
Set columns.
static const QPixmap & appCockpit16()
Application cockpit.
static const QPixmap & resize16()
Resize.
static const QPixmap & appTextMessages16()
Application text messages.
Value object encapsulating information about an ATC station.
bool hasCallsign() const
Has callsign?
Value object for a list of ATC stations.
Models to be used with views, mainly QTableView.
Views, mainly QTableView.
Free functions in swift::misc.
virtual int columnCount(const QModelIndex &parent) const const=0
virtual QVariant data(const QModelIndex &index, int role) const const=0
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const=0
virtual int rowCount(const QModelIndex &parent) const const=0
QModelIndex currentIndex() const const
QAbstractItemModel * model() const const
QItemSelectionModel * selectionModel() const const
void triggered(bool checked)
QModelIndexList indexes() const const
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
bool isEmpty() const const
QModelIndex siblingAtColumn(int column) const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * parent() const const
T qobject_cast(QObject *object)
void expanded(const QModelIndex &index)
bool isExpanded(const QModelIndex &index) const const
void resizeColumnToContents(int column)
void setExpanded(const QModelIndex &index, bool expanded)
virtual void setModel(QAbstractItemModel *model) override
QString toString() const const