Falkon Develop
Cross-platform Qt-based web browser
locationcompleter.h
Go to the documentation of this file.
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
25class QUrl;
26class QModelIndex;
27
28class LocationBar;
29class LoadRequest;
30class BrowserWindow;
34
35class FALKON_EXPORT LocationCompleter : public QObject
36{
37 Q_OBJECT
38public:
39 explicit LocationCompleter(QObject* parent = nullptr);
40
41 void setMainWindow(BrowserWindow* window);
42 void setLocationBar(LocationBar* locationBar);
43
44 bool isVisible() const;
45 void closePopup();
46
47public Q_SLOTS:
48 void complete(const QString &string);
49 void showMostVisited();
50
51Q_SIGNALS:
52 void showCompletion(const QString &completion, bool completeDomain);
53 void showDomainCompletion(const QString &completion);
57 void loadRequested(const LoadRequest &request);
58
59private 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
70private:
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
void showCompletion(const QString &completion, bool completeDomain)
void loadRequested(const LoadRequest &request)
void showDomainCompletion(const QString &completion)
A class representing a single search engine described in OpenSearch format.
#define FALKON_EXPORT
Definition: qzcommon.h:28