From e73f7e8334f0c3143b2fe86f7896e2b9faca6cd5 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Fri, 9 Aug 2019 11:25:50 +0100 Subject: [PATCH] Add option to highlight un-worked grid fields This is a check box option in "Settings->Colors" rather than new highlighting types so un-worked field highlighting and un-worked grid square highlighting are mutually exclusive. The check box state can be changed at any time, no log rescanning is necessary, and subsequent decoded message highlighting will be according to the check box state. --- Configuration.cpp | 7 +++ Configuration.hpp | 1 + Configuration.ui | 116 +++++++++++++++++++-------------------- logbook/WorkedBefore.cpp | 59 ++++++++++++++------ 4 files changed, 108 insertions(+), 75 deletions(-) diff --git a/Configuration.cpp b/Configuration.cpp index ebb6380b3..f4bf79e82 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -571,6 +571,7 @@ private: DecodeHighlightingModel decode_highlighing_model_; DecodeHighlightingModel next_decode_highlighing_model_; bool highlight_by_mode_; + bool highlight_only_fields_; bool include_WAE_entities_; int LotW_days_since_upload_; @@ -753,6 +754,7 @@ bool Configuration::pwrBandTuneMemory () const {return m_->pwrBandTuneMemory_;} LotWUsers const& Configuration::lotw_users () const {return m_->lotw_users_;} DecodeHighlightingModel const& Configuration::decode_highlighting () const {return m_->decode_highlighing_model_;} bool Configuration::highlight_by_mode () const {return m_->highlight_by_mode_;} +bool Configuration::highlight_only_fields () const {return m_->highlight_only_fields_;} bool Configuration::include_WAE_entities () const {return m_->include_WAE_entities_;} void Configuration::set_calibration (CalibrationParams params) @@ -959,6 +961,7 @@ Configuration::impl::impl (Configuration * self, QNetworkAccessManager * network , station_insert_action_ {tr ("&Insert ..."), nullptr} , station_dialog_ {new StationDialog {&next_stations_, &bands_, this}} , highlight_by_mode_ {false} + , highlight_only_fields_ {false} , include_WAE_entities_ {false} , LotW_days_since_upload_ {0} , last_port_type_ {TransceiverFactory::Capabilities::none} @@ -1325,6 +1328,7 @@ void Configuration::impl::initialize_models () next_decode_highlighing_model_.items (decode_highlighing_model_.items ()); ui_->highlight_by_mode_check_box->setChecked (highlight_by_mode_); + ui_->only_fields_check_box->setChecked (highlight_only_fields_); ui_->include_WAE_check_box->setChecked (include_WAE_entities_); ui_->LotW_days_since_upload_spin_box->setValue (LotW_days_since_upload_); @@ -1474,6 +1478,7 @@ void Configuration::impl::read_settings () if (!highlight_items.size ()) highlight_items = DecodeHighlightingModel::default_items (); decode_highlighing_model_.items (highlight_items); highlight_by_mode_ = settings_->value("HighlightByMode", false).toBool (); + highlight_only_fields_ = settings_->value("OnlyFieldsSought", false).toBool (); include_WAE_entities_ = settings_->value("IncludeWAEEntities", false).toBool (); LotW_days_since_upload_ = settings_->value ("LotWDaysSinceLastUpload", 365).toInt (); lotw_users_.set_age_constraint (LotW_days_since_upload_); @@ -1588,6 +1593,7 @@ void Configuration::impl::write_settings () settings_->setValue ("stations", QVariant::fromValue (stations_.station_list ())); settings_->setValue ("DecodeHighlighting", QVariant::fromValue (decode_highlighing_model_.items ())); settings_->setValue ("HighlightByMode", highlight_by_mode_); + settings_->setValue ("OnlyFieldsSought", highlight_only_fields_); settings_->setValue ("IncludeWAEEntities", include_WAE_entities_); settings_->setValue ("LotWDaysSinceLastUpload", LotW_days_since_upload_); settings_->setValue ("toRTTY", log_as_RTTY_); @@ -2130,6 +2136,7 @@ void Configuration::impl::accept () Q_EMIT self_->decode_highlighting_changed (decode_highlighing_model_); } highlight_by_mode_ = ui_->highlight_by_mode_check_box->isChecked (); + highlight_only_fields_ = ui_->only_fields_check_box->isChecked (); include_WAE_entities_ = ui_->include_WAE_check_box->isChecked (); LotW_days_since_upload_ = ui_->LotW_days_since_upload_spin_box->value (); lotw_users_.set_age_constraint (LotW_days_since_upload_); diff --git a/Configuration.hpp b/Configuration.hpp index dbf232fd5..3e57267e3 100644 --- a/Configuration.hpp +++ b/Configuration.hpp @@ -177,6 +177,7 @@ public: LotWUsers const& lotw_users () const; DecodeHighlightingModel const& decode_highlighting () const; bool highlight_by_mode () const; + bool highlight_only_fields () const; bool include_WAE_entities () const; enum class SpecialOperatingActivity {NONE, NA_VHF, EU_VHF, FIELD_DAY, RTTY, FOX, HOUND}; diff --git a/Configuration.ui b/Configuration.ui index b3d0836d3..f473bb6b4 100644 --- a/Configuration.ui +++ b/Configuration.ui @@ -2206,8 +2206,45 @@ Right click for insert and delete options. Decode Highlightling - - + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + <html><head/><body><p>Click to scan the wsjtx_log.adi ADIF file again for worked before information</p></body></html> + + + Rescan ADIF Log + + + + + + + + + <html><head/><body><p>Push to reset all highlight items above to default values and priorities.</p></body></html> + + + Reset Highlighting + + + + @@ -2247,69 +2284,32 @@ Right click for insert and delete options. - - + + - <html><head/><body><p>Push to reset all highlight items above to default values and priorities.</p></body></html> + <html><head/><body><p>Check to indicate new DXCC entities, grid squares, and callsigns per mode.</p></body></html> - Reset Highlighting + Highlight by Mode - - - - - - <html><head/><body><p>Check to indicate new DXCC entities, grid squares, and callsigns per mode.</p></body></html> - - - Highlight by Mode - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - <html><head/><body><p>Click to scan the wsjtx_log.adi ADIF file again for worked before information</p></body></html> - - - Rescan ADIF Log - - - - + + + + Include extra WAE entities + + - - - - - - - - - Include extra WAE entities - - - include_WAE_check_box - - - - + + + + Check to for grid highlighting to only apply to unworked grid fields + + + Only grid Fields sought + + diff --git a/logbook/WorkedBefore.cpp b/logbook/WorkedBefore.cpp index aa65ab651..a1d774e4e 100644 --- a/logbook/WorkedBefore.cpp +++ b/logbook/WorkedBefore.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -362,7 +363,8 @@ class WorkedBefore::impl final { public: impl (Configuration const * configuration) - : path_ {QDir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)}.absoluteFilePath (logFileName)} + : configuration_ {configuration} + , path_ {QDir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)}.absoluteFilePath (logFileName)} , prefixes_ {configuration} { } @@ -373,6 +375,7 @@ public: loader_watcher_.setFuture (async_loader_); } + Configuration const * configuration_; QString path_; AD1CCty prefixes_; QFutureWatcher loader_watcher_; @@ -491,34 +494,56 @@ bool WorkedBefore::country_worked (QString const& country, QString const& mode, bool WorkedBefore::grid_worked (QString const& grid, QString const& mode, QString const& band) const { - if (mode.size ()) + auto gridsquare = grid.left (4).toUpper (); + if (m_->configuration_->highlight_only_fields ()) { - if (band.size ()) + // can't use a direct set find operation or a set operation with + // a (CompatibleKey, CompatibleCompare) concept so we must + // partially scan the index + auto range = boost::make_iterator_range ( + m_->worked_.get ().lower_bound (gridsquare.left (2)) + , m_->worked_.get ().upper_bound (gridsquare.left (2) + "99")); + for (worked_entry const& worked : range) { - return m_->worked_.get ().end () - != m_->worked_.get ().find (std::make_tuple (grid.left (4).toUpper (), mode.toUpper (), band.toUpper ())); - } - else - { - // partial key lookup - return m_->worked_.get ().end () - != m_->worked_.get ().find (std::make_tuple (grid.left (4).toUpper (), mode.toUpper ())); + if ((!mode.size () || mode.toUpper () == worked.mode_) + && (!band.size () || worked.band_ == band.toUpper ())) + { + return true; + } } } else { - if (band.size ()) + if (mode.size ()) { - return m_->worked_.get ().end () - != m_->worked_.get ().find (std::make_tuple (grid.left (4).toUpper (), band.toUpper ())); + if (band.size ()) + { + return m_->worked_.get ().end () + != m_->worked_.get ().find (std::make_tuple (gridsquare, mode.toUpper (), band.toUpper ())); + } + else + { + // partial key lookup + return m_->worked_.get ().end () + != m_->worked_.get ().find (std::make_tuple (gridsquare, mode.toUpper ())); + } } else { - // partial key lookup - return m_->worked_.get ().end () - != m_->worked_.get ().find (grid.left (4).toUpper ()); + if (band.size ()) + { + return m_->worked_.get ().end () + != m_->worked_.get ().find (std::make_tuple (gridsquare, band.toUpper ())); + } + else + { + // partial key lookup + return m_->worked_.get ().end () + != m_->worked_.get ().find (gridsquare); + } } } + return false; } bool WorkedBefore::call_worked (QString const& call, QString const& mode, QString const& band) const