1 /* ============================================================ 2 * Falkon - Qt web browser 3 * Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com> 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * ============================================================ */ 18 #ifndef LOCATIONCOMPLETER_H 19 #define LOCATIONCOMPLETER_H 20 21 #include <QObject> 22 23 #include "qzcommon.h" 24 25 class QUrl; 26 class QModelIndex; 27 28 class LocationBar; 29 class LoadRequest; 30 class BrowserWindow; 31 class OpenSearchEngine; 32 class LocationCompleterModel; 33 class LocationCompleterView; 34 35 class FALKON_EXPORT LocationCompleter : public QObject 36 { 37 Q_OBJECT 38 public: 39 explicit LocationCompleter(QObject* parent = 0); 40 41 void setMainWindow(BrowserWindow* window); 42 void setLocationBar(LocationBar* locationBar); 43 44 bool isVisible() const; 45 void closePopup(); 46 47 public Q_SLOTS: 48 void complete(const QString &string); 49 void showMostVisited(); 50 51 Q_SIGNALS: 52 void showCompletion(const QString &completion, bool completeDomain); 53 void showDomainCompletion(const QString &completion); 54 void clearCompletion(); 55 void popupClosed(); 56 void cancelRefreshJob(); 57 void loadRequested(const LoadRequest &request); 58 59 private Q_SLOTS: 60 void refreshJobFinished(); 61 void slotPopupClosed(); 62 void addSuggestions(const QStringList &suggestions); 63 64 void currentChanged(const QModelIndex &index); 65 void indexActivated(const QModelIndex &index); 66 void indexCtrlActivated(const QModelIndex &index); 67 void indexShiftActivated(const QModelIndex &index); 68 void indexDeleteRequested(const QModelIndex &index); 69 70 private: 71 LoadRequest createLoadRequest(const QModelIndex &index); 72 void switchToTab(BrowserWindow* window, int tab); 73 void loadRequest(const LoadRequest &reqeust); 74 void openSearchEnginesDialog(); 75 76 void showPopup(); 77 void adjustPopupSize(); 78 79 BrowserWindow* m_window; 80 LocationBar* m_locationBar; 81 qint64 m_lastRefreshTimestamp; 82 bool m_popupClosed; 83 bool m_ignoreCurrentChanged = false; 84 OpenSearchEngine* m_openSearchEngine = nullptr; 85 QStringList m_oldSuggestions; 86 QString m_suggestionsTerm; 87 88 static LocationCompleterView* s_view; 89 static LocationCompleterModel* s_model; 90 }; 91 92 #endif // LOCATIONCOMPLETER_H 93