summaryrefslogtreecommitdiffstats
path: root/kbabel/kbabeldict/modules/pocompendium/preferenceswidget.cpp
blob: 8af71c484ff20d03b396c5ab0e71792b63f33ce6 (plain)
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
/* ****************************************************************************
  This file is part of KBabel

  Copyright (C) 2000 by Matthias Kiefer
                            <matthias.kiefer@gmx.de>

  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.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

  In addition, as a special exception, the copyright holders give
  permission to link the code of this program with any edition of
  the TQt library by Trolltech AS, Norway (or with modified versions
  of TQt that use the same license as TQt), and distribute linked
  combinations including the two.  You must obey the GNU General
  Public License in all respects for all of the code used other than
  TQt. If you modify this file, you may extend this exception to
  your version of the file, but you are not obligated to do so.  If
  you do not wish to do so, delete this exception statement from
  your version.

**************************************************************************** */
#include <tqcheckbox.h>
#include <tqlabel.h>
#include <tqlayout.h>

#include <kfiledialog.h>
#include <tqpushbutton.h>
#include <tqwhatsthis.h>
#include <klineedit.h>
#include <klocale.h>
#include <kurlrequester.h>

#include "preferenceswidget.h"
#include "pwidget.h"

CompendiumPreferencesWidget::CompendiumPreferencesWidget(TQWidget *parent, const char* name)
		: PrefWidget(parent,name)
		, changed(false)
{
	TQVBoxLayout *layout = new TQVBoxLayout(this);
		
	prefWidget = new CompendiumPWidget(this);
	layout->addWidget(prefWidget);

	connect(prefWidget->caseBtn, TQT_SIGNAL(toggled(bool))
					, this, TQT_SLOT(setChanged()));
	connect(prefWidget->equalBtn, TQT_SIGNAL(toggled(bool))
					, this, TQT_SLOT(setChanged()));
	connect(prefWidget->ngramBtn, TQT_SIGNAL(toggled(bool))
					, this, TQT_SLOT(setChanged()));
	connect(prefWidget->isContainedBtn, TQT_SIGNAL(toggled(bool))
					, this, TQT_SLOT(setChanged()));
	connect(prefWidget->containsBtn, TQT_SIGNAL(toggled(bool))
					, this, TQT_SLOT(setChanged()));
	connect(prefWidget->fuzzyBtn, TQT_SIGNAL(toggled(bool))
					, this, TQT_SLOT(setChanged()));
	connect(prefWidget->hasWordBtn, TQT_SIGNAL(toggled(bool))
					, this, TQT_SLOT(setChanged()));
	connect(prefWidget->wholeBtn, TQT_SIGNAL(toggled(bool))
					, this, TQT_SLOT(setChanged()));
	
	connect(prefWidget->urlInput->lineEdit(),TQT_SIGNAL(textChanged(const TQString&))
					, this, TQT_SLOT(setChanged()));

	connect(prefWidget->equalBtn, TQT_SIGNAL(toggled(bool))
					, this, TQT_SLOT(equalBtnToggled(bool)));
	connect(prefWidget->ngramBtn, TQT_SIGNAL(toggled(bool))
					, this, TQT_SLOT(ngramBtnToggled(bool)));
	connect(prefWidget->isContainedBtn, TQT_SIGNAL(toggled(bool))
					, this, TQT_SLOT(isContainedBtnToggled(bool)));
	connect(prefWidget->containsBtn, TQT_SIGNAL(toggled(bool))
					, this, TQT_SLOT(containsBtnToggled(bool)));
	connect(prefWidget->hasWordBtn, TQT_SIGNAL(toggled(bool))
					, this, TQT_SLOT(hasWordBtnToggled(bool)));


	TQString whatsthis=i18n("<qt><p><b>Parameters</b></p>"
		"<p>Here you can fine-tune searching within the PO file. "
		"For example if you want to perform a case sensitive search, or if "
		"you want fuzzy messages to be ignored.</p></qt>" );
	TQWhatsThis::add(prefWidget->caseBtn,whatsthis);
	TQWhatsThis::add(prefWidget->fuzzyBtn,whatsthis);
	TQWhatsThis::add(prefWidget->wholeBtn,whatsthis);

	whatsthis = i18n("<qt><p><b>Comparison Options</b></p>"
		"<p>Choose here which messages you want to have treated as a matching "
		"message.</p></qt>");
	TQWhatsThis::add(prefWidget->equalBtn,whatsthis);
	TQWhatsThis::add(prefWidget->containsBtn,whatsthis);
	TQWhatsThis::add(prefWidget->isContainedBtn,whatsthis);
	TQWhatsThis::add(prefWidget->hasWordBtn,whatsthis);

	whatsthis = i18n("<qt><p><b>3-Gram-matching</b></p>"
			 "<p>A message matches another if most of its 3-letter groups are "
			 "contained in the other message. e.g. 'abc123' matches 'abcx123c12'.</p></qt>");
	TQWhatsThis::add(prefWidget->ngramBtn,whatsthis);

	whatsthis = i18n("<qt><p><b>Location</b></p>"
					"<p>Configure here which file is to be used for searching."
					"</p></qt>");
	TQWhatsThis::add(prefWidget->urlInput,whatsthis);
}

CompendiumPreferencesWidget::~CompendiumPreferencesWidget()
{
}


void CompendiumPreferencesWidget::apply()
{
	emit applySettings();
}

void CompendiumPreferencesWidget::cancel()
{
	emit restoreSettings();
}

void CompendiumPreferencesWidget::standard()
{
	prefWidget->urlInput->setURL("http://i18n.kde.org/po_overview/@LANG@.messages");
	prefWidget->caseBtn->setChecked(false);
	prefWidget->equalBtn->setChecked(true);
	prefWidget->ngramBtn->setChecked(true);
	prefWidget->isContainedBtn->setChecked(false);
	prefWidget->containsBtn->setChecked(false);
	prefWidget->wholeBtn->setChecked(true);
	prefWidget->hasWordBtn->setChecked(true);

	prefWidget->fuzzyBtn->setChecked(true);
	
	changed=true;
}

void CompendiumPreferencesWidget::setURL(const TQString url)
{
	prefWidget->urlInput->setURL(url);
	changed=false;
}

void CompendiumPreferencesWidget::setCaseSensitive(bool on)
{
	prefWidget->caseBtn->setChecked(on);
	changed=false;
}

void CompendiumPreferencesWidget::setMatchEqual(bool on)
{
	prefWidget->equalBtn->setChecked(on);
	changed=false;
}

void CompendiumPreferencesWidget::setMatchNGram(bool on)
{
	prefWidget->ngramBtn->setChecked(on);
	changed=false;
}

void CompendiumPreferencesWidget::setMatchIsContained(bool on)
{
	prefWidget->isContainedBtn->setChecked(on);
	changed=false;
}

void CompendiumPreferencesWidget::setMatchContains(bool on)
{
	prefWidget->containsBtn->setChecked(on);
	changed=false;
}

void CompendiumPreferencesWidget::setIgnoreFuzzy(bool on)
{
	prefWidget->fuzzyBtn->setChecked(on);
	changed=false;
}

void CompendiumPreferencesWidget::setWholeWords(bool on)
{
	prefWidget->wholeBtn->setChecked(on);
	changed=false;
}


void CompendiumPreferencesWidget::setMatchWords(bool on)
{
	prefWidget->hasWordBtn->setChecked(on);
	changed=false;
}



TQString CompendiumPreferencesWidget::url()
{
	changed=false;
	return prefWidget->urlInput->url();
}

bool CompendiumPreferencesWidget::caseSensitive()
{
	changed=false;

	return prefWidget->caseBtn->isChecked();
}

bool CompendiumPreferencesWidget::matchEqual()
{
	changed=false;

	return prefWidget->equalBtn->isChecked();
}

bool CompendiumPreferencesWidget::matchNGram()
{
	changed=false;

	return prefWidget->ngramBtn->isChecked();
}

bool CompendiumPreferencesWidget::matchIsContained()
{
	changed=false;

	return prefWidget->isContainedBtn->isChecked();
}

bool CompendiumPreferencesWidget::matchContains()
{
	changed=false;

	return prefWidget->containsBtn->isChecked();
}

bool CompendiumPreferencesWidget::ignoreFuzzy()
{
	changed=false;

	return prefWidget->fuzzyBtn->isChecked();
}


bool CompendiumPreferencesWidget::wholeWords()
{
	changed=false;

	return prefWidget->wholeBtn->isChecked();
}


bool CompendiumPreferencesWidget::matchWords()
{
	changed=false;

	return prefWidget->hasWordBtn->isChecked();
}



bool CompendiumPreferencesWidget::settingsChanged() const
{
	return changed;
}

void CompendiumPreferencesWidget::setChanged()
{
	changed=true;
}


void CompendiumPreferencesWidget::equalBtnToggled(bool on)
{
	if(!on)
	{
		if(!prefWidget->isContainedBtn->isChecked() 
		   && !prefWidget->ngramBtn->isChecked()
		   && !prefWidget->containsBtn->isChecked()
		   && !prefWidget->hasWordBtn->isChecked())
		{
			prefWidget->equalBtn->setChecked(true);
		}
	}
}

void CompendiumPreferencesWidget::ngramBtnToggled(bool on)
{
	if(!on)
	{
		if(!prefWidget->isContainedBtn->isChecked() 
		   && !prefWidget->equalBtn->isChecked()
		   && !prefWidget->containsBtn->isChecked()
		   && !prefWidget->hasWordBtn->isChecked())
		{
		  prefWidget->equalBtn->setChecked(true);
		}
	}
}

void CompendiumPreferencesWidget::isContainedBtnToggled(bool on)
{
	if(!on)
	{
		if(!prefWidget->equalBtn->isChecked() 
		   && !prefWidget->ngramBtn->isChecked()
		   && !prefWidget->containsBtn->isChecked()
		   && !prefWidget->hasWordBtn->isChecked())
		{
		  prefWidget->isContainedBtn->setChecked(true);
		}
	}
}

void CompendiumPreferencesWidget::containsBtnToggled(bool on)
{
	if(!on)
	{
		if(!prefWidget->isContainedBtn->isChecked() 
		   && !prefWidget->ngramBtn->isChecked()
		   && !prefWidget->equalBtn->isChecked()
		   && !prefWidget->hasWordBtn->isChecked())
		{
		  prefWidget->containsBtn->setChecked(true);
		}
	}
}

void CompendiumPreferencesWidget::hasWordBtnToggled(bool on)
{
	if(!on)
	{
		if(!prefWidget->isContainedBtn->isChecked() 
		   && !prefWidget->ngramBtn->isChecked()
		   && !prefWidget->equalBtn->isChecked()
		   && !prefWidget->containsBtn->isChecked())
		{
		  prefWidget->hasWordBtn->setChecked(true);
		}
	}
}



#include "preferenceswidget.moc"