File indexing completed on 2024-12-22 04:41:07
0001 /* ============================================================ 0002 * Falkon - Qt web browser 0003 * Copyright (C) 2010-2018 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 LOCATIONCOMPLETERMODEL_H 0019 #define LOCATIONCOMPLETERMODEL_H 0020 0021 #include <QStandardItemModel> 0022 0023 #include "qzcommon.h" 0024 0025 class QSqlQuery; 0026 class QUrl; 0027 0028 class LocationCompleterModel : public QStandardItemModel 0029 { 0030 public: 0031 enum Role { 0032 IdRole = Qt::UserRole + 1, 0033 TitleRole, 0034 UrlRole, 0035 CountRole, 0036 HistoryRole, 0037 BookmarkRole, 0038 BookmarkItemRole, 0039 SearchStringRole, 0040 TabPositionWindowRole, 0041 TabPositionTabRole, 0042 ImageRole, 0043 VisitSearchItemRole, 0044 SearchSuggestionRole 0045 }; 0046 0047 explicit LocationCompleterModel(QObject* parent = nullptr); 0048 0049 void setCompletions(const QList<QStandardItem*> &items); 0050 void addCompletions(const QList<QStandardItem*> &items); 0051 0052 QList<QStandardItem*> suggestionItems() const; 0053 0054 static QSqlQuery createHistoryQuery(const QString &searchString, int limit, bool exactMatch = false); 0055 static QSqlQuery createDomainQuery(const QString &text); 0056 0057 private: 0058 enum Type { 0059 HistoryAndBookmarks = 0, 0060 History = 1, 0061 Bookmarks = 2, 0062 Nothing = 4 0063 }; 0064 0065 void setTabPosition(QStandardItem* item) const; 0066 void refreshTabPositions() const; 0067 }; 0068 0069 #endif // LOCATIONCOMPLETERMODEL_H