File: patchreview.h

package info (click to toggle)
kdevelop 4%3A25.04.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 73,508 kB
  • sloc: cpp: 291,803; python: 4,322; javascript: 3,518; sh: 1,316; ansic: 703; xml: 414; php: 95; lisp: 66; makefile: 31; sed: 12
file content (131 lines) | stat: -rw-r--r-- 3,568 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
    SPDX-FileCopyrightText: 2006 David Nolden <david.nolden.kdevelop@art-master.de>

    SPDX-License-Identifier: GPL-2.0-or-later
*/

#ifndef KDEVPLATFORM_PLUGIN_PATCHREVIEW_H
#define KDEVPLATFORM_PLUGIN_PATCHREVIEW_H

#include <QPointer>

#include <interfaces/iplugin.h>
#include <interfaces/ipatchsource.h>
#include <interfaces/ilanguagesupport.h>

class PatchHighlighter;
class PatchReviewToolViewFactory;

class QTimer;

namespace KDevelop {
class IDocument;
}
namespace Sublime {
class Area;
}

namespace KompareDiff2 {
class DiffModel;
class DiffSettings;
class Info;
class ModelList;
}

class PatchReviewPlugin;

class PatchReviewPlugin : public KDevelop::IPlugin, public KDevelop::IPatchReview, public KDevelop::ILanguageSupport
{
    Q_OBJECT
    Q_INTERFACES( KDevelop::IPatchReview )
    Q_INTERFACES( KDevelop::ILanguageSupport )

public :
    explicit PatchReviewPlugin(QObject* parent, const KPluginMetaData& metaData, const QVariantList& = QVariantList());
    ~PatchReviewPlugin() override;
    void unload() override;

    KDevelop::IPatchSource::Ptr patch() const {
        return m_patch;
    }

    KompareDiff2::ModelList* modelList() const
    {
        return m_modelList.data();
    }

    QString name() const override {
      return QStringLiteral("diff");
    }

    KDevelop::ParseJob *createParseJob(const KDevelop::IndexedString &) override {
      return nullptr;
    }

    void seekHunk( bool forwards, const QUrl& file = QUrl() );

    void setPatch( KDevelop::IPatchSource* patch );

    void startReview( KDevelop::IPatchSource* patch, ReviewMode mode ) override;

    void finishReview(const QList<QUrl>& selection);

    QUrl urlForFileModel(const KompareDiff2::DiffModel* model) const;
    QAction* finishReviewAction() const { return m_finishReview; }

    KDevelop::ContextMenuExtension contextMenuExtension(KDevelop::Context* context, QWidget* parent) override;

Q_SIGNALS:
    void startingNewReview();
    void patchChanged();

public Q_SLOTS :
    //Does parts of the review-starting that are problematic to do directly in startReview, as they may open dialogs etc.
    void updateReview();

    void cancelReview();
    void notifyPatchChanged();
    void highlightPatch();
    void updateKompareModel();
    void forceUpdate();
    void areaChanged(Sublime::Area* area);
    void executeFileReviewAction();

private Q_SLOTS :
    void documentClosed( KDevelop::IDocument* );
    void textDocumentCreated( KDevelop::IDocument* );
    void documentSaved( KDevelop::IDocument* );
    void closeReview();

private:
    void switchToEmptyReviewArea();

    /// Makes sure that this working set is active only in the @p area, and that its name starts with "review".
    void setUniqueEmptyWorkingSet(Sublime::Area* area);

    void addHighlighting( const QUrl& file, KDevelop::IDocument* document = nullptr );
    void removeHighlighting( const QUrl& file = QUrl() );

    KDevelop::IPatchSource::Ptr m_patch;

    QTimer* m_updateKompareTimer;

    PatchReviewToolViewFactory* m_factory;
    QAction* m_finishReview;

    #if 0
    void determineState();
    #endif

    QScopedPointer<KompareDiff2::DiffSettings> m_diffSettings;
    QScopedPointer<KompareDiff2::Info> m_kompareInfo;
    QScopedPointer<KompareDiff2::ModelList> m_modelList;
    uint m_depth = 0; // depth of the patch represented by m_modelList
    using HighlightMap = QMap<QUrl, QPointer<PatchHighlighter>>;
    HighlightMap m_highlighters;
    QString m_lastArea;

    friend class PatchReviewToolView; // to access slot exporterSelected();
};

#endif