29 #include <kmessagebox.h>
42 I18N_NOOP(
"Do not Care"), 0
45 {I18N_NOOP(
"30 Min"), 30 * 60},
46 {I18N_NOOP(
"1 Hour"), 1 * 60 * 60},
47 {I18N_NOOP(
"2 Hours"), 2 * 60 * 60},
48 {I18N_NOOP(
"4 Hours"), 4 * 60 * 60},
49 {I18N_NOOP(
"8 Hours"), 8 * 60 * 60},
50 {I18N_NOOP(
"12 Hours"), 12 * 60 * 60},
51 {I18N_NOOP(
"18 Hours"), 18 * 60 * 60},
53 {I18N_NOOP(
"1 Day"), 1 * 60 * 60 * 24},
54 {I18N_NOOP(
"2 Days"), 2 * 60 * 60 * 24},
55 {I18N_NOOP(
"3 Days"), 3 * 60 * 60 * 24},
56 {I18N_NOOP(
"4 Days"), 4 * 60 * 60 * 24},
57 {I18N_NOOP(
"5 Days"), 5 * 60 * 60 * 24},
58 {I18N_NOOP(
"6 Days"), 6 * 60 * 60 * 24},
60 {I18N_NOOP(
"1 Week"), 1 * 60 * 60 * 24 * 7},
61 {I18N_NOOP(
"2 Weeks"), 2 * 60 * 60 * 24 * 7},
62 {I18N_NOOP(
"3 Weeks"), 3 * 60 * 60 * 24 * 7},
63 {I18N_NOOP(
"4 Weeks"), 4 * 60 * 60 * 24 * 7},
65 {I18N_NOOP(
"1 Month"), 1 * 60 * 60 * 24 * 30},
66 {I18N_NOOP(
"2 Months"), 2 * 60 * 60 * 24 * 30},
67 {I18N_NOOP(
"3 Months"), 3 * 60 * 60 * 24 * 30},
68 {I18N_NOOP(
"4 Months"), 4 * 60 * 60 * 24 * 30},
69 {I18N_NOOP(
"5 Months"), 5 * 60 * 60 * 24 * 30},
70 {I18N_NOOP(
"6 Months"), 6 * 60 * 60 * 24 * 30},
71 {I18N_NOOP(
"10 Months"), 10 * 60 * 60 * 24 * 30},
72 {I18N_NOOP(
"12 Months"), 12 * 60 * 60 * 24 * 30},
102 void BlockOptions::fillWidgets()
104 fillComboBox(block1);
105 fillComboBox(block2);
106 fillComboBox(block3);
107 fillComboBox(block4);
108 fillComboBox(block5);
109 fillComboBox(block6);
110 fillComboBox(block7);
112 m_blockComboList.
append(block1);
113 m_blockComboList.
append(block2);
114 m_blockComboList.
append(block3);
115 m_blockComboList.
append(block4);
116 m_blockComboList.
append(block5);
117 m_blockComboList.
append(block6);
118 m_blockComboList.
append(block7);
120 fillComboBox(expire1);
121 fillComboBox(expire2);
122 fillComboBox(expire3);
123 fillComboBox(expire4);
124 fillComboBox(expire5);
125 fillComboBox(expire6);
126 fillComboBox(expire7);
128 m_expireComboList.
append(expire1);
129 m_expireComboList.
append(expire2);
130 m_expireComboList.
append(expire3);
131 m_expireComboList.
append(expire4);
132 m_expireComboList.
append(expire5);
133 m_expireComboList.
append(expire6);
134 m_expireComboList.
append(expire7);
156 kcfg_Block->setChecked(block);
157 block1->setEnabled(block);
158 block2->setEnabled(block);
159 block3->setEnabled(block);
160 block4->setEnabled(block);
161 block5->setEnabled(block);
162 block6->setEnabled(block);
163 block7->setEnabled(block);
166 kcfg_Expire->setChecked(expire);
167 expire1->setEnabled(expire);
168 expire2->setEnabled(expire);
169 expire3->setEnabled(expire);
170 expire4->setEnabled(expire);
171 expire5->setEnabled(expire);
172 expire6->setEnabled(expire);
173 expire7->setEnabled(expire);
176 void BlockOptions::fillComboBox(KComboBox * cb)
181 while (ref->text != 0) {
182 cb->addItem(i18n(ref->text));
187 void BlockOptions::updateComboBox(
int value, KComboBox * cb)
192 while (ref->text != 0) {
193 if (value == ref->num)
197 cb->setCurrentIndex(index);
202 block1->setEnabled(state);
203 block2->setEnabled(state);
204 block3->setEnabled(state);
205 block4->setEnabled(state);
206 block5->setEnabled(state);
207 block6->setEnabled(state);
208 block7->setEnabled(state);
213 expire1->setEnabled(state);
214 expire2->setEnabled(state);
215 expire3->setEnabled(state);
216 expire4->setEnabled(state);
217 expire5->setEnabled(state);
218 expire6->setEnabled(state);
219 expire7->setEnabled(state);
229 void BlockOptions::checkValidity()
233 for (
int i = 1; i <= 6; i++) {
234 if (kcfg_Block->isChecked()) {
238 if (date_itemlist[m_blockComboList[i - 1]->currentIndex()].num != 0 &&
239 date_itemlist[m_blockComboList[i]->currentIndex()].num != 0 &&
240 date_itemlist[m_blockComboList[i - 1]->currentIndex()].num >= date_itemlist[m_blockComboList[i]->currentIndex()].num) {
243 message.
append(i18n(
"Illogical blocking times.\n"));
245 message.
append(i18n(
"The time for level %1 should be lower than the time for level %2.\n", i, i + 1));
250 for (
int i = 1; i <= 6; i++) {
252 if (kcfg_Expire->isChecked()) {
253 if (date_itemlist[m_expireComboList[i - 1]->currentIndex()].num != 0 &&
254 date_itemlist[m_expireComboList[i]->currentIndex()].num != 0 &&
255 date_itemlist[m_expireComboList[i - 1]->currentIndex()].num >=
256 date_itemlist[m_expireComboList[i]->currentIndex()].num) {
259 message.
append(i18n(
"\nIllogical expiration times.\n"));
261 message.
append(i18n(
"The time for level %1 should be lower than the time for level %2.\n", i, i + 1));
266 if (message.
length() == 0) {
268 for (
int i = 0; i <= 6; i++) {
269 if (kcfg_Block->isChecked() &&
270 kcfg_Expire->isChecked() &&
271 m_expireComboList[i]->currentIndex() >= 0 &&
272 m_blockComboList[i]->currentIndex() >= 0 &&
273 date_itemlist[m_expireComboList[i]->currentIndex()].num != 0 &&
274 date_itemlist[m_blockComboList[i]->currentIndex()].num != 0 &&
275 date_itemlist[m_blockComboList[i]->currentIndex()].num >= date_itemlist[m_expireComboList[i]->currentIndex()].num) {
278 message.
append(i18n(
"\nIllogical blocking vs. expiration times.\n"));
280 message.
append(i18n(
"The blocking time at level %1 should be lower than the expiration time.\n", i + 1));
285 if (message.
length() != 0)
286 KMessageBox::sorry(
this, message, i18n(
"Illogical Values"));
292 if (block7->currentIndex() < 0 ||
293 block6->currentIndex() < 0 ||
294 block5->currentIndex() < 0 ||
295 block4->currentIndex() < 0 ||
296 block3->currentIndex() < 0 ||
297 block2->currentIndex() < 0 ||
298 block1->currentIndex() < 0 ||
299 expire7->currentIndex() < 0 ||
300 expire6->currentIndex() < 0 ||
301 expire5->currentIndex() < 0 ||
302 expire4->currentIndex() < 0 ||
303 expire3->currentIndex() < 0 ||
304 expire2->currentIndex() < 0 ||
305 expire1->currentIndex() < 0)
308 return date_itemlist[block7->currentIndex()].num == 5184000 &&
309 date_itemlist[block6->currentIndex()].num == 2592000 &&
310 date_itemlist[block5->currentIndex()].num == 1209600 &&
311 date_itemlist[block4->currentIndex()].num == 604800 &&
312 date_itemlist[block3->currentIndex()].num == 345600 &&
313 date_itemlist[block2->currentIndex()].num == 172800 &&
314 date_itemlist[block1->currentIndex()].num == 86400 &&
315 date_itemlist[expire7->currentIndex()].num == 10368000 &&
316 date_itemlist[expire6->currentIndex()].num == 5184000 &&
317 date_itemlist[expire5->currentIndex()].num == 2592000 &&
318 date_itemlist[expire4->currentIndex()].num == 1209600 &&
319 date_itemlist[expire3->currentIndex()].num == 604800 &&
320 date_itemlist[expire2->currentIndex()].num == 345600 &&
321 date_itemlist[expire1->currentIndex()].num == 172800;
327 if (block7->currentIndex() < 0 ||
328 block6->currentIndex() < 0 ||
329 block5->currentIndex() < 0 ||
330 block4->currentIndex() < 0 ||
331 block3->currentIndex() < 0 ||
332 block2->currentIndex() < 0 ||
333 block1->currentIndex() < 0 ||
334 expire7->currentIndex() < 0 ||
335 expire6->currentIndex() < 0 ||
336 expire5->currentIndex() < 0 ||
337 expire4->currentIndex() < 0 ||
338 expire3->currentIndex() < 0 ||
339 expire2->currentIndex() < 0 ||
340 expire1->currentIndex() < 0)
362 if (block7->currentIndex() < 0 ||
363 block6->currentIndex() < 0 ||
364 block5->currentIndex() < 0 ||
365 block4->currentIndex() < 0 ||
366 block3->currentIndex() < 0 ||
367 block2->currentIndex() < 0 ||
368 block1->currentIndex() < 0 ||
369 expire7->currentIndex() < 0 ||
370 expire6->currentIndex() < 0 ||
371 expire5->currentIndex() < 0 ||
372 expire4->currentIndex() < 0 ||
373 expire3->currentIndex() < 0 ||
374 expire2->currentIndex() < 0 ||
375 expire1->currentIndex() < 0)
378 return date_itemlist[block7->currentIndex()].num !=
Prefs::blockItem(KV_LEV7_GRADE) ||
379 date_itemlist[block6->currentIndex()].num !=
Prefs::blockItem(KV_LEV6_GRADE) ||
380 date_itemlist[block5->currentIndex()].num !=
Prefs::blockItem(KV_LEV5_GRADE) ||
381 date_itemlist[block4->currentIndex()].num !=
Prefs::blockItem(KV_LEV4_GRADE) ||
382 date_itemlist[block3->currentIndex()].num !=
Prefs::blockItem(KV_LEV3_GRADE) ||
383 date_itemlist[block2->currentIndex()].num !=
Prefs::blockItem(KV_LEV2_GRADE) ||
384 date_itemlist[block1->currentIndex()].num !=
Prefs::blockItem(KV_LEV1_GRADE) ||
385 date_itemlist[expire7->currentIndex()].num !=
Prefs::expireItem(KV_LEV7_GRADE) ||
386 date_itemlist[expire6->currentIndex()].num !=
Prefs::expireItem(KV_LEV6_GRADE) ||
387 date_itemlist[expire5->currentIndex()].num !=
Prefs::expireItem(KV_LEV5_GRADE) ||
388 date_itemlist[expire4->currentIndex()].num !=
Prefs::expireItem(KV_LEV4_GRADE) ||
389 date_itemlist[expire3->currentIndex()].num !=
Prefs::expireItem(KV_LEV3_GRADE) ||
390 date_itemlist[expire2->currentIndex()].num !=
Prefs::expireItem(KV_LEV2_GRADE) ||
394 #include "blockoptions.moc"
static void setExpireItem(int i, int v)
Set Amount of time after which different confidence levels should expire.
QString & append(QChar ch)
static int expireItem(int i)
Get Amount of time after which different confidence levels should expire.
BlockOptions(QWidget *parent=0)
void slotComboBoxActivated(int)
static int blockItem(int i)
Get Amount of time different confidence levels should be blocked.
static void setBlockItem(int i, int v)
Set Amount of time different confidence levels should be blocked.
void slotBlockToggled(bool)
void append(const T &value)
static ListRef date_itemlist[]
static bool expire()
Get In Blocking Query Tab Dialog, if checked then the Query accepts an expiring time.
static bool block()
Get In Blocking Query Tab Dialog, if checked then the Query is blocked.
void slotExpireToggled(bool)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)