mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 13:36:48 +08:00
Ref T345, directly update ATC stations when "in range" radio button changes
- forced update - use component directly, no copy of settings
This commit is contained in:
@@ -96,6 +96,8 @@ namespace BlackGui
|
||||
connect(ui->tvp_AtcStationsOnline, &CAtcStationView::requestComFrequency, this, &CAtcStationComponent::setComFrequency);
|
||||
connect(ui->tvp_AtcStationsOnline, &CAtcStationView::requestTextMessageWidget, this, &CAtcStationComponent::requestTextMessageWidget);
|
||||
|
||||
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);
|
||||
@@ -152,6 +154,12 @@ namespace BlackGui
|
||||
return c && parentDockableWidget;
|
||||
}
|
||||
|
||||
void CAtcStationComponent::forceUpdate()
|
||||
{
|
||||
m_timestampOnlineStationsChanged = QDateTime::currentDateTimeUtc();
|
||||
this->update();
|
||||
}
|
||||
|
||||
void CAtcStationComponent::update()
|
||||
{
|
||||
if (!this->canAccessContext()) { return; }
|
||||
@@ -180,7 +188,7 @@ namespace BlackGui
|
||||
// update
|
||||
if (m_timestampOnlineStationsChanged > m_timestampLastReadOnlineStations)
|
||||
{
|
||||
const CAtcStationsSettings settings = m_settingsAtc.getThreadLocal();
|
||||
const CAtcStationsSettings settings = ui->comp_AtcStationsSettings->getSettings();
|
||||
CAtcStationList onlineStations =
|
||||
sGui->getIContextNetwork()->getAtcStationsOnline(true).stationsWithValidFrequency(); // alternatively: stationsWithValidVoiceRoom()
|
||||
|
||||
|
||||
@@ -88,6 +88,9 @@ namespace BlackGui
|
||||
void requestAudioWidget();
|
||||
|
||||
private:
|
||||
//! Set timestampd and call update
|
||||
void forceUpdate();
|
||||
|
||||
//! \copydoc Models::CAtcStationListModel::changedAtcStationConnectionStatus
|
||||
void changedAtcStationOnlineConnectionStatus(const BlackMisc::Aviation::CAtcStation &station, bool added);
|
||||
|
||||
@@ -155,7 +158,6 @@ namespace BlackGui
|
||||
QDateTime m_timestampLastReadBookedStations; //!< stations read
|
||||
QDateTime m_timestampBookedStationsChanged; //!< stations marked as changed
|
||||
BlackMisc::CSettingReadOnly<BlackGui::Settings::TViewUpdateSettings> m_settingsView { this, &CAtcStationComponent::settingsChanged };
|
||||
BlackMisc::CSettingReadOnly<BlackGui::Settings::TAtcStationsSettings> m_settingsAtc { this, &CAtcStationComponent::settingsChanged };
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace BlackGui
|
||||
CSettingsAtcStationsInlineComponent::~CSettingsAtcStationsInlineComponent()
|
||||
{ }
|
||||
|
||||
void CSettingsAtcStationsInlineComponent::settingsChanged()
|
||||
void CSettingsAtcStationsInlineComponent::onSettingsChanged()
|
||||
{
|
||||
const CAtcStationsSettings s = m_atcSettings.getThreadLocal();
|
||||
ui->rb_InRange->setChecked(s.showOnlyInRange());
|
||||
@@ -35,9 +35,13 @@ namespace BlackGui
|
||||
|
||||
void CSettingsAtcStationsInlineComponent::changeSettings()
|
||||
{
|
||||
const bool onlyInRange = ui->rb_InRange->isChecked();
|
||||
CAtcStationsSettings s = m_atcSettings.getThreadLocal();
|
||||
s.setShowOnlyInRange(ui->rb_InRange->isChecked());
|
||||
if (s.showOnlyInRange() && onlyInRange) { return; }
|
||||
s.setShowOnlyInRange(onlyInRange);
|
||||
m_atcSettings.setAndSave(s);
|
||||
|
||||
emit this->changed();
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -34,15 +34,22 @@ namespace BlackGui
|
||||
//! Destructor
|
||||
virtual ~CSettingsAtcStationsInlineComponent();
|
||||
|
||||
//! Get the settings
|
||||
Settings::CAtcStationsSettings getSettings() const { return m_atcSettings.get(); }
|
||||
|
||||
signals:
|
||||
//! Changed value
|
||||
void changed();
|
||||
|
||||
private:
|
||||
//! Settings have been changed
|
||||
void settingsChanged();
|
||||
void onSettingsChanged();
|
||||
|
||||
//! Change the settings
|
||||
void changeSettings();
|
||||
|
||||
QScopedPointer<Ui::CSettingsAtcStationsInlineComponent> ui;
|
||||
BlackMisc::CSetting<BlackGui::Settings::TAtcStationsSettings> m_atcSettings { this, &CSettingsAtcStationsInlineComponent::settingsChanged };
|
||||
BlackMisc::CSetting<BlackGui::Settings::TAtcStationsSettings> m_atcSettings { this, &CSettingsAtcStationsInlineComponent::onSettingsChanged };
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user