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

#include <albert/globalqueryhandler.h>

Inheritance diagram for albert::GlobalQueryHandler:
[legend]
Collaboration 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. Implements TriggeredQueryHandler.

Note
Do not use this for long running tasks!

Public Member Functions

virtual std::vector< RankItemhandleGlobalQuery (const Query *)=0
 The query handling function.
 
virtual std::vector< std::shared_ptr< Item > > handleEmptyQuery (const Query *)
 The empty query handling function.
 
void applyUsageScore (std::vector< RankItem > *) const
 Takes rank items and modifies the score according to the users usage.
 
void handleTriggerQuery (Query *) override
 Implements pure virtual handleTriggerQuery(…).
 
- Public Member Functions inherited from albert::TriggerQueryHandler
virtual QString synopsis () 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.
 
- 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

◆ applyUsageScore()

void albert::GlobalQueryHandler::applyUsageScore ( std::vector< RankItem > *  ) const

Takes rank items and modifies the score according to the users usage.

Use this if you want to reuse your global results in the trigger handler.

◆ handleEmptyQuery()

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

The empty query handling function.

Empty patterns match everything. For triggered queries this is desired. For global queries it may quickly result in long running queries on show. Since a lot of global query handlers relay the handleTriggerQuery to handleGlobalQuery it is not possible to have both. This function allows extensions to handle empty global queries differently, while still yielding all items using the trigger handler.

◆ handleGlobalQuery()

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

The query handling function.

The match score should make sense and often (if not always) be the fraction matched chars (legth of query string / length of item title).

Returns
A list of match items. Empty query should return all items with a score of 0.
Note
Executed in a worker thread.

Implemented in albert::IndexQueryHandler.

◆ handleTriggerQuery()

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

Implements pure virtual handleTriggerQuery(…).

Calls handleGlobalQuery, applyUsageScore, sort and adds the items.

Note
Reimplement if the handler should have custom triggered behavior, but think twice if this is necessary. It may break user expectation.
See also
handleTriggerQuery and rankItems

Implements albert::TriggerQueryHandler.


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