KWeatherCore

alertfeedentry.cpp
1 /*
2  * SPDX-FileCopyrightText: 2021 Han Young <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 #include "alertfeedentry.h"
7 #include "kweathercore_p.h"
8 #include <QNetworkAccessManager>
9 #include <QUrl>
10 namespace KWeatherCore
11 {
12 class AlertFeedEntry::AlertFeedEntryPrivate
13 {
14 public:
15  QString title;
17  QString area;
18  AlertInfo::Urgency urgency = AlertInfo::Urgency::Unknown;
19  AlertInfo::Severity severity = AlertInfo::Severity::Unknown;
20  AlertInfo::Certainty certainty = AlertInfo::Certainty::Unknown;
22  QUrl CAPUrl;
23  AreaCodeVec areaCodes;
24  Polygon polygon;
25 };
26 
28  : d(std::make_unique<AlertFeedEntryPrivate>())
29 {
30 }
32  : d(std::make_unique<AlertFeedEntryPrivate>(*other.d))
33 {
34 }
36 AlertFeedEntry::~AlertFeedEntry() = default;
37 const QString &AlertFeedEntry::title() const
38 {
39  return d->title;
40 }
41 const QString &AlertFeedEntry::summary() const
42 {
43  return d->summary;
44 }
45 const QString &AlertFeedEntry::area() const
46 {
47  return d->area;
48 }
50 {
51  return self()->urgencyToString(d->urgency);
52 }
54 {
55  return self()->severityToString(d->severity);
56 }
58 {
59  return self()->certaintyToString(d->certainty);
60 }
61 const QDateTime &AlertFeedEntry::date() const
62 {
63  return d->date;
64 }
66 {
67  QNetworkAccessManager manager;
68  auto reply = manager.get(QNetworkRequest(d->CAPUrl));
69  return new PendingCAP(reply);
70 }
71 const AreaCodeVec &AlertFeedEntry::areaCodes() const
72 {
73  return d->areaCodes;
74 }
75 const Polygon &AlertFeedEntry::polygon() const
76 {
77  return d->polygon;
78 }
79 
80 void AlertFeedEntry::setTitle(const QString &title)
81 {
82  d->title = title;
83 }
84 void AlertFeedEntry::setSummary(const QString &summary)
85 {
86  d->summary = summary;
87 }
88 void AlertFeedEntry::setArea(const QString &area)
89 {
90  d->area = area;
91 }
92 void AlertFeedEntry::setUrgency(AlertInfo::Urgency urgency)
93 {
94  d->urgency = urgency;
95 }
96 void AlertFeedEntry::setCertainty(AlertInfo::Certainty certainty)
97 {
98  d->certainty = certainty;
99 }
100 void AlertFeedEntry::setSeverity(AlertInfo::Severity severity)
101 {
102  d->severity = severity;
103 }
104 void AlertFeedEntry::setDate(const QDateTime &date)
105 {
106  d->date = date;
107 }
108 void AlertFeedEntry::setUrl(const QUrl &url)
109 {
110  d->CAPUrl = url;
111 }
112 void AlertFeedEntry::setAreaCodes(const AreaCodeVec &areaCodes)
113 {
114  d->areaCodes = areaCodes;
115 }
116 void AlertFeedEntry::setPolygon(const Polygon &polygon)
117 {
118  d->polygon = polygon;
119 }
120 void AlertFeedEntry::setAreaCodes(AreaCodeVec &&areaCodes)
121 {
122  d->areaCodes = std::move(areaCodes);
123 }
124 void AlertFeedEntry::setPolygon(Polygon &&polygon)
125 {
126  d->polygon = std::move(polygon);
127 }
128 AlertFeedEntry &AlertFeedEntry::operator=(const AlertFeedEntry &other)
129 {
130  *this->d = *other.d;
131  return *this;
132 }
133 AlertFeedEntry &AlertFeedEntry::operator=(AlertFeedEntry &&other) = default;
134 }
QString severity() const
severity
The PendingAlerts class contains the reply to an asynchronous CAP request.
Definition: pendingcap.h:23
QString urgency() const
urgency
QString certainty() const
certainty
const QString & summary() const
summary of this entry
Class represents single CAP.
const QString & area() const
area name, for accurate location use if possible
const Polygon & polygon() const
area polygon
const AreaCodeVec & areaCodes() const
areaCodes
AlertFeedEntry()
default constructor
const QDateTime & date() const
could be date of the alert or the date of this message refer to CAP for accurate date see ...
PendingCAP * CAP() const
CAP, request to download CAP file.
QNetworkReply * get(const QNetworkRequest &request)
const QString & title() const
title of this entry
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Oct 21 2021 23:05:33 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.