File indexing completed on 2024-05-05 04:40:11
0001 /* 0002 SPDX-FileCopyrightText: 2006 David Nolden <david.nolden.kdevelop@art-master.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KDEVPLATFORM_PLUGIN_PATCHHIGHLIGHTER_H 0008 #define KDEVPLATFORM_PLUGIN_PATCHHIGHLIGHTER_H 0009 0010 #include <KTextEditor/MovingRangeFeedback> 0011 0012 #include <QMap> 0013 #include <QObject> 0014 #include <QPair> 0015 #include <QPoint> 0016 #include <QSet> 0017 0018 namespace Diff2 { 0019 class Difference; 0020 class DiffModel; 0021 } 0022 0023 class PatchReviewPlugin; 0024 0025 namespace KDevelop 0026 { 0027 class IDocument; 0028 } 0029 0030 namespace KTextEditor 0031 { 0032 class Document; 0033 class Range; 0034 class Cursor; 0035 class Mark; 0036 class MovingRange; 0037 } 0038 0039 ///Delete itself when the document(or textDocument), or Diff-Model is deleted. 0040 class PatchHighlighter : public QObject 0041 { 0042 Q_OBJECT 0043 public: 0044 PatchHighlighter( Diff2::DiffModel* model, KDevelop::IDocument* doc, PatchReviewPlugin* plugin, bool updatePatchFromEdits ); 0045 ~PatchHighlighter() override; 0046 KDevelop::IDocument* doc(); 0047 QList< KTextEditor::MovingRange* > ranges() const; 0048 private Q_SLOTS: 0049 void documentReloaded( KTextEditor::Document* ); 0050 void documentDestroyed(); 0051 void aboutToDeleteMovingInterfaceContent( KTextEditor::Document* ); 0052 private: 0053 void addLineMarker( KTextEditor::MovingRange* arg1, Diff2::Difference* arg2 ); 0054 void removeLineMarker( KTextEditor::MovingRange* range ); 0055 void performContentChange( KTextEditor::Document* doc, const QStringList& oldLines, const QStringList& newLines, int editLineNumber ); 0056 0057 QPair<KTextEditor::MovingRange*, Diff2::Difference*> rangeForMark(const KTextEditor::Mark &mark); 0058 0059 void clear(); 0060 QMap< KTextEditor::MovingRange*, Diff2::Difference* > m_ranges; 0061 KDevelop::IDocument* m_doc; 0062 PatchReviewPlugin* m_plugin; 0063 Diff2::DiffModel* m_model; 0064 bool m_applying; 0065 static const unsigned int m_allmarks; 0066 public Q_SLOTS: 0067 void markToolTipRequested( KTextEditor::Document*, const KTextEditor::Mark&, QPoint, bool & ); 0068 void showToolTipForMark(const QPoint& arg1, KTextEditor::MovingRange* arg2); 0069 bool isRemoval( Diff2::Difference* ); 0070 bool isInsertion( Diff2::Difference* ); 0071 void markClicked( KTextEditor::Document*, const KTextEditor::Mark&, bool& ); 0072 void textInserted(KTextEditor::Document* doc, const KTextEditor::Cursor& cursor, const QString& text); 0073 void newlineInserted(KTextEditor::Document* doc, const KTextEditor::Cursor& cursor); 0074 void textRemoved( KTextEditor::Document*, const KTextEditor::Range&, const QString& oldText ); 0075 void newlineRemoved(KTextEditor::Document*, int line); 0076 }; 0077 0078 #endif