Changeset View
Changeset View
Standalone View
Standalone View
plugins/perforce/perforceplugin.h
- This file was added.
1 | /*************************************************************************** | ||||
---|---|---|---|---|---|
2 | * Copyright 2010 Morten Danielsen Volden * | ||||
3 | * * | ||||
4 | * This program is free software: you can redistribute it and/or modify * | ||||
5 | * it under the terms of the GNU General Public License as published by * | ||||
6 | * the Free Software Foundation, either version 2 of the License, or * | ||||
7 | * (at your option) any later version. * | ||||
8 | * * | ||||
9 | * This program is distributed in the hope that it will be useful, * | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||||
12 | * GNU General Public License for more details. * | ||||
13 | * * | ||||
14 | * You should have received a copy of the GNU General Public License * | ||||
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. * | ||||
16 | ***************************************************************************/ | ||||
17 | | ||||
18 | #ifndef KDEVPERFORCEPLUGIN_H | ||||
19 | #define KDEVPERFORCEPLUGIN_H | ||||
20 | | ||||
21 | #include <vcs/interfaces/icentralizedversioncontrol.h> | ||||
22 | #include <vcs/vcsstatusinfo.h> | ||||
23 | #include <interfaces/iplugin.h> | ||||
24 | #include <outputview/outputjob.h> | ||||
25 | | ||||
26 | | ||||
27 | #include <QVariantList> | ||||
28 | #include <QString> | ||||
29 | | ||||
30 | #include <memory> | ||||
31 | | ||||
32 | class QMenu; | ||||
33 | class QFileInfo; | ||||
34 | class QDir; | ||||
35 | | ||||
36 | | ||||
37 | namespace KDevelop | ||||
38 | { | ||||
39 | class ContextMenuExtension; | ||||
40 | class VcsPluginHelper; | ||||
41 | class DVcsJob; | ||||
42 | } | ||||
43 | | ||||
44 | | ||||
45 | class PerforcePlugin : public KDevelop::IPlugin, public KDevelop::ICentralizedVersionControl | ||||
46 | { | ||||
47 | Q_OBJECT | ||||
48 | Q_INTERFACES(KDevelop::IBasicVersionControl KDevelop::ICentralizedVersionControl) | ||||
49 | | ||||
50 | friend class PerforcePluginTest; | ||||
51 | public: | ||||
52 | PerforcePlugin(QObject* parent, const QVariantList & = QVariantList()); | ||||
53 | ~PerforcePlugin() override; | ||||
54 | | ||||
55 | //@{ | ||||
56 | /** Methods inherited from KDevelop::IBasicVersionControl */ | ||||
57 | QString name() const override; | ||||
58 | | ||||
59 | KDevelop::VcsImportMetadataWidget* createImportMetadataWidget(QWidget* parent) override; | ||||
60 | | ||||
61 | bool isVersionControlled(const QUrl& localLocation) override; | ||||
62 | | ||||
63 | KDevelop::VcsJob* repositoryLocation(const QUrl& localLocation) override; | ||||
64 | | ||||
65 | KDevelop::VcsJob* add(const QList<QUrl>& localLocations, | ||||
66 | RecursionMode recursion = IBasicVersionControl::Recursive) override; | ||||
67 | KDevelop::VcsJob* remove(const QList<QUrl>& localLocations) override; | ||||
68 | | ||||
69 | KDevelop::VcsJob* copy(const QUrl& localLocationSrc, | ||||
70 | const QUrl& localLocationDstn) override; | ||||
71 | KDevelop::VcsJob* move(const QUrl& localLocationSrc, | ||||
72 | const QUrl& localLocationDst) override; | ||||
73 | KDevelop::VcsJob* status(const QList<QUrl>& localLocations, | ||||
74 | RecursionMode recursion = IBasicVersionControl::Recursive) override; | ||||
75 | | ||||
76 | KDevelop::VcsJob* revert(const QList<QUrl>& localLocations, | ||||
77 | RecursionMode recursion = IBasicVersionControl::Recursive) override; | ||||
78 | | ||||
79 | KDevelop::VcsJob* update(const QList<QUrl>& localLocations, | ||||
80 | const KDevelop::VcsRevision& rev = KDevelop::VcsRevision::createSpecialRevision(KDevelop::VcsRevision::Head), | ||||
81 | KDevelop::IBasicVersionControl::RecursionMode recursion = KDevelop::IBasicVersionControl::Recursive) override; | ||||
82 | | ||||
83 | KDevelop::VcsJob* commit(const QString& message, | ||||
84 | const QList<QUrl>& localLocations, | ||||
85 | KDevelop::IBasicVersionControl::RecursionMode recursion = KDevelop::IBasicVersionControl::Recursive) override; | ||||
86 | | ||||
87 | KDevelop::VcsJob* diff(const QUrl& fileOrDirectory, | ||||
88 | const KDevelop::VcsRevision& srcRevision, | ||||
89 | const KDevelop::VcsRevision& dstRevision, | ||||
90 | KDevelop::VcsDiff::Type = KDevelop::VcsDiff::DiffUnified, | ||||
91 | KDevelop::IBasicVersionControl::RecursionMode recursion = KDevelop::IBasicVersionControl::Recursive) override; | ||||
92 | | ||||
93 | KDevelop::VcsJob* log(const QUrl& localLocation, | ||||
94 | const KDevelop::VcsRevision& rev, | ||||
95 | unsigned long limit = 0) override; | ||||
96 | | ||||
97 | KDevelop::VcsJob* log(const QUrl& localLocation, | ||||
98 | const KDevelop::VcsRevision& rev = KDevelop::VcsRevision::createSpecialRevision(KDevelop::VcsRevision::Base), | ||||
99 | const KDevelop::VcsRevision& limit = KDevelop::VcsRevision::createSpecialRevision(KDevelop::VcsRevision::Start)) override; | ||||
100 | | ||||
101 | KDevelop::VcsJob* annotate(const QUrl& localLocation, | ||||
102 | const KDevelop::VcsRevision& rev = KDevelop::VcsRevision::createSpecialRevision(KDevelop::VcsRevision::Head)) override; | ||||
103 | | ||||
104 | KDevelop::VcsJob* resolve(const QList<QUrl>& localLocations, | ||||
105 | KDevelop::IBasicVersionControl::RecursionMode recursion) override; | ||||
106 | | ||||
107 | KDevelop::VcsJob* createWorkingCopy(const KDevelop::VcsLocation & sourceRepository, | ||||
108 | const QUrl & destinationDirectory, | ||||
109 | KDevelop::IBasicVersionControl::RecursionMode recursion = IBasicVersionControl::Recursive) override; | ||||
110 | | ||||
111 | | ||||
112 | KDevelop::VcsLocationWidget* vcsLocation(QWidget* parent) const override; | ||||
113 | //@} | ||||
114 | | ||||
115 | //@{ | ||||
116 | /** Methods inherited from KDevelop::ICentralizedVersionControl */ | ||||
117 | KDevelop::VcsJob* edit(const QUrl& localLocation) override; | ||||
118 | | ||||
119 | KDevelop::VcsJob* unedit(const QUrl& localLocation) override; | ||||
120 | | ||||
121 | KDevelop::VcsJob* localRevision(const QUrl& localLocation, | ||||
122 | KDevelop::VcsRevision::RevisionType) override; | ||||
123 | | ||||
124 | KDevelop::VcsJob* import(const QString & commitMessage, | ||||
125 | const QUrl & sourceDirectory, | ||||
126 | const KDevelop::VcsLocation & destinationRepository) override; | ||||
127 | //@} | ||||
128 | | ||||
129 | /// This plugin implements its own edit method | ||||
130 | KDevelop::VcsJob* edit(const QList<QUrl>& localLocations); | ||||
131 | | ||||
132 | | ||||
133 | bool hasError() const override; | ||||
134 | QString errorDescription() const override; | ||||
135 | | ||||
136 | KDevelop::ContextMenuExtension contextMenuExtension(KDevelop::Context* context) override; | ||||
137 | | ||||
138 | | ||||
139 | public Q_SLOTS: | ||||
140 | | ||||
141 | /// invoked by context-menu | ||||
142 | void ctxEdit(); | ||||
143 | // void ctxUnedit(); | ||||
144 | // void ctxLocalRevision(); | ||||
145 | // void ctxImport(); | ||||
146 | | ||||
147 | private slots: | ||||
148 | void parseP4StatusOutput(KDevelop::DVcsJob* job); | ||||
149 | void parseP4DiffOutput(KDevelop::DVcsJob* job); | ||||
150 | void parseP4LogOutput(KDevelop::DVcsJob* job); | ||||
151 | void parseP4AnnotateOutput(KDevelop::DVcsJob* job); | ||||
152 | | ||||
153 | | ||||
154 | | ||||
155 | private: | ||||
156 | bool isValidDirectory(const QUrl & dirPath); | ||||
157 | KDevelop::DVcsJob* p4fstatJob(const QFileInfo& curFile, | ||||
158 | KDevelop::OutputJob::OutputJobVerbosity verbosity = KDevelop::OutputJob::Verbose); | ||||
159 | | ||||
160 | bool parseP4fstat(const QFileInfo& curFile, | ||||
161 | KDevelop::OutputJob::OutputJobVerbosity verbosity = KDevelop::OutputJob::Verbose); | ||||
162 | | ||||
163 | KDevelop::VcsJob* errorsFound(const QString& error, | ||||
164 | KDevelop::OutputJob::OutputJobVerbosity verbosity = KDevelop::OutputJob::Verbose); | ||||
165 | | ||||
166 | QString getRepositoryName(const QFileInfo& curFile); | ||||
167 | | ||||
168 | | ||||
169 | void setEnvironmentForJob(KDevelop::DVcsJob* job, QFileInfo const& fsObject); | ||||
170 | QList<QVariant> getQvariantFromLogOutput(QStringList const& outputLines); | ||||
171 | | ||||
172 | std::unique_ptr<KDevelop::VcsPluginHelper> m_common; | ||||
173 | QMenu* m_perforcemenu; | ||||
174 | QString m_perforceConfigName; | ||||
175 | QString m_perforceExecutable; | ||||
176 | QAction* m_edit_action; | ||||
177 | | ||||
178 | bool m_hasError; | ||||
179 | QString m_errorDescription; | ||||
180 | | ||||
181 | }; | ||||
182 | | ||||
183 | #endif // PERFORCEPLUGIN_H |