File indexing completed on 2024-12-22 04:41:07

0001 /* ============================================================
0002 * Falkon - Qt web browser
0003 * Copyright (C) 2014-2017 David Rosca <nowrep@gmail.com>
0004 *
0005 * This program is free software: you can redistribute it and/or modify
0006 * it under the terms of the GNU General Public License as published by
0007 * the Free Software Foundation, either version 3 of the License, or
0008 * (at your option) any later version.
0009 *
0010 * This program is distributed in the hope that it will be useful,
0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013 * GNU General Public License for more details.
0014 *
0015 * You should have received a copy of the GNU General Public License
0016 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0017 * ============================================================ */
0018 #ifndef LOCATIONCOMPLETERREFRESHJOB_H
0019 #define LOCATIONCOMPLETERREFRESHJOB_H
0020 
0021 #include <QFutureWatcher>
0022 
0023 #include "qzcommon.h"
0024 
0025 class QStandardItem;
0026 
0027 class FALKON_EXPORT LocationCompleterRefreshJob : public QObject
0028 {
0029     Q_OBJECT
0030 
0031 public:
0032     explicit LocationCompleterRefreshJob(const QString &searchString);
0033 
0034     // Timestamp when the job was created
0035     qint64 timestamp() const;
0036     QString searchString() const;
0037     bool isCanceled() const;
0038 
0039     QList<QStandardItem*> completions() const;
0040     QString domainCompletion() const;
0041 
0042 Q_SIGNALS:
0043     void finished();
0044 
0045 private Q_SLOTS:
0046     void slotFinished();
0047     void jobCancelled();
0048 
0049 private:
0050     enum Type {
0051         HistoryAndBookmarks = 0,
0052         History = 1,
0053         Bookmarks = 2,
0054         Nothing = 4
0055     };
0056 
0057     void runJob();
0058     void completeFromHistory();
0059     void completeMostVisited();
0060 
0061     QString createDomainCompletion(const QString &completion) const;
0062 
0063     qint64 m_timestamp;
0064     QString m_searchString;
0065     QString m_domainCompletion;
0066     QList<QStandardItem*> m_items;
0067     QFutureWatcher<void>* m_watcher;
0068     bool m_jobCancelled;
0069 };
0070 
0071 #endif // LOCATIONCOMPLETERREFRESHJOB_H