mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
Add request cancellation
This commit is contained in:
parent
07a8734bca
commit
5e49c32b53
|
@ -285,7 +285,7 @@ ArticleRequest::ArticleRequest(
|
||||||
sptr< Dictionary::WordSearchRequest > s = activeDicts[ x ]->findHeadwordsForSynonym( gd::toWString( word ) );
|
sptr< Dictionary::WordSearchRequest > s = activeDicts[ x ]->findHeadwordsForSynonym( gd::toWString( word ) );
|
||||||
|
|
||||||
connect( s.get(), SIGNAL( finished() ),
|
connect( s.get(), SIGNAL( finished() ),
|
||||||
this, SLOT( altSearchFinished() ) );
|
this, SLOT( altSearchFinished() ), Qt::QueuedConnection );
|
||||||
|
|
||||||
altSearches.push_back( s );
|
altSearches.push_back( s );
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ void ArticleRequest::altSearchFinished()
|
||||||
gd::toWString( contexts.value( QString::fromStdString( activeDicts[ x ]->getId() ) ) ) );
|
gd::toWString( contexts.value( QString::fromStdString( activeDicts[ x ]->getId() ) ) ) );
|
||||||
|
|
||||||
connect( r.get(), SIGNAL( finished() ),
|
connect( r.get(), SIGNAL( finished() ),
|
||||||
this, SLOT( bodyFinished() ) );
|
this, SLOT( bodyFinished() ), Qt::QueuedConnection );
|
||||||
|
|
||||||
bodyRequests.push_back( r );
|
bodyRequests.push_back( r );
|
||||||
}
|
}
|
||||||
|
@ -812,3 +812,27 @@ std::string ArticleRequest::escapeSpacing( QString const & str )
|
||||||
|
|
||||||
return spacing.data();
|
return spacing.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ArticleRequest::cancel()
|
||||||
|
{
|
||||||
|
if( isFinished() )
|
||||||
|
return;
|
||||||
|
if( !altSearches.empty() )
|
||||||
|
{
|
||||||
|
for( list< sptr< Dictionary::WordSearchRequest > >::iterator i =
|
||||||
|
altSearches.begin(); i != altSearches.end(); ++i )
|
||||||
|
{
|
||||||
|
(*i)->cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( !bodyRequests.empty() )
|
||||||
|
{
|
||||||
|
for( list< sptr< Dictionary::DataRequest > >::iterator i =
|
||||||
|
bodyRequests.begin(); i != bodyRequests.end(); ++i )
|
||||||
|
{
|
||||||
|
(*i)->cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( stemmedWordFinder.get() ) stemmedWordFinder->cancel();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
|
@ -110,8 +110,8 @@ public:
|
||||||
std::vector< sptr< Dictionary::Class > > const & activeDicts,
|
std::vector< sptr< Dictionary::Class > > const & activeDicts,
|
||||||
std::string const & header );
|
std::string const & header );
|
||||||
|
|
||||||
virtual void cancel()
|
virtual void cancel();
|
||||||
{ finish(); } // Add our own requests cancellation here
|
// { finish(); } // Add our own requests cancellation here
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ WordFinder::WordFinder( QObject * parent ):
|
||||||
updateResultsTimer.setSingleShot( true );
|
updateResultsTimer.setSingleShot( true );
|
||||||
|
|
||||||
connect( &updateResultsTimer, SIGNAL( timeout() ),
|
connect( &updateResultsTimer, SIGNAL( timeout() ),
|
||||||
this, SLOT( updateResults() ) );
|
this, SLOT( updateResults() ), Qt::QueuedConnection );
|
||||||
}
|
}
|
||||||
|
|
||||||
WordFinder::~WordFinder()
|
WordFinder::~WordFinder()
|
||||||
|
|
Loading…
Reference in a new issue