//view code
//after user presses enter
if (!finder)
{
finder->stop();
}
finder = new QueryFinder(this, queryTerm);
finder->execute();
void updateView(QueryResult &result)
{
//display the query result properly
}
//QueryFinder code, header file
{
public:
QUeryFinder
(QWidget *, QueryTerm
&);
void execute();
void stop();
private:
bool shouldStop;
QueryTerm fTerm;
}
//QueryFinder code, implementation file
QueryFinder
::QueryFinder(QWidget *w, QueryTerm
& term
): fView
(w
), fTerm
(term
){
shouldStop = false;
}
void QueryFinder::execute()
{
//do the polling and if any result found, say newResult, update view, but only if no new query request has come in
//the meantime, else abnson this object altogether
while (cursor->hasNext()) {
newResult = cursor->getCurResult();
if (!shouldStop)
fView->updateView(newResult);
else
return;
}
}
void QueryFinder::stop()
{
shouldStop = true;
}
//view code
//after user presses enter
if (!finder)
{
finder->stop();
}
finder = new QueryFinder(this, queryTerm);
finder->execute();
void updateView(QueryResult &result)
{
//display the query result properly
}
//QueryFinder code, header file
class QueryFinder: public QObject
{
public:
QUeryFinder(QWidget *, QueryTerm&);
void execute();
void stop();
private:
bool shouldStop;
QWidget *fView;
QueryTerm fTerm;
}
//QueryFinder code, implementation file
QueryFinder::QueryFinder(QWidget *w, QueryTerm& term): fView(w), fTerm(term)
{
shouldStop = false;
}
void QueryFinder::execute()
{
//do the polling and if any result found, say newResult, update view, but only if no new query request has come in
//the meantime, else abnson this object altogether
while (cursor->hasNext()) {
newResult = cursor->getCurResult();
if (!shouldStop)
fView->updateView(newResult);
else
return;
}
}
void QueryFinder::stop()
{
shouldStop = true;
}
To copy to clipboard, switch view to plain text mode
Bookmarks