js8call/JS8_Logbook/CountriesWorked.cpp

53 lines
1.4 KiB
C++
Raw Permalink Normal View History

/**
* @file CountriesWorked.cpp
* @brief Initialize the CountriesWorked instance with the specified country
* names.
* @param countryNames A list of country names to track.
*/
2026-01-18 12:53:55 -06:00
#include "CountriesWorked.h"
void CountriesWorked::init(const QStringList countryNames) {
2018-02-08 21:28:33 -05:00
_data.clear();
foreach (QString name, countryNames)
_data.insert(name, false);
2018-02-08 21:28:33 -05:00
}
/**
* @brief Mark a country as worked.
* @param countryName The name of the country to mark as worked.
*/
void CountriesWorked::setAsWorked(const QString countryName) {
2018-02-08 21:28:33 -05:00
if (_data.contains(countryName))
_data.insert(countryName, true);
}
/**
* @brief Check if a country has been worked.
* @param countryName The name of the country to check.
* @return True if the country has been worked, false otherwise.
*/
bool CountriesWorked::getHasWorked(const QString countryName) const {
2018-02-08 21:28:33 -05:00
if (_data.contains(countryName))
return _data.value(countryName);
2018-02-08 21:28:33 -05:00
return false;
}
/**
* @brief Get the count of countries that have been worked.
* @return The number of worked countries.
*/
qsizetype CountriesWorked::getWorkedCount() const {
qsizetype count = 0;
foreach (bool value, _data)
if (value)
count += 1;
2018-02-08 21:28:33 -05:00
return count;
}
/**
* @brief Get the total number of countries being tracked.
* @return The total number of countries.
*/
qsizetype CountriesWorked::getSize() const { return _data.count(); }