Changeset View
Changeset View
Standalone View
Standalone View
src/bugzillaintegration/libbugzilla/models/bug.cpp
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | Copyright 2019 Harald Sitter <sitter@kde.org> | ||||
3 | | ||||
4 | This library is free software; you can redistribute it and/or | ||||
5 | modify it under the terms of the GNU Lesser General Public | ||||
6 | License as published by the Free Software Foundation; either | ||||
7 | version 2.1 of the License, or (at your option) version 3, or any | ||||
8 | later version accepted by the membership of KDE e.V. (or its | ||||
9 | successor approved by the membership of KDE e.V.), which shall | ||||
10 | act as a proxy defined in Section 6 of version 3 of the license. | ||||
11 | | ||||
12 | This library is distributed in the hope that it will be useful, | ||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
15 | Lesser General Public License for more details. | ||||
16 | | ||||
17 | You should have received a copy of the GNU Lesser General Public | ||||
18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | */ | ||||
20 | | ||||
21 | #include "bug.h" | ||||
22 | | ||||
23 | #include <QDebug> | ||||
24 | #include <QJsonDocument> | ||||
25 | #include <QJsonObject> | ||||
26 | #include <QMetaEnum> | ||||
27 | #include <QUrlQuery> | ||||
28 | | ||||
29 | namespace Bugzilla { | ||||
30 | | ||||
31 | Bug::Bug(const QVariantHash &obj, QObject *parent) | ||||
32 | : QObject(parent) | ||||
33 | { | ||||
34 | for (auto it = obj.constBegin(); it != obj.constEnd(); ++it) { | ||||
35 | setProperty(qPrintable(it.key()), it.value()); | ||||
36 | } | ||||
37 | // Enums are auto-translated from strings so long as the string is equal | ||||
38 | // to the stringified enum key. Fail if the mapping failed. | ||||
39 | const QString status = obj.value(QStringLiteral("status")).toString(); | ||||
40 | Q_ASSERT_X(m_status != Status::Unknown, Q_FUNC_INFO, | ||||
41 | qPrintable(QStringLiteral("Status mapping failed on bug %1 : %2").arg(id()).arg(status))); | ||||
42 | #warning fixme resolution can be emptys string when unresolved, does this need special care maybe | ||||
43 | // const QString resolution = obj.value(QStringLiteral("resolution")).toString(); | ||||
44 | // Q_ASSERT_X(m_resolution != Resolution::Unknown, Q_FUNC_INFO, | ||||
45 | // qPrintable(QStringLiteral("Resolution mapping failed on bug %1 : %2").arg(id()).arg(resolution))); | ||||
46 | // qDebug() << this; | ||||
47 | } | ||||
48 | | ||||
49 | Bug::Resolution Bug::resolution() const | ||||
50 | { | ||||
51 | return m_resolution; | ||||
52 | } | ||||
53 | | ||||
54 | void Bug::setResolution(Resolution resolution) | ||||
55 | { | ||||
56 | m_resolution = resolution; | ||||
57 | } | ||||
58 | | ||||
59 | QString Bug::summary() const | ||||
60 | { | ||||
61 | return m_summary; | ||||
62 | } | ||||
63 | | ||||
64 | void Bug::setSummary(const QString &summary) | ||||
65 | { | ||||
66 | m_summary = summary; | ||||
67 | } | ||||
68 | | ||||
69 | QString Bug::version() const | ||||
70 | { | ||||
71 | return m_version; | ||||
72 | } | ||||
73 | | ||||
74 | void Bug::setVersion(const QString &version) | ||||
75 | { | ||||
76 | m_version = version; | ||||
77 | } | ||||
78 | | ||||
79 | QString Bug::product() const | ||||
80 | { | ||||
81 | return m_product; | ||||
82 | } | ||||
83 | | ||||
84 | void Bug::setProduct(const QString &product) | ||||
85 | { | ||||
86 | m_product = product; | ||||
87 | } | ||||
88 | | ||||
89 | QString Bug::component() const | ||||
90 | { | ||||
91 | return m_component; | ||||
92 | } | ||||
93 | | ||||
94 | void Bug::setComponent(const QString &component) | ||||
95 | { | ||||
96 | m_component = component; | ||||
97 | } | ||||
98 | | ||||
99 | QString Bug::op_sys() const | ||||
100 | { | ||||
101 | return m_op_sys; | ||||
102 | } | ||||
103 | | ||||
104 | void Bug::setOp_sys(const QString &op_sys) | ||||
105 | { | ||||
106 | m_op_sys = op_sys; | ||||
107 | } | ||||
108 | | ||||
109 | QString Bug::priority() const | ||||
110 | { | ||||
111 | return m_priority; | ||||
112 | } | ||||
113 | | ||||
114 | void Bug::setPriority(const QString &priority) | ||||
115 | { | ||||
116 | m_priority = priority; | ||||
117 | } | ||||
118 | | ||||
119 | QString Bug::severity() const | ||||
120 | { | ||||
121 | return m_severity; | ||||
122 | } | ||||
123 | | ||||
124 | void Bug::setSeverity(const QString &severity) | ||||
125 | { | ||||
126 | m_severity = severity; | ||||
127 | } | ||||
128 | | ||||
129 | bool Bug::is_open() const | ||||
130 | { | ||||
131 | return m_is_open; | ||||
132 | } | ||||
133 | | ||||
134 | void Bug::setIs_open(bool is_open) | ||||
135 | { | ||||
136 | m_is_open = is_open; | ||||
137 | } | ||||
138 | | ||||
139 | qint64 Bug::dupe_of() const | ||||
140 | { | ||||
141 | return m_dupe_of; | ||||
142 | } | ||||
143 | | ||||
144 | void Bug::setDupe_of(qint64 dupe_of) | ||||
145 | { | ||||
146 | m_dupe_of = dupe_of; | ||||
147 | } | ||||
148 | | ||||
149 | qint64 Bug::id() const | ||||
150 | { | ||||
151 | return m_id; | ||||
152 | } | ||||
153 | | ||||
154 | void Bug::setId(qint64 id) | ||||
155 | { | ||||
156 | m_id = id; | ||||
157 | } | ||||
158 | | ||||
159 | QVariant Bug::customField(const char *key) | ||||
160 | { | ||||
161 | return property(key); | ||||
162 | } | ||||
163 | | ||||
164 | Bug::Status Bug::status() const | ||||
165 | { | ||||
166 | return m_status; | ||||
167 | } | ||||
168 | | ||||
169 | void Bug::setStatus(Status status) | ||||
170 | { | ||||
171 | m_status = status; | ||||
172 | } | ||||
173 | | ||||
174 | } // namespace Bugzilla |