From 929a8a4a275d9e82dea6c614db6406408cc40148 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Mon, 2 Sep 2024 16:41:26 +0200 Subject: [PATCH] Reuse of "class ATBWeekDays": Description of a weekday: Mon-Sun. For holidays contains a type-flag to indicate such a day. Each weekday has some tariff-settings and some carry-over-settings. --- library/include/mobilisis/weekdays.h | 65 ++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/library/include/mobilisis/weekdays.h b/library/include/mobilisis/weekdays.h index 3911cf5..e5187e9 100644 --- a/library/include/mobilisis/weekdays.h +++ b/library/include/mobilisis/weekdays.h @@ -1,10 +1,57 @@ -#pragma once -#include +#include "tariff_settings.h" +#include "tariff_carryover_settings.h" -class ATBWeekDays -{ -public: - int pdiw_id; - std::string pdiw_label; - int pdiw_index; -}; \ No newline at end of file +#include +#include +#include + +struct ATBWeekDay { + enum WeekDayType {USUAL_WEEKDAY=0, HOLIDAY=1}; + + Qt::DayOfWeek m_id; + QString m_name; + QDate m_date; + WeekDayType m_type; + ATBTariffSettings m_tariffSettings; + ATBTariffCarryOverSettings m_tariffCarryOverSettings; + + explicit ATBWeekDay() + : m_id(Qt::Monday) + , m_name("") + , m_date(QDate()) + , m_type(USUAL_WEEKDAY) + , m_tariffSettings() + , m_tariffCarryOverSettings() {} + + explicit ATBWeekDay(Qt::DayOfWeek id, QString const &name, WeekDayType type, + QDate const &date, + ATBTariffSettings const &tariffSettings, + ATBTariffCarryOverSettings const &tariffCarryOverSettings) + : m_id(id) + , m_name(name) + , m_date(date) + , m_type(type) + , m_tariffSettings(tariffSettings) + , m_tariffCarryOverSettings(tariffCarryOverSettings) {} + + ATBTariffCarryOverSettings &getTariffCarryOverSettings() { return m_tariffCarryOverSettings; } + ATBTariffCarryOverSettings const &getTariffCarryOverSettings() const { return m_tariffCarryOverSettings; } + + ATBTariffSettings &getTariffSettings() { return m_tariffSettings; } + ATBTariffSettings const &getTariffSettings() const { return m_tariffSettings; } + + friend QDebug operator<<(QDebug debug, ATBWeekDay const &wd) { + QDebugStateSaver saver(debug); + + debug.nospace() + << " id: " << (int)wd.m_id << "\n" + << " name: " << wd.m_name << "\n" + << " type: " << (int)wd.m_type << "\n\n" + << " tariff settings: " << "\n" + << wd.m_tariffSettings << "\n" + << "tariff carryover settings: " << "\n" + << wd.m_tariffCarryOverSettings << endl; + + return debug; + } +};