File indexing completed on 2024-04-28 04:42:41

0001 /*
0002  * SPDX-FileCopyrightText: 2021 Han Young <hanyoung@protonmail.com>
0003  * SPDX-FileCopyrightText: 2021 Anjani Kumar <anjanik012@gmail.com>
0004  * SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
0005  * SPDX-License-Identifier: LGPL-2.0-or-later
0006  */
0007 #include "capalertinfo.h"
0008 #include "caparea.h"
0009 
0010 namespace KWeatherCore
0011 {
0012 class CAPAlertInfoPrivate : public QSharedData
0013 {
0014 public:
0015     QString headline;
0016     QString description;
0017     QString event;
0018     QString sender;
0019     QString language = QStringLiteral("en-US"); // default value according to CAP specification
0020     QDateTime effectiveTime;
0021     QDateTime onsetTime;
0022     QDateTime expireTime;
0023     CAPAlertInfo::Categories categories = CAPAlertInfo::Category::Unknown;
0024     QString instruction;
0025     CAPAlertInfo::Urgency urgency = CAPAlertInfo::Urgency::UnknownUrgency;
0026     CAPAlertInfo::Severity severity = CAPAlertInfo::Severity::UnknownSeverity;
0027     CAPAlertInfo::Certainty certainty = CAPAlertInfo::Certainty::UnknownCertainty;
0028     CAPAlertInfo::ResponseTypes responseTypes = CAPAlertInfo::ResponseType::UnknownResponseType;
0029     QString contact;
0030     QString web;
0031     std::vector<CAPNamedValue> parameters;
0032     std::vector<CAPArea> areas;
0033     std::vector<CAPNamedValue> eventCodes;
0034 };
0035 
0036 CAPAlertInfo::CAPAlertInfo()
0037     : d(new CAPAlertInfoPrivate)
0038 {
0039 }
0040 CAPAlertInfo::CAPAlertInfo(const CAPAlertInfo &other) = default;
0041 CAPAlertInfo::CAPAlertInfo(CAPAlertInfo &&other) = default;
0042 CAPAlertInfo::~CAPAlertInfo() = default;
0043 CAPAlertInfo &CAPAlertInfo::operator=(const CAPAlertInfo &other) = default;
0044 CAPAlertInfo &CAPAlertInfo::operator=(CAPAlertInfo &&other) = default;
0045 
0046 QString CAPAlertInfo::event() const
0047 {
0048     return d->event;
0049 }
0050 QDateTime CAPAlertInfo::effectiveTime() const
0051 {
0052     return d->effectiveTime;
0053 }
0054 QDateTime CAPAlertInfo::onsetTime() const
0055 {
0056     return d->onsetTime;
0057 }
0058 QDateTime CAPAlertInfo::expireTime() const
0059 {
0060     return d->expireTime;
0061 }
0062 CAPAlertInfo::Categories CAPAlertInfo::categories() const
0063 {
0064     return d->categories;
0065 }
0066 QString CAPAlertInfo::headline() const
0067 {
0068     return d->headline;
0069 }
0070 QString CAPAlertInfo::description() const
0071 {
0072     return d->description;
0073 }
0074 QString CAPAlertInfo::instruction() const
0075 {
0076     return d->instruction;
0077 }
0078 QString CAPAlertInfo::sender() const
0079 {
0080     return d->sender;
0081 }
0082 QString CAPAlertInfo::language() const
0083 {
0084     return d->language;
0085 }
0086 CAPAlertInfo::Urgency CAPAlertInfo::urgency() const
0087 {
0088     return d->urgency;
0089 }
0090 CAPAlertInfo::Severity CAPAlertInfo::severity() const
0091 {
0092     return d->severity;
0093 }
0094 CAPAlertInfo::Certainty CAPAlertInfo::certainty() const
0095 {
0096     return d->certainty;
0097 }
0098 CAPAlertInfo::ResponseTypes CAPAlertInfo::responseTypes() const
0099 {
0100     return d->responseTypes;
0101 }
0102 QString CAPAlertInfo::contact() const
0103 {
0104     return d->contact;
0105 }
0106 QString CAPAlertInfo::web() const
0107 {
0108     return d->web;
0109 }
0110 const std::vector<CAPNamedValue> &CAPAlertInfo::parameters() const
0111 {
0112     return d->parameters;
0113 }
0114 const std::vector<CAPArea> &CAPAlertInfo::areas() const
0115 {
0116     return d->areas;
0117 }
0118 const std::vector<CAPNamedValue> &CAPAlertInfo::eventCodes() const
0119 {
0120     return d->eventCodes;
0121 }
0122 
0123 void CAPAlertInfo::setHeadline(const QString &headline)
0124 {
0125     d->headline = headline;
0126 }
0127 void CAPAlertInfo::setDescription(const QString &description)
0128 {
0129     d->description = description;
0130 }
0131 void CAPAlertInfo::setInstruction(const QString &instruction)
0132 {
0133     d->instruction = instruction;
0134 }
0135 void CAPAlertInfo::setSender(const QString &sender)
0136 {
0137     d->sender = sender;
0138 }
0139 void CAPAlertInfo::setLanguage(const QString &language)
0140 {
0141     d->language = language;
0142 }
0143 void CAPAlertInfo::addCategory(Category category)
0144 {
0145     d->categories |= category;
0146 }
0147 void CAPAlertInfo::setEvent(const QString &event)
0148 {
0149     d->event = event;
0150 }
0151 
0152 void CAPAlertInfo::setEffectiveTime(const QDateTime &time)
0153 {
0154     d->effectiveTime = time;
0155 }
0156 void CAPAlertInfo::setOnsetTime(const QDateTime &time)
0157 {
0158     d->onsetTime = time;
0159 }
0160 void CAPAlertInfo::setExpireTime(const QDateTime &time)
0161 {
0162     d->expireTime = time;
0163 }
0164 void CAPAlertInfo::setUrgency(Urgency urgency)
0165 {
0166     d->urgency = urgency;
0167 }
0168 void CAPAlertInfo::setSeverity(Severity severity)
0169 {
0170     d->severity = severity;
0171 }
0172 void CAPAlertInfo::setCertainty(Certainty certainty)
0173 {
0174     d->certainty = certainty;
0175 }
0176 void CAPAlertInfo::addResponseType(ResponseType responseType)
0177 {
0178     d->responseTypes |= responseType;
0179 }
0180 void CAPAlertInfo::setContact(const QString &contact)
0181 {
0182     d->contact = contact;
0183 }
0184 void CAPAlertInfo::setWeb(const QString &web)
0185 {
0186     d->web = web;
0187 }
0188 void CAPAlertInfo::addParameter(CAPNamedValue &&param)
0189 {
0190     d->parameters.push_back(std::move(param));
0191 }
0192 
0193 void CAPAlertInfo::addArea(CAPArea &&area)
0194 {
0195     d->areas.push_back(std::move(area));
0196 }
0197 
0198 void CAPAlertInfo::addEventCode(CAPNamedValue &&code)
0199 {
0200     d->eventCodes.push_back(std::move(code));
0201 }
0202 }
0203 
0204 #include "moc_capalertinfo.cpp"