Purpose

phabricatorjobs.h
1/*
2 SPDX-FileCopyrightText: 2017 René J.V. Bertin <rjvbertin@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KDEVPLATFORM_PLUGIN_PHABRICATORJOBS_H
8#define KDEVPLATFORM_PLUGIN_PHABRICATORJOBS_H
9
10#include <QHash>
11#include <QList>
12#include <QPair>
13#include <QUrl>
14
15#include <KJob>
16#include <QProcess>
17
18class QNetworkReply;
19
20namespace Phabricator
21{
22class DifferentialRevision : public KJob
23{
25public:
26 DifferentialRevision(const QString &id, QObject *parent)
27 : KJob(parent)
28 , m_id(id)
29 , m_commit(QString())
30 {
31 setPercent(0);
32 }
33 QString requestId() const
34 {
35 return m_id;
36 }
37 void setRequestId(const QString &id)
38 {
39 m_id = id;
40 }
41 QString commitRef() const
42 {
43 return m_commit;
44 }
45 void setCommitRef(const QString &commit)
46 {
47 m_commit = commit;
48 }
49 void start() override;
50 QString errorString() const override
51 {
52 return m_errorString;
53 }
54 void setErrorString(const QString &msg);
55 QString scrubbedResult();
56 QStringList scrubbedResultList();
57
58private Q_SLOTS:
59 virtual void done(int exitCode, QProcess::ExitStatus exitStatus) = 0;
60
61protected:
62 virtual bool buildArcCommand(const QString &workDir, const QString &patchFile = QString(), bool doBrowse = false);
63 QProcess m_arcCmd;
64
65private:
66 QString m_id;
67 QString m_commit;
68 QString m_errorString;
69 QString m_arcInput;
70};
71
72class NewDiffRev : public DifferentialRevision
73{
75public:
76 NewDiffRev(const QUrl &patch, const QString &project, bool doBrowse = false, QObject *parent = nullptr);
77 QString diffURI() const
78 {
79 return m_diffURI;
80 }
81
82private Q_SLOTS:
83 void done(int exitCode, QProcess::ExitStatus exitStatus) override;
84
85private:
86 QUrl m_patch;
87 QString m_project;
88 QString m_diffURI;
89};
90
91class UpdateDiffRev : public DifferentialRevision
92{
94public:
95 UpdateDiffRev(const QUrl &patch,
96 const QString &basedir,
97 const QString &id,
98 const QString &updateComment = QString(),
99 bool doBrowse = false,
100 QObject *parent = nullptr);
101 QString diffURI() const
102 {
103 return m_diffURI;
104 }
105
106private Q_SLOTS:
107 void done(int exitCode, QProcess::ExitStatus exitStatus) override;
108
109private:
110 QUrl m_patch;
111 QString m_basedir;
112 QString m_diffURI;
113};
114
115class DiffRevList : public DifferentialRevision
116{
118public:
119 enum Status {
120 Accepted,
121 NeedsReview,
122 NeedsRevision,
123 };
124 Q_ENUM(Status)
125
126 DiffRevList(const QString &projectDir, QObject *parent = nullptr);
127 // return the open diff. revisions as a list of <diffID,diffDescription> pairs
128 QList<QPair<QString, QString>> reviews() const
129 {
130 return m_reviews;
131 }
132 // return the open diff. revisions as a map of diffDescription->diffID entries
133 QHash<QString, QString> reviewMap() const
134 {
135 return m_revMap;
136 }
137 // return the open diff. revision statuses as a map of diffDescription->Status entries
138 QHash<QString, Status> statusMap() const
139 {
140 return m_statusMap;
141 }
142
143private Q_SLOTS:
144 void done(int exitCode, QProcess::ExitStatus exitStatus) override;
145
146protected:
147 bool buildArcCommand(const QString &workDir, const QString &unused = QString(), bool ignored = false) override;
148
149private:
152 QHash<QString, Status> m_statusMap;
153 QString m_projectDir;
154};
155}
156
157#endif
void setPercent(unsigned long percentage)
Q_ENUM(...)
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:03:06 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.