Version: 9.15.0
SUIT_ActionSearcher Class Reference

Searches in data, provided in action asset files and shortcut preferences. More...

#include <SUIT_ShortcutMgr.h>

Classes

class  AssetsAndSearchData
 

Public Types

enum  MatchField { ID , Name , ToolTip , KeySequence }
 

Public Member Functions

 SUIT_ActionSearcher ()
 
 SUIT_ActionSearcher (const SUIT_ActionSearcher &)=delete
 
SUIT_ActionSearcheroperator= (const SUIT_ActionSearcher &)=delete
 
virtual ~SUIT_ActionSearcher ()
 
bool setIncludedModuleIDs (std::set< QString > theIncludedModuleIDs, bool doNotUpdateResults=false)
 
bool includeDisabledActions (bool theOn, bool doNotUpdateResults=false)
 
bool areDisabledActionsIncluded () const
 
bool setFieldsToMatch (const std::set< SUIT_ActionSearcher::MatchField > &theFields, bool doNotUpdateResults=false)
 
std::pair< bool, bool > setKeySequenceGetter (const std::function< QString(const QString &, const QString &)> &theKeySequenceGetter=std::function< QString(const QString &, const QString &)>(), bool doNotUpdateResults=false)
 
bool setCaseSensitive (bool theOn, bool doNotUpdateResults=false)
 
bool setQuery (const QString &theQuery)
 
const QString & getQuery () const
 
const std::map< QString, std::map< QString, SUIT_ActionSearcher::AssetsAndSearchData > > & getSearchResults () const
 

Static Public Member Functions

static double matchKeySequenceString (const QString &theQuery, const QString &theKeySequence)
 

Private Member Functions

std::pair< bool, bool > filter ()
 Applies filter to all actions, provided in asset files for SUIT_ShortcutMgr. More...
 
std::pair< bool, bool > filterResults ()
 Applies filter to search results only. More...
 
bool extendResults ()
 Applies filter only to actions, which are not in search results. More...
 
double matchAction (const SUIT_ShortcutItemAssets &theAssets)
 
QString toString () const
 

Private Attributes

std::set< QString > myIncludedModuleIDs
 
bool myIncludeDisabledActions
 
std::set< SUIT_ActionSearcher::MatchFieldmyFieldsToMatch
 
::SUIT_tools::SUIT_SentenceMatchermyMatcher
 
std::function< QString(const QString &, const QString &)> myKeySequenceGetter
 
std::map< QString, std::map< QString, SUIT_ActionSearcher::AssetsAndSearchData > > mySearchResults
 

Detailed Description

Searches in data, provided in action asset files and shortcut preferences.

Member Enumeration Documentation

◆ MatchField

Enumerator
ID 
Name 
ToolTip 
KeySequence 

Constructor & Destructor Documentation

◆ SUIT_ActionSearcher() [1/2]

SUIT_ActionSearcher::SUIT_ActionSearcher ( )

Default config: Included modules' IDs = { ROOT_MODULE_ID }; Include disabled actions = false; Fields to match = { Name, Tooltip }; Case sensitive = false; Fuzzy matching = true; Query = ""; // matches nothing.

References SUIT_ShortcutMgr::get(), SUIT_ShortcutMgr::getKeySequence(), myFieldsToMatch, myIncludeDisabledActions, myIncludedModuleIDs, myKeySequenceGetter, myMatcher, SUIT_ShortcutMgr::ROOT_MODULE_ID, SUIT_tools::SUIT_SentenceMatcher::setCaseSensitive(), SUIT_tools::SUIT_SentenceMatcher::setUseExactWordOrder(), and SUIT_tools::SUIT_SentenceMatcher::setUseFuzzyWords().

◆ SUIT_ActionSearcher() [2/2]

SUIT_ActionSearcher::SUIT_ActionSearcher ( const SUIT_ActionSearcher )
delete

◆ ~SUIT_ActionSearcher()

SUIT_ActionSearcher::~SUIT_ActionSearcher ( )
virtual

References myMatcher.

Member Function Documentation

◆ areDisabledActionsIncluded()

bool SUIT_ActionSearcher::areDisabledActionsIncluded ( ) const
inline

◆ extendResults()

bool SUIT_ActionSearcher::extendResults ( )
private

Applies filter only to actions, which are not in search results.

Returns
True, if set of results is extended.

References SUIT_ShortcutMgr::get(), matchAction(), myIncludedModuleIDs, mySearchResults, ShCutDbg(), and TOKEN_SEPARATOR.

◆ filter()

std::pair< bool, bool > SUIT_ActionSearcher::filter ( )
private

Applies filter to all actions, provided in asset files for SUIT_ShortcutMgr.

Returns
{ true, _ } if set of results is changed; { _ , true } if matching metrics is changed for at least one result.

References SUIT_ShortcutMgr::get(), matchAction(), SUIT_ActionSearcher::AssetsAndSearchData::matchMetrics(), SUIT_ActionSearcher::AssetsAndSearchData::myAssets, myIncludedModuleIDs, mySearchResults, SUIT_ActionSearcher::AssetsAndSearchData::setMatchMetrics(), and ShCutDbg().

◆ filterResults()

std::pair< bool, bool > SUIT_ActionSearcher::filterResults ( )
private

Applies filter to search results only.

Returns
{ true, _ } if set of results is shrunk; { _ , true } if matching metrics is changed for at least one result.

References matchAction(), SUIT_ActionSearcher::AssetsAndSearchData::matchMetrics(), SUIT_ActionSearcher::AssetsAndSearchData::myAssets, mySearchResults, and SUIT_ActionSearcher::AssetsAndSearchData::setMatchMetrics().

◆ getQuery()

const QString & SUIT_ActionSearcher::getQuery ( ) const
inline

◆ getSearchResults()

const std::map< QString, std::map< QString, SUIT_ActionSearcher::AssetsAndSearchData > > & SUIT_ActionSearcher::getSearchResults ( ) const

References mySearchResults.

◆ includeDisabledActions()

bool SUIT_ActionSearcher::includeDisabledActions ( bool  theOn,
bool  doNotUpdateResults = false 
)
Returns
true, if set of results is changed.
Parameters
doNotUpdateResultsSet to true to initialize the instance without unnececessary computations.

References extendResults(), filterResults(), myIncludeDisabledActions, ShCutDbg(), and toString().

◆ matchAction()

◆ matchKeySequenceString()

double SUIT_ActionSearcher::matchKeySequenceString ( const QString &  theQuery,
const QString &  theKeySequence 
)
static

◆ operator=()

SUIT_ActionSearcher& SUIT_ActionSearcher::operator= ( const SUIT_ActionSearcher )
delete

◆ setCaseSensitive()

bool SUIT_ActionSearcher::setCaseSensitive ( bool  theOn,
bool  doNotUpdateResults = false 
)
Returns
true, if set of results is changed.
Parameters
doNotUpdateResultsSet to true to initialize the instance without unnececessary computations.

References extendResults(), filterResults(), SUIT_tools::SUIT_SentenceMatcher::isCaseSensitive(), myMatcher, SUIT_tools::SUIT_SentenceMatcher::setCaseSensitive(), ShCutDbg(), and toString().

◆ setFieldsToMatch()

bool SUIT_ActionSearcher::setFieldsToMatch ( const std::set< SUIT_ActionSearcher::MatchField > &  theFields,
bool  doNotUpdateResults = false 
)
Returns
true, if set of results is changed.
Parameters
doNotUpdateResultsSet to true to initialize the instance without unnececessary computations.

References extendResults(), filter(), filterResults(), myFieldsToMatch, mySearchResults, ShCutDbg(), and toString().

◆ setIncludedModuleIDs()

bool SUIT_ActionSearcher::setIncludedModuleIDs ( std::set< QString >  theIncludedModuleIDs,
bool  doNotUpdateResults = false 
)
Returns
true, if set of results is changed.
Parameters
doNotUpdateResultsSet to true to initialize the instance without unnececessary computations.

References SUIT_ShortcutMgr::get(), SUIT_ShortcutMgr::getModuleAssets(), matchAction(), myIncludedModuleIDs, mySearchResults, ShCutDbg(), and toString().

◆ setKeySequenceGetter()

std::pair< bool, bool > SUIT_ActionSearcher::setKeySequenceGetter ( const std::function< QString(const QString &, const QString &)> &  theKeySequenceGetter = std::function<QString(const QString&, const QString&)>(),
bool  doNotUpdateResults = false 
)
Returns
{ true, _ } if set of results is changed; { _ , true } if matching metrics is changed for at least one result.
Parameters
theKeySequenceGettergetKeySequence(theModuleID, theInModuleActionID). If empty, a default getter, retrieving key sequence from ShortcutMgr, is set.
doNotUpdateResultsSet to true to initialize the instance without unnececessary computations.

References filter(), SUIT_ShortcutMgr::get(), SUIT_ShortcutMgr::getKeySequence(), and myKeySequenceGetter.

◆ setQuery()

bool SUIT_ActionSearcher::setQuery ( const QString &  theQuery)

◆ toString()

QString SUIT_ActionSearcher::toString ( ) const
private

Member Data Documentation

◆ myFieldsToMatch

std::set<SUIT_ActionSearcher::MatchField> SUIT_ActionSearcher::myFieldsToMatch
private

◆ myIncludeDisabledActions

bool SUIT_ActionSearcher::myIncludeDisabledActions
private

◆ myIncludedModuleIDs

std::set<QString> SUIT_ActionSearcher::myIncludedModuleIDs
private

◆ myKeySequenceGetter

std::function<QString(const QString&, const QString&)> SUIT_ActionSearcher::myKeySequenceGetter
private

◆ myMatcher

::SUIT_tools::SUIT_SentenceMatcher* SUIT_ActionSearcher::myMatcher
private

◆ mySearchResults

std::map<QString, std::map<QString, SUIT_ActionSearcher::AssetsAndSearchData> > SUIT_ActionSearcher::mySearchResults
private

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