Changeset View
Changeset View
Standalone View
Standalone View
krusader/Filter/generalfilter.cpp
Show First 20 Lines • Show All 226 Lines • ▼ Show 20 Line(s) | 224 | if (properties & FilterTabs::HasDontSearchIn) { | |||
---|---|---|---|---|---|
227 | QGroupBox *dontSearchInGroup = new QGroupBox(this); | 227 | QGroupBox *dontSearchInGroup = new QGroupBox(this); | ||
228 | dontSearchInGroup->setTitle(i18n("&Do not search in")); | 228 | dontSearchInGroup->setTitle(i18n("&Do not search in")); | ||
229 | QGridLayout *dontSearchInLayout = new QGridLayout(dontSearchInGroup); | 229 | QGridLayout *dontSearchInLayout = new QGridLayout(dontSearchInGroup); | ||
230 | dontSearchInLayout->setAlignment(Qt::AlignTop); | 230 | dontSearchInLayout->setAlignment(Qt::AlignTop); | ||
231 | dontSearchInLayout->setSpacing(6); | 231 | dontSearchInLayout->setSpacing(6); | ||
232 | dontSearchInLayout->setContentsMargins(11, 11, 11, 11); | 232 | dontSearchInLayout->setContentsMargins(11, 11, 11, 11); | ||
233 | 233 | | |||
234 | dontSearchIn = new KURLListRequester(KURLListRequester::RequestDirs, dontSearchInGroup); | 234 | dontSearchIn = new KURLListRequester(KURLListRequester::RequestDirs, dontSearchInGroup); | ||
235 | dontSearchInLayout->addWidget(dontSearchIn, 0, 0); | 235 | dontSearchInLayout->addWidget(dontSearchIn, 0, 0, 1, 2); | ||
236 | | ||||
237 | if (properties & FilterTabs::HasRecurseOptions) { | ||||
238 | KConfigGroup group(krConfig, "Search"); | ||||
239 | | ||||
240 | useExcludeFolderNames = new QCheckBox(this); | ||||
241 | useExcludeFolderNames->setText(i18n("Exclude Folder Names")); | ||||
242 | useExcludeFolderNames->setToolTip(i18n("Filters out specified directory names from the results.")); | ||||
243 | useExcludeFolderNames->setChecked(static_cast<Qt::CheckState>(group.readEntry("ExcludeFolderNamesUse", 0))); | ||||
244 | dontSearchInLayout->addWidget(useExcludeFolderNames, 1, 0, 1, 1); | ||||
245 | | ||||
246 | excludeFolderNames = new KHistoryComboBox(false, dontSearchInGroup); | ||||
247 | QSizePolicy excludeFolderNamesPolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); | ||||
248 | excludeFolderNamesPolicy.setHeightForWidth(excludeFolderNames->sizePolicy().hasHeightForWidth()); | ||||
249 | excludeFolderNames->setSizePolicy(excludeFolderNamesPolicy); | ||||
250 | excludeFolderNames->setEditable(true); | ||||
251 | excludeFolderNames->setDuplicatesEnabled(false); | ||||
252 | excludeFolderNames->setMaxCount(25); | ||||
253 | excludeFolderNames->setMinimumContentsLength(10); | ||||
254 | excludeFolderNames->lineEdit()->setPlaceholderText("Enter colon separated folder names"); | ||||
255 | dontSearchInLayout->addWidget(excludeFolderNames, 1, 1, 1, 1); | ||||
256 | excludeFolderNames->setHistoryItems(group.readEntry("ExcludeFolderNamesHistory", QStringList())); | ||||
257 | excludeFolderNames->setEditText(group.readEntry("ExcludeFolderNames", "")); | ||||
258 | if (!useExcludeFolderNames->isChecked()) { | ||||
259 | excludeFolderNames->setDisabled(true); | ||||
260 | } | ||||
261 | | ||||
262 | connect(useExcludeFolderNames, &QCheckBox::toggled, excludeFolderNames, &KHistoryComboBox::setEnabled); | ||||
263 | } | ||||
236 | 264 | | |||
237 | middleLayout->addWidget(dontSearchInGroup); | 265 | middleLayout->addWidget(dontSearchInGroup); | ||
238 | } | 266 | } | ||
239 | 267 | | |||
240 | filterLayout->addLayout(middleLayout, 1, 0); | 268 | filterLayout->addLayout(middleLayout, 1, 0); | ||
241 | 269 | | |||
242 | // Options for containing text | 270 | // Options for containing text | ||
243 | 271 | | |||
▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Line(s) | 420 | { | |||
397 | group.writeEntry("SearchFor Completion", list); | 425 | group.writeEntry("SearchFor Completion", list); | ||
398 | list = searchFor->historyItems(); | 426 | list = searchFor->historyItems(); | ||
399 | group.writeEntry("SearchFor History", list); | 427 | group.writeEntry("SearchFor History", list); | ||
400 | // ==> grep text | 428 | // ==> grep text | ||
401 | list = containsText->completionObject()->items(); | 429 | list = containsText->completionObject()->items(); | ||
402 | group.writeEntry("ContainsText Completion", list); | 430 | group.writeEntry("ContainsText Completion", list); | ||
403 | list = containsText->historyItems(); | 431 | list = containsText->historyItems(); | ||
404 | group.writeEntry("ContainsText History", list); | 432 | group.writeEntry("ContainsText History", list); | ||
405 | 433 | if (properties & FilterTabs::HasDontSearchIn) { | |||
434 | if (properties & FilterTabs::HasRecurseOptions) { | ||||
435 | list = excludeFolderNames->historyItems(); | ||||
436 | group.writeEntry("ExcludeFolderNamesHistory", list); | ||||
437 | group.writeEntry("ExcludeFolderNames", excludeFolderNames->currentText()); | ||||
438 | group.writeEntry("ExcludeFolderNamesUse", static_cast<int>(useExcludeFolderNames->checkState())); | ||||
439 | } | ||||
440 | } | ||||
nmel: minor: two ifs could be combined in if ((properties & FilterTabs::HasDontSearchIn) &&… | |||||
406 | krConfig->sync(); | 441 | krConfig->sync(); | ||
407 | } | 442 | } | ||
408 | 443 | | |||
409 | bool GeneralFilter::isExtraOptionChecked(QString name) | 444 | bool GeneralFilter::isExtraOptionChecked(QString name) | ||
410 | { | 445 | { | ||
411 | QCheckBox *option = extraOptions[name]; | 446 | QCheckBox *option = extraOptions[name]; | ||
412 | return option ? option->isChecked() : false; | 447 | return option ? option->isChecked() : false; | ||
413 | } | 448 | } | ||
414 | 449 | | |||
415 | void GeneralFilter::checkExtraOption(QString name, bool check) | 450 | void GeneralFilter::checkExtraOption(QString name, bool check) | ||
416 | { | 451 | { | ||
417 | QCheckBox *option = extraOptions[name]; | 452 | QCheckBox *option = extraOptions[name]; | ||
418 | if(option) | 453 | if(option) | ||
419 | option->setChecked(check); | 454 | option->setChecked(check); | ||
420 | } | 455 | } | ||
421 | 456 | | |||
422 | void GeneralFilter::queryAccepted() | 457 | void GeneralFilter::queryAccepted() | ||
423 | { | 458 | { | ||
424 | searchFor->addToHistory(searchFor->currentText()); | 459 | searchFor->addToHistory(searchFor->currentText()); | ||
425 | containsText->addToHistory(containsText->currentText()); | 460 | containsText->addToHistory(containsText->currentText()); | ||
461 | if (properties & FilterTabs::HasDontSearchIn) { | ||||
minor: two ifs could be combined in if ((properties & FilterTabs::HasDontSearchIn) && (properties & FilterTabs::HasRecurseOptions)) nmel: minor: two ifs could be combined in if ((properties & FilterTabs::HasDontSearchIn) &&… | |||||
462 | if (properties & FilterTabs::HasRecurseOptions) { | ||||
463 | excludeFolderNames->addToHistory(excludeFolderNames->currentText()); | ||||
464 | } | ||||
465 | } | ||||
426 | } | 466 | } | ||
427 | 467 | | |||
428 | void GeneralFilter::refreshProfileListBox() | 468 | void GeneralFilter::refreshProfileListBox() | ||
429 | { | 469 | { | ||
430 | profileListBox->clear(); | 470 | profileListBox->clear(); | ||
431 | profileListBox->addItems(ProfileManager::availableProfiles("SelectionProfile")); | 471 | profileListBox->addItems(ProfileManager::availableProfiles("SelectionProfile")); | ||
432 | 472 | | |||
433 | if (profileListBox->count() != 0) { | 473 | if (profileListBox->count() != 0) { | ||
▲ Show 20 Lines • Show All 118 Lines • ▼ Show 20 Line(s) | 591 | if (properties & FilterTabs::HasSearchIn) { | |||
552 | s.searchIn = searchIn->urlList(); | 592 | s.searchIn = searchIn->urlList(); | ||
553 | if (s.searchIn.isEmpty()) { // we need a place to search in | 593 | if (s.searchIn.isEmpty()) { // we need a place to search in | ||
554 | KMessageBox::error(this , i18n("Please specify a location to search in.")); | 594 | KMessageBox::error(this , i18n("Please specify a location to search in.")); | ||
555 | searchIn->lineEdit()->setFocus(); | 595 | searchIn->lineEdit()->setFocus(); | ||
556 | return false; | 596 | return false; | ||
557 | } | 597 | } | ||
558 | } | 598 | } | ||
559 | 599 | | |||
560 | if (properties & FilterTabs::HasDontSearchIn) | 600 | if (properties & FilterTabs::HasDontSearchIn) { | ||
561 | s.dontSearchIn = dontSearchIn->urlList(); | 601 | s.dontSearchIn = dontSearchIn->urlList(); | ||
562 | 602 | if (properties & FilterTabs::HasRecurseOptions) { | |||
603 | if(useExcludeFolderNames->isChecked()) { | ||||
nmel: space: if ( | |||||
604 | s.excludeFolderNames = excludeFolderNames->currentText().split(':'); | ||||
605 | } else { | ||||
606 | s.excludeFolderNames = QStringList(); | ||||
607 | } | ||||
608 | } | ||||
609 | } | ||||
563 | return true; | 610 | return true; | ||
564 | } | 611 | } | ||
565 | 612 | | |||
566 | void GeneralFilter::applySettings(const FilterSettings &s) | 613 | void GeneralFilter::applySettings(const FilterSettings &s) | ||
567 | { | 614 | { | ||
568 | searchFor->setEditText(s.searchFor); | 615 | searchFor->setEditText(s.searchFor); | ||
569 | searchForCase->setChecked(s.searchForCase); | 616 | searchForCase->setChecked(s.searchForCase); | ||
570 | 617 | | |||
Show All 29 Lines |
minor: two ifs could be combined in if ((properties & FilterTabs::HasDontSearchIn) && (properties & FilterTabs::HasRecurseOptions))