fix: Remove broken ATC station booking overview

Related to #252
This commit is contained in:
Lars Toenning
2024-01-25 11:19:58 +01:00
parent 945ef36151
commit 9f50aaaa4a
39 changed files with 62 additions and 972 deletions

View File

@@ -78,26 +78,22 @@ namespace BlackGui::Components
// set station mode
ui->tvp_AtcStationsOnline->setStationMode(CAtcStationListModel::StationsOnline);
ui->tvp_AtcStationsBooked->setStationMode(CAtcStationListModel::StationsBooked);
ui->tvp_AtcStationsOnlineTree->setColumns(ui->tvp_AtcStationsOnline->getColumns());
// menus
ui->tvp_AtcStationsOnline->menuRemoveItems(CAtcStationView::MenuClear);
ui->tvp_AtcStationsBooked->menuRemoveItems(CAtcStationView::MenuClear);
// Signal / Slots
connect(ui->le_AtcStationsOnlineMetar, &QLineEdit::returnPressed, this, &CAtcStationComponent::getMetarAsEntered);
connect(ui->tb_AtcStationsLoadMetar, &QPushButton::clicked, this, &CAtcStationComponent::getMetarAsEntered);
connect(ui->tb_Audio, &QPushButton::clicked, this, &CAtcStationComponent::requestAudioWidget);
connect(ui->tb_TextMessageOverlay, &QPushButton::clicked, this, &CAtcStationComponent::showOverlayInlineTextMessage);
connect(ui->tw_Atc, &QTabWidget::currentChanged, this, &CAtcStationComponent::atcStationsTabChanged); // "local" tab changed (booked, online)
connect(ui->tvp_AtcStationsOnline, &CAtcStationView::objectClicked, this, &CAtcStationComponent::onOnlineAtcStationVariantSelected, Qt::QueuedConnection);
connect(ui->tvp_AtcStationsOnline, &CAtcStationView::objectSelected, this, &CAtcStationComponent::onOnlineAtcStationVariantSelected, Qt::QueuedConnection);
connect(ui->tvp_AtcStationsOnline, &CAtcStationView::testRequestDummyAtcOnlineStations, this, &CAtcStationComponent::testCreateDummyOnlineAtcStations);
connect(ui->tvp_AtcStationsOnline, &CAtcStationView::requestUpdate, this, &CAtcStationComponent::requestOnlineStationsUpdate);
connect(ui->tvp_AtcStationsOnline, &CAtcStationView::requestNewBackendData, this, &CAtcStationComponent::requestOnlineStationsUpdate);
connect(ui->tvp_AtcStationsOnline, &CAtcStationView::modelDataChangedDigest, this, &CAtcStationComponent::onCountChanged);
connect(ui->tvp_AtcStationsOnline, &CAtcStationView::requestComFrequency, this, &CAtcStationComponent::setComFrequency);
connect(ui->tvp_AtcStationsOnline, &CAtcStationView::requestTextMessageWidget, this, &CAtcStationComponent::requestTextMessageWidget);
@@ -107,10 +103,6 @@ namespace BlackGui::Components
connect(ui->comp_AtcStationsSettings, &CSettingsAtcStationsInlineComponent::changed, this, &CAtcStationComponent::forceUpdate, Qt::QueuedConnection);
connect(ui->tvp_AtcStationsBooked, &CAtcStationView::requestUpdate, this, &CAtcStationComponent::reloadAtcStationsBooked);
connect(ui->tvp_AtcStationsBooked, &CAtcStationView::requestNewBackendData, this, &CAtcStationComponent::reloadAtcStationsBooked);
connect(ui->tvp_AtcStationsBooked, &CAtcStationView::modelDataChangedDigest, this, &CAtcStationComponent::onCountChanged);
connect(ui->tb_AtcStationsAtisReload, &QPushButton::clicked, this, &CAtcStationComponent::requestAtisUpdates);
connect(&m_updateTimer, &QTimer::timeout, this, &CAtcStationComponent::update);
@@ -121,7 +113,6 @@ namespace BlackGui::Components
if (sGui)
{
connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationsOnlineDigest, this, &CAtcStationComponent::changedAtcStationsOnline, Qt::QueuedConnection);
connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationsBookedDigest, this, &CAtcStationComponent::changedAtcStationsBooked, Qt::QueuedConnection);
connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationOnlineConnectionStatus, this, &CAtcStationComponent::changedAtcStationOnlineConnectionStatus, Qt::QueuedConnection);
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CAtcStationComponent::connectionStatusChanged, Qt::QueuedConnection);
}
@@ -159,11 +150,6 @@ namespace BlackGui::Components
ui->tw_Atc->setCurrentIndex(t);
}
int CAtcStationComponent::countBookedStations() const
{
return ui->tvp_AtcStationsBooked->rowCount();
}
int CAtcStationComponent::countOnlineStations() const
{
return ui->tvp_AtcStationsOnline->rowCount();
@@ -187,25 +173,17 @@ namespace BlackGui::Components
void CAtcStationComponent::update()
{
if (!this->canAccessContext()) { return; }
Q_ASSERT(ui->tvp_AtcStationsBooked);
Q_ASSERT(ui->tvp_AtcStationsOnline);
// check if component is visible, if we have already data then skip udpate
const bool hasData = this->countBookedStations() > 0 || this->countOnlineStations() > 0;
const bool hasData = this->countOnlineStations() > 0;
if (hasData && !this->isVisibleWidget())
{
// Update skipped, as not visible
ui->tvp_AtcStationsBooked->hideLoadIndicator();
ui->tvp_AtcStationsOnline->hideLoadIndicator();
return;
}
// bookings
if (m_timestampBookedStationsChanged > m_timestampLastReadBookedStations)
{
this->reloadAtcStationsBooked();
}
// online stations, only when connected
if (sGui->getIContextNetwork()->isConnected())
{
@@ -296,25 +274,6 @@ namespace BlackGui::Components
}
}
void CAtcStationComponent::reloadAtcStationsBooked()
{
Q_ASSERT(ui->tvp_AtcStationsBooked);
if (!this->canAccessContext()) { return; }
QObject *sender = QObject::sender();
if (sender == ui->tvp_AtcStationsBooked)
{
// trigger new read, which takes some time. A signal will be received when this is done
CLogMessage(this).info(u"Requested new bookings");
sGui->getIContextNetwork()->requestAtcBookingsUpdate();
}
else
{
ui->tvp_AtcStationsBooked->updateContainerMaybeAsync(sGui->getIContextNetwork()->getAtcStationsBooked(false));
m_timestampLastReadBookedStations = QDateTime::currentDateTimeUtc();
}
}
void CAtcStationComponent::changedAtcStationsOnline()
{
// just update timestamp, data will be pulled by timer
@@ -322,19 +281,6 @@ namespace BlackGui::Components
m_timestampOnlineStationsChanged = QDateTime::currentDateTimeUtc();
}
void CAtcStationComponent::changedAtcStationsBooked()
{
// a change can mean a complete change of the bookings, or
// a single value is updated (e.g. online status)
// just update timestamp, data will be pulled by timer
// the timestamp will tell if there are any newer data
// unlike online stations, this can happen if we are not connected to a FSD server
m_timestampBookedStationsChanged = QDateTime::currentDateTimeUtc();
if (m_updateTimer.isActive()) { return; } // update by timer
this->update();
}
void CAtcStationComponent::connectionStatusChanged(const CConnectionStatus &from, const CConnectionStatus &to)
{
Q_UNUSED(from)
@@ -382,16 +328,6 @@ namespace BlackGui::Components
Q_UNUSED(index)
}
void CAtcStationComponent::onCountChanged(int count, bool withFilter)
{
Q_UNUSED(count)
Q_UNUSED(withFilter)
const int ib = ui->tw_Atc->indexOf(ui->tb_AtcStationsBooked);
QString b = ui->tw_Atc->tabBar()->tabText(ib);
b = CGuiUtility::replaceTabCountValue(b, this->countBookedStations());
ui->tw_Atc->tabBar()->setTabText(ib, b);
}
void CAtcStationComponent::setOnlineTabs(int count, int filtered)
{
const int io = ui->tw_Atc->indexOf(ui->tb_AtcStationsOnline);
@@ -483,19 +419,6 @@ namespace BlackGui::Components
m_selectedCallsign = station.getCallsign();
}
void CAtcStationComponent::atcStationsTabChanged()
{
const bool booked = ui->tw_Atc->currentWidget() == ui->tb_AtcStationsBooked;
if (booked)
{
if (ui->tvp_AtcStationsBooked->isEmpty())
{
this->reloadAtcStationsBooked();
}
}
ui->gb_Details->setVisible(!booked);
}
void CAtcStationComponent::requestAtisUpdates()
{
if (!this->canAccessContext()) { return; }

View File

@@ -56,7 +56,6 @@ namespace BlackGui
{
TabAtcOnline = 0,
TabAtcOnlineTree,
TabAtcBooked
};
//! Constructor
@@ -68,9 +67,6 @@ namespace BlackGui
//! Set tab
void setTab(AtcTab tab);
//! Number of booked stations
int countBookedStations() const;
//! Number of online stations
int countOnlineStations() const;
@@ -109,15 +105,6 @@ namespace BlackGui
//! Trigger a selection of an onlie station (async)
void triggerOnlineAtcStationSelected(const BlackMisc::Aviation::CAtcStation &station);
//! Tab changed
void atcStationsTabChanged();
//! Booked stations reloading
void reloadAtcStationsBooked();
//! Booked stations changed
void changedAtcStationsBooked();
//! Online stations changed
void changedAtcStationsOnline();
@@ -133,9 +120,6 @@ namespace BlackGui
//! Info area tab bar has changed
void infoAreaTabBarChanged(int index);
//! Count has been changed
void onCountChanged(int count, bool withFilter);
//! Online tab info
void setOnlineTabs(int count, int filtered);
@@ -175,8 +159,6 @@ namespace BlackGui
BlackMisc::Aviation::CCallsign m_selectedCallsign;
QDateTime m_timestampLastReadOnlineStations; //!< stations read
QDateTime m_timestampOnlineStationsChanged; //!< stations marked as changed
QDateTime m_timestampLastReadBookedStations; //!< stations read
QDateTime m_timestampBookedStationsChanged; //!< stations marked as changed
BlackMisc::CSettingReadOnly<BlackGui::Settings::TViewUpdateSettings> m_settingsView { this, &CAtcStationComponent::settingsChanged };
};
} // namespace

View File

@@ -120,59 +120,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_AtcStationsBooked">
<attribute name="title">
<string>ATC booked</string>
</attribute>
<layout class="QVBoxLayout" name="vl_AtcBooked">
<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="BlackGui::Views::CAtcStationView" name="tvp_AtcStationsBooked">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QGroupBox" name="gb_Details">
<property name="title">
@@ -341,7 +288,6 @@
<tabstop>tb_Audio</tabstop>
<tabstop>te_AtcStationsOnlineInfo</tabstop>
<tabstop>tvp_AtcStationsOnlineTree</tabstop>
<tabstop>tvp_AtcStationsBooked</tabstop>
</tabstops>
<resources/>
<connections/>

View File

@@ -40,8 +40,6 @@ namespace BlackGui::Models
(void)QT_TRANSLATE_NOOP("ModelAtcList", "distance");
(void)QT_TRANSLATE_NOOP("ModelAtcList", "controllername");
(void)QT_TRANSLATE_NOOP("ModelAtcList", "online");
(void)QT_TRANSLATE_NOOP("ModelAtcList", "bookedfrom");
(void)QT_TRANSLATE_NOOP("ModelAtcList", "bookeduntil");
}
void CAtcStationListModel::setStationMode(CAtcStationListModel::AtcStationMode stationMode)
@@ -64,8 +62,7 @@ namespace BlackGui::Models
m_columns.addColumn(CColumn("xc.", "AFV cross coupled", CAtcStation::IndexIsAfvCrossCoupled, new CBoolIconFormatter("AFV cross coupled", "not coupled")));
m_columns.addColumn(CColumn("range", CAtcStation::IndexRange, new CAirspaceDistanceFormatter()));
m_columns.addColumnIncognito(CColumn::standardString("controllername", { CAtcStation::IndexController, CUser::IndexRealName }));
m_columns.addColumn(CColumn("from", "booked from", CAtcStation::IndexBookedFrom, new CDateTimeFormatter(CDateTimeFormatter::formatHm())));
m_columns.addColumn(CColumn("until", "booked until", CAtcStation::IndexBookedUntil, new CDateTimeFormatter(CDateTimeFormatter::formatHm())));
m_columns.addColumn(CColumn("until", "expected logoff time", CAtcStation::IndexLogoffTime, new CDateTimeFormatter(CDateTimeFormatter::formatHm())));
// default sort order
this->setSortColumnByPropertyIndex(CAtcStation::IndexRelativeDistance);
@@ -73,24 +70,6 @@ namespace BlackGui::Models
}
break;
case StationsBooked:
{
m_columns.addColumn(CColumn::standardString("cs.", "callsign", { CAtcStation::IndexCallsign, CCallsign::IndexCallsignStringAsSet }));
CColumn col = CColumn("type", CAtcStation::IndexIcon);
col.setSortPropertyIndex({ CAtcStation::IndexCallsign, CCallsign::IndexSuffix });
m_columns.addColumn(col);
m_columns.addColumn(CColumn("", "on/offline", CAtcStation::IndexIsOnline, new CBoolLedFormatter("online", "offline")));
m_columns.addColumnIncognito(CColumn::standardString("controllername", { CAtcStation::IndexController, CUser::IndexRealName }));
m_columns.addColumn(CColumn("from", "booked from", CAtcStation::IndexBookedFrom, new CDateTimeFormatter(CDateTimeFormatter::formatYmdhm())));
m_columns.addColumn(CColumn("until", "booked until", CAtcStation::IndexBookedUntil, new CDateTimeFormatter(CDateTimeFormatter::formatYmdhm())));
m_columns.addColumn(CColumn("frequency", CAtcStation::IndexFrequency, new CComFrequencyFormatter()));
// default sort order
this->setSortColumnByPropertyIndex(CAtcStation::IndexBookedFrom);
m_sortOrder = Qt::AscendingOrder;
}
break;
default:
qFatal("Wrong mode");
break;

View File

@@ -27,7 +27,6 @@ namespace BlackGui::Models
enum AtcStationMode
{
NotSet,
StationsBooked,
StationsOnline
};