KWeatherCore

alertfeedentry.h
1 /*
2  * SPDX-FileCopyrightText: 2021 Han Young <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 #pragma once
7 #include "alertinfo.h"
8 #include "kweathercore/kweathercore_export.h"
9 #include "pendingcap.h"
10 #include <QObject>
11 #include <memory>
12 namespace KWeatherCore
13 {
14 // code name (FIPS6, UGC...)/code value (002050, AKZ155)
15 using AreaCodeVec = std::vector<std::pair<QString, QString>>;
16 using Polygon = std::vector<std::pair<float, float>>;
17 /**
18  * @short Class represents single CAP
19  *
20  * This class contains the parsed CAP FEED entry
21  *
22  * @author Han Young <[email protected]>
23  */
24 class KWEATHERCORE_EXPORT AlertFeedEntry
25 {
26  Q_GADGET
27  Q_PROPERTY(QString title READ title)
28  Q_PROPERTY(QString summary READ summary)
29  Q_PROPERTY(QString area READ area)
30  Q_PROPERTY(QString urgency READ urgency)
31  Q_PROPERTY(QString severity READ severity)
32  Q_PROPERTY(QString certainty READ certainty)
33  Q_PROPERTY(QDateTime date READ date)
34 public:
35  /**
36  * default constructor
37  */
39  /**
40  * copy constructor
41  */
42  AlertFeedEntry(const AlertFeedEntry &other);
44  ~AlertFeedEntry();
45  /**
46  * title of this entry
47  */
48  const QString &title() const;
49  /**
50  * summary of this entry
51  */
52  const QString &summary() const;
53  /**
54  * area name, for accurate location
55  * use @AreaCodes if possible
56  */
57  const QString &area() const;
58  /**
59  * urgency
60  * @return localized, "Unknown" by defaut
61  */
62  QString urgency() const;
63  /**
64  * severity
65  * @return localized, "Unknown" by defaut
66  */
67  QString severity() const;
68  /**
69  * certainty
70  * @return localized, "Unknown" by defaut
71  */
72  QString certainty() const;
73  /**
74  * could be date of the alert or the date of this message
75  * refer to CAP for accurate date
76  * see @CAP
77  */
78  const QDateTime &date() const;
79  /**
80  * CAP, request to download CAP file
81  * @return it is the client's responsibility to delete the
82  * PendingCAP afterward to avoid memory leak
83  */
84  PendingCAP *CAP() const;
85  /**
86  * areaCodes
87  * @return pairs of QString, the first one is code type,
88  * ie. {"UGC", "AKZ017 AKZ020 AKZ021 AKZ022 AKZ023"}
89  */
90  const AreaCodeVec &areaCodes() const;
91  /**
92  * area polygon
93  * @return latitude longitude pairs
94  */
95  const Polygon &polygon() const;
96 
97  void setTitle(const QString &title);
98  void setSummary(const QString &summary);
99  void setArea(const QString &area);
100  void setUrgency(AlertInfo::Urgency urgency);
101  void setCertainty(AlertInfo::Certainty certainty);
102  void setSeverity(AlertInfo::Severity severity);
103  void setDate(const QDateTime &date);
104  void setUrl(const QUrl &url);
105  void setAreaCodes(const AreaCodeVec &areaCodes);
106  void setPolygon(const Polygon &polygon);
107  void setAreaCodes(AreaCodeVec &&areaCodes);
108  void setPolygon(Polygon &&polygon);
109  AlertFeedEntry &operator=(const AlertFeedEntry &other);
110  AlertFeedEntry &operator=(AlertFeedEntry &&other);
111 
112 private:
113  class AlertFeedEntryPrivate;
114  std::unique_ptr<AlertFeedEntryPrivate> d;
115 };
116 }
The PendingAlerts class contains the reply to an asynchronous CAP request.
Definition: pendingcap.h:23
Class represents single CAP.
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.