Version: 9.15.0
SUIT_ShortcutContainer Class Reference

Provides means to keep and edit shortcuts in compliance with the application logics. See SUIT_ShortcutMgr for details. More...

#include <SUIT_ShortcutMgr.h>

Public Member Functions

 SUIT_ShortcutContainer ()
 Uncomment this to enable DevTools. More...
 
std::set< QString > getIDsOfInterferingModules (const QString &theModuleID) const
 
std::set< QString > getIDsOfAllModules () const
 
bool isEmpty () const
 
std::set< std::pair< QString, QString > > setShortcut (QString theModuleID, const QString &theInModuleActionID, const QKeySequence &theKeySequence, bool theOverride)
 Checks for conflicts. If theOverride, modifies incoming and disables all conflicting shortcuts. Redefining a key sequence for the action, if theKeySequence does not conflict with other shortcuts, is not considered as a conflict. More...
 
std::set< std::pair< QString, QString > > getConflicts (QString theModuleID, const QString &theInModuleActionID, const QKeySequence &theKeySequence) const
 Checks for conflicts. Existence of a shortcut with another key sequence for the action, if theKeySequence does not conflict with other shortcuts, is not considered as a conflict. More...
 
const QKeySequence & getKeySequence (QString theModuleID, const QString &theInModuleActionID) const
 
bool hasShortcut (QString theModuleID, const QString &theInModuleActionID) const
 
const std::map< QString, QKeySequence > & getModuleShortcutsInversed (const QString &theModuleID) const
 
const std::map< QString, QKeySequence > getModuleShortcutsInversed (const QString &theModuleID, const QString &theInModuleActionIDPrefix) const
 Seeks for shortcuts in the module with in-module action IDs, which start with theInModuleActionIDPrefix. More...
 
std::map< QString, std::map< QString, std::pair< QKeySequence, QKeySequence > > > merge (const SUIT_ShortcutContainer &theOther, bool theOverride, bool theTreatAbsentIncomingAsDisabled=false)
 Merges shortcuts of theOther into this. More...
 
bool hasKeySequence (const QString &theModuleID, const QKeySequence &theKeySequence) const
 
QString toString () const
 Generates human-readable text representation of content. More...
 

Private Attributes

std::map< QString, std::map< QKeySequence, QString > > myShortcuts
 { moduleID, { keySequence, inModuleActionID }[] }[]. More...
 
std::map< QString, std::map< QString, QKeySequence > > myShortcutsInversed
 { moduleID, { inModuleActionID, keySequence }[] }[]. More...
 

Detailed Description

Provides means to keep and edit shortcuts in compliance with the application logics. See SUIT_ShortcutMgr for details.

Constructor & Destructor Documentation

◆ SUIT_ShortcutContainer()

SUIT_ShortcutContainer::SUIT_ShortcutContainer ( )

Uncomment this to enable DevTools.

References myShortcuts, myShortcutsInversed, and SUIT_ShortcutMgr::ROOT_MODULE_ID.

Member Function Documentation

◆ getConflicts()

std::set< std::pair< QString, QString > > SUIT_ShortcutContainer::getConflicts ( QString  theModuleID,
const QString &  theInModuleActionID,
const QKeySequence &  theKeySequence 
) const

Checks for conflicts. Existence of a shortcut with another key sequence for the action, if theKeySequence does not conflict with other shortcuts, is not considered as a conflict.

Parameters
theInModuleActionIDIf theInModuleActionID is meta-action ID, the shortcut is looked for in root module, and theModuleID is ignored.
theKeySequenceEmpty theKeySequence does not have conflicts.
Returns
{moduleID, inModuleActionID}[] - Set of conflicting actions.

References getIDsOfInterferingModules(), SUIT_ShortcutMgr::isInModuleMetaActionID(), myShortcuts, and SUIT_ShortcutMgr::ROOT_MODULE_ID.

◆ getIDsOfAllModules()

std::set< QString > SUIT_ShortcutContainer::getIDsOfAllModules ( ) const

References myShortcutsInversed.

◆ getIDsOfInterferingModules()

std::set< QString > SUIT_ShortcutContainer::getIDsOfInterferingModules ( const QString &  theModuleID) const
Returns
IDs of modules, which interfere with the module: if the module is root (theModuleID is empty) - returns all module IDs, otherwise returns ["", theModuleID].

References myShortcuts, and SUIT_ShortcutMgr::ROOT_MODULE_ID.

◆ getKeySequence()

const QKeySequence & SUIT_ShortcutContainer::getKeySequence ( QString  theModuleID,
const QString &  theInModuleActionID 
) const
Returns
empty key sequence if shortcut for the action is not set.
Parameters
theInModuleActionIDIf theInModuleActionID is meta-action ID, seeks in root module, and theModuleID is ignored.

References SUIT_ShortcutMgr::isInModuleMetaActionID(), myShortcutsInversed, NO_KEYSEQUENCE, and SUIT_ShortcutMgr::ROOT_MODULE_ID.

◆ getModuleShortcutsInversed() [1/2]

const std::map< QString, QKeySequence > & SUIT_ShortcutContainer::getModuleShortcutsInversed ( const QString &  theModuleID) const
Returns
{inModuleActionID, keySequence}[] - If the module was not added, the map is empty.

References myShortcutsInversed.

◆ getModuleShortcutsInversed() [2/2]

const std::map< QString, QKeySequence > SUIT_ShortcutContainer::getModuleShortcutsInversed ( const QString &  theModuleID,
const QString &  theInModuleActionIDPrefix 
) const

Seeks for shortcuts in the module with in-module action IDs, which start with theInModuleActionIDPrefix.

Returns
{inModuleActionID, keySequence}[] - If the module was not added, the map is empty.

References myShortcutsInversed.

◆ hasKeySequence()

bool SUIT_ShortcutContainer::hasKeySequence ( const QString &  theModuleID,
const QKeySequence &  theKeySequence 
) const

References myShortcuts.

◆ hasShortcut()

bool SUIT_ShortcutContainer::hasShortcut ( QString  theModuleID,
const QString &  theInModuleActionID 
) const
Returns
true, if shortcut for the action is set (even if the mapped key sequence is empty).
Parameters
theInModuleActionIDIf theInModuleActionID is meta-action ID, seeks in root module, and theModuleID is ignored.

References SUIT_ShortcutMgr::isInModuleMetaActionID(), myShortcutsInversed, and SUIT_ShortcutMgr::ROOT_MODULE_ID.

◆ isEmpty()

bool SUIT_ShortcutContainer::isEmpty ( ) const
Returns
True, if no shortcut is added.

References myShortcutsInversed.

◆ merge()

std::map< QString, std::map< QString, std::pair< QKeySequence, QKeySequence > > > SUIT_ShortcutContainer::merge ( const SUIT_ShortcutContainer theOther,
bool  theOverride,
bool  theTreatAbsentIncomingAsDisabled = false 
)

Merges shortcuts of theOther into this.

Parameters
theOverrideif true, overrides conflicting shortcuts. If false, and this has no shortcut for an incoming action, and the incoming shortcut conflicts with an existing shortcut, disabled shortcut for the incoming action is set.
theTreatAbsentIncomingAsDisabledIf theOverride == false, theTreatAbsentIncomingAsDisabled is ignored. If theOverride and theTreatAbsentIncomingAsDisabled, and theOther has no shortcut for an action, which exists in this, the existing shortcut in this is set disabled.
Returns
{ moduleID, { inModuleActionID, {oldKeySequence, newKeySequence} }[] }[] - Modiified shortcuts inversed.

References getKeySequence(), hasShortcut(), myShortcuts, myShortcutsInversed, NO_KEYSEQUENCE, and setShortcut().

◆ setShortcut()

std::set< std::pair< QString, QString > > SUIT_ShortcutContainer::setShortcut ( QString  theModuleID,
const QString &  theInModuleActionID,
const QKeySequence &  theKeySequence,
bool  theOverride 
)

Checks for conflicts. If theOverride, modifies incoming and disables all conflicting shortcuts. Redefining a key sequence for the action, if theKeySequence does not conflict with other shortcuts, is not considered as a conflict.

Parameters
theModuleIDThe method has no effect if theModuleID is invalid. See SUIT_ShortcutMgr::isModuleIDValid(const QString&) for details.
theInModuleActionIDThe method has no effect if theInModuleActionID is invalid. See SUIT_ShortcutMgr::isInModuleActionIDValid(const QString&). If theInModuleActionID is meta-action ID, the shortcut is set to root module, and theModuleID is ignored.
theKeySequenceEmpty theKeySequence does not cause conflicts, in this case a shortcut for the action is disabled: theInModuleActionID is added/retained in the container but mapped to empty key sequence.
theOverrideIf true, conflicting shortcuts are disabled.
Returns
{moduleID, inModuleActionID}[] - Set of conflicting actions if theOverride = false, otherwise set of actions (without incoming one), whose shortcuts have been disabled.

References getIDsOfInterferingModules(), SUIT_ShortcutMgr::isInModuleActionIDValid(), SUIT_ShortcutMgr::isInModuleMetaActionID(), SUIT_ShortcutMgr::isModuleIDValid(), myShortcuts, myShortcutsInversed, NO_KEYSEQUENCE, SUIT_ShortcutMgr::ROOT_MODULE_ID, and ShCutDbg().

◆ toString()

QString SUIT_ShortcutContainer::toString ( ) const

Generates human-readable text representation of content.

References myShortcuts, and myShortcutsInversed.

Member Data Documentation

◆ myShortcuts

std::map<QString, std::map<QKeySequence, QString> > SUIT_ShortcutContainer::myShortcuts
private

{ moduleID, { keySequence, inModuleActionID }[] }[].

keySequence can not be empty. Can not contain entries like { <non-root module ID>, { keySequence, <meta-action ID> } }.

◆ myShortcutsInversed

std::map<QString, std::map<QString, QKeySequence> > SUIT_ShortcutContainer::myShortcutsInversed
private

{ moduleID, { inModuleActionID, keySequence }[] }[].

keySequence can be empty. Can not contain entries like { <non-root module ID>, { <meta-action ID>, keySequence } }.


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