Global settings search: builds a ranked result list for a query. More...
#include <PhosphorControl/SearchController.h>
Signals | |
| void | queryChanged () |
| void | resultsChanged () |
| void | limitChanged () |
Public Member Functions | |
| SearchController (ApplicationController *app, QObject *parent=nullptr) | |
| ~SearchController () override | |
| QString | query () const |
| void | setQuery (const QString &q) |
| QVariantList | results () const |
| int | resultCount () const |
| QString | suggestion () const |
| int | limit () const |
| void | setLimit (int n) |
| Max results. n < 0 = uncapped; n == 0 = no results. | |
| void | setPageKeywords (const QString &pageId, const QStringList &keywords) |
| Sets the synonyms for the auto-derived page entry for pageId (the ranker weighs them alongside the page's title/breadcrumb). | |
| void | addEntry (const SearchEntry &entry) |
| A static section / setting anchor entry (or any extra entry). | |
| void | registerProvider (ISearchProvider *provider) |
| Register a dynamic content source. | |
| void | unregisterProvider (ISearchProvider *provider) |
Stop asking provider, and refresh the results of a live query. | |
| void | invalidate () |
| Mark the index stale; the next query (or the current one) rebuilds it. | |
| void | holdUpdates () |
| Hold back the rebuild a live query makes on every change, until the matching releaseUpdates(), which makes one rebuild when anything changed in between and the index was not rebuilt since. | |
| void | releaseUpdates () |
| End a holdUpdates(). | |
Global settings search: builds a ranked result list for a query.
Generic shell component — any settings app on PhosphorControl gets global search by wiring its content in:
QML binds query (the search field) and results (a ListView). Each result map carries title, subtitle, icon, kind, mode, pageId, anchor, address and actionId — selecting one calls SettingsController::navigateTo(address), except for Kind::Action results, which are dispatched by actionId instead. The index spans BOTH simple/advanced modes: mode (SearchEntry::Mode as an int — 0 both, 1 simple-only, 2 advanced-only) tags each result with where it lives, and the app's search UI is expected to badge mode-specific results and flip the mode before navigating to one the live mode does not show. suggestion holds a "did you mean …" title, populated only when a non-empty query yields zero results.
The index is built lazily and cached; invalidate() marks it stale (call when dynamic content changes) so the next query rebuilds it — no per-entry live signal wiring.
|
explicit |
|
override |
| void PhosphorControl::SearchController::addEntry | ( | const SearchEntry & | entry | ) |
A static section / setting anchor entry (or any extra entry).
| void PhosphorControl::SearchController::holdUpdates | ( | ) |
Hold back the rebuild a live query makes on every change, until the matching releaseUpdates(), which makes one rebuild when anything changed in between and the index was not rebuilt since.
Calls nest. For a run of changes that would otherwise rebuild the index once each, such as a module placing its pages and setting their keywords. setQuery() still answers at once, with every change made before it.
| void PhosphorControl::SearchController::invalidate | ( | ) |
Mark the index stale; the next query (or the current one) rebuilds it.
| int PhosphorControl::SearchController::limit | ( | ) | const |
|
signal |
| QString PhosphorControl::SearchController::query | ( | ) | const |
|
signal |
| void PhosphorControl::SearchController::registerProvider | ( | ISearchProvider * | provider | ) |
Register a dynamic content source.
Not owned: it must outlive this controller, or be taken out with unregisterProvider() before it goes.
| void PhosphorControl::SearchController::releaseUpdates | ( | ) |
End a holdUpdates().
One without a matching hold is ignored with a warning.
| int PhosphorControl::SearchController::resultCount | ( | ) | const |
| QVariantList PhosphorControl::SearchController::results | ( | ) | const |
|
signal |
| void PhosphorControl::SearchController::setLimit | ( | int | n | ) |
Max results. n < 0 = uncapped; n == 0 = no results.
| void PhosphorControl::SearchController::setPageKeywords | ( | const QString & | pageId, |
| const QStringList & | keywords ) |
Sets the synonyms for the auto-derived page entry for pageId (the ranker weighs them alongside the page's title/breadcrumb).
Replaces any list previously set for this pageId — successive calls do not accumulate.
| void PhosphorControl::SearchController::setQuery | ( | const QString & | q | ) |
| QString PhosphorControl::SearchController::suggestion | ( | ) | const |
| void PhosphorControl::SearchController::unregisterProvider | ( | ISearchProvider * | provider | ) |
Stop asking provider, and refresh the results of a live query.
For a provider that goes before this controller does. Nothing happens for one that is not registered.