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}
49QString AlertFeedEntry::urgency() const
50{
51 return KWeatherCorePrivate::urgencyToString(d->urgency);
52}
53QString AlertFeedEntry::severity() const
54{
55 return KWeatherCorePrivate::severityToString(d->severity);
56}
57QString AlertFeedEntry::certainty() const
58{
59 return KWeatherCorePrivate::certaintyToString(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(const AreaCodeVec &areaCodes)
113{
114 d->areaCodes = areaCodes;
115}
116void AlertFeedEntry::setAreaCodes(AreaCodeVec &&areaCodes)
117{
118 d->areaCodes = std::move(areaCodes);
119}
120void AlertFeedEntry::setPolygon(CAPPolygon &&polygon)
121{
122 d->polygon = std::move(polygon);
123}
124AlertFeedEntry &AlertFeedEntry::operator=(const AlertFeedEntry &other)
125{
126 *this->d = *other.d;
127 return *this;
128}
129AlertFeedEntry &AlertFeedEntry::operator=(AlertFeedEntry &&other) = default;
130}
131
132#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 Tue Mar 26 2024 11:20:42 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.