mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
[LocationCompleter] Cancel unneeded refresh jobs
This commit is contained in:
parent
a32e809bf6
commit
5bd24400e1
@ -70,8 +70,11 @@ void LocationCompleter::complete(const QString &string)
|
|||||||
// Eg. popup was not closed yet this completion session
|
// Eg. popup was not closed yet this completion session
|
||||||
m_popupClosed = false;
|
m_popupClosed = false;
|
||||||
|
|
||||||
|
emit cancelRefreshJob();
|
||||||
|
|
||||||
LocationCompleterRefreshJob* job = new LocationCompleterRefreshJob(trimmedStr);
|
LocationCompleterRefreshJob* job = new LocationCompleterRefreshJob(trimmedStr);
|
||||||
connect(job, SIGNAL(finished()), this, SLOT(refreshJobFinished()));
|
connect(job, SIGNAL(finished()), this, SLOT(refreshJobFinished()));
|
||||||
|
connect(this, SIGNAL(cancelRefreshJob()), job, SLOT(jobCancelled()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocationCompleter::showMostVisited()
|
void LocationCompleter::showMostVisited()
|
||||||
|
@ -51,6 +51,7 @@ signals:
|
|||||||
void loadCompletion();
|
void loadCompletion();
|
||||||
void clearCompletion();
|
void clearCompletion();
|
||||||
void popupClosed();
|
void popupClosed();
|
||||||
|
void cancelRefreshJob();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void refreshJobFinished();
|
void refreshJobFinished();
|
||||||
|
@ -36,6 +36,7 @@ LocationCompleterRefreshJob::LocationCompleterRefreshJob(const QString &searchSt
|
|||||||
: QObject()
|
: QObject()
|
||||||
, m_timestamp(QDateTime::currentMSecsSinceEpoch())
|
, m_timestamp(QDateTime::currentMSecsSinceEpoch())
|
||||||
, m_searchString(searchString)
|
, m_searchString(searchString)
|
||||||
|
, m_jobCancelled(false)
|
||||||
{
|
{
|
||||||
m_watcher = new QFutureWatcher<void>(this);
|
m_watcher = new QFutureWatcher<void>(this);
|
||||||
connect(m_watcher, SIGNAL(finished()), this, SLOT(slotFinished()));
|
connect(m_watcher, SIGNAL(finished()), this, SLOT(slotFinished()));
|
||||||
@ -64,6 +65,11 @@ QString LocationCompleterRefreshJob::domainCompletion() const
|
|||||||
return m_domainCompletion;
|
return m_domainCompletion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LocationCompleterRefreshJob::jobCancelled()
|
||||||
|
{
|
||||||
|
m_jobCancelled = true;
|
||||||
|
}
|
||||||
|
|
||||||
void LocationCompleterRefreshJob::slotFinished()
|
void LocationCompleterRefreshJob::slotFinished()
|
||||||
{
|
{
|
||||||
emit finished();
|
emit finished();
|
||||||
@ -84,7 +90,7 @@ static bool countBiggerThan(const QStandardItem* i1, const QStandardItem* i2)
|
|||||||
|
|
||||||
void LocationCompleterRefreshJob::runJob()
|
void LocationCompleterRefreshJob::runJob()
|
||||||
{
|
{
|
||||||
if (mApp->isClosing() || !mApp) {
|
if (m_jobCancelled || mApp->isClosing() || !mApp) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,6 +106,10 @@ void LocationCompleterRefreshJob::runJob()
|
|||||||
query.prepare(QSL("SELECT icon FROM icons WHERE url LIKE ? ESCAPE ? LIMIT 1"));
|
query.prepare(QSL("SELECT icon FROM icons WHERE url LIKE ? ESCAPE ? LIMIT 1"));
|
||||||
|
|
||||||
foreach (QStandardItem* item, m_items) {
|
foreach (QStandardItem* item, m_items) {
|
||||||
|
if (m_jobCancelled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const QUrl url = item->data(LocationCompleterModel::UrlRole).toUrl();
|
const QUrl url = item->data(LocationCompleterModel::UrlRole).toUrl();
|
||||||
|
|
||||||
query.bindValue(0, QString(QL1S("%1%")).arg(QzTools::escapeSqlString(QString::fromUtf8(url.toEncoded(QUrl::RemoveFragment)))));
|
query.bindValue(0, QString(QL1S("%1%")).arg(QzTools::escapeSqlString(QString::fromUtf8(url.toEncoded(QUrl::RemoveFragment)))));
|
||||||
|
@ -43,6 +43,7 @@ signals:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void slotFinished();
|
void slotFinished();
|
||||||
|
void jobCancelled();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum Type {
|
enum Type {
|
||||||
@ -63,6 +64,7 @@ private:
|
|||||||
QString m_domainCompletion;
|
QString m_domainCompletion;
|
||||||
QList<QStandardItem*> m_items;
|
QList<QStandardItem*> m_items;
|
||||||
QFutureWatcher<void>* m_watcher;
|
QFutureWatcher<void>* m_watcher;
|
||||||
|
bool m_jobCancelled;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LOCATIONCOMPLETERREFRESHJOB_H
|
#endif // LOCATIONCOMPLETERREFRESHJOB_H
|
||||||
|
Loading…
Reference in New Issue
Block a user