File indexing completed on 2024-12-22 04:41:14
0001 /* ============================================================ 0002 * Falkon - Qt web browser 0003 * Copyright (C) 2018 Anmol Gautam <tarptaeya@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 #pragma once 0019 0020 #include <QObject> 0021 #include "qmlhistoryitem.h" 0022 0023 /** 0024 * @brief The class exposing the History API to QML 0025 */ 0026 class QmlHistory : public QObject 0027 { 0028 Q_OBJECT 0029 public: 0030 explicit QmlHistory(QObject *parent = nullptr); 0031 /** 0032 * @brief Searches History Entries against a search query 0033 * @param String representing the search query 0034 * @return List of History Entries, each of type [QmlHistoryItem](@ref QmlHistoryItem), 0035 * matching the search query 0036 */ 0037 Q_INVOKABLE QList<QObject*> search(const QString &text); 0038 /** 0039 * @brief Get the visit count of a url 0040 * @param String representing the url 0041 * @return Integer representing the visit count of the given url 0042 */ 0043 Q_INVOKABLE int getVisits(const QString &url); 0044 /** 0045 * @brief Add url to the history 0046 * @param A JavaScript object containing 0047 * - title: 0048 * String representing the title of the hisotry entry 0049 * - url: 0050 * String representing the url of the history entry 0051 */ 0052 Q_INVOKABLE void addUrl(const QVariantMap &map); 0053 /** 0054 * @brief Deletes a url from the history 0055 * @param String representing the url of the history entry 0056 */ 0057 Q_INVOKABLE void deleteUrl(const QString &url); 0058 /** 0059 * @brief Deletes history entries within the given range 0060 * @param A JavaScript object containing 0061 * - startTime: 0062 * A JavaScript Date object representing the start time 0063 * - endTime: 0064 * A JavaScript Date object representing the end time 0065 */ 0066 Q_INVOKABLE void deleteRange(const QVariantMap &map); 0067 /** 0068 * @brief Clears all the history 0069 */ 0070 Q_INVOKABLE void deleteAll(); 0071 Q_SIGNALS: 0072 /** 0073 * @brief The signal emitted when a HistoryEntry is added 0074 * @param Object of type [QmlHistoryItem](@ref QmlHistoryItem), representing 0075 * the added History Entry 0076 */ 0077 void visited(QmlHistoryItem *historyItem); 0078 0079 /** 0080 * @brief The signal emitted when a HistoryEntry is removed 0081 * @param Object of type [QmlHistoryItem](@ref QmlHistoryItem), representing 0082 * the removed History Entry 0083 */ 0084 void visitRemoved(QmlHistoryItem *historyItem); 0085 };