File indexing completed on 2024-05-12 04:38:53

0001 /*
0002     SPDX-FileCopyrightText: 2008 Evgeniy Ivanov <powerfox@kde.ru>
0003 
0004     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006 
0007 #ifndef KDEVPLATFORM_DVCS_PLUGIN_H
0008 #define KDEVPLATFORM_DVCS_PLUGIN_H
0009 
0010 #include <QObject>
0011 #include <QUrl>
0012 
0013 #include <interfaces/iplugin.h>
0014 
0015 #include "dvcsevent.h"
0016 #include <vcs/vcsexport.h>
0017 #include <vcs/interfaces/idistributedversioncontrol.h>
0018 #include <vcs/interfaces/ibranchingversioncontrol.h>
0019 
0020 class QMenu;
0021 
0022 namespace KDevelop
0023 {
0024 class DVcsJob;
0025 class DistributedVersionControlPluginPrivate;
0026 
0027 /**
0028  * DistributedVersionControlPlugin is a base class for git/hg/bzr plugins. This class implements
0029  * KDevelop::IBasicVersionControl, KDevelop::IDistributedVersionControl and KDevelop::IPlugin (contextMenuExtension).
0030  * DistributedVersionControlPlugin class uses IDVCSexecutor to get all jobs
0031  * from real DVCS plugins like Git. It is based on KDevelop's CVS plugin (also looks like svn plugin is it's relative too).
0032  * @note Create only special items in contextMenuExtension, all standard menu items are created in vcscommon plugin!
0033  */
0034 class KDEVPLATFORMVCS_EXPORT DistributedVersionControlPlugin : public IPlugin, public IDistributedVersionControl, public IBranchingVersionControl
0035 {
0036     Q_OBJECT
0037     Q_INTERFACES(KDevelop::IBasicVersionControl KDevelop::IDistributedVersionControl KDevelop::IBranchingVersionControl)
0038 public:
0039 
0040     DistributedVersionControlPlugin(QObject *parent, const QString& componentName);
0041     ~DistributedVersionControlPlugin() override;
0042 
0043     // Begin: KDevelop::IBasicVersionControl
0044 
0045     /** Used in KDevelop's appwizardplugin (creates import widget) */
0046     VcsImportMetadataWidget* createImportMetadataWidget(QWidget* parent) override;
0047 
0048     // From KDevelop::IPlugin
0049     /** Creates context menu
0050      * @note Create only special items here (like checkout), all standard menu items are created in vcscommon plugin!
0051      */
0052     ContextMenuExtension contextMenuExtension(Context* context, QWidget* parent) override;
0053 
0054     /**
0055       * Parses the output generated by a <tt>dvcs log</tt> command and
0056       * fills the given QList with all commits infos found in the given output.
0057       * @param job The finished job of a <tt>dvcs log</tt> call
0058       * @param revisions Will be filled with all revision infos found in @p jobOutput
0059       * TODO: Change it to pass the results in @c job->getResults()
0060       */
0061     virtual void parseLogOutput(const DVcsJob * job,
0062                                 QVector<KDevelop::DVcsEvent>& revisions) const = 0;
0063     
0064     /** Returns the list of all commits (in all branches).
0065      * @see CommitView and CommitViewDelegate to see how this list is used.
0066      */
0067     virtual QVector<KDevelop::DVcsEvent> allCommits(const QString& repo) = 0;
0068 
0069     /**
0070      * When a plugin wants to add elements to the vcs menu, this method can be
0071      * overridden.
0072      */
0073     virtual void additionalMenuEntries(QMenu* menu, const QList<QUrl>& urls);
0074 public Q_SLOTS:
0075     //slots for context menu
0076     void ctxBranchManager();
0077 
0078 protected:
0079     /** Checks if dirPath is located in DVCS repository */
0080     virtual bool isValidDirectory(const QUrl &dirPath) = 0;
0081 
0082 private:
0083     const QScopedPointer<class DistributedVersionControlPluginPrivate> d_ptr;
0084     Q_DECLARE_PRIVATE(DistributedVersionControlPlugin)
0085 };
0086 
0087 }
0088 
0089 #endif