mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
fix: code smells
[autofix.ci] apply automated fixes
This commit is contained in:
parent
791da91645
commit
477f22c304
|
@ -437,7 +437,7 @@ sptr< Dictionary::DataRequest > ArticleMaker::makeEmptyPage() const
|
|||
sptr< Dictionary::DataRequest > ArticleMaker::makePicturePage( string const & url ) const
|
||||
{
|
||||
string result = makeHtmlHeader( tr( "(picture)" ), QString(), true )
|
||||
+ "<a href=\"javascript: if(history.length>2) history.go(-1)\">" + "<img src=\"" + url + "\" /></a>"
|
||||
+ R"lit(<a href="javascript: if(history.length>2) history.go(-1)">)lit" + R"(<img src=")" + url + R"(" /></a>)"
|
||||
+ "</body></html>";
|
||||
|
||||
sptr< Dictionary::DataRequestInstant > r = std::make_shared< Dictionary::DataRequestInstant >( true );
|
||||
|
@ -490,9 +490,8 @@ ArticleRequest::ArticleRequest( QString const & word,
|
|||
emit GlobalBroadcaster::instance()->dictionaryClear( ActiveDictIds{ group.id, word } );
|
||||
|
||||
// Accumulate main forms
|
||||
for ( unsigned x = 0; x < activeDicts.size(); ++x ) {
|
||||
sptr< Dictionary::WordSearchRequest > s =
|
||||
activeDicts[ x ]->findHeadwordsForSynonym( gd::removeTrailingZero( word ) );
|
||||
for ( const auto & activeDict : activeDicts ) {
|
||||
auto const s = activeDict->findHeadwordsForSynonym( gd::removeTrailingZero( word ) );
|
||||
|
||||
connect( s.get(), &Dictionary::Request::finished, this, &ArticleRequest::altSearchFinished, Qt::QueuedConnection );
|
||||
|
||||
|
@ -508,7 +507,7 @@ void ArticleRequest::altSearchFinished()
|
|||
return;
|
||||
|
||||
// Check every request for finishing
|
||||
for ( list< sptr< Dictionary::WordSearchRequest > >::iterator i = altSearches.begin(); i != altSearches.end(); ) {
|
||||
for ( auto i = altSearches.begin(); i != altSearches.end(); ) {
|
||||
if ( ( *i )->isFinished() ) {
|
||||
// This one's finished
|
||||
for ( size_t count = ( *i )->matchesCount(), x = 0; x < count; ++x )
|
||||
|
@ -532,8 +531,8 @@ void ArticleRequest::altSearchFinished()
|
|||
vector< wstring > altsVector( alts.begin(), alts.end() );
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
for ( unsigned x = 0; x < altsVector.size(); ++x ) {
|
||||
qDebug() << "Alt:" << QString::fromStdU32String( altsVector[ x ] );
|
||||
for ( const auto & x : altsVector ) {
|
||||
qDebug() << "Alt:" << QString::fromStdU32String( x );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -542,12 +541,12 @@ void ArticleRequest::altSearchFinished()
|
|||
if ( activeDicts.size() <= 1 )
|
||||
articleSizeLimit = -1; // Don't collapse article if only one dictionary presented
|
||||
|
||||
for ( unsigned x = 0; x < activeDicts.size(); ++x ) {
|
||||
for ( const auto & activeDict : activeDicts ) {
|
||||
try {
|
||||
sptr< Dictionary::DataRequest > r = activeDicts[ x ]->getArticle(
|
||||
sptr< Dictionary::DataRequest > r = activeDict->getArticle(
|
||||
wordStd,
|
||||
altsVector,
|
||||
gd::removeTrailingZero( contexts.value( QString::fromStdString( activeDicts[ x ]->getId() ) ) ),
|
||||
gd::removeTrailingZero( contexts.value( QString::fromStdString( activeDict->getId() ) ) ),
|
||||
ignoreDiacritics );
|
||||
|
||||
connect( r.get(), &Dictionary::Request::finished, this, &ArticleRequest::bodyFinished, Qt::QueuedConnection );
|
||||
|
@ -555,7 +554,7 @@ void ArticleRequest::altSearchFinished()
|
|||
bodyRequests.push_back( r );
|
||||
}
|
||||
catch ( std::exception & e ) {
|
||||
gdWarning( "getArticle request error (%s) in \"%s\"\n", e.what(), activeDicts[ x ]->getName().c_str() );
|
||||
gdWarning( "getArticle request error (%s) in \"%s\"\n", e.what(), activeDict->getName().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -303,15 +303,15 @@ void EpwingDictionary::loadArticle(
|
|||
articleHeadword = string( headword.toUtf8().data() );
|
||||
articleText = string( text.toUtf8().data() );
|
||||
|
||||
string prefix( "<div class=\"epwing_text\">" );
|
||||
const string prefix( "<div class=\"epwing_text\">" );
|
||||
|
||||
articleText = prefix + articleText + "</div>";
|
||||
}
|
||||
|
||||
string Epwing::EpwingDictionary::epwing_previous_button( const int & articlePage, const int & articleOffset )
|
||||
{
|
||||
QString previousButton = QString( "p%1At%2" ).arg( articlePage ).arg( articleOffset );
|
||||
string previousLink = R"(<p><a class="epwing_previous_page" href="gdlookup://localhost/)"
|
||||
const QString previousButton = QString( "p%1At%2" ).arg( articlePage ).arg( articleOffset );
|
||||
string previousLink = R"(<p><a class="epwing_previous_page" href="gdlookup://localhost/)"
|
||||
+ previousButton.toStdString() + "?dictionaries=" + getId() + "\">" + tr( "Previous Page" ).toStdString()
|
||||
+ "</a></p>";
|
||||
|
||||
|
@ -349,8 +349,8 @@ void EpwingDictionary::loadArticleNextPage( string & articleHeadword,
|
|||
string Epwing::EpwingDictionary::epwing_next_button( const int & articlePage, const int & articleOffset )
|
||||
{
|
||||
QString refLink = QString( "r%1At%2" ).arg( articlePage ).arg( articleOffset );
|
||||
string nextLink = R"(<p><a class="epwing_next_page" href="gdlookup://localhost/)" + refLink.toStdString() + "?dictionaries="+getId()+"\">"
|
||||
+ tr( "Next Page" ).toStdString() + "</a></p>";
|
||||
string nextLink = R"(<p><a class="epwing_next_page" href="gdlookup://localhost/)" + refLink.toStdString()
|
||||
+ "?dictionaries=" + getId() + "\">" + tr( "Next Page" ).toStdString() + "</a></p>";
|
||||
|
||||
return nextLink;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue