opt: refactor code (#1657)

* opt: refactor code

* [autofix.ci] apply automated fixes

* opt: refactor code

* opt: refactor code

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
xiaoyifang 2024-07-10 13:47:53 +08:00 committed by GitHub
parent c42a79c7d4
commit 93ca284bad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 40 deletions

View file

@ -707,40 +707,38 @@ void ArticleRequest::bodyFinished()
bodyDone = true;
{
string footer;
string footer;
if ( closePrevSpan ) {
footer += "</div></div>";
closePrevSpan = false;
}
if ( !foundAnyDefinitions ) {
// No definitions were ever found, say so to the user.
// Larger words are usually whole sentences - don't clutter the output
// with their full bodies.
footer += ArticleMaker::makeNotFoundBody( word.size() < 40 ? word : "", group.name );
// When there were no definitions, we run stemmed search.
stemmedWordFinder = std::make_shared< WordFinder >( this );
connect( stemmedWordFinder.get(),
&WordFinder::finished,
this,
&ArticleRequest::stemmedSearchFinished,
Qt::QueuedConnection );
stemmedWordFinder->stemmedMatch( word, activeDicts );
}
else {
footer += R"(<div class="empty-space"></div>)";
footer += "</body></html>";
}
appendString( footer );
if ( closePrevSpan ) {
footer += "</div></div>";
closePrevSpan = false;
}
if ( !foundAnyDefinitions ) {
// No definitions were ever found, say so to the user.
// Larger words are usually whole sentences - don't clutter the output
// with their full bodies.
footer += ArticleMaker::makeNotFoundBody( word.size() < 40 ? word : word.left( 40 ) + "...", group.name );
// When there were no definitions, we run stemmed search.
stemmedWordFinder = std::make_shared< WordFinder >( this );
connect( stemmedWordFinder.get(),
&WordFinder::finished,
this,
&ArticleRequest::stemmedSearchFinished,
Qt::QueuedConnection );
stemmedWordFinder->stemmedMatch( word, activeDicts );
}
else {
footer += R"(<div class="empty-space"></div>)";
footer += "</body></html>";
}
appendString( footer );
if ( stemmedWordFinder.get() ) {
update();
qDebug() << "send dicts(stemmed):" << hittedWord;

View file

@ -8,15 +8,6 @@
#include <QThreadPool>
#include <QMessageBox>
#include <qalgorithms.h>
#if defined( Q_OS_WIN32 )
#include "initializing.hh"
#include <qt_windows.h>
#include <QOperatingSystemVersion>
#endif
#include "globalregex.hh"
namespace FTS {