Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PhosphorControl::SearchController Class Reference

Global settings search: builds a ranked result list for a query. More...

#include <PhosphorControl/SearchController.h>

Inheritance diagram for PhosphorControl::SearchController:
[legend]

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().

Detailed Description

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.

Constructor & Destructor Documentation

◆ SearchController()

PhosphorControl::SearchController::SearchController ( ApplicationController * app,
QObject * parent = nullptr )
explicit

◆ ~SearchController()

PhosphorControl::SearchController::~SearchController ( )
override

Member Function Documentation

◆ addEntry()

void PhosphorControl::SearchController::addEntry ( const SearchEntry & entry)

A static section / setting anchor entry (or any extra entry).

◆ holdUpdates()

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.

◆ invalidate()

void PhosphorControl::SearchController::invalidate ( )

Mark the index stale; the next query (or the current one) rebuilds it.

◆ limit()

int PhosphorControl::SearchController::limit ( ) const

◆ limitChanged

void PhosphorControl::SearchController::limitChanged ( )
signal

◆ query()

QString PhosphorControl::SearchController::query ( ) const

◆ queryChanged

void PhosphorControl::SearchController::queryChanged ( )
signal

◆ registerProvider()

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.

◆ releaseUpdates()

void PhosphorControl::SearchController::releaseUpdates ( )

End a holdUpdates().

One without a matching hold is ignored with a warning.

◆ resultCount()

int PhosphorControl::SearchController::resultCount ( ) const

◆ results()

QVariantList PhosphorControl::SearchController::results ( ) const

◆ resultsChanged

void PhosphorControl::SearchController::resultsChanged ( )
signal

◆ setLimit()

void PhosphorControl::SearchController::setLimit ( int n)

Max results. n < 0 = uncapped; n == 0 = no results.

◆ setPageKeywords()

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.

◆ setQuery()

void PhosphorControl::SearchController::setQuery ( const QString & q)

◆ suggestion()

QString PhosphorControl::SearchController::suggestion ( ) const

◆ unregisterProvider()

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.


The documentation for this class was generated from the following file: