Added struct ATBTariffCarryOver
This commit is contained in:
		@@ -3,6 +3,80 @@
 | 
			
		||||
 | 
			
		||||
#include <QTime>
 | 
			
		||||
 | 
			
		||||
#include "time_range.h"
 | 
			
		||||
 | 
			
		||||
enum class ApplyCarryOver {
 | 
			
		||||
    NEVER = 0,
 | 
			
		||||
    MATCH_PREV_DAY = 1,
 | 
			
		||||
    MATCH_NEXT_DAY = 2,
 | 
			
		||||
    ALWAYS = 3
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct ATBTariffCarryOver {
 | 
			
		||||
    int m_id;
 | 
			
		||||
    QString m_weekDay;
 | 
			
		||||
    TimeRange m_range;
 | 
			
		||||
    QDate m_date;
 | 
			
		||||
    ApplyCarryOver m_carryOverIf;
 | 
			
		||||
 | 
			
		||||
    explicit ATBTariffCarryOver()
 | 
			
		||||
      : m_id(-1)
 | 
			
		||||
      , m_carryOverIf(ApplyCarryOver::NEVER) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void setCarryOverIf(QString const &coif) {
 | 
			
		||||
        if (coif == "never") {
 | 
			
		||||
            m_carryOverIf = ApplyCarryOver::NEVER;
 | 
			
		||||
        } else
 | 
			
		||||
        if (coif == "match_prev_day") {
 | 
			
		||||
            m_carryOverIf = ApplyCarryOver::MATCH_PREV_DAY;
 | 
			
		||||
        } else
 | 
			
		||||
        if (coif == "match_next_day") {
 | 
			
		||||
            m_carryOverIf = ApplyCarryOver::MATCH_NEXT_DAY;
 | 
			
		||||
        } else
 | 
			
		||||
        if (coif == "always") {
 | 
			
		||||
            m_carryOverIf = ApplyCarryOver::ALWAYS;
 | 
			
		||||
        } else {
 | 
			
		||||
           qCritical() << "ERROR unknown carry over application" << coif;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ApplyCarryOver carryOverIf() const {
 | 
			
		||||
        return m_carryOverIf;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QString carryOverIfStr() const {
 | 
			
		||||
        if (m_carryOverIf == ApplyCarryOver::NEVER) {
 | 
			
		||||
            return "never";
 | 
			
		||||
        }
 | 
			
		||||
        if (m_carryOverIf == ApplyCarryOver::ALWAYS) {
 | 
			
		||||
            return "always";
 | 
			
		||||
        }
 | 
			
		||||
        if (m_carryOverIf == ApplyCarryOver::MATCH_PREV_DAY) {
 | 
			
		||||
            return "match prev day";
 | 
			
		||||
        }
 | 
			
		||||
        if (m_carryOverIf == ApplyCarryOver::MATCH_NEXT_DAY) {
 | 
			
		||||
            return "match next day";
 | 
			
		||||
        }
 | 
			
		||||
        return QString("ERROR unknown carry over application: %1").arg(static_cast<int>(m_carryOverIf));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    friend QDebug operator<<(QDebug debug, ATBTariffCarryOver const &co) {
 | 
			
		||||
        QDebugStateSaver saver(debug);
 | 
			
		||||
 | 
			
		||||
        debug.nospace()
 | 
			
		||||
            << "\nTariffCarryOver:\n"
 | 
			
		||||
            << "         week day: " << co.m_weekDay << "\n"
 | 
			
		||||
            << "             date: " << co.m_date.toString(Qt::ISODate) << "\n"
 | 
			
		||||
            << "               id: " << co.m_id << "\n"
 | 
			
		||||
            << "            start: " << co.m_range.m_start << "\n"
 | 
			
		||||
            << "              end: " << co.m_range.m_end << "\n"
 | 
			
		||||
            << "         duration: " << co.m_range.m_duration << "\n"
 | 
			
		||||
            << "    carry over if: " << co.carryOverIfStr() << endl;
 | 
			
		||||
        return debug;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct ATBCarryOver {
 | 
			
		||||
    struct week {
 | 
			
		||||
        int day;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user