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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
|
/***************************************************************************
diffprefs.cpp - description
-------------------
begin : Sun Mar 4 2001
copyright : (C) 2001-2004 Otto Bruggeman
email : 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.
**
***************************************************************************/
#include <tqcheckbox.h>
#include <tqhgroupbox.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqradiobutton.h>
#include <tqspinbox.h>
#include <tqtooltip.h>
#include <tqvbuttongroup.h>
#include <tqwhatsthis.h>
#include <kapplication.h>
#include <kcombobox.h>
#include <kdialog.h>
#include <keditlistbox.h>
#include <klineedit.h>
#include <klocale.h>
#include <ktrader.h>
#include <kurlcombobox.h>
#include <kurlrequester.h>
#include <kparts/componentfactory.h>
#include <kregexpeditorinterface.h>
#include "diffsettings.h"
#include "diffpage.h"
DiffPage::DiffPage( TQWidget* parent ) : PageBase( parent ),
m_ignoreRegExpDialog( 0 )
{
addDiffTab();
addFormatTab();
addOptionsTab();
addExcludeTab();
}
DiffPage::~DiffPage()
{
m_settings = 0;
}
void DiffPage::setSettings( DiffSettings* setts )
{
m_settings = setts;
m_diffURLRequester->setURL( m_settings->m_diffProgram );
m_smallerCheckBox->setChecked ( m_settings->m_createSmallerDiff );
m_largerCheckBox->setChecked ( m_settings->m_largeFiles );
m_tabsCheckBox->setChecked ( m_settings->m_convertTabsToSpaces );
m_caseCheckBox->setChecked ( m_settings->m_ignoreChangesInCase );
m_linesCheckBox->setChecked ( m_settings->m_ignoreEmptyLines );
m_whitespaceCheckBox->setChecked ( m_settings->m_ignoreWhiteSpace );
m_allWhitespaceCheckBox->setChecked ( m_settings->m_ignoreAllWhiteSpace );
m_ignoreTabExpansionCheckBox->setChecked( m_settings->m_ignoreChangesDueToTabExpansion );
m_ignoreRegExpCheckBox->setChecked ( m_settings->m_ignoreRegExp );
m_ignoreRegExpEdit->setCompletedItems( m_settings->m_ignoreRegExpTextHistory );
m_ignoreRegExpEdit->setText ( m_settings->m_ignoreRegExpText );
m_locSpinBox->setValue( m_settings->m_linesOfContext );
m_modeButtonGroup->setButton( m_settings->m_format );
m_excludeFilePatternCheckBox->setChecked ( m_settings->m_excludeFilePattern );
slotExcludeFilePatternToggled ( m_settings->m_excludeFilePattern );
m_excludeFilePatternEditListBox->insertStringList( m_settings->m_excludeFilePatternList );
m_excludeFileCheckBox->setChecked( m_settings->m_excludeFilesFile );
slotExcludeFileToggled ( m_settings->m_excludeFilesFile );
m_excludeFileURLComboBox->setURLs( m_settings->m_excludeFilesFileHistoryList );
m_excludeFileURLComboBox->setURL ( KURL( m_settings->m_excludeFilesFileURL ) );
}
DiffSettings* DiffPage::settings( void )
{
return m_settings;
}
void DiffPage::restore()
{
// this shouldn't do a thing...
}
void DiffPage::apply()
{
m_settings->m_diffProgram = m_diffURLRequester->url();
m_settings->m_largeFiles = m_largerCheckBox->isChecked();
m_settings->m_createSmallerDiff = m_smallerCheckBox->isChecked();
m_settings->m_convertTabsToSpaces = m_tabsCheckBox->isChecked();
m_settings->m_ignoreChangesInCase = m_caseCheckBox->isChecked();
m_settings->m_ignoreEmptyLines = m_linesCheckBox->isChecked();
m_settings->m_ignoreWhiteSpace = m_whitespaceCheckBox->isChecked();
m_settings->m_ignoreAllWhiteSpace = m_allWhitespaceCheckBox->isChecked();
m_settings->m_ignoreChangesDueToTabExpansion = m_ignoreTabExpansionCheckBox->isChecked();
m_settings->m_ignoreRegExp = m_ignoreRegExpCheckBox->isChecked();
m_settings->m_ignoreRegExpText = m_ignoreRegExpEdit->text();
m_settings->m_ignoreRegExpTextHistory = m_ignoreRegExpEdit->completionObject()->items();
m_settings->m_linesOfContext = m_locSpinBox->value();
m_settings->m_format = static_cast<Kompare::Format>( m_modeButtonGroup->selectedId() );
m_settings->m_excludeFilePattern = m_excludeFilePatternCheckBox->isChecked();
m_settings->m_excludeFilePatternList = m_excludeFilePatternEditListBox->items();
m_settings->m_excludeFilesFile = m_excludeFileCheckBox->isChecked();
m_settings->m_excludeFilesFileURL = m_excludeFileURLComboBox->currentText();
m_settings->m_excludeFilesFileHistoryList = m_excludeFileURLComboBox->urls();
m_settings->saveSettings( kapp->config() );
}
void DiffPage::setDefaults()
{
m_diffURLRequester->setURL( "diff" );
m_smallerCheckBox->setChecked( true );
m_largerCheckBox->setChecked( true );
m_tabsCheckBox->setChecked( false );
m_caseCheckBox->setChecked( false );
m_linesCheckBox->setChecked( false );
m_whitespaceCheckBox->setChecked( false );
m_allWhitespaceCheckBox->setChecked( false );
m_ignoreTabExpansionCheckBox->setChecked( false );
m_ignoreRegExpCheckBox->setChecked( false );
m_ignoreRegExpEdit->setText( TQString() );
m_locSpinBox->setValue( 3 );
m_modeButtonGroup->setButton( Kompare::Unified );
m_excludeFilePatternCheckBox->setChecked( false );
m_excludeFileCheckBox->setChecked( false );
}
void DiffPage::slotShowRegExpEditor()
{
if ( ! m_ignoreRegExpDialog )
m_ignoreRegExpDialog = KParts::ComponentFactory::createInstanceFromQuery<TQDialog>( "KRegExpEditor/KRegExpEditor", TQString(), TQT_TQOBJECT(this) );
KRegExpEditorInterface *iface = static_cast<KRegExpEditorInterface *>( m_ignoreRegExpDialog->tqt_cast( "KRegExpEditorInterface" ) );
if ( !iface )
return;
iface->setRegExp( m_ignoreRegExpEdit->text() );
bool ok = m_ignoreRegExpDialog->exec();
if ( ok )
m_ignoreRegExpEdit->setText( iface->regExp() );
}
void DiffPage::slotExcludeFilePatternToggled( bool on )
{
if ( !on )
{
m_excludeFilePatternEditListBox->setEnabled( false );
}
else
{
m_excludeFilePatternEditListBox->setEnabled( true );
}
}
void DiffPage::slotExcludeFileToggled( bool on )
{
if ( !on )
{
m_excludeFileURLComboBox->setEnabled( false );
m_excludeFileURLRequester->setEnabled( false );
}
else
{
m_excludeFileURLComboBox->setEnabled( true );
m_excludeFileURLRequester->setEnabled( true );
}
}
void DiffPage::addDiffTab()
{
TQWidget* page = new TQWidget( this );
TQVBoxLayout* layout = new TQVBoxLayout( page );
layout->setSpacing( KDialog::spacingHint() );
layout->setMargin( KDialog::marginHint() );
// add diff program selector
m_diffProgramGroup = new TQVButtonGroup( i18n( "Diff Program" ), page );
layout->addWidget( m_diffProgramGroup );
m_diffProgramGroup->setMargin( KDialog::marginHint() );
m_diffURLRequester = new KURLRequester( m_diffProgramGroup, "diffURLRequester" );
TQWhatsThis::add( m_diffURLRequester, i18n( "You can select a different diff program here. On Solaris the standard diff program does not support all the options that the GNU version does. This way you can select that version." ) );
layout->addStretch( 1 );
page->setMinimumSize( sizeHintForWidget( page ) );
addTab( page, i18n( "&Diff" ) );
}
void DiffPage::addFormatTab()
{
TQWidget* page = new TQWidget( this );
TQVBoxLayout* layout = new TQVBoxLayout( page );
layout->setSpacing( KDialog::spacingHint() );
layout->setMargin( KDialog::marginHint() );
// add diff modes
m_modeButtonGroup = new TQVButtonGroup( i18n( "Output Format" ), page );
TQWhatsThis::add( m_modeButtonGroup, i18n( "Select the format of the output generated by diff. Unified is the one that is used most frequently because it is very readable. The KDE developers like this format the best so use it for sending patches." ) );
layout->addWidget( m_modeButtonGroup );
m_modeButtonGroup->setMargin( KDialog::marginHint() );
TQRadioButton* radioButton;
radioButton = new TQRadioButton( i18n( "Context" ), m_modeButtonGroup );
radioButton = new TQRadioButton( i18n( "Ed" ), m_modeButtonGroup );
radioButton->setEnabled( false );
radioButton = new TQRadioButton( i18n( "Normal" ), m_modeButtonGroup );
radioButton = new TQRadioButton( i18n( "RCS" ), m_modeButtonGroup );
radioButton->setEnabled( false );
radioButton = new TQRadioButton( i18n( "Unified" ), m_modeButtonGroup );
// #lines of context (loc)
TQHGroupBox* groupBox = new TQHGroupBox( i18n( "Lines of Context" ), page );
layout->addWidget( groupBox );
groupBox->setMargin( KDialog::marginHint() );
TQLabel* label = new TQLabel( i18n( "Number of context lines:" ), groupBox );
m_locSpinBox = new TQSpinBox( 0, 100, 1, groupBox );
TQWhatsThis::add( m_locSpinBox, i18n( "The number of context lines is normally 2 or 3. This makes the diff readable and applicable in most cases. More than 3 lines will only bloat the diff unnecessarily." ) );
label->setBuddy( m_locSpinBox );
layout->addStretch( 1 );
page->setMinimumSize( sizeHintForWidget( page ) );
addTab( page, i18n( "&Format" ) );
}
void DiffPage::addOptionsTab()
{
TQWidget* page = new TQWidget( this );
TQVBoxLayout* layout = new TQVBoxLayout( page );
layout->setSpacing( KDialog::spacingHint() );
layout->setMargin( KDialog::marginHint() );
// add diff options
TQVButtonGroup* optionButtonGroup = new TQVButtonGroup( i18n( "General" ), page );
layout->addWidget( optionButtonGroup );
optionButtonGroup->setMargin( KDialog::marginHint() );
m_smallerCheckBox = new TQCheckBox( i18n( "&Look for smaller changes" ), optionButtonGroup );
TQToolTip::add( m_smallerCheckBox, i18n( "This corresponds to the -d diff option." ) );
m_largerCheckBox = new TQCheckBox( i18n( "O&ptimize for large files" ), optionButtonGroup );
TQToolTip::add( m_largerCheckBox, i18n( "This corresponds to the -H diff option." ) );
m_caseCheckBox = new TQCheckBox( i18n( "&Ignore changes in case" ), optionButtonGroup );
TQToolTip::add( m_caseCheckBox, i18n( "This corresponds to the -i diff option." ) );
TQHBoxLayout* groupLayout = new TQHBoxLayout( layout, -1, "regexp_horizontal_layout" );
groupLayout->setMargin( KDialog::marginHint() );
m_ignoreRegExpCheckBox = new TQCheckBox( i18n( "Ignore regexp:" ), page );
TQToolTip::add( m_ignoreRegExpCheckBox, i18n( "This option corresponds to the -I diff option." ) );
groupLayout->addWidget( m_ignoreRegExpCheckBox );
m_ignoreRegExpEdit = new KLineEdit( TQString(), page, "regexplineedit" );
TQToolTip::add( m_ignoreRegExpEdit, i18n( "Add the regular expression here that you want to use\nto ignore lines that match it." ) );
groupLayout->addWidget( m_ignoreRegExpEdit );
if ( !KTrader::self()->query("KRegExpEditor/KRegExpEditor").isEmpty() )
{
// Ok editor is available, use it
TQButton* ignoreRegExpEditButton = new TQPushButton( i18n( "&Edit..." ), page, "regexp_editor_button" );
TQToolTip::add( ignoreRegExpEditButton, i18n( "Clicking this will open a regular expression dialog where\nyou can graphically create regular expressions." ) );
groupLayout->addWidget( ignoreRegExpEditButton );
connect( ignoreRegExpEditButton, TQT_SIGNAL( clicked() ), this, TQT_SLOT( slotShowRegExpEditor() ) );
}
TQVButtonGroup* moreOptionButtonGroup = new TQVButtonGroup( i18n( "Whitespace" ), page );
layout->addWidget( moreOptionButtonGroup );
moreOptionButtonGroup->setMargin( KDialog::marginHint() );
m_tabsCheckBox = new TQCheckBox( i18n( "E&xpand tabs to spaces in output" ), moreOptionButtonGroup );
TQToolTip::add( m_tabsCheckBox, i18n( "This option corresponds to the -t diff option." ) );
m_linesCheckBox = new TQCheckBox( i18n( "I&gnore added or removed empty lines" ), moreOptionButtonGroup );
TQToolTip::add( m_linesCheckBox, i18n( "This option corresponds to the -B diff option." ) );
m_whitespaceCheckBox = new TQCheckBox( i18n( "Ig&nore changes in the amount of whitespace" ), moreOptionButtonGroup );
TQToolTip::add( m_whitespaceCheckBox, i18n( "This option corresponds to the -b diff option." ) );
m_allWhitespaceCheckBox = new TQCheckBox( i18n( "Ign&ore all whitespace" ), moreOptionButtonGroup );
TQToolTip::add( m_allWhitespaceCheckBox, i18n( "This option corresponds to the -w diff option." ) );
m_ignoreTabExpansionCheckBox = new TQCheckBox( i18n( "Igno&re changes due to tab expansion" ), moreOptionButtonGroup );
TQToolTip::add( m_ignoreTabExpansionCheckBox, i18n( "This option corresponds to the -E diff option." ) );
layout->addStretch( 1 );
page->setMinimumSize( sizeHintForWidget( page ) );
addTab( page, i18n( "O&ptions" ) );
}
void DiffPage::addExcludeTab()
{
TQWidget* page = new TQWidget( this );
TQVBoxLayout* layout = new TQVBoxLayout( page );
layout->setSpacing( KDialog::spacingHint() );
layout->setMargin( KDialog::marginHint() );
TQHGroupBox* excludeFilePatternGroupBox = new TQHGroupBox( i18n( "File Pattern to Exclude" ), page );
m_excludeFilePatternCheckBox = new TQCheckBox( "", excludeFilePatternGroupBox );
TQToolTip::add( m_excludeFilePatternCheckBox, i18n( "If this is checked you can enter a shell pattern in the text box on the right or select entries from the list." ) );
m_excludeFilePatternEditListBox = new KEditListBox( excludeFilePatternGroupBox, "exclude_file_pattern_editlistbox", false, KEditListBox::Add|KEditListBox::Remove );
TQToolTip::add( m_excludeFilePatternEditListBox, i18n( "Here you can enter or remove a shell pattern or select one or more entries from the list." ) );
layout->addWidget( excludeFilePatternGroupBox );
connect( m_excludeFilePatternCheckBox, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotExcludeFilePatternToggled(bool)));
TQHGroupBox* excludeFileNameGroupBox = new TQHGroupBox( i18n( "File with Filenames to Exclude" ), page );
m_excludeFileCheckBox = new TQCheckBox( "", excludeFileNameGroupBox );
TQToolTip::add( m_excludeFileCheckBox, i18n( "If this is checked you can enter a filename in the combo box on the right." ) );
m_excludeFileURLComboBox = new KURLComboBox( KURLComboBox::Files, true, excludeFileNameGroupBox, "exclude_file_urlcombo" );
TQToolTip::add( m_excludeFileURLComboBox, i18n( "Here you can enter the URL of a file with shell patterns to ignore during the comparison of the folders." ) );
m_excludeFileURLRequester = new KURLRequester( m_excludeFileURLComboBox, excludeFileNameGroupBox, "exclude_file_name_urlrequester" );
TQToolTip::add( m_excludeFileURLRequester, i18n( "Any file you select in the dialog that pops up when you click it will be put in the dialog to the left of this button." ) );
layout->addWidget( excludeFileNameGroupBox );
connect( m_excludeFileCheckBox, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotExcludeFileToggled(bool)));
layout->addStretch( 1 );
page->setMinimumSize( sizeHintForWidget( page ) );
addTab( page, i18n( "&Exclude" ) );
}
#include "diffpage.moc"
|