2026-01-09 09:40:24 -05:00
|
|
|
/**
|
2026-01-17 15:24:43 -06:00
|
|
|
* @file CountriesWorked.cpp
|
|
|
|
|
* @brief Initialize the CountriesWorked instance with the specified country
|
|
|
|
|
* names.
|
2026-01-09 09:40:24 -05:00
|
|
|
* @param countryNames A list of country names to track.
|
|
|
|
|
*/
|
2026-01-18 12:53:55 -06:00
|
|
|
#include "CountriesWorked.h"
|
|
|
|
|
|
2026-01-17 15:24:43 -06:00
|
|
|
void CountriesWorked::init(const QStringList countryNames) {
|
2018-02-08 21:28:33 -05:00
|
|
|
_data.clear();
|
2026-01-17 15:24:43 -06:00
|
|
|
foreach (QString name, countryNames)
|
|
|
|
|
_data.insert(name, false);
|
2018-02-08 21:28:33 -05:00
|
|
|
}
|
|
|
|
|
|
2026-01-09 09:40:24 -05:00
|
|
|
/**
|
|
|
|
|
* @brief Mark a country as worked.
|
|
|
|
|
* @param countryName The name of the country to mark as worked.
|
|
|
|
|
*/
|
2026-01-17 15:24:43 -06:00
|
|
|
void CountriesWorked::setAsWorked(const QString countryName) {
|
2018-02-08 21:28:33 -05:00
|
|
|
if (_data.contains(countryName))
|
2026-01-17 15:24:43 -06:00
|
|
|
_data.insert(countryName, true);
|
2025-10-14 13:12:57 +02:00
|
|
|
}
|
|
|
|
|
|
2026-01-09 09:40:24 -05:00
|
|
|
/**
|
|
|
|
|
* @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.
|
|
|
|
|
*/
|
2026-01-17 15:24:43 -06:00
|
|
|
bool CountriesWorked::getHasWorked(const QString countryName) const {
|
2018-02-08 21:28:33 -05:00
|
|
|
if (_data.contains(countryName))
|
2026-01-17 15:24:43 -06:00
|
|
|
return _data.value(countryName);
|
2018-02-08 21:28:33 -05:00
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2025-10-14 13:12:57 +02:00
|
|
|
|
2026-01-09 09:40:24 -05:00
|
|
|
/**
|
|
|
|
|
* @brief Get the count of countries that have been worked.
|
|
|
|
|
* @return The number of worked countries.
|
|
|
|
|
*/
|
2026-01-17 15:24:43 -06:00
|
|
|
qsizetype CountriesWorked::getWorkedCount() const {
|
2025-07-15 14:19:05 -07:00
|
|
|
qsizetype count = 0;
|
2026-01-17 15:24:43 -06:00
|
|
|
foreach (bool value, _data)
|
|
|
|
|
if (value)
|
|
|
|
|
count += 1;
|
2018-02-08 21:28:33 -05:00
|
|
|
return count;
|
|
|
|
|
}
|
2025-10-14 13:12:57 +02:00
|
|
|
|
2026-01-09 09:40:24 -05:00
|
|
|
/**
|
|
|
|
|
* @brief Get the total number of countries being tracked.
|
|
|
|
|
* @return The total number of countries.
|
|
|
|
|
*/
|
2026-01-17 15:24:43 -06:00
|
|
|
qsizetype CountriesWorked::getSize() const { return _data.count(); }
|