Changeset View
Changeset View
Standalone View
Standalone View
src/search/dolphinsearchbox.cpp
Show First 20 Lines • Show All 524 Lines • ▼ Show 20 Line(s) | 519 | #ifdef HAVE_BALOO | |||
---|---|---|---|---|---|
525 | 525 | | |||
526 | const QString customDir = query.includeFolder(); | 526 | const QString customDir = query.includeFolder(); | ||
527 | if (!customDir.isEmpty()) { | 527 | if (!customDir.isEmpty()) { | ||
528 | setSearchPath(QUrl::fromLocalFile(customDir)); | 528 | setSearchPath(QUrl::fromLocalFile(customDir)); | ||
529 | } else { | 529 | } else { | ||
530 | setSearchPath(QUrl::fromLocalFile(QDir::homePath())); | 530 | setSearchPath(QUrl::fromLocalFile(QDir::homePath())); | ||
531 | } | 531 | } | ||
532 | 532 | | |||
533 | setText(query.searchString()); | | |||
534 | | ||||
535 | QStringList types = query.types(); | 533 | QStringList types = query.types(); | ||
536 | if (!types.isEmpty()) { | 534 | if (!types.isEmpty()) { | ||
537 | m_facetsWidget->setFacetType(types.first()); | 535 | m_facetsWidget->setFacetType(types.first()); | ||
538 | } | 536 | } | ||
539 | 537 | | |||
538 | bool hasFileName = false; | ||||
539 | QStringList searchTextItems; | ||||
540 | | ||||
540 | const QStringList subTerms = query.searchString().split(' ', QString::SkipEmptyParts); | 541 | const QStringList subTerms = query.searchString().split(' ', QString::SkipEmptyParts); | ||
chehrlic: Wouldn't it be better to use
```
const QString searchString = query.searchString();
const… | |||||
Nice, will do in this patch if @elvisangelaccio agrees, or else in a different one. Thanks for this kind of comments; I'm quite lost in all of the C++/Qt optimization subtleties. iasensio: Nice, will do in this patch if @elvisangelaccio agrees, or else in a different one. Thanks for… | |||||
541 | foreach (const QString& subTerm, subTerms) { | 542 | for (const QString& subTerm : subTerms) { | ||
543 | QString value; | ||||
elvisangelaccio: Sorry, missed this one. | |||||
542 | if (subTerm.startsWith(QLatin1String("filename:"))) { | 544 | if (subTerm.startsWith(QLatin1String("filename:"))) { | ||
543 | const QString value = subTerm.mid(9); | 545 | hasFileName = true; | ||
544 | setText(value); | 546 | value = subTerm.mid(9); | ||
545 | } else if (m_facetsWidget->isRatingTerm(subTerm)) { | 547 | } else if (m_facetsWidget->isRatingTerm(subTerm)) { | ||
546 | m_facetsWidget->setRatingTerm(subTerm); | 548 | m_facetsWidget->setRatingTerm(subTerm); | ||
549 | continue; | ||||
550 | } else if (subTerm == QStringLiteral("AND") && subTerm != subTerms.at(0) && subTerm != subTerms.back()) { | ||||
elvisangelaccio: Prefer `QLatin1String` for comparisons. | |||||
551 | continue; | ||||
552 | } else { | ||||
elvisangelaccio: Also here | |||||
553 | value = subTerm; | ||||
554 | } | ||||
555 | | ||||
556 | if (!value.isEmpty()) { | ||||
557 | if (value.at(0) == QLatin1Char('"')) { | ||||
558 | value = value.mid(1); | ||||
559 | } | ||||
560 | if (value.back() == QLatin1Char('"')) { | ||||
561 | value = value.mid(0, value.size()-1); | ||||
562 | } | ||||
563 | searchTextItems << value; | ||||
547 | } | 564 | } | ||
548 | } | 565 | } | ||
549 | 566 | | |||
567 | setText(searchTextItems.join(" ")); | ||||
chehrlic: QLatin1Char(' ') instead " " | |||||
568 | | ||||
569 | if (hasFileName) { | ||||
570 | m_fileNameButton->setChecked(true); | ||||
571 | } else { | ||||
572 | m_contentButton->setChecked(true); | ||||
573 | } | ||||
574 | | ||||
550 | m_startSearchTimer->stop(); | 575 | m_startSearchTimer->stop(); | ||
551 | blockSignals(false); | 576 | blockSignals(false); | ||
552 | #else | 577 | #else | ||
553 | Q_UNUSED(url); | 578 | Q_UNUSED(url); | ||
554 | #endif | 579 | #endif | ||
555 | } | 580 | } | ||
556 | 581 | | |||
557 | void DolphinSearchBox::updateFacetsToggleButton() | 582 | void DolphinSearchBox::updateFacetsToggleButton() | ||
558 | { | 583 | { | ||
559 | const bool facetsIsVisible = SearchSettings::showFacetsWidget(); | 584 | const bool facetsIsVisible = SearchSettings::showFacetsWidget(); | ||
560 | m_facetsToggleButton->setChecked(facetsIsVisible ? true : false); | 585 | m_facetsToggleButton->setChecked(facetsIsVisible ? true : false); | ||
561 | m_facetsToggleButton->setIcon(QIcon::fromTheme(facetsIsVisible ? QStringLiteral("arrow-up-double") : QStringLiteral("arrow-down-double"))); | 586 | m_facetsToggleButton->setIcon(QIcon::fromTheme(facetsIsVisible ? QStringLiteral("arrow-up-double") : QStringLiteral("arrow-down-double"))); | ||
562 | m_facetsToggleButton->setText(facetsIsVisible ? i18nc("action:button", "Fewer Options") : i18nc("action:button", "More Options")); | 587 | m_facetsToggleButton->setText(facetsIsVisible ? i18nc("action:button", "Fewer Options") : i18nc("action:button", "More Options")); | ||
563 | } | 588 | } | ||
564 | 589 | |
Wouldn't it be better to use
to avoid the creation of the substrings?