Changeset View
Changeset View
Standalone View
Standalone View
src/bugzillaintegration/libbugzilla/bug.h
- 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 | #ifndef BUG_H | ||||
22 | #define BUG_H | ||||
23 | | ||||
24 | #include <QObject> | ||||
25 | #include <QPointer> | ||||
26 | | ||||
27 | #include "connection.h" | ||||
28 | #include "comment.h" | ||||
29 | | ||||
30 | namespace Bugzilla { | ||||
31 | | ||||
32 | struct Search { | ||||
33 | QStringList products; | ||||
34 | QString severity; | ||||
35 | QString creationTime; | ||||
36 | qint64 id = -1; | ||||
37 | qint64 limit = -1; | ||||
38 | | ||||
39 | QUrlQuery toQuery() const; | ||||
40 | }; | ||||
41 | | ||||
42 | struct NewBug { | ||||
43 | QString product; | ||||
44 | QString component; | ||||
45 | QString summary; // aka shortdesc | ||||
46 | QString version; | ||||
47 | QString description; | ||||
48 | QString op_sys; | ||||
49 | QString platform; | ||||
50 | QString priority; | ||||
51 | QString severity; | ||||
52 | QStringList keywords; // not documented but also supported | ||||
53 | | ||||
54 | QJsonDocument toJsonDocument() const; | ||||
55 | }; | ||||
56 | | ||||
57 | struct BugUpdate { | ||||
58 | struct CCUpdate { | ||||
59 | QList<QString> add; | ||||
60 | QList<QString> remove; | ||||
61 | }; | ||||
62 | | ||||
63 | CCUpdate cc; | ||||
64 | | ||||
65 | QByteArray toJson() const; | ||||
66 | }; | ||||
67 | | ||||
68 | class Bug : public QObject | ||||
69 | { | ||||
70 | public: | ||||
71 | enum class Status { | ||||
72 | Unknown, // First value is default if QMetaEnum can't map the key. | ||||
73 | UNCONFIRMED, | ||||
74 | CONFIRMED, | ||||
75 | ASSIGNED, | ||||
76 | REOPENED, | ||||
77 | RESOLVED, | ||||
78 | NEEDSINFO, | ||||
79 | VERIFIED, | ||||
80 | CLOSED | ||||
81 | }; | ||||
82 | Q_ENUM(Status) | ||||
83 | | ||||
84 | enum class Resolution { | ||||
85 | Unknown, // First value is default if QMetaEnum can't map the key. | ||||
86 | FIXED, | ||||
87 | INVALID, | ||||
88 | WONTFIX, | ||||
89 | LATER, | ||||
90 | REMIND, | ||||
91 | DUPLICATE, | ||||
92 | WORKSFORME, | ||||
93 | MOVED, | ||||
94 | UPSTREAM, | ||||
95 | DOWNSTREAM, | ||||
96 | WAITINGFORINFO, | ||||
97 | BACKTRACE, | ||||
98 | UNMAINTAINED | ||||
99 | }; | ||||
100 | Q_ENUM(Resolution) | ||||
101 | | ||||
102 | private: | ||||
103 | Q_OBJECT | ||||
104 | Q_PROPERTY(qint64 id READ id WRITE setId CONSTANT) | ||||
105 | Q_PROPERTY(QString product READ product WRITE setProduct CONSTANT) | ||||
106 | Q_PROPERTY(QString component READ component WRITE setComponent CONSTANT) | ||||
107 | Q_PROPERTY(QString summary READ summary WRITE setSummary CONSTANT) | ||||
108 | Q_PROPERTY(QString version READ version WRITE setVersion CONSTANT) | ||||
109 | Q_PROPERTY(bool is_open READ is_open WRITE setIs_open CONSTANT) | ||||
110 | // maybe should be camel mapped, who knows | ||||
111 | Q_PROPERTY(QString op_sys READ op_sys WRITE setOp_sys CONSTANT) | ||||
112 | Q_PROPERTY(QString priority READ priority WRITE setPriority CONSTANT) | ||||
113 | Q_PROPERTY(QString severity READ severity WRITE setSeverity CONSTANT) | ||||
114 | Q_PROPERTY(Status status READ status WRITE setStatus CONSTANT) | ||||
115 | Q_PROPERTY(Resolution resolution READ resolution WRITE setResolution CONSTANT) | ||||
116 | Q_PROPERTY(qint64 dupe_of READ dupe_of WRITE setDupe_of CONSTANT) | ||||
117 | | ||||
118 | // This can be extended into with comments. It's empty by default! | ||||
119 | Q_PROPERTY(QList<Comment::Ptr> comments READ comments WRITE setComments NOTIFY commentsChanged) | ||||
120 | | ||||
121 | // Custom fields (versionfixedin etc) are only available via customField(). | ||||
122 | | ||||
123 | public: | ||||
124 | typedef QPointer<Bug> Ptr; | ||||
125 | | ||||
126 | explicit Bug(const QVariantHash &object, QObject *parent = nullptr); | ||||
127 | | ||||
128 | qint64 id() const; | ||||
129 | void setId(qint64 id); | ||||
130 | | ||||
131 | QVariant customField(const char *key); | ||||
132 | | ||||
133 | Status status() const; | ||||
134 | void setStatus(Status status); | ||||
135 | | ||||
136 | Resolution resolution() const; | ||||
137 | void setResolution(Resolution resolution); | ||||
138 | | ||||
139 | QString summary() const; | ||||
140 | void setSummary(const QString &summary); | ||||
141 | | ||||
142 | // bool isOpen() const; | ||||
143 | // bool isNeedingInfo() const; | ||||
144 | // bool isClosed() const; | ||||
145 | | ||||
146 | QString version() const; | ||||
147 | void setVersion(const QString &version); | ||||
148 | | ||||
149 | QString product() const; | ||||
150 | void setProduct(const QString &product); | ||||
151 | | ||||
152 | QString component() const; | ||||
153 | void setComponent(const QString &component); | ||||
154 | | ||||
155 | QString op_sys() const; | ||||
156 | void setOp_sys(const QString &op_sys); | ||||
157 | | ||||
158 | QString priority() const; | ||||
159 | void setPriority(const QString &priority); | ||||
160 | | ||||
161 | QString severity() const; | ||||
162 | void setSeverity(const QString &severity); | ||||
163 | | ||||
164 | QList<Comment::Ptr> comments() const; | ||||
165 | void setComments(const QList<Comment::Ptr> &comments); | ||||
166 | | ||||
167 | bool is_open() const; | ||||
168 | void setIs_open(bool is_open); | ||||
169 | | ||||
170 | qint64 dupe_of() const; | ||||
171 | void setDupe_of(qint64 dupe_of); | ||||
172 | | ||||
173 | Q_SIGNALS: | ||||
174 | void commentsChanged(); | ||||
175 | | ||||
176 | private: | ||||
177 | qint64 m_id = -1; | ||||
178 | QString m_product; | ||||
179 | QString m_component; | ||||
180 | QString m_summary; | ||||
181 | QString m_version; | ||||
182 | bool m_is_open = false; | ||||
183 | QString m_op_sys; | ||||
184 | QString m_priority; | ||||
185 | QString m_severity; | ||||
186 | Status m_status; | ||||
187 | Resolution m_resolution; | ||||
188 | qint64 m_dupe_of = -1; | ||||
189 | | ||||
190 | QList<Comment::Ptr> m_comments; | ||||
191 | }; | ||||
192 | | ||||
193 | class BugClient : QObject | ||||
194 | { | ||||
195 | Q_OBJECT | ||||
196 | public: | ||||
197 | BugClient(Connection &connection = Bugzilla::connection()); | ||||
198 | | ||||
199 | QList<Bug::Ptr> search(KJob *kjob); | ||||
200 | KJob *search(const Search &search); | ||||
201 | | ||||
202 | qint64 create(KJob *kjob); | ||||
203 | KJob *create(const NewBug &bug); | ||||
204 | | ||||
205 | qint64 update(KJob *kjob); | ||||
206 | KJob *update(qint64 bugId, BugUpdate &bug); | ||||
207 | | ||||
208 | private: | ||||
209 | Connection &m_connection; | ||||
210 | }; | ||||
211 | | ||||
212 | } // namespace Bugzilla | ||||
213 | | ||||
214 | #endif // BUG_H |