KompareDiff2

diffmodel.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_DIFFMODEL_H
9#define KOMPAREDIFF2_DIFFMODEL_H
10
11// lib
12#include "diffhunk.h"
13#include "global.h"
14#include "komparediff2_export.h"
15// Qt
16#include <QObject>
17#include <QStringList>
18// Std
19#include <memory>
20
21namespace KompareDiff2
22{
23class DiffModelPrivate;
24
25/**
26 * @class DiffModel diffmodel.h <KompareDiff2/DiffModel>
27 *
28 * A model describing the differences between two files.
29 */
30class KOMPAREDIFF2_EXPORT DiffModel : public QObject
31{
32 Q_OBJECT
33
34public:
35 DiffModel(const QString &srcBaseURL, const QString &destBaseURL);
36 DiffModel();
37 ~DiffModel() override;
38
39public:
40 DiffModel &operator=(const DiffModel &model);
41 bool operator<(const DiffModel &model) const;
42
43 int parseDiff(Format format, const QStringList &list);
44
45 QString recreateDiff() const;
46
47 int hunkCount() const;
48 int differenceCount() const;
49 int appliedCount() const;
50
51 DiffHunk *hunkAt(int i);
52 const Difference *differenceAt(int i) const;
53 Difference *differenceAt(int i);
54
55 DiffHunkList *hunks();
56 const DiffHunkList *hunks() const;
57 DifferenceList *differences();
58 const DifferenceList *differences() const;
59
60 int findDifference(Difference *diff) const;
61
62 Difference *firstDifference();
63 Difference *lastDifference();
64 Difference *prevDifference();
65 Difference *nextDifference();
66
67 QString source() const;
68 QString destination() const;
69 QString sourceFile() const;
70 QString destinationFile() const;
71 QString sourcePath() const;
72 QString destinationPath() const;
73 QString sourceTimestamp() const;
74 QString destinationTimestamp() const;
75 QString sourceRevision() const;
76 QString destinationRevision() const;
77
78 void setSourceFile(const QString &path);
79 void setDestinationFile(const QString &path);
80 void setSourceTimestamp(const QString &timestamp);
81 void setDestinationTimestamp(const QString &timestamp);
82 void setSourceRevision(const QString &revision);
83 void setDestinationRevision(const QString &revision);
84
85 void addHunk(DiffHunk *hunk);
86 void addDiff(Difference *diff);
87 bool hasUnsavedChanges() const;
88
89 int diffIndex() const;
90 void setDiffIndex(int diffIndex);
91
92 void applyDifference(bool apply);
93 void applyAllDifferences(bool apply);
94
95 bool setSelectedDifference(Difference *diff);
96
97 int localeAwareCompareSource(const DiffModel &model) const;
98
99 bool isBlended() const;
100 void setBlended(bool blended);
101
102 /**
103 * @p oldlines - lines that were removed.
104 * @p newLines - lines that were inserted.
105 * @p startPos - number of line at which the change occurred
106 */
107 QPair<QList<Difference *>, QList<Difference *>> linesChanged(const QStringList &oldLines, const QStringList &newLines, int editLineNumber);
108
109private Q_SLOTS:
110 void slotDifferenceApplied(Difference *diff);
111
112private:
113 Q_DECLARE_PRIVATE(DiffModel)
114 std::unique_ptr<DiffModelPrivate> const d_ptr;
115};
116
117} // End of namespace KompareDiff2
118
119#endif
A model describing the differences between two files.
Definition diffmodel.h:31
KompareDiff2 namespace.
Format
Patch format enum.
Definition global.h:16
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:50:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.