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:
Klaus Basan
2018-09-17 20:03:20 +02:00
parent c379a722e3
commit a4fc474d09
4 changed files with 27 additions and 6 deletions

View File

@@ -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()

View File

@@ -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

View File

@@ -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

View File

@@ -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