File indexing completed on 2024-05-12 04:58:06
0001 /* ============================================================ 0002 * Falkon - Qt web browser 0003 * Copyright (C) 2010-2014 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 HISTORY_H 0019 #define HISTORY_H 0020 0021 #include <QObject> 0022 #include <QList> 0023 #include <QDateTime> 0024 #include <QUrl> 0025 0026 #include "qzcommon.h" 0027 0028 class QIcon; 0029 0030 class WebView; 0031 class HistoryModel; 0032 0033 class FALKON_EXPORT History : public QObject 0034 { 0035 Q_OBJECT 0036 public: 0037 History(QObject* parent); 0038 0039 struct HistoryEntry { 0040 int id; 0041 int count; 0042 QDateTime date; 0043 QUrl url; 0044 QString urlString; 0045 QString title; 0046 }; 0047 0048 static QString titleCaseLocalizedMonth(int month); 0049 0050 HistoryModel* model(); 0051 0052 void addHistoryEntry(WebView* view); 0053 void addHistoryEntry(const QUrl &url, QString title); 0054 0055 void deleteHistoryEntry(int index); 0056 void deleteHistoryEntry(const QList<int> &list); 0057 void deleteHistoryEntry(const QString &url); 0058 void deleteHistoryEntry(const QString &url, const QString &title); 0059 0060 QList<int> indexesFromTimeRange(qint64 start, qint64 end); 0061 0062 QVector<HistoryEntry> mostVisited(int count); 0063 0064 void clearHistory(); 0065 bool isSaving(); 0066 void setSaving(bool state); 0067 0068 void loadSettings(); 0069 0070 QList<HistoryEntry> searchHistoryEntry(const QString &text); 0071 HistoryEntry getHistoryEntry(const QString &text); 0072 0073 Q_SIGNALS: 0074 void historyEntryAdded(const HistoryEntry &entry); 0075 void historyEntryDeleted(const HistoryEntry &entry); 0076 void historyEntryEdited(const HistoryEntry &before, const HistoryEntry &after); 0077 0078 void resetHistory(); 0079 0080 private: 0081 bool m_isSaving; 0082 HistoryModel* m_model; 0083 }; 0084 0085 using HistoryEntry = History::HistoryEntry; 0086 0087 // Hint to QVector to use std::realloc on item moving 0088 Q_DECLARE_TYPEINFO(HistoryEntry, Q_MOVABLE_TYPE); 0089 0090 #endif // HISTORY_H