KWeatherCore

alertfeedentry.cpp
1/*
2 * SPDX-FileCopyrightText: 2021 Han Young <hanyoung@protonmail.com>
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>
10namespace KWeatherCore
11{
12class AlertFeedEntry::AlertFeedEntryPrivate
13{
14public:
15 QString title;
16 QString summary;
17 QString area;
18 CAPAlertInfo::Urgency urgency = CAPAlertInfo::Urgency::UnknownUrgency;
19 CAPAlertInfo::Severity severity = CAPAlertInfo::Severity::UnknownSeverity;
20 CAPAlertInfo::Certainty certainty = CAPAlertInfo::Certainty::UnknownCertainty;
21 QDateTime date;
22 QUrl CAPUrl;
23 AreaCodeVec areaCodes;
24 CAPPolygon polygon;
25};
26
28 : d(std::make_unique<AlertFeedEntryPrivate>())
29{
30}
32 : d(std::make_unique<AlertFeedEntryPrivate>(*other.d))
33{
34}
36AlertFeedEntry::~AlertFeedEntry() = default;
37const QString &AlertFeedEntry::title() const
38{
39 return d->title;
40}
41const QString &AlertFeedEntry::summary() const
42{
43 return d->summary;
44}
45const QString &AlertFeedEntry::area() const
46{
47 return d->area;
48}
49CAPAlertInfo::Urgency AlertFeedEntry::urgency() const
50{
51 return d->urgency;
52}
53CAPAlertInfo::Severity AlertFeedEntry::severity() const
54{
55 return d->severity;
56}
57CAPAlertInfo::Certainty AlertFeedEntry::certainty() const
58{
59 return d->certainty;
60}
61const QDateTime &AlertFeedEntry::date() const
62{
63 return d->date;
64}
66{
68 auto reply = manager.get(QNetworkRequest(d->CAPUrl));
69 return new PendingCAP(reply);
70}
71const AreaCodeVec &AlertFeedEntry::areaCodes() const
72{
73 return d->areaCodes;
74}
75const CAPPolygon &AlertFeedEntry::polygon() const
76{
77 return d->polygon;
78}
79
80void AlertFeedEntry::setTitle(const QString &title)
81{
82 d->title = title;
83}
84void AlertFeedEntry::setSummary(const QString &summary)
85{
86 d->summary = summary;
87}
88void AlertFeedEntry::setArea(const QString &area)
89{
90 d->area = area;
91}
92void AlertFeedEntry::setUrgency(CAPAlertInfo::Urgency urgency)
93{
94 d->urgency = urgency;
95}
96void AlertFeedEntry::setCertainty(CAPAlertInfo::Certainty certainty)
97{
98 d->certainty = certainty;
99}
100void AlertFeedEntry::setSeverity(CAPAlertInfo::Severity severity)
101{
102 d->severity = severity;
103}
104void AlertFeedEntry::setDate(const QDateTime &date)
105{
106 d->date = date;
107}
108void AlertFeedEntry::setUrl(const QUrl &url)
109{
110 d->CAPUrl = url;
111}
112void AlertFeedEntry::setAreaCodes(AreaCodeVec &&areaCodes)
113{
114 d->areaCodes = std::move(areaCodes);
115}
116void AlertFeedEntry::setPolygon(CAPPolygon &&polygon)
117{
118 d->polygon = std::move(polygon);
119}
120AlertFeedEntry &AlertFeedEntry::operator=(const AlertFeedEntry &other)
121{
122 *this->d = *other.d;
123 return *this;
124}
125AlertFeedEntry &AlertFeedEntry::operator=(AlertFeedEntry &&other) = default;
126}
127
128#include "moc_alertfeedentry.cpp"
Class represents single CAP.
AlertFeedEntry()
default constructor
const CAPPolygon & polygon() const
area polygon
PendingCAP * CAP() const
CAP, request to download CAP file.
const AreaCodeVec & areaCodes() const
areaCodes
The PendingAlerts class contains the reply to an asynchronous CAP request.
Definition pendingcap.h:25
QNetworkReply * get(const QNetworkRequest &request)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 12:02:06 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.