From 08299e8b2bf50ba90daf570f57def529dd29d6e7 Mon Sep 17 00:00:00 2001 From: tony mancill Date: Sat, 30 Nov 2019 16:20:58 -0800 Subject: New upstream version 2.1.2+repack --- logbook/WorkedBefore.cpp | 59 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 17 deletions(-) (limited to 'logbook/WorkedBefore.cpp') diff --git a/logbook/WorkedBefore.cpp b/logbook/WorkedBefore.cpp index aa65ab65..a1d774e4 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 ()) - { - return m_->worked_.get ().end () - != m_->worked_.get ().find (std::make_tuple (grid.left (4).toUpper (), mode.toUpper (), band.toUpper ())); - } - else + // 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) { - // 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 -- cgit v1.2.3