From 5e210a19b1e6aacdce412d07d1fc80f1564cbbd1 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 16 Aug 2010 17:33:17 +0200 Subject: HistoryManager review (the second): - impressive cleanup of the code - removed unneeded classes - one List to manage the items in the historyManager, one easier Hash in the HistoryFilterModel to speed up searches - better HistoryItem updates --- src/history/historymanager.h | 47 ++++++-------------------------------------- 1 file changed, 6 insertions(+), 41 deletions(-) (limited to 'src/history/historymanager.h') diff --git a/src/history/historymanager.h b/src/history/historymanager.h index 85702b84..1e03fb1c 100644 --- a/src/history/historymanager.h +++ b/src/history/historymanager.h @@ -32,6 +32,8 @@ // Rekonq Includes #include "rekonq_defines.h" + +// Local Includes #include "urlresolver.h" // KDE Includes @@ -84,35 +86,8 @@ public: // --------------------------------------------------------------------------------------------------------------- -class HistoryHashItem : public HistoryItem -{ -public: - HistoryHashItem() {} - explicit HistoryHashItem(const QString &u - ,const QDateTime &d = QDateTime() - ,const QString &t = QString() - ) - : HistoryItem(u, d, t) - ,visitCount(1) - ,savedCount(0) - {} - - inline bool operator <(const HistoryHashItem &other) const - { - return visitCount > other.visitCount; - } - - int visitCount; - int savedCount; -}; - - -// --------------------------------------------------------------------------------------------------------------- - - // Forward Declarations class AutoSaver; -class HistoryModel; class HistoryFilterModel; class HistoryTreeModel; @@ -124,7 +99,6 @@ class HistoryTreeModel; class REKONQ_TESTS_EXPORT HistoryManager : public QWebHistoryInterface { Q_OBJECT - Q_PROPERTY(int historyLimit READ historyLimit WRITE setHistoryLimit) signals: void historyReset(); @@ -141,19 +115,14 @@ public: void updateHistoryEntry(const KUrl &url, const QString &title); void removeHistoryEntry(const KUrl &url, const QString &title = QString()); - HistoryHashItem get(const QString &url); - QList find(const QString &text); - - int historyLimit() const; - void setHistoryLimit(int limit); + QList find(const QString &text); - QList history() const; + QList history() const { return m_history; }; void setHistory(const QList &history, bool loadedAndSorted = false); // History manager keeps around these models for use by the completer and other classes - HistoryModel *historyModel() const; - HistoryFilterModel *historyFilterModel() const; - HistoryTreeModel *historyTreeModel() const; + HistoryFilterModel *historyFilterModel() const { return m_historyFilterModel; }; + HistoryTreeModel *historyTreeModel() const { return m_historyTreeModel; }; public slots: void clear(); @@ -164,17 +133,13 @@ private slots: void checkForExpired(); private: - void addHistoryHashEntry(const HistoryItem &item); void load(); AutoSaver *m_saveTimer; int m_historyLimit; - QTimer m_expiredTimer; QList m_history; - QHash m_hash; QString m_lastSavedUrl; - HistoryModel *m_historyModel; HistoryFilterModel *m_historyFilterModel; HistoryTreeModel *m_historyTreeModel; }; -- cgit v1.2.1