File indexing completed on 2024-05-05 16:49:20
0001 /* 0002 * SPDX-FileCopyrightText: 2021 Han Young <hanyoung@protonmail.com> 0003 * SPDX-FileCopyrightText: 2021 Anjani Kumar <anjanik012@gmail.com> 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 #include "alertinfo.h" 0007 namespace KWeatherCore 0008 { 0009 class AlertInfo::AlertInfoPrivate 0010 { 0011 public: 0012 QString headline; 0013 QString description; 0014 QString event; 0015 QString sender; 0016 QString language = QStringLiteral("en-US"); // default value according to CAP specification 0017 QDateTime effectiveTime; 0018 QDateTime onsetTime; 0019 QDateTime expireTime; 0020 Category category = Category::Unknown; 0021 QString instruction; 0022 Urgency urgency = Urgency::Unknown; 0023 Severity severity = Severity::Unknown; 0024 Certainty certainty = Certainty::Unknown; 0025 Parameter parameter; 0026 QString areaDesc; 0027 AreaCodeVec areaCodes; 0028 std::vector<std::vector<std::pair<float, float>>> polygon; 0029 }; 0030 AlertInfo::AlertInfo() 0031 : d(std::make_unique<AlertInfoPrivate>()) 0032 { 0033 } 0034 AlertInfo::AlertInfo(const AlertInfo &other) 0035 : d(std::make_unique<AlertInfoPrivate>(*other.d)) 0036 { 0037 } 0038 AlertInfo::AlertInfo(AlertInfo &&other) = default; 0039 AlertInfo::~AlertInfo() = default; 0040 AlertInfo &AlertInfo::operator=(AlertInfo &&other) = default; 0041 0042 const QString &AlertInfo::event() const 0043 { 0044 return d->event; 0045 } 0046 const AreaCodeVec &AlertInfo::areaCodes() const 0047 { 0048 return d->areaCodes; 0049 } 0050 const QDateTime &AlertInfo::effectiveTime() const 0051 { 0052 return d->effectiveTime; 0053 } 0054 const QDateTime &AlertInfo::onsetTime() const 0055 { 0056 return d->onsetTime; 0057 } 0058 const QDateTime &AlertInfo::expireTime() const 0059 { 0060 return d->expireTime; 0061 } 0062 AlertInfo::Category AlertInfo::category() const 0063 { 0064 return d->category; 0065 } 0066 const QString &AlertInfo::headline() const 0067 { 0068 return d->headline; 0069 } 0070 const QString &AlertInfo::description() const 0071 { 0072 return d->description; 0073 } 0074 const QString &AlertInfo::instruction() const 0075 { 0076 return d->instruction; 0077 } 0078 const QString &AlertInfo::sender() const 0079 { 0080 return d->sender; 0081 } 0082 const QString &AlertInfo::language() const 0083 { 0084 return d->language; 0085 } 0086 AlertInfo::Urgency AlertInfo::urgency() const 0087 { 0088 return d->urgency; 0089 } 0090 AlertInfo::Severity AlertInfo::severity() const 0091 { 0092 return d->severity; 0093 } 0094 AlertInfo::Certainty AlertInfo::certainty() const 0095 { 0096 return d->certainty; 0097 } 0098 const Parameter &AlertInfo::parameter() const 0099 { 0100 return d->parameter; 0101 } 0102 const QString &AlertInfo::areaDesc() const 0103 { 0104 return d->areaDesc; 0105 } 0106 const std::vector<std::vector<std::pair<float, float>>> &AlertInfo::polygon() const 0107 { 0108 return d->polygon; 0109 } 0110 void AlertInfo::setHeadline(const QString &headline) 0111 { 0112 d->headline = headline; 0113 } 0114 void AlertInfo::setDescription(const QString &description) 0115 { 0116 d->description = description; 0117 } 0118 void AlertInfo::setInstruction(const QString &instruction) 0119 { 0120 d->instruction = instruction; 0121 } 0122 void AlertInfo::setSender(const QString &sender) 0123 { 0124 d->sender = sender; 0125 } 0126 void AlertInfo::setLanguage(const QString &language) 0127 { 0128 d->language = language; 0129 } 0130 void AlertInfo::setCategory(Category category) 0131 { 0132 d->category = category; 0133 } 0134 void AlertInfo::addCategory(Category category) 0135 { 0136 d->category |= category; 0137 } 0138 void AlertInfo::setEvent(const QString &event) 0139 { 0140 d->event = event; 0141 } 0142 void AlertInfo::setAreaCodes(const AreaCodeVec &areaCodes) 0143 { 0144 d->areaCodes = areaCodes; 0145 } 0146 void AlertInfo::addAreaCode(std::pair<QString, QString> &areaCode) 0147 { 0148 d->areaCodes.push_back(areaCode); 0149 } 0150 0151 void AlertInfo::setEffectiveTime(const QDateTime &time) 0152 { 0153 d->effectiveTime = time; 0154 } 0155 void AlertInfo::setOnsetTime(const QDateTime &time) 0156 { 0157 d->onsetTime = time; 0158 } 0159 void AlertInfo::setExpireTime(const QDateTime &time) 0160 { 0161 d->expireTime = time; 0162 } 0163 void AlertInfo::setUrgency(Urgency urgency) 0164 { 0165 d->urgency = urgency; 0166 } 0167 void AlertInfo::setSeverity(Severity severity) 0168 { 0169 d->severity = severity; 0170 } 0171 void AlertInfo::setCertainty(Certainty certainty) 0172 { 0173 d->certainty = certainty; 0174 } 0175 void AlertInfo::setParameter(const Parameter ¶meter) 0176 { 0177 d->parameter = parameter; 0178 } 0179 void AlertInfo::addParameter(std::pair<QString, QString> &p) 0180 { 0181 d->parameter.push_back(p); 0182 } 0183 0184 void AlertInfo::setAreaDesc(const QString &areaDesc) 0185 { 0186 d->areaDesc = areaDesc; 0187 } 0188 void AlertInfo::setPolygon(const std::vector<std::vector<std::pair<float, float>>> &polygon) 0189 { 0190 d->polygon = polygon; 0191 } 0192 void AlertInfo::setPolygon(std::vector<std::vector<std::pair<float, float>>> &&polygon) 0193 { 0194 d->polygon = std::move(polygon); 0195 } 0196 void AlertInfo::addPolygon(const std::vector<std::pair<float, float>> &area) 0197 { 0198 d->polygon.push_back(area); 0199 } 0200 void AlertInfo::addPolygon(std::vector<std::pair<float, float>> &&area) 0201 { 0202 d->polygon.emplace_back(area); 0203 } 0204 AlertInfo &AlertInfo::operator=(const AlertInfo &other) 0205 { 0206 *d = *other.d; 0207 return *this; 0208 } 0209 }