Implement

std::optional<QVector<ATBTariffProduct>> getTariffProductForAllKeys() const;
    std::optional<QVector<ATBTariffProduct>> getTariffProductForProductId(int id) const;
    std::optional<QVector<ATBTariffProduct>> getTariffProductForProductId(PermitType permitType) const;
This commit is contained in:
Gerhard Hoffmann 2024-02-22 16:34:57 +01:00
parent afb0e20dd2
commit e980d8c451

View File

@ -561,6 +561,48 @@ QVector<ATBPaymentOption> &Configuration::getAllPaymentOptions() {
return this->currentPaymentOptions;
}
std::optional<QVector<ATBTariffProduct>>
Configuration::getTariffProductForAllKeys() const {
QVector<ATBTariffProduct> products;
std::optional<QVector<ATBTariffProduct>> value;
products.clear();
for (std::multimap<int, ATBTariffProduct>::const_iterator it = this->TariffProduct.cbegin();
it != this->TariffProduct.cend(); ++it) {
products.append(it->second);
}
if (products.size() > 0) {
value = value.value_or(products);
}
return value;
}
std::optional<QVector<ATBTariffProduct>>
Configuration::getTariffProductForProductId(PermitType permitType) const {
QVector<ATBTariffProduct> products;
std::optional<QVector<ATBTariffProduct>> value;
products.clear();
for (auto[it, rangeEnd] = this->TariffProduct.equal_range(permitType); it != rangeEnd; ++it) {
products.append(it->second);
}
if (products.size() > 0) {
value = value.value_or(products);
}
return value;
}
std::optional<QVector<ATBTariffProduct>>
Configuration::getTariffProductForProductId(int id) const {
return getTariffProductForProductId(PermitType(id));
}
std::optional<QVector<ATBDailyTicket>>
Configuration::getDailyTicketsForAllKeys() const {
QVector<ATBDailyTicket> tickets;