diff --git a/src/dictionary_group.cc b/src/dictionary_group.cc index cc354264b..0b35ff1af 100644 --- a/src/dictionary_group.cc +++ b/src/dictionary_group.cc @@ -5,44 +5,47 @@ #include "dictionary_group.hh" -sptr< Dictionary::Class > DictionaryGroup::getDictionaryByName(QString const & dictName){ +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; - + for ( const auto & allDictionarie : allDictionaries ) { + if ( dictName.compare( QString::fromUtf8( allDictionarie->getName().c_str() ) ) == 0 ) { + return allDictionarie; + } + } + return nullptr; } -std::vector< sptr< Dictionary::Class > > const * DictionaryGroup::getActiveDictionaries(unsigned currentGroup){ +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; - } + if ( !groups.empty() ) { + for ( const auto & group : groups ) + if ( group.id == currentGroup ) { + activeDicts = &( group.dictionaries ); + break; } - else - activeDicts = &allDictionaries; + } + else + activeDicts = &allDictionaries; - return activeDicts; + return activeDicts; } -sptr< Dictionary::Class > DictionaryGroup::getDictionaryById(std::string dictId){ - +sptr< Dictionary::Class > DictionaryGroup::getDictionaryById( const std::string & dictId ) +{ + for ( unsigned x = allDictionaries.size(); x--; ) { - if ( allDictionaries[ x ]->getId() == dictId ) { - return allDictionaries[ x ]; - } + if ( allDictionaries[ x ]->getId() == dictId ) { + return allDictionaries[ x ]; + } } return nullptr; } -Instances::Group const * DictionaryGroup::getGroupById(unsigned groupId){ - return groups.findGroup( group ); +Instances::Group const * DictionaryGroup::getGroupById( unsigned groupId ) +{ + return groups.findGroup( groupId ); } diff --git a/src/dictionary_group.hh b/src/dictionary_group.hh index 2981bafdf..5d08f54cd 100644 --- a/src/dictionary_group.hh +++ b/src/dictionary_group.hh @@ -4,27 +4,30 @@ #ifndef DICTIONARYGROUP_HH_INCLUDED #define DICTIONARYGROUP_HH_INCLUDED -#include "audioplayerinterface.hh" -#include - +#include "sptr.hh" +#include +#include "dictionary.hh" +#include "instances.hh" class DictionaryGroup: public QObject { Q_OBJECT public: - DictionaryGroup(QObject* parent,std::vector< sptr< Dictionary::Class > > const & allDictionaries_, - Instances::Groups const & groups_):allDictionaries(allDictionaries_),groups(groups_){ - - } - ~DictionaryGroup(); - + DictionaryGroup( QObject * parent, + std::vector< sptr< Dictionary::Class > > const & allDictionaries_, + Instances::Groups const & groups_ ): + QObject( parent ), + allDictionaries( allDictionaries_ ), + groups( groups_ ) + { + } sptr< Dictionary::Class > getDictionaryByName(QString const & dictionaryName); - std::vector< sptr< Dictionary::Class > > * const getActiveDictionaries(unsigned groupId); + const std::vector< sptr< Dictionary::Class > > * getActiveDictionaries( unsigned groupId ); - sptr< Dictionary::Class > getDictionaryById(std::string dictId); + sptr< Dictionary::Class > getDictionaryById( const std::string & dictId ); Instances::Group const * getGroupById(unsigned groupId); diff --git a/src/ui/articleview.cc b/src/ui/articleview.cc index 357fe144a..7f0046b9f 100644 --- a/src/ui/articleview.cc +++ b/src/ui/articleview.cc @@ -1584,7 +1584,7 @@ void ArticleView::contextMenuRequested( QPoint const & pos ) if ( txt.size() > 60 ) txt = txt.left( 60 ) + "..."; - addHeaderToHistoryAction = new QAction( tr( "&Add \"%1\" to history" ).arg( txt ), &menu ); + addHeaderToHistoryAction = new QAction( tr( R"(&Add "%1" to history)" ).arg( txt ), &menu ); menu.addAction( addHeaderToHistoryAction ); } @@ -1602,7 +1602,7 @@ void ArticleView::contextMenuRequested( QPoint const & pos ) // Add table of contents QStringList ids = getArticlesList(); - if ( !menu.isEmpty() && ids.size() ) + if ( !menu.isEmpty() && !ids.empty() ) menu.addSeparator(); unsigned refsAdded = 0;