KompareDiff2

difference.h
1/*
2 SPDX-FileCopyrightText: 2001-2004,2009 Otto Bruggeman <bruggie@gmail.com>
3 SPDX-FileCopyrightText: 2001-2003 John Firebaugh <jfirebaugh@kde.org>
4
5 SPDX-License-Identifier: GPL-2.0-or-later
6*/
7
8#ifndef KOMPAREDIFF2_DIFFERENCE_H
9#define KOMPAREDIFF2_DIFFERENCE_H
10
11// lib
12#include "differencestring.h"
13#include "komparediff2_export.h"
14// Qt
15#include <QObject>
16// Std
17#include <memory>
18
19namespace KompareDiff2
20{
21class DifferencePrivate;
22
23/**
24 * @class Difference difference.h <KompareDiff2/Difference>
25 *
26 * A difference.
27 */
28class KOMPAREDIFF2_EXPORT Difference : public QObject
29{
30 Q_OBJECT
31public:
32 enum Type {
33 Change,
34 Insert,
35 Delete,
36 Unchanged,
37 };
38
39public:
40 Difference(int sourceLineNo, int destinationLineNo, int type = Difference::Unchanged);
41 ~Difference() override;
42
43public:
44 int type() const;
45
46 int sourceLineNumber() const;
47 int destinationLineNumber() const;
48
49 int sourceLineCount() const;
50 int destinationLineCount() const;
51
52 int sourceLineEnd() const;
53 int destinationLineEnd() const;
54
55 /// Destination line number that tracks applying/unapplying of other differences
56 /// Essentially a line number in a patch consisting of applied diffs only
57 int trackingDestinationLineNumber() const;
58 int trackingDestinationLineEnd() const;
59 void setTrackingDestinationLineNumber(int i);
60
61 DifferenceString *sourceLineAt(int i) const;
62 DifferenceString *destinationLineAt(int i) const;
63
64 DifferenceStringList sourceLines() const;
65 DifferenceStringList destinationLines() const;
66
67 bool hasConflict() const;
68 void setConflict(bool conflicts);
69
70 bool isUnsaved() const;
71 void setUnsaved(bool unsaved);
72
73 void apply(bool apply);
74 /// Apply without emitting any signals
75 void applyQuietly(bool apply);
76 bool applied() const;
77
78 void setType(int type);
79
80 void addSourceLine(const QString &line);
81 void addDestinationLine(const QString &line);
82
83 /** This method will calculate the differences between the individual strings and store them as Markers */
84 void determineInlineDifferences();
85
86 QString recreateDifference() const;
87
88Q_SIGNALS:
89 void differenceApplied(KompareDiff2::Difference *);
90
91private:
92 Q_DECLARE_PRIVATE(Difference)
93 std::unique_ptr<DifferencePrivate> const d_ptr;
94};
95
99
100} // End of namespace KompareDiff2
101
102#endif
KompareDiff2 namespace.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:54:52 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.