Version: 9.15.0
SUIT_ShortcutAssets Class Referenceabstract

Base class for GUI-related assets of module, action or folder. Used by Shortcut Manager, Find Action Dialog, etc. More...

#include <SUIT_ShortcutMgr.h>

Inheritance diagram for SUIT_ShortcutAssets:
Inheritance graph

Classes

struct  LangDependentAssets
 

Public Types

enum class  Type { Module , Item }
 

Public Member Functions

virtual ~SUIT_ShortcutAssets ()=0
 
const std::map< QString, std::shared_ptr< SUIT_ShortcutItemAssets > > & children () const
 
std::shared_ptr< SUIT_ShortcutItemAssetsfindDescendantItem (const QString &theRelativeID) const
 
std::shared_ptr< SUIT_ShortcutItemAssetsdescendantItem (const QString &theRelativeID, bool theIsAction=true)
 
virtual int depth () const =0
 
virtual SUIT_ShortcutAssets::Type type () const =0
 
bool fromJSON (const QJsonObject &theJsonObject, bool theParseDescendants=true, const std::set< QString > &theLangs={})
 
bool fromJSON (const QJsonObject &theJsonObject, const QString &theRelativeID, const std::set< QString > &theLangs={})
 Parses only the branch of descdendants, which leads to the item with theRelativeID. More...
 
void toJSON (QJsonObject &oJsonObject) const
 
virtual void merge (const SUIT_ShortcutAssets &theOther, bool theOverride)
 
virtual void merge (SUIT_ShortcutAssets &&theOther, bool theOverride)
 
void loadIcon (bool theReload=false)
 
void forEachDescendant (const std::function< void(SUIT_ShortcutItemAssets &)> &theFunc) const
 Iterates all descendants. *this is not iterated. More...
 
void forEachDescendant (const std::function< void(const SUIT_ShortcutItemAssets &)> &theFunc) const
 Iterates all descendants. *this is not iterated. More...
 
void forEachDescendant (const std::function< void(std::shared_ptr< SUIT_ShortcutItemAssets >)> &theFunc) const
 Iterates all descendants. *this is not iterated. More...
 
void forEachDescendant (const std::function< void(std::shared_ptr< const SUIT_ShortcutItemAssets >)> &theFunc) const
 Iterates all descendants. *this is not iterated. More...
 
QString toString () const
 
virtual QString description () const =0
 
QStringList getLangs () const
 
void clearAllLangsExcept (const QString &theLang)
 
const LangDependentAssetsbestLangDependentAssets (QString theLang=QString()) const
 
virtual const QString & bestName (const QString &theLang=QString()) const =0
 
virtual const QString & bestToolTip (const QString &theLang=QString()) const
 

Public Attributes

const QString myModuleID
 
std::map< QString, LangDependentAssetsmyLangDependentAssets
 
QString myIconPath
 
QIcon myIcon
 

Static Public Attributes

static const QString PROP_ID_LANG_DEPENDENT_ASSETS = "langDependentAssets"
 
static const QString PROP_ID_ICON_PATH = "iconPath"
 
static const QString PROP_ID_CHILDREN = "children"
 

Protected Member Functions

 SUIT_ShortcutAssets (const QString &theModuleID)
 

Private Member Functions

bool fromJSONOwnProps (const QJsonObject &theJsonObject, const std::set< QString > &theLangs={})
 Parses everything, except children. More...
 
virtual bool fromJSONOtherProps (const QJsonObject &theJsonObject)
 Parses properties of SUIT_ShortcutAssets subclasses. More...
 
virtual void toJSONVirtual (QJsonObject &oJsonObject) const
 

Private Attributes

std::map< QString, std::shared_ptr< SUIT_ShortcutItemAssets > > myChildren
 

Detailed Description

Base class for GUI-related assets of module, action or folder. Used by Shortcut Manager, Find Action Dialog, etc.

Member Enumeration Documentation

◆ Type

Enumerator
Module 
Item 

Constructor & Destructor Documentation

◆ SUIT_ShortcutAssets()

SUIT_ShortcutAssets::SUIT_ShortcutAssets ( const QString &  theModuleID)
protected

◆ ~SUIT_ShortcutAssets()

SUIT_ShortcutAssets::~SUIT_ShortcutAssets ( )
pure virtual

Member Function Documentation

◆ bestLangDependentAssets()

const SUIT_ShortcutAssets::LangDependentAssets * SUIT_ShortcutAssets::bestLangDependentAssets ( QString  theLang = QString()) const
Parameters
theLangIf empty, current language is requested.
Returns
Requested assets or assets in EN, if requested language is absent.

References SUIT_ShortcutMgr::currentLang(), DEFAULT_LANG, and myLangDependentAssets.

◆ bestName()

virtual const QString& SUIT_ShortcutAssets::bestName ( const QString &  theLang = QString()) const
pure virtual

◆ bestToolTip()

const QString & SUIT_ShortcutAssets::bestToolTip ( const QString &  theLang = QString()) const
virtual
Parameters
theLangIf empty, current language is requested.
Returns
Requested tool tip or tool tip in EN, if requested language is absent. If EN is absent - empty string.

References bestLangDependentAssets().

◆ children()

const std::map< QString, std::shared_ptr< SUIT_ShortcutItemAssets > > & SUIT_ShortcutAssets::children ( ) const

References myChildren.

◆ clearAllLangsExcept()

void SUIT_ShortcutAssets::clearAllLangsExcept ( const QString &  theLang)

References myLangDependentAssets.

◆ depth()

virtual int SUIT_ShortcutAssets::depth ( ) const
pure virtual

◆ descendantItem()

std::shared_ptr< SUIT_ShortcutItemAssets > SUIT_ShortcutAssets::descendantItem ( const QString &  theRelativeID,
bool  theIsAction = true 
)
Parameters
theRelativeIDIf empty, nullptr is returned.
theIsActionIf true and the descendant is missing, makes the created item action.
Returns
Descdendant item with inModuleID = myInModuleID/theRelativeID. If the descendant item does not exist, creates the item and its missing ancestors. All missing ancestors are created as not actions. Module assets effectively have empty myInModuleID.

References SUIT_ShortcutItemAssets::create(), and SUIT_ShortcutMgr::splitIntoTokens().

◆ description()

virtual QString SUIT_ShortcutAssets::description ( ) const
pure virtual

◆ findDescendantItem()

std::shared_ptr< SUIT_ShortcutItemAssets > SUIT_ShortcutAssets::findDescendantItem ( const QString &  theRelativeID) const
Parameters
theRelativeIDIf empty, nullptr is returned.
Returns
Descdendant item (if exist) with inModuleID = myInModuleID/theRelativeID. Module assets effectively have empty myInModuleID.

References SUIT_ShortcutMgr::splitIntoTokens().

◆ forEachDescendant() [1/4]

void SUIT_ShortcutAssets::forEachDescendant ( const std::function< void(const SUIT_ShortcutItemAssets &)> &  theFunc) const

Iterates all descendants. *this is not iterated.

References forEachDescendant(), and myChildren.

◆ forEachDescendant() [2/4]

void SUIT_ShortcutAssets::forEachDescendant ( const std::function< void(std::shared_ptr< const SUIT_ShortcutItemAssets >)> &  theFunc) const

Iterates all descendants. *this is not iterated.

References myChildren.

◆ forEachDescendant() [3/4]

void SUIT_ShortcutAssets::forEachDescendant ( const std::function< void(std::shared_ptr< SUIT_ShortcutItemAssets >)> &  theFunc) const

Iterates all descendants. *this is not iterated.

References myChildren.

◆ forEachDescendant() [4/4]

void SUIT_ShortcutAssets::forEachDescendant ( const std::function< void(SUIT_ShortcutItemAssets &)> &  theFunc) const

Iterates all descendants. *this is not iterated.

References forEachDescendant(), and myChildren.

◆ fromJSON() [1/2]

bool SUIT_ShortcutAssets::fromJSON ( const QJsonObject &  theJsonObject,
bool  theParseDescendants = true,
const std::set< QString > &  theLangs = {} 
)
Parameters
theLangsIf empty, LangDependentAssets in all available languages are parsed.
Returns
true, if any property is parsed.

References SUIT_ShortcutItemAssets::create(), description(), fromJSONOwnProps(), SUIT_ShortcutMgr::isInModuleIDTokenValid(), myChildren, PROP_ID_CHILDREN, and Warning().

◆ fromJSON() [2/2]

bool SUIT_ShortcutAssets::fromJSON ( const QJsonObject &  theJsonObject,
const QString &  theRelativeID,
const std::set< QString > &  theLangs = {} 
)

Parses only the branch of descdendants, which leads to the item with theRelativeID.

Parameters
theRelativeIDIf empty, no descendants are added/updated.
theLangsIf empty, LangDependentAssets in all available languages are parsed.
Returns
true, if any property is parsed.

References SUIT_ShortcutItemAssets::create(), description(), fromJSONOwnProps(), SUIT_ShortcutMgr::isInModuleIDTokenValid(), SUIT_ShortcutMgr::joinIntoRelativeID(), myChildren, PROP_ID_CHILDREN, SUIT_ShortcutMgr::splitIntoTokens(), and Warning().

◆ fromJSONOtherProps()

virtual bool SUIT_ShortcutAssets::fromJSONOtherProps ( const QJsonObject &  theJsonObject)
inlineprivatevirtual

Parses properties of SUIT_ShortcutAssets subclasses.

Returns
true, if any property is parsed.

Reimplemented in SUIT_ShortcutItemAssets.

◆ fromJSONOwnProps()

bool SUIT_ShortcutAssets::fromJSONOwnProps ( const QJsonObject &  theJsonObject,
const std::set< QString > &  theLangs = {} 
)
private

Parses everything, except children.

Parameters
theLangsIf empty, LangDependentAssets in all available languages are parsed.

References fromJSONOtherProps(), myIconPath, myLangDependentAssets, PROP_ID_ICON_PATH, and PROP_ID_LANG_DEPENDENT_ASSETS.

◆ getLangs()

QStringList SUIT_ShortcutAssets::getLangs ( ) const

References myLangDependentAssets.

◆ loadIcon()

void SUIT_ShortcutAssets::loadIcon ( bool  theReload = false)

◆ merge() [1/2]

void SUIT_ShortcutAssets::merge ( const SUIT_ShortcutAssets theOther,
bool  theOverride 
)
virtual
Parameters
theOverrideIf true, values of theOther override conflicting values of this.

References SUIT_ShortcutItemAssets::create(), loadIcon(), myChildren, myIcon, myIconPath, myLangDependentAssets, myModuleID, and Warning().

◆ merge() [2/2]

void SUIT_ShortcutAssets::merge ( SUIT_ShortcutAssets &&  theOther,
bool  theOverride 
)
virtual
Parameters
theOverrideIf true, values of theOther override conflicting values of this.

References loadIcon(), myChildren, myIcon, myIconPath, myLangDependentAssets, myModuleID, and Warning().

◆ toJSON()

void SUIT_ShortcutAssets::toJSON ( QJsonObject &  oJsonObject) const

◆ toJSONVirtual()

virtual void SUIT_ShortcutAssets::toJSONVirtual ( QJsonObject &  oJsonObject) const
inlineprivatevirtual

Reimplemented in SUIT_ShortcutItemAssets.

◆ toString()

QString SUIT_ShortcutAssets::toString ( ) const

References toJSON().

◆ type()

virtual SUIT_ShortcutAssets::Type SUIT_ShortcutAssets::type ( ) const
pure virtual

Member Data Documentation

◆ myChildren

std::map<QString, std::shared_ptr<SUIT_ShortcutItemAssets> > SUIT_ShortcutAssets::myChildren
private

◆ myIcon

QIcon SUIT_ShortcutAssets::myIcon

Not serialized.

◆ myIconPath

QString SUIT_ShortcutAssets::myIconPath

◆ myLangDependentAssets

std::map<QString, LangDependentAssets> SUIT_ShortcutAssets::myLangDependentAssets

◆ myModuleID

const QString SUIT_ShortcutAssets::myModuleID

◆ PROP_ID_CHILDREN

const QString SUIT_ShortcutAssets::PROP_ID_CHILDREN = "children"
static

◆ PROP_ID_ICON_PATH

const QString SUIT_ShortcutAssets::PROP_ID_ICON_PATH = "iconPath"
static

◆ PROP_ID_LANG_DEPENDENT_ASSETS

const QString SUIT_ShortcutAssets::PROP_ID_LANG_DEPENDENT_ASSETS = "langDependentAssets"
static

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