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

#include <albert/rankedqueryhandler.h>

Description

Usage-ranked query handler.

Convenience base class for triggered query handlers that return a complete set of match-scored items eagerly. rankItems is executed in a worker thread, allowing CPU-bound work without blocking the main thread. The provided match scores will be combined with the usage-based scoring weighted by user configuration. Finally the items will be yielded lazily in order of their final score.

Inheritance diagram for albert::RankedQueryHandler:
[legend]

Public Member Functions

virtual std::vector< RankItemrankItems (QueryContext &context)=0
 Returns a list of scored matches for context.
 
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.
 
virtual bool supportsFuzzyMatching () const
 Returns true if the handler supports fuzzy matching, otherwise returns false.
 
- 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.
 

Static Public Member Functions

static ItemGenerator lazySort (std::vector< RankItem > rank_items)
 Yields rank_items lazily sorted.
 

Protected Member Functions

 ~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 setFuzzyMatching (bool enabled)
 Sets the fuzzy matching mode to enabled.
 
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.
 

Constructor & Destructor Documentation

◆ ~RankedQueryHandler()

albert::RankedQueryHandler::~RankedQueryHandler ( )
overrideprotected

Destructs the handler.

Member Function Documentation

◆ items()

ItemGenerator albert::RankedQueryHandler::items ( QueryContext context)
overridevirtual

Yields result of rankItems for context usage scored and lazily sorted.

Implements albert::GeneratorQueryHandler.

◆ lazySort()

static ItemGenerator albert::RankedQueryHandler::lazySort ( std::vector< RankItem rank_items)
static

Yields rank_items lazily sorted.

◆ rankItems()

virtual std::vector< RankItem > albert::RankedQueryHandler::rankItems ( QueryContext context)
pure virtual

Returns a list of scored matches for context.

The match score should make sense and often is the fraction of matched characters (legth of query string / length of matched string). The empty pattern matches everything and returns all items with a score of 0.

Note
Executed in a background thread.

Implemented in albert::IndexQueryHandler.


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