Changeset View
Changeset View
Standalone View
Standalone View
src/search/dolphinsearchbox.cpp
Show All 16 Lines | |||||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | ||
18 | * **************************************************************************/ | 18 | * **************************************************************************/ | ||
19 | 19 | | |||
20 | #include "global.h" | 20 | #include "global.h" | ||
21 | #include "dolphinsearchbox.h" | 21 | #include "dolphinsearchbox.h" | ||
22 | 22 | | |||
23 | #include "dolphin_searchsettings.h" | 23 | #include "dolphin_searchsettings.h" | ||
24 | #include "dolphinfacetswidget.h" | 24 | #include "dolphinfacetswidget.h" | ||
25 | #include "dolphinquery.h" | ||||
25 | #include "panels/places/placesitemmodel.h" | 26 | #include "panels/places/placesitemmodel.h" | ||
26 | 27 | | |||
27 | #include <KLocalizedString> | 28 | #include <KLocalizedString> | ||
28 | #include <KNS3/KMoreToolsMenuFactory> | 29 | #include <KNS3/KMoreToolsMenuFactory> | ||
29 | #include <KSeparator> | 30 | #include <KSeparator> | ||
30 | #include <config-baloo.h> | 31 | #include <config-baloo.h> | ||
31 | #ifdef HAVE_BALOO | 32 | #ifdef HAVE_BALOO | ||
32 | #include <Baloo/Query> | 33 | #include <Baloo/Query> | ||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Line(s) | 122 | { | |||
138 | } | 139 | } | ||
139 | 140 | | |||
140 | return url; | 141 | return url; | ||
141 | } | 142 | } | ||
142 | 143 | | |||
143 | void DolphinSearchBox::fromSearchUrl(const QUrl& url) | 144 | void DolphinSearchBox::fromSearchUrl(const QUrl& url) | ||
144 | { | 145 | { | ||
145 | if (url.scheme() == QLatin1String("baloosearch")) { | 146 | if (url.scheme() == QLatin1String("baloosearch")) { | ||
146 | fromBalooSearchUrl(url); | 147 | const DolphinQuery query = DolphinQuery::fromBalooSearchUrl(url); | ||
148 | updateFromQuery (query); | ||||
bruns: extra space | |||||
147 | } else if (url.scheme() == QLatin1String("filenamesearch")) { | 149 | } else if (url.scheme() == QLatin1String("filenamesearch")) { | ||
148 | const QUrlQuery query(url); | 150 | const QUrlQuery query(url); | ||
149 | setText(query.queryItemValue(QStringLiteral("search"))); | 151 | setText(query.queryItemValue(QStringLiteral("search"))); | ||
150 | if (m_searchPath.scheme() != url.scheme()) { | 152 | if (m_searchPath.scheme() != url.scheme()) { | ||
151 | m_searchPath = QUrl(); | 153 | m_searchPath = QUrl(); | ||
152 | } | 154 | } | ||
153 | setSearchPath(QUrl::fromUserInput(query.queryItemValue(QStringLiteral("url")), QString(), QUrl::AssumeLocalFile)); | 155 | setSearchPath(QUrl::fromUserInput(query.queryItemValue(QStringLiteral("url")), QString(), QUrl::AssumeLocalFile)); | ||
154 | m_contentButton->setChecked(query.queryItemValue(QStringLiteral("checkContent")) == QLatin1String("yes")); | 156 | m_contentButton->setChecked(query.queryItemValue(QStringLiteral("checkContent")) == QLatin1String("yes")); | ||
▲ Show 20 Lines • Show All 338 Lines • ▼ Show 20 Line(s) | 472 | #ifdef HAVE_BALOO | |||
493 | 495 | | |||
494 | return query.toSearchUrl(i18nc("@title UDS_DISPLAY_NAME for a KIO directory listing. %1 is the query the user entered.", | 496 | return query.toSearchUrl(i18nc("@title UDS_DISPLAY_NAME for a KIO directory listing. %1 is the query the user entered.", | ||
495 | "Query Results from '%1'", text)); | 497 | "Query Results from '%1'", text)); | ||
496 | #else | 498 | #else | ||
497 | return QUrl(); | 499 | return QUrl(); | ||
498 | #endif | 500 | #endif | ||
499 | } | 501 | } | ||
500 | 502 | | |||
501 | void DolphinSearchBox::fromBalooSearchUrl(const QUrl& url) | 503 | void DolphinSearchBox::updateFromQuery (const DolphinQuery& query) | ||
bruns: `const&` instead of `*`. | |||||
bruns: extra space | |||||
502 | { | 504 | { | ||
503 | #ifdef HAVE_BALOO | | |||
504 | const Baloo::Query query = Baloo::Query::fromSearchUrl(url); | | |||
505 | | ||||
506 | // Block all signals to avoid unnecessary "searchRequest" signals | 505 | // Block all signals to avoid unnecessary "searchRequest" signals | ||
507 | // while we adjust the search text and the facet widget. | 506 | // while we adjust the search text and the facet widget. | ||
508 | blockSignals(true); | 507 | blockSignals(true); | ||
509 | 508 | | |||
510 | const QString customDir = query.includeFolder(); | 509 | const QString customDir = query.includeFolder(); | ||
511 | if (!customDir.isEmpty()) { | 510 | if (!customDir.isEmpty()) { | ||
512 | setSearchPath(QUrl::fromLocalFile(customDir)); | 511 | setSearchPath(QUrl::fromLocalFile(customDir)); | ||
513 | } else { | 512 | } else { | ||
514 | setSearchPath(QUrl::fromLocalFile(QDir::homePath())); | 513 | setSearchPath(QUrl::fromLocalFile(QDir::homePath())); | ||
515 | } | 514 | } | ||
516 | 515 | | |||
517 | m_facetsWidget->resetOptions(); | 516 | setText(query.text()); | ||
518 | | ||||
519 | setText(query.searchString()); | | |||
520 | | ||||
521 | QStringList types = query.types(); | | |||
522 | if (!types.isEmpty()) { | | |||
523 | m_facetsWidget->setFacetType(types.first()); | | |||
524 | } | | |||
525 | 517 | | |||
526 | const QStringList subTerms = query.searchString().split(' ', QString::SkipEmptyParts); | 518 | m_facetsWidget->resetOptions(); | ||
527 | foreach (const QString& subTerm, subTerms) { | 519 | m_facetsWidget->setFacetType(query.type()); | ||
528 | if (subTerm.startsWith(QLatin1String("filename:"))) { | 520 | const QStringList searchTerms = query.searchTerms(); | ||
Please use qAsConst or put the container in const variable, otherwise it will detach. elvisangelaccio: Please use `qAsConst` or put the container in `const` variable, otherwise it will detach. | |||||
529 | const QString value = subTerm.mid(9); | 521 | for (const QString& searchTerm : searchTerms) { | ||
530 | setText(value); | 522 | m_facetsWidget->setRatingTerm(searchTerm); | ||
531 | } else if (m_facetsWidget->isRatingTerm(subTerm)) { | | |||
532 | m_facetsWidget->setRatingTerm(subTerm); | | |||
533 | } | | |||
534 | } | 523 | } | ||
535 | 524 | | |||
536 | m_startSearchTimer->stop(); | 525 | m_startSearchTimer->stop(); | ||
537 | blockSignals(false); | 526 | blockSignals(false); | ||
538 | #else | | |||
539 | Q_UNUSED(url) | | |||
540 | #endif | | |||
541 | } | 527 | } | ||
542 | 528 | | |||
543 | void DolphinSearchBox::updateFacetsVisible() | 529 | void DolphinSearchBox::updateFacetsVisible() | ||
544 | { | 530 | { | ||
545 | const bool indexingEnabled = isIndexingEnabled(); | 531 | const bool indexingEnabled = isIndexingEnabled(); | ||
546 | m_facetsWidget->setEnabled(indexingEnabled); | 532 | m_facetsWidget->setEnabled(indexingEnabled); | ||
547 | m_facetsWidget->setVisible(indexingEnabled); | 533 | m_facetsWidget->setVisible(indexingEnabled); | ||
548 | } | 534 | } | ||
Show All 10 Lines |
extra space