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

#include <albert/globalqueryhandler.h>

Inheritance diagram for albert::GlobalQueryHandler:
[legend]

Detailed Description

Abstract global query handler.

A functional query handler returning scored items. Applicable for the global search. Use this if you want your results show up in the global search.

By design choice every global query handler should also provide a trigger handler. To enforce this GlobalQueryHandler inherits TriggerQueryHandler and implements the TriggerQueryHandler::handleTriggerQuery.

Note
Do not use this for long running tasks!

Public Member Functions

virtual std::vector< RankItemhandleGlobalQuery (const Query &query)=0
 Returns a list of items matching the query or all items if the query is empty.
 
virtual std::vector< std::shared_ptr< Item > > handleEmptyQuery ()
 Returns a list of special items that should show up on an emtpy query.
 
void handleTriggerQuery (Query &query) override
 Calls handleGlobalQuery, applyUsageScore, sorts and adds the items to query.
 
- Public Member Functions inherited from albert::TriggerQueryHandler
virtual QString synopsis (const QString &query) const
 The synopsis, displayed on empty query.
 
virtual bool allowTriggerRemap () const
 Enable user remapping of the trigger.
 
virtual QString defaultTrigger () const
 The default (not user defined) trigger.
 
virtual void setTrigger (const QString &)
 Setter for the user defined trigger.
 
virtual bool supportsFuzzyMatching () const
 Fuzzy matching capability.
 
virtual void setFuzzyMatching (bool enabled)
 Fuzzy matching behavior.
 
void applyUsageScore (std::vector< RankItem > &rank_items)
 Modifies the score of rank_items to reflect the users usage history.
 
- Public Member Functions inherited from albert::Extension
virtual QString id () const =0
 The identifier of this extension.
 
virtual QString name () const =0
 Pretty, human readable name.
 
virtual QString description () const =0
 Brief description of this extension.
 

Protected Member Functions

 ~GlobalQueryHandler () override
 
- Protected Member Functions inherited from albert::TriggerQueryHandler
 ~TriggerQueryHandler () override
 
- Protected Member Functions inherited from albert::Extension
virtual ~Extension ()
 

Constructor & Destructor Documentation

◆ ~GlobalQueryHandler()

albert::GlobalQueryHandler::~GlobalQueryHandler ( )
overrideprotected

Member Function Documentation

◆ handleEmptyQuery()

virtual std::vector< std::shared_ptr< Item > > albert::GlobalQueryHandler::handleEmptyQuery ( )
virtual

Returns a list of special items that should show up on an emtpy query.

Empty patterns match everything. For triggered queries this is desired and by design lots of handlers relay the handleTriggerQuery to handleGlobalQuery. For global queries this leads to an expensive query execution on empty queries. Therefore the empty global query is not executed. This function allows dedicated empty global query handling.

◆ handleGlobalQuery()

virtual std::vector< RankItem > albert::GlobalQueryHandler::handleGlobalQuery ( const Query query)
pure virtual

Returns a list of items matching the query or all items if the query is empty.

The match score should make sense and often (if not always) be the fraction of matched chars (legth of query string / length of item title). The empty query should return all items with a score of 0.

Note
Executed in a worker thread.

Implemented in albert::util::IndexQueryHandler.

◆ handleTriggerQuery()

void albert::GlobalQueryHandler::handleTriggerQuery ( Query query)
overridevirtual

Calls handleGlobalQuery, applyUsageScore, sorts and adds the items to query.

Note
Reimplement if the handler should have custom triggered behavior. Think twice though, it may break user expectation.

Implements albert::TriggerQueryHandler.


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