mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 23:25:53 +08:00
Added an (experimental) tree view to ATC stations
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
|
||||
#include "atcstationcomponent.h"
|
||||
#include "../views/atcstationview.h"
|
||||
#include "../guiutility.h"
|
||||
#include "ui_atcstationcomponent.h"
|
||||
#include "blackmisc/avinformationmessage.h"
|
||||
@@ -47,6 +46,9 @@ namespace BlackGui
|
||||
this->ui->tvp_AtcStationsBooked->setStationMode(CAtcStationListModel::StationsBooked);
|
||||
this->ui->tvp_AtcStationsBooked->setResizeMode(CAtcStationView::ResizingOnce);
|
||||
|
||||
// header
|
||||
this->ui->tvp_AtcStationsOnlineTree->setHeaderHidden(true);
|
||||
|
||||
// Signal / Slots
|
||||
bool connected = this->connect(this->ui->le_AtcStationsOnlineMetar, SIGNAL(returnPressed()), this, SLOT(getMetar()));
|
||||
Q_ASSERT(connected);
|
||||
@@ -123,11 +125,14 @@ namespace BlackGui
|
||||
this->ui->tvp_AtcStationsOnline->updateContainerMaybeAsync(this->getIContextNetwork()->getAtcStationsOnline());
|
||||
this->m_timestampLastReadOnlineStations = QDateTime::currentDateTimeUtc();
|
||||
this->m_timestampOnlineStationsChanged = this->m_timestampLastReadOnlineStations;
|
||||
|
||||
this->updateTreeView();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui->tvp_AtcStationsOnline->clear();
|
||||
this->updateTreeView();
|
||||
this->ui->le_AtcStationsOnlineMetar->clear();
|
||||
}
|
||||
}
|
||||
@@ -146,9 +151,9 @@ namespace BlackGui
|
||||
}
|
||||
QString icao = airportIcaoCode.isEmpty() ? this->ui->le_AtcStationsOnlineMetar->text().trimmed().toUpper() : airportIcaoCode.trimmed().toUpper();
|
||||
this->ui->le_AtcStationsOnlineMetar->setText(icao);
|
||||
if (icao.length() != 4) return;
|
||||
if (icao.length() != 4) { return; }
|
||||
CInformationMessage metar = this->getIContextNetwork()->getMetar(icao);
|
||||
if (metar.getType() != CInformationMessage::METAR) return;
|
||||
if (metar.getType() != CInformationMessage::METAR) { return; }
|
||||
if (metar.isEmpty())
|
||||
{
|
||||
this->ui->te_AtcStationsOnlineInfo->clear();
|
||||
@@ -202,6 +207,7 @@ namespace BlackGui
|
||||
if (INetwork::isDisconnectedStatus(toStatus))
|
||||
{
|
||||
this->ui->tvp_AtcStationsOnline->clear();
|
||||
this->updateTreeView();
|
||||
this->ui->le_AtcStationsOnlineMetar->clear();
|
||||
}
|
||||
}
|
||||
@@ -252,6 +258,22 @@ namespace BlackGui
|
||||
this->getIContextOwnAircraft()->updateComFrequency(frequency, static_cast<int>(unit), originator());
|
||||
}
|
||||
|
||||
void CAtcStationComponent::updateTreeView()
|
||||
{
|
||||
QAbstractItemModel *old = (this->ui->tvp_AtcStationsOnlineTree->model());
|
||||
this->ui->tvp_AtcStationsOnlineTree->setModel(
|
||||
this->ui->tvp_AtcStationsOnline->derivedModel()->toAtcGroupModel()
|
||||
);
|
||||
if (old) { old->deleteLater(); }
|
||||
if (!this->ui->tvp_AtcStationsOnlineTree->model()) { return; }
|
||||
|
||||
this->ui->tvp_AtcStationsOnlineTree->expandAll();
|
||||
for (int i = 0; i < this->ui->tvp_AtcStationsOnlineTree->model()->columnCount(); i++)
|
||||
{
|
||||
this->ui->tvp_AtcStationsOnlineTree->resizeColumnToContents(i);
|
||||
}
|
||||
}
|
||||
|
||||
void CAtcStationComponent::ps_onlineAtcStationSelected(QModelIndex index)
|
||||
{
|
||||
this->ui->te_AtcStationsOnlineInfo->setText(""); // reset
|
||||
|
||||
@@ -113,6 +113,8 @@ namespace BlackGui
|
||||
void ps_setComFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, BlackMisc::Aviation::CComSystem::ComUnit unit);
|
||||
|
||||
private:
|
||||
void updateTreeView();
|
||||
|
||||
QScopedPointer<Ui::CAtcStationComponent> ui;
|
||||
CUpdateTimer *m_updateTimer = nullptr;
|
||||
QDateTime m_timestampLastReadOnlineStations = CUpdateTimer::epoch(); //!< stations read
|
||||
|
||||
@@ -211,6 +211,31 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tb_AtcStationsOnlineTree">
|
||||
<attribute name="title">
|
||||
<string>Online (tree)</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="vl_AtcStationsOnlineTree">
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTreeView" name="tvp_AtcStationsOnlineTree"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tb_AtcStationsBooked">
|
||||
<attribute name="title">
|
||||
<string>Booked</string>
|
||||
|
||||
Reference in New Issue
Block a user