Albert
Loading...
Searching...
No Matches
albert::IndexQueryHandler Class Referenceabstract

#include <albert/indexqueryhandler.h>

Description

Index-based global query handler.

Convenience base class for global query handlers backed by a precomputed index. Query execution is performed against the index and provides fast, deterministic matching suitable for the global search. Implementations are responsible for providing the indexed items and keeping the index up to date when the underlying data changes.

Inheritance diagram for albert::IndexQueryHandler:
[legend]

Public Member Functions

bool supportsFuzzyMatching () const override
 Returns true
 
void setFuzzyMatching (bool enabled) override
 Sets the fuzzy matching mode to enabled and triggers updateIndexItems().
 
std::vector< RankItemrankItems (QueryContext &context) override
 Returns a list of scored matches for context using the index.
 
virtual void updateIndexItems ()=0
 Updates the index.
 
void setIndexItems (std::vector< IndexItem > &&index_items)
 Sets the items of the index to index_items.
 
- Public Member Functions inherited from albert::GlobalQueryHandler
virtual std::vector< std::shared_ptr< Item > > handleEmptyQuery ()
 Returns a list of special items that should show up on an emtpy query.
 
- Public Member Functions inherited from albert::RankedQueryHandler
ItemGenerator items (QueryContext &context) override
 Yields result of rankItems for context usage scored and lazily sorted.
 
- Public Member Functions inherited from albert::QueryHandler
virtual QString synopsis (const QString &query) const
 Returns the input hint for the given query.
 
virtual bool allowTriggerRemap () const
 Returns true if the user is allowed to set a custom trigger, otherwise returns false.
 
virtual QString defaultTrigger () const
 Returns the default trigger.
 
- Public Member Functions inherited from albert::Extension
virtual QString id () const =0
 Returns the extension identifier.
 
virtual QString name () const =0
 Returns the pretty, human readable extension name.
 
virtual QString description () const =0
 Returns the brief extension description.
 

Protected Member Functions

 IndexQueryHandler ()
 Constructs an index query handler.
 
 ~IndexQueryHandler () override
 Destructs the index query handler.
 
- Protected Member Functions inherited from albert::GlobalQueryHandler
 ~GlobalQueryHandler () override
 Destructs the handler.
 
- Protected Member Functions inherited from albert::RankedQueryHandler
 ~RankedQueryHandler () override
 Destructs the handler.
 
- Protected Member Functions inherited from albert::GeneratorQueryHandler
 ~GeneratorQueryHandler () override
 Destructs the handler.
 
std::unique_ptr< QueryExecutionexecution (QueryContext &context) override
 Returns a threaded synchronous generator query execution for context.
 
- Protected Member Functions inherited from albert::QueryHandler
 ~QueryHandler () override
 Destructs the handler.
 
virtual void setTrigger (const QString &trigger)
 Notifies that the user-defined trigger has changed to trigger.
 
- Protected Member Functions inherited from albert::Extension
virtual ~Extension ()
 Destructs the extension.
 

Additional Inherited Members

- Static Public Member Functions inherited from albert::RankedQueryHandler
static ItemGenerator lazySort (std::vector< RankItem > rank_items)
 Yields rank_items lazily sorted.
 

Constructor & Destructor Documentation

◆ IndexQueryHandler()

albert::IndexQueryHandler::IndexQueryHandler ( )
protected

Constructs an index query handler.

◆ ~IndexQueryHandler()

albert::IndexQueryHandler::~IndexQueryHandler ( )
overrideprotected

Destructs the index query handler.

Member Function Documentation

◆ rankItems()

std::vector< RankItem > albert::IndexQueryHandler::rankItems ( QueryContext context)
overridevirtual

Returns a list of scored matches for context using the index.

Implements albert::RankedQueryHandler.

◆ setFuzzyMatching()

void albert::IndexQueryHandler::setFuzzyMatching ( bool  enabled)
overridevirtual

Sets the fuzzy matching mode to enabled and triggers updateIndexItems().

Reimplemented from albert::QueryHandler.

◆ setIndexItems()

void albert::IndexQueryHandler::setIndexItems ( std::vector< IndexItem > &&  index_items)

Sets the items of the index to index_items.

◆ supportsFuzzyMatching()

bool albert::IndexQueryHandler::supportsFuzzyMatching ( ) const
overridevirtual

Returns true

Reimplemented from albert::QueryHandler.

◆ updateIndexItems()

virtual void albert::IndexQueryHandler::updateIndexItems ( )
pure virtual

Updates the index.

Called when the index needs to be updated, i.e. for initialization, on user changes to the index config (fuzzy, etc…) and probably by the client itself if the items changed. This function should call setIndexItems to update the index.

Note
Do not call this method on plugin initialization. It will be called once loaded.

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