File indexing completed on 2024-04-28 04:37:47

0001 /*
0002     SPDX-FileCopyrightText: 2008 Andreas Pakulat <apaku@gmx.de>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef KDEVPLATFORM_VCSPLUGINHELPER_H
0008 #define KDEVPLATFORM_VCSPLUGINHELPER_H
0009 
0010 #include "vcsexport.h"
0011 
0012 #include <QUrl>
0013 
0014 #include "vcsrevision.h"
0015 
0016 class KJob;
0017 class QMenu;
0018 
0019 namespace KTextEditor
0020 {
0021 class View;
0022 class Document;
0023 }
0024 
0025 // KTextEditor::AnnotationViewInterface has a bad signature in the
0026 // annotationBorderVisibilityChanged signal, using type "View" instead
0027 // of "KTextEditor::View".
0028 // To enable a string based signal-slot connection, as needed due to
0029 // annotationBorderVisibilityChanged being an "interface" signal,
0030 // with the slot VcsPluginHelper::removeAnnotationModel,
0031 // make View known here
0032 using KTextEditor::View;
0033 
0034 namespace KDevelop
0035 {
0036 class IPlugin;
0037 class IBasicVersionControl;
0038 class Context;
0039 class VcsPluginHelperPrivate;
0040 
0041 class KDEVPLATFORMVCS_EXPORT VcsPluginHelper
0042             : public QObject
0043 {
0044     Q_OBJECT
0045 public:
0046     VcsPluginHelper(IPlugin * parent, IBasicVersionControl * vcs);
0047     ~VcsPluginHelper() override;
0048 
0049     void setupFromContext(KDevelop::Context*);
0050     void addContextDocument(const QUrl& url);
0051     QList<QUrl> contextUrlList() const;
0052     /**
0053      * Creates and returns a menu with common actions.
0054      * Ownership of the actions in the menu stays with this VcsPluginHelper object.
0055      * @param parent the parent widget set for the QMenu for memory management
0056      */
0057     QMenu* commonActions(QWidget* parent);
0058 
0059 public Q_SLOTS:
0060     void commit();
0061     void add();
0062     void revert();
0063     void history(const VcsRevision& rev = VcsRevision::createSpecialRevision( VcsRevision::Base ));
0064     void annotation();
0065     void annotationContextMenuAboutToShow( KTextEditor::View* view, QMenu* menu, int line);
0066     void diffToBase();
0067     void diffForRev();
0068     void diffForRevGlobal();
0069     void update();
0070     void pull();
0071     void push();
0072     void diffJobFinished(KJob* job);
0073 
0074     void revertDone(KJob* job);
0075     void disposeEventually(KTextEditor::Document*);
0076     void disposeEventually(View*, bool);
0077 
0078 private Q_SLOTS:
0079     void delayedModificationWarningOn();
0080     // namespace-less type "View" needed here, see comment above on "using KTextEditor::View;"
0081     void handleAnnotationBorderVisibilityChanged(View* view, bool visible);
0082 
0083 private:
0084     void diffForRev(const QUrl& url);
0085 
0086 private:
0087     const QScopedPointer<class VcsPluginHelperPrivate> d_ptr;
0088     Q_DECLARE_PRIVATE(VcsPluginHelper)
0089 };
0090 
0091 } // namespace KDevelop
0092 
0093 #endif