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
|
/***************************************************************************
komparemodellist.h - description
-------------------
begin : Tue Jun 26 2001
copyright : (C) 2001-2003 by John Firebaugh
and Otto Bruggeman
email : jfirebaugh@kde.org
otto.bruggeman@home.nl
***************************************************************************/
/***************************************************************************
* *
* 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 KOMPAREMODELLIST_H
#define KOMPAREMODELLIST_H
#include <tqobject.h>
#include "diffmodel.h"
#include "diffmodellist.h"
#include "kompare.h"
class TQFile;
class KAction;
class KDirWatch;
class KTempFile;
class DiffSettings;
class KompareProcess;
namespace Diff2
{
class KompareModelList : public TQObject
{
Q_OBJECT
TQ_OBJECT
public:
KompareModelList( DiffSettings* diffSettings, struct Kompare::Info& info, TQObject* tqparent = 0, const char* name = 0 );
~KompareModelList();
public:
// Swap source with destination and show differences
void swap();
/* Comparing methods */
bool compare( const TQString& source, const TQString& destination );
bool compareFiles( const TQString& source, const TQString& destination );
bool compareDirs( const TQString& source, const TQString& destination );
bool openDiff( const TQString& diff );
bool openFileAndDiff( const TQString& file, const TQString& diff );
bool openDirAndDiff( const TQString& dir, const TQString& diff );
bool saveDiff( const TQString& url, TQString directory, DiffSettings* diffSettings );
bool saveAll();
bool saveDestination( DiffModel* model );
void setEncoding( const TQString& encoding );
TQString recreateDiff() const;
// This parses the difflines and creates new models
int parseDiffOutput( const TQString& diff );
// Call this to emit the signals to the rest of the "world" to show the diff
void show();
// This will blend the original URL (dir or file) into the diffmodel,
// this is like patching but with a twist
bool blendOriginalIntoModelList( const TQString& localURL );
enum Kompare::Mode mode() const { return m_info.mode; };
const DiffModelList* models() const { return m_models; };
int modelCount() const;
int differenceCount() const;
int appliedCount() const;
const DiffModel* modelAt( int i ) const { return *( m_models->at( i ) ); };
int findModel( DiffModel* model ) const { return m_models->findIndex( model ); };
bool isModified() const;
int currentModel() const { return m_models->findIndex( m_selectedModel ); };
int currentDifference() const { return m_selectedModel ? m_selectedModel->findDifference( m_selectedDifference ) : -1; };
const DiffModel* selectedModel() const { return m_selectedModel; };
const Difference* selectedDifference() const { return m_selectedDifference; };
void clear();
private:
Diff2::DiffModel* firstModel();
Diff2::DiffModel* lastModel();
Diff2::DiffModel* prevModel();
Diff2::DiffModel* nextModel();
bool setSelectedModel( Diff2::DiffModel* model );
void updateModelListActions();
protected:
bool blendFile( DiffModel* model, const TQString& lines );
signals:
void status( Kompare::tqStatus status );
void setStatusBarModelInfo( int modelIndex, int differenceIndex, int modelCount, int differenceCount, int appliedCount );
void error( TQString error );
void modelsChanged( const Diff2::DiffModelList* models );
void setSelection( const Diff2::DiffModel* model, const Diff2::Difference* diff );
void setSelection( const Diff2::Difference* diff );
void applyDifference( bool apply );
void applyAllDifferences( bool apply );
void applyDifference( const Diff2::Difference* diff, bool apply );
// Emits true when m_noOfModified > 0, false when m_noOfModified == 0
void setModified( bool modified );
public slots:
void slotSelectionChanged( const Diff2::DiffModel* model, const Diff2::Difference* diff );
void slotSelectionChanged( const Diff2::Difference* diff );
void slotApplyDifference( bool apply );
void slotApplyAllDifferences( bool apply );
void slotPreviousModel();
void slotNextModel();
void slotPreviousDifference();
void slotNextDifference();
// This slot is called by the diffmodels whenever their status changes to modified or unmodified
void slotSetModified( bool modified );
protected slots:
void slotDiffProcessFinished( bool success );
void slotWriteDiffOutput( bool success );
void slotActionApplyDifference();
void slotActionUnApplyDifference();
void slotActionApplyAllDifferences();
void slotActionUnapplyAllDifferences();
/** Save the currently selected destination in a multi-file diff,
or the single destination if a single file diff. */
void slotSaveDestination();
private slots:
void slotDirectoryChanged( const TQString& );
void slotFileChanged( const TQString& );
private: // Helper methods
bool isDirectory( const TQString& url ) const;
bool isDiff( const TQString& mimetype ) const;
TQString readFile( const TQString& fileName );
bool hasPrevModel() const;
bool hasNextModel() const;
bool hasPrevDiff() const;
bool hasNextDiff() const;
TQStringList split( const TQString& diff );
private:
KTempFile* m_diffTemp;
TQString m_diffURL;
KompareProcess* m_diffProcess;
DiffSettings* m_diffSettings;
DiffModelList* m_models;
TQString m_source;
TQString m_destination;
DiffModel* m_selectedModel;
Difference* m_selectedDifference;
KDirWatch* m_dirWatch;
KDirWatch* m_fileWatch;
int m_noOfModified;
unsigned int m_modelIndex;
struct Kompare::Info& m_info;
KAction* m_applyDifference;
KAction* m_unApplyDifference;
KAction* m_applyAll;
KAction* m_unapplyAll;
KAction* m_previousFile;
KAction* m_nextFile;
KAction* m_previousDifference;
KAction* m_nextDifference;
KAction* m_save;
TQString m_encoding;
TQTextCodec* m_textCodec;
};
} // End of namespace Diff2
#endif
|