mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-21 19:55:20 -05:00
Defer dwonloading LoTW users file until "Settings->Colors->Fetch" button pressed
This change also repairs a defect in showing potential LoTW users when the "Settings->General->Show DXCC, grid, and worked before status" option is not checked.
This commit is contained in:
parent
90617b29ab
commit
5b0f713cd4
@ -1004,13 +1004,11 @@ Configuration::impl::impl (Configuration * self, QNetworkAccessManager * network
|
||||
// this must be done after the default paths above are set
|
||||
read_settings ();
|
||||
|
||||
// conditionally load LotW users data
|
||||
ui_->LotW_CSV_fetch_push_button->setEnabled (false);
|
||||
// set up LoTW users CSV file fetching
|
||||
connect (&lotw_users_, &LotWUsers::load_finished, [this] () {
|
||||
ui_->LotW_CSV_fetch_push_button->setEnabled (true);
|
||||
});
|
||||
lotw_users_.set_local_file_path (writeable_data_dir_.absoluteFilePath ("lotw-user-activity.csv"));
|
||||
lotw_users_.load (ui_->LotW_CSV_URL_line_edit->text ());
|
||||
|
||||
//
|
||||
// validation
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "LotWUsers.hpp"
|
||||
|
||||
#include <future>
|
||||
#include <chrono>
|
||||
|
||||
#include <QHash>
|
||||
#include <QString>
|
||||
@ -265,7 +266,9 @@ void LotWUsers::set_age_constraint (qint64 uploaded_since_days)
|
||||
|
||||
bool LotWUsers::user (QString const& call) const
|
||||
{
|
||||
if (m_->future_load_.valid ())
|
||||
// check if a pending asynchronous load is ready
|
||||
if (m_->future_load_.valid ()
|
||||
&& std::future_status::ready == m_->future_load_.wait_for (std::chrono::seconds {0}))
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -278,10 +281,13 @@ bool LotWUsers::user (QString const& call) const
|
||||
}
|
||||
Q_EMIT load_finished ();
|
||||
}
|
||||
auto p = m_->last_uploaded_.constFind (call);
|
||||
if (p != m_->last_uploaded_.end ())
|
||||
if (m_->last_uploaded_.size ())
|
||||
{
|
||||
return p.value ().daysTo (QDate::currentDate ()) <= m_->age_constraint_;
|
||||
auto p = m_->last_uploaded_.constFind (call);
|
||||
if (p != m_->last_uploaded_.end ())
|
||||
{
|
||||
return p.value ().daysTo (QDate::currentDate ()) <= m_->age_constraint_;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -400,7 +400,11 @@ void DisplayText::displayDecodedText(DecodedText const& decodedText, QString con
|
||||
}
|
||||
else
|
||||
{
|
||||
highlight_types types {Highlight::CQ, Highlight::LotW};
|
||||
highlight_types types {Highlight::CQ};
|
||||
if (m_config && m_config->lotw_users ().user (decodedText.CQersCall()))
|
||||
{
|
||||
types.push_back (Highlight::LotW);
|
||||
}
|
||||
set_colours (m_config, &bg, &fg, types);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user