Changeset View
Changeset View
Standalone View
Standalone View
src/search/dolphinsearchbox.cpp
Show First 20 Lines • Show All 522 Lines • ▼ Show 20 Line(s) | 515 | #ifdef HAVE_BALOO | |||
---|---|---|---|---|---|
523 | if (!customDir.isEmpty()) { | 523 | if (!customDir.isEmpty()) { | ||
524 | setSearchPath(QUrl::fromLocalFile(customDir)); | 524 | setSearchPath(QUrl::fromLocalFile(customDir)); | ||
525 | } else { | 525 | } else { | ||
526 | setSearchPath(QUrl::fromLocalFile(QDir::homePath())); | 526 | setSearchPath(QUrl::fromLocalFile(QDir::homePath())); | ||
527 | } | 527 | } | ||
528 | 528 | | |||
529 | m_facetsWidget->resetOptions(); | 529 | m_facetsWidget->resetOptions(); | ||
530 | 530 | | |||
531 | setText(query.searchString()); | | |||
532 | | ||||
533 | QStringList types = query.types(); | 531 | QStringList types = query.types(); | ||
534 | if (!types.isEmpty()) { | 532 | if (!types.isEmpty()) { | ||
535 | m_facetsWidget->setFacetType(types.first()); | 533 | m_facetsWidget->setFacetType(types.first()); | ||
536 | } | 534 | } | ||
537 | 535 | | |||
536 | bool hasFileName = false; | ||||
537 | QStringList searchTextItems; | ||||
538 | | ||||
538 | const QStringList subTerms = query.searchString().split(' ', QString::SkipEmptyParts); | 539 | 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… | |||||
539 | foreach (const QString& subTerm, subTerms) { | 540 | foreach (const QString& subTerm, subTerms) { | ||
541 | QString value; | ||||
elvisangelaccio: Sorry, missed this one. | |||||
540 | if (subTerm.startsWith(QLatin1String("filename:"))) { | 542 | if (subTerm.startsWith(QLatin1String("filename:"))) { | ||
541 | const QString value = subTerm.mid(9); | 543 | hasFileName = true; | ||
542 | setText(value); | 544 | value = subTerm.mid(9); | ||
543 | } else if (m_facetsWidget->isRatingTerm(subTerm)) { | 545 | } else if (m_facetsWidget->isRatingTerm(subTerm)) { | ||
544 | m_facetsWidget->setRatingTerm(subTerm); | 546 | m_facetsWidget->setRatingTerm(subTerm); | ||
547 | continue; | ||||
548 | } else if (subTerm == QLatin1String("AND") && subTerm != subTerms.at(0) && subTerm != subTerms.back()) { | ||||
elvisangelaccio: Prefer `QLatin1String` for comparisons. | |||||
549 | continue; | ||||
550 | } else if (subTerm == QLatin1String("\"\"")) { | ||||
elvisangelaccio: Also here | |||||
551 | continue; | ||||
552 | } else { | ||||
553 | value = subTerm; | ||||
554 | } | ||||
555 | | ||||
556 | if (!value.isEmpty() && value.at(0) == QLatin1Char('"')) { | ||||
557 | value = value.mid(1); | ||||
558 | } | ||||
559 | if (!value.isEmpty() && value.back() == QLatin1Char('"')) { | ||||
560 | value = value.mid(0, value.size() - 1); | ||||
561 | } | ||||
562 | if (!value.isEmpty()) { | ||||
563 | searchTextItems << value; | ||||
545 | } | 564 | } | ||
546 | } | 565 | } | ||
547 | 566 | | |||
567 | setText(searchTextItems.join(QLatin1Char(' '))); | ||||
568 | | ||||
569 | if (hasFileName) { | ||||
570 | m_fileNameButton->setChecked(true); | ||||
571 | } else { | ||||
572 | m_contentButton->setChecked(true); | ||||
573 | } | ||||
574 | | ||||
548 | m_startSearchTimer->stop(); | 575 | m_startSearchTimer->stop(); | ||
549 | blockSignals(false); | 576 | blockSignals(false); | ||
550 | #else | 577 | #else | ||
chehrlic: QLatin1Char(' ') instead " " | |||||
551 | Q_UNUSED(url); | 578 | Q_UNUSED(url); | ||
552 | #endif | 579 | #endif | ||
553 | } | 580 | } | ||
554 | 581 | | |||
555 | void DolphinSearchBox::setFacetsVisible(bool visible) | 582 | void DolphinSearchBox::setFacetsVisible(bool visible) | ||
556 | { | 583 | { | ||
557 | const bool indexingEnabled = isIndexingEnabled(); | 584 | const bool indexingEnabled = isIndexingEnabled(); | ||
558 | m_facetsWidget->setEnabled(indexingEnabled); | 585 | m_facetsWidget->setEnabled(indexingEnabled); | ||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |
Wouldn't it be better to use
to avoid the creation of the substrings?