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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
/***************************************************************************
kompare_part.h - description
-------------------
begin : Sun Mar 4 2001
copyright : (C) 2001-2004 Otto Bruggeman
(C) 2001-2003 John Firebaugh
(C) 2004 Jeff Snyder
email : otto.bruggeman@home.nl
jfirebaugh@kde.org
jeff@caffeinated.me.uk
****************************************************************************/
/***************************************************************************
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
***************************************************************************/
#ifndef KOMPAREPART_H
#define KOMPAREPART_H
#include <tdeparts/factory.h>
#include <tdeparts/part.h>
#include "kompare.h"
#include "kompareinterface.h"
class TQWidget;
class KTempFile;
class TDEToggleAction;
class KURL;
namespace Diff2 {
class Difference;
class DiffModel;
class DiffModelList;
class KompareModelList;
}
class DiffSettings;
class ViewSettings;
class KFileTreeView;
class KompareSplitter;
class KompareProcess;
/**
* This is a "Part". It does all the real work in a KPart
* application.
*
* @short Main Part
* @author John Firebaugh <jfirebaugh@kde.org>
* @author Otto Bruggeman <bruggie@home.nl>
* @version 0.3
*/
class KomparePart : public KParts::ReadWritePart,
public KompareInterface
{
Q_OBJECT
public:
/**
* Default constructor
*/
KomparePart( TQWidget *parentWidget, const char *widgetName,
TQObject *parent, const char *name, const TQStringList & /*args*/);
/**
* Destructor
*/
virtual ~KomparePart();
// Sessionmanagement stuff, added to the kompare iface
// because they are not in the Part class where they belong
// Should be added when bic changes are allowed again (kde 4.0)
virtual int readProperties( TDEConfig *config );
virtual int saveProperties( TDEConfig *config );
// this one is called when the shell_app is about to close.
// we need it now to save the properties of the part when apps dont (can't)
// use the readProperties and saveProperties methods
virtual bool queryClose();
// bool isModified() const { return m_modelList->isModified(); }
// Do we really want to expose this ???
const Diff2::KompareModelList* model() const { return m_modelList; };
static TDEAboutData *createAboutData();
public:
// Reimplemented from the KompareInterface
/**
* Open and parse the diff file at diffUrl.
*/
virtual bool openDiff( const KURL& diffUrl );
/** Added on request of Harald Fernengel */
virtual bool openDiff( const TQString& diffOutput );
/** Open and parse the diff3 file at diff3Url */
virtual bool openDiff3( const KURL& diff3URL );
/** Open and parse the file diff3Output with the output of diff3 */
virtual bool openDiff3( const TQString& diff3Output );
/** Compare, with diff, source with destination */
virtual void compare( const KURL& sourceFile, const KURL& destinationFile );
/** Compare, with diff, source with destination */
virtual void compareFiles( const KURL& sourceFile, const KURL& destinationFile );
/** Compare, with diff, source with destination */
virtual void compareDirs ( const KURL& sourceDir, const KURL& destinationDir );
/** Compare, with diff3, originalFile with changedFile1 and changedFile2 */
virtual void compare3Files( const KURL& originalFile, const KURL& changedFile1, const KURL& changedFile2 );
/** This will show the file and the file with the diff applied */
virtual void openFileAndDiff( const KURL& file, const KURL& diffFile );
/** This will show the directory and the directory with the diff applied */
virtual void openDirAndDiff ( const KURL& dir, const KURL& diffFile );
/** Reimplementing this because this one knows more about the real part then the interface */
virtual void setEncoding( const TQString& encoding );
// This is the interpart interface, it is signal and slot based so no "real" interface here
// All you have to do is connect the parts from your application.
// These just point to their counterpart in the KompareModelList or get called from their
// counterpart in KompareModelList.
signals:
void modelsChanged( const Diff2::DiffModelList* models );
void setSelection( const Diff2::DiffModel* model, const Diff2::Difference* diff );
void setSelection( const Diff2::Difference* diff );
void selectionChanged( const Diff2::DiffModel* model, const Diff2::Difference* diff );
void selectionChanged( const Diff2::Difference* diff );
void applyDifference( bool apply );
void applyAllDifferences( bool apply );
void applyDifference( const Diff2::Difference*, bool apply );
void configChanged();
/*
** This is emitted when a difference is clicked in the kompare view. You can connect to
** it so you can use it to jump to this particular line in the editor in your app.
*/
void differenceClicked( int lineNumber );
// Stuff that can probably be removed by putting it in the part where it belongs in my opinion
public slots:
/** Save all destinations. */
bool saveAll();
/** Save the results of a comparison as a diff file. */
void saveDiff();
/** This slot is connected to the setModifed( bool ) signal from the KompareModelList */
void slotSetModified( bool modified );
signals:
void appliedChanged();
void diffURLChanged();
void kompareInfo( Kompare::Info* info );
void setStatusBarModelInfo( int modelIndex, int differenceIndex, int modelCount, int differenceCount, int appliedCount );
// void setStatusBarText( const TQString& text );
protected:
/**
* This is the method that gets called when the file is opened,
* when using openURL( const KURL& ) or in our case also openDiff( const KURL& );
* return true when everything went ok, false if there were problems
*/
virtual bool openFile();
virtual bool saveFile() { return true; };
// patchFile
bool patchFile(KURL&);
bool patchDir();
protected slots:
void slotSetStatus( Kompare::Status status );
void slotShowError( TQString error );
void slotSwap();
void slotShowDiffstats();
void optionsPreferences();
void updateActions();
void updateCaption();
void updateStatus();
private:
void cleanUpTemporaryFiles();
void setupActions();
bool exists( const TQString& url );
bool isDirectory( const KURL& url );
const TQString fetchURL( const KURL& url );
private:
// Uhm why were these static again ???
// Ah yes, so multiple instances of kompare use the
// same settings after one of them changes them
static ViewSettings* m_viewSettings;
static DiffSettings* m_diffSettings;
Diff2::KompareModelList* m_modelList;
KompareSplitter* m_splitter;
TDEAction* m_saveAll;
TDEAction* m_saveDiff;
TDEAction* m_swap;
TDEAction* m_diffStats;
KTempFile* m_tempDiff;
struct Kompare::Info m_info;
};
#endif // KOMPAREPART_H
|