1 /***************************************************************************
2 * Copyright 2008 Evgeniy Ivanov <powerfox@kde.ru> *
4 * This program is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU General Public License as *
6 * published by the Free Software Foundation; either version 2 of *
7 * the License or (at your option) version 3 or any later version *
8 * accepted by the membership of KDE e.V. (or its successor approved *
9 * by the membership of KDE e.V.), which shall act as a proxy *
10 * defined in Section 14 of version 3 of the license. *
12 * This program 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 *
15 * GNU General Public License for more details. *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19 ***************************************************************************/
26 #include <kcomponentdata.h>
28 #include <QtCore/QObject>
30 #include <vcs/interfaces/idistributedversioncontrol.h>
31 #include <interfaces/iuicontroller.h>
32 #include <interfaces/iplugin.h>
34 #include "../vcsexport.h"
36 #include "idvcsexecutor.h"
39 class KDevDVCSViewFactory
;
41 struct DistributedVersionControlPluginPrivate
{
42 KDevDVCSViewFactory
* m_factory
;
43 KDevelop::IDVCSexecutor
* m_exec
;
44 KUrl::List m_ctxUrlList
;
51 class ContextMenuExtension
;
54 * DistributedVersionControlPlugin is a base class for git/hg/bzr plugins. This class implements
55 * KDevelop::IBasicVersionControl, KDevelop::IDistributedVersionControl and KDevelop::IPlugin (contextMenuExtension).
56 * DistributedVersionControlPlugin class uses IDVCSexecutor to get all jobs
57 * from real DVCS plugins like Git. It is based on KDevelop's CVS plugin (also looks like svn plugin is it's relative too).
58 * @note Create only special items in contextMenuExtension, all standart menu items are created in vcscommon plugin!
60 class KDEVPLATFORMVCS_EXPORT DistributedVersionControlPlugin
: public IPlugin
, public IDistributedVersionControl
63 Q_INTERFACES(KDevelop::IBasicVersionControl
KDevelop::IDistributedVersionControl
)
66 DistributedVersionControlPlugin(QObject
*parent
, KComponentData compData
);
67 virtual ~DistributedVersionControlPlugin(){}
69 // Begin: KDevelop::IBasicVersionControl
70 virtual QString
name() const;
71 virtual bool isVersionControlled(const KUrl
& localLocation
);
72 virtual VcsJob
* repositoryLocation(const KUrl
& localLocation
);
73 virtual VcsJob
* add(const KUrl::List
& localLocations
,
74 IBasicVersionControl::RecursionMode recursion
);
75 virtual VcsJob
* remove(const KUrl::List
& localLocations
);
76 virtual VcsJob
* status(const KUrl::List
& localLocations
,
77 IBasicVersionControl::RecursionMode recursion
);
78 virtual VcsJob
* copy(const KUrl
& localLocationSrc
,
79 const KUrl
& localLocationDstn
); ///Not used in DVCS;
80 virtual VcsJob
* move(const KUrl
& localLocationSrc
,
81 const KUrl
& localLocationDst
); ///Not used in DVCS;
82 virtual VcsJob
* revert(const KUrl::List
& localLocations
,
83 IBasicVersionControl::RecursionMode recursion
);
84 virtual VcsJob
* update(const KUrl::List
& localLocations
,
85 const VcsRevision
& rev
,
86 IBasicVersionControl::RecursionMode recursion
);
87 virtual VcsJob
* commit(const QString
& message
,
88 const KUrl::List
& localLocations
,
89 IBasicVersionControl::RecursionMode recursion
);
90 virtual VcsJob
* diff(const VcsLocation
& localOrRepoLocationSrc
,
91 const VcsLocation
& localOrRepoLocationDst
,
92 const VcsRevision
& srcRevision
,
93 const VcsRevision
& dstRevision
,
95 IBasicVersionControl::RecursionMode
= IBasicVersionControl::Recursive
);
96 virtual VcsJob
* log(const KUrl
& localLocation
,
97 const VcsRevision
& rev
,
99 virtual VcsJob
* log(const KUrl
& localLocation
,
100 const VcsRevision
& rev
,
101 const VcsRevision
& limit
);
102 virtual VcsJob
* annotate(const KUrl
& localLocation
,
103 const VcsRevision
& rev
);
104 virtual VcsJob
* merge(const VcsLocation
& localOrRepoLocationSrc
,
105 const VcsLocation
& localOrRepoLocationDst
,
106 const VcsRevision
& srcRevision
,
107 const VcsRevision
& dstRevision
,
108 const KUrl
& localLocation
);
109 virtual VcsJob
* resolve(const KUrl::List
& localLocations
,
110 IBasicVersionControl::RecursionMode recursion
);
111 // End: KDevelop::IBasicVersionControl
113 // Begin: KDevelop::IDistributedVersionControl
114 virtual VcsJob
* init(const KUrl
& localRepositoryRoot
);
115 virtual VcsJob
* clone(const VcsLocation
& localOrRepoLocationSrc
,
116 const KUrl
& localRepositoryRoot
);
117 virtual VcsJob
* push(const KUrl
& localRepositoryLocation
,
118 const VcsLocation
& localOrRepoLocationDst
);
119 virtual VcsJob
* pull(const VcsLocation
& localOrRepoLocationSrc
,
120 const KUrl
& localRepositoryLocation
);
121 virtual VcsJob
* checkout(const QString
&localLocation
,
122 const QString
&repo
);
123 // End: KDevelop::IDistributedVersionControl
125 /** Returns pointer to IDVCSexecutor used in DistributedVersionControlPlugin */
126 IDVCSexecutor
* proxy();
128 /** Used in KDevelop's appwizardplugin (creates import widget) */
129 virtual VcsImportMetadataWidget
* createImportMetadataWidget(QWidget
* parent
);
131 // From KDevelop::IPlugin
132 /** Creates context menu
133 * @note Create only special items here (like checkout), all standart menu items are created in vcscommon plugin!
135 virtual ContextMenuExtension
contextMenuExtension(Context
*);
138 //slots for context menu
145 void ctxRevHistory();
151 * Updates project state after checkout (simply reloads it now)
153 void checkoutFinished(KJob
*);
157 * Some actions like commit, add, remove... will connect the job's
158 * result() signal to this signal. Anybody, like for instance the
159 * DVCSMainView class, that is interested in getting notified about
160 * jobs that finished can connect to this signal.
161 * @see class GitMainView
163 void jobFinished(KJob
* job
);
166 * Gets emmited when a job like log, editors... was created.
167 * GitPlugin will connect the newly created view to the result() signal
168 * of a job. So the new view will show the output of that job as
169 * soon as it has finished.
171 void addNewTabToMainView(QWidget
* tab
, QString label
);
174 const KUrl
urlFocusedDocument() const;
177 DistributedVersionControlPluginPrivate
* const d
;
182 class KDevDVCSViewFactory
: public KDevelop::IToolViewFactory
{
184 KDevDVCSViewFactory(KDevelop::DistributedVersionControlPlugin
*plugin
): m_plugin(plugin
) {}
185 virtual QWidget
* create(QWidget
*parent
= 0);
186 virtual Qt::DockWidgetArea
defaultPosition();
187 virtual QString
id() const;
189 KDevelop::DistributedVersionControlPlugin
*m_plugin
;