KompareDiff2

modellist.h
1/*
2 SPDX-FileCopyrightText: 2001-2003 John Firebaugh <jfirebaugh@kde.org>
3 SPDX-FileCopyrightText: 2001-2005,2009 Otto Bruggeman <bruggie@gmail.com>
4 SPDX-FileCopyrightText: 2007-2008 Kevin Kofler <kevin.kofler@chello.at>
5 SPDX-FileCopyrightText: 2012 Jean -Nicolas Artaud <jeannicolasartaud@gmail.com>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9
10#ifndef KOMPAREDIFF2_MODELLIST_H
11#define KOMPAREDIFF2_MODELLIST_H
12
13// lib
14#include "diffmodel.h"
15#include "diffmodellist.h"
16#include "info.h"
17#include "komparediff2_export.h"
18// Qt
19#include <QObject>
20// Std
21#include <memory>
22
24
25namespace KompareDiff2
26{
27class DiffSettings;
28class ModelListPrivate;
29
30/**
31 * @class ModelList modellist.h <KompareDiff2/ModelList>
32 *
33 * ModelList
34 */
35class KOMPAREDIFF2_EXPORT ModelList : public QObject
36{
37 Q_OBJECT
38public:
39 ModelList(DiffSettings *diffSettings, QObject *parent, bool supportReadWrite = true);
40 ~ModelList() override;
41
42public:
43 void refresh();
44 // Swap source with destination and show differences
45 void swap();
46
47 /* Comparing methods */
48 bool compare();
49
50 bool compare(Mode);
51
52 bool openDiff(const QString &diff);
53
54 bool openFileAndDiff();
55 bool openDirAndDiff();
56
57 bool saveDiff(const QString &url, const QString &directory, DiffSettings *diffSettings);
58 bool saveAll();
59
60 bool saveDestination(DiffModel *model);
61
62 void setEncoding(const QString &encoding);
63
64 void setReadWrite(bool isReadWrite);
65 bool isReadWrite() const;
66
67 QString recreateDiff() const;
68
69 // This parses the difflines and creates new models
70 int parseDiffOutput(const QString &diff);
71
72 // This open the difflines after parsing them
73 bool parseAndOpenDiff(const QString &diff);
74
75 // Call this to emit the signals to the rest of the "world" to show the diff
76 void show();
77
78 // This will blend the original URL (dir or file) into the diffmodel,
79 // this is like patching but with a twist
80 bool blendOriginalIntoModelList(const QString &localURL);
81
82 // This mode() method is superfluous now so FIXME
83 Mode mode() const;
84 const DiffModelList *models() const;
85
86 KActionCollection *actionCollection() const;
87 int modelCount() const;
88 int differenceCount() const;
89 int appliedCount() const;
90
91 const DiffModel *modelAt(int i) const;
92 DiffModel *modelAt(int i);
93 int findModel(DiffModel *model) const;
94
95 bool hasUnsavedChanges() const;
96
97 int currentModel() const;
98 int currentDifference() const;
99
100 const DiffModel *selectedModel() const;
101 const Difference *selectedDifference() const;
102
103 void clear();
104
105Q_SIGNALS:
107 void setStatusBarModelInfo(int modelIndex, int differenceIndex, int modelCount, int differenceCount, int appliedCount);
108 void error(const QString &error);
109 void modelsChanged(const KompareDiff2::DiffModelList *models);
110 void setSelection(const KompareDiff2::DiffModel *model, const KompareDiff2::Difference *diff);
111 void setSelection(const KompareDiff2::Difference *diff);
112 void applyDifference(bool apply);
113 void applyAllDifferences(bool apply);
114 void applyDifference(const KompareDiff2::Difference *diff, bool apply);
115 void diffString(const QString &);
116 void updateActions();
117
118public Q_SLOTS:
119 void slotSelectionChanged(const KompareDiff2::DiffModel *model, const KompareDiff2::Difference *diff);
120 void slotSelectionChanged(const KompareDiff2::Difference *diff);
121
122 void slotApplyDifference(bool apply);
123 void slotApplyAllDifferences(bool apply);
124 void slotPreviousModel();
125 void slotNextModel();
126 void slotPreviousDifference();
127 void slotNextDifference();
128
129 void slotKompareInfo(KompareDiff2::Info *);
130
131protected Q_SLOTS:
132 void slotDiffProcessFinished(bool success);
133 void slotWriteDiffOutput(bool success);
134
135 void slotActionApplyDifference();
136 void slotActionUnApplyDifference();
137 void slotActionApplyAllDifferences();
138 void slotActionUnapplyAllDifferences();
139
140 /** Save the currently selected destination in a multi-file diff,
141 or the single destination if a single file diff. */
142 void slotSaveDestination();
143
144private:
145 Q_DECLARE_PRIVATE(ModelList)
146 std::unique_ptr<ModelListPrivate> const d_ptr;
147};
148
149} // End of namespace KompareDiff2
150
151#endif
A list of DiffModel.
A model describing the differences between two files.
Definition diffmodel.h:31
The settings for a diff.
Q_SCRIPTABLE CaptureState status()
KompareDiff2 namespace.
Status
State.
Definition global.h:69
Mode
Mode.
Definition global.h:46
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Aug 30 2024 11:51:22 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.