2024-07-03 07:16:53 +00:00
|
|
|
/* Licensed under GPLv3 or later, see the LICENSE file */
|
|
|
|
|
|
|
|
|
|
|
|
#include "dictionary_group.hh"
|
|
|
|
|
|
|
|
|
|
|
|
sptr< Dictionary::Class > DictionaryGroup::getDictionaryByName( QString const & dictName )
|
|
|
|
{
|
|
|
|
// Link to other dictionary
|
|
|
|
for ( const auto & allDictionarie : allDictionaries ) {
|
|
|
|
if ( dictName.compare( QString::fromUtf8( allDictionarie->getName().c_str() ) ) == 0 ) {
|
|
|
|
return allDictionarie;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::vector< sptr< Dictionary::Class > > * DictionaryGroup::getActiveDictionaries( unsigned currentGroup )
|
|
|
|
{
|
|
|
|
std::vector< sptr< Dictionary::Class > > const * activeDicts = nullptr;
|
|
|
|
|
|
|
|
if ( !groups.empty() ) {
|
|
|
|
for ( const auto & group : groups ) {
|
|
|
|
if ( group.id == currentGroup ) {
|
|
|
|
activeDicts = &( group.dictionaries );
|
|
|
|
break;
|
|
|
|
}
|
2024-10-10 07:13:23 +00:00
|
|
|
}
|
2024-07-03 07:16:53 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
activeDicts = &allDictionaries;
|
2024-10-10 07:13:23 +00:00
|
|
|
}
|
2024-07-03 07:16:53 +00:00
|
|
|
|
|
|
|
return activeDicts;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sptr< Dictionary::Class > DictionaryGroup::getDictionaryById( const std::string & dictId )
|
|
|
|
{
|
|
|
|
|
|
|
|
for ( unsigned x = allDictionaries.size(); x--; ) {
|
|
|
|
if ( allDictionaries[ x ]->getId() == dictId ) {
|
|
|
|
return allDictionaries[ x ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
Instances::Group const * DictionaryGroup::getGroupById( unsigned groupId )
|
|
|
|
{
|
|
|
|
return groups.findGroup( groupId );
|
|
|
|
}
|