1 | /******************************************************************* |
2 | * duplicatefinderjob.h |
3 | * Copyright 2011 Matthias Fuchs <mat69@gmx.net> |
4 | * |
5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License as |
7 | * published by the Free Software Foundation; either version 2 of |
8 | * the License, or (at your option) any later version. |
9 | * |
10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | * |
18 | ******************************************************************/ |
19 | |
20 | #ifndef DUPLICATE_FINDER_H |
21 | #define DUPLICATE_FINDER_H |
22 | |
23 | #include <QtCore/QList> |
24 | |
25 | #include <KJob> |
26 | |
27 | #include "bugzillalib.h" |
28 | |
29 | /** |
30 | * Looks if of the current backtrace is a |
31 | * duplicate of any of the specified bug ids. |
32 | * If a duplicate is found result is emitted instantly |
33 | */ |
34 | class DuplicateFinderJob : public KJob |
35 | { |
36 | Q_OBJECT |
37 | public: |
38 | struct Result |
39 | { |
40 | Result() |
41 | : duplicate(0), |
42 | parentDuplicate(0), |
43 | status(BugReport::UnknownStatus), |
44 | resolution(BugReport::UnknownResolution) |
45 | {} |
46 | |
47 | /** |
48 | * First duplicate that was found, it might be that |
49 | * this one is a duplicate itself, though this is still |
50 | * useful for example to inform the user that their |
51 | * backtrace is a duplicate of this bug, which is |
52 | * tracked at another number though. |
53 | * |
54 | * @note 0 means that there is no duplicate |
55 | * @see parrentDuplicate |
56 | */ |
57 | int duplicate; |
58 | |
59 | /** |
60 | * This always points to the parent bug, i.e. |
61 | * the bug that has no duplicates itself. |
62 | * If this is 0 it means that there are no duplicates |
63 | */ |
64 | int parentDuplicate; |
65 | |
66 | BugReport::Status status; |
67 | |
68 | BugReport::Resolution resolution; |
69 | }; |
70 | |
71 | DuplicateFinderJob(const QList<int> &bugIds, BugzillaManager *manager, QObject *parent = 0); |
72 | virtual ~DuplicateFinderJob(); |
73 | |
74 | virtual void start(); |
75 | |
76 | /** |
77 | * Call this after result has been emitted to |
78 | * get the result |
79 | */ |
80 | Result result() const; |
81 | |
82 | private slots: |
83 | void slotBugReportFetched(const BugReport &bug, QObject *owner); |
84 | void slotBugReportError(const QString &message, QObject *owner); |
85 | |
86 | private: |
87 | void analyzeNextBug(); |
88 | void fetchBug(const QString &bugId); |
89 | |
90 | private: |
91 | BugzillaManager *m_manager; |
92 | QList<int> m_bugIds; |
93 | Result m_result; |
94 | }; |
95 | #endif |
96 | |