summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-08-19 21:05:08 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-08-19 21:05:08 +0200
commit61b5cf17fcd4312332a933e68d5ddcf45f281b98 (patch)
tree543ac39768f7e4370ed107188ffc40d518da41c2 /src
parentMerge branch 'master' of gitorious.org:rekonq/mainline (diff)
parentStupid me, QtWebKit calls addHistoryEntry itself when you let it load a page.. (diff)
downloadrekonq-61b5cf17fcd4312332a933e68d5ddcf45f281b98.tar.xz
Merge branch 'HistoryReview3'
Diffstat (limited to 'src')
-rw-r--r--src/application.cpp6
-rw-r--r--src/history/historymanager.cpp158
-rw-r--r--src/history/historymanager.h47
-rw-r--r--src/history/historymodels.cpp305
-rw-r--r--src/history/historymodels.h78
-rw-r--r--src/urlbar/urlresolver.cpp4
6 files changed, 105 insertions, 493 deletions
diff --git a/src/application.cpp b/src/application.cpp
index 8a24014d..5cc3b460 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -451,12 +451,6 @@ void Application::loadResolvedUrl(ThreadWeaver::Job *job)
if (view)
{
view->load(url);
-
- // we are sure of the url now, let's add it to history
- // anyway we store here just http sites because local and ftp ones are
- // added trough the protocol handler and the other are ignored
- if (url.protocol() == QL1S("http") || url.protocol() == QL1S("https"))
- historyManager()->addHistoryEntry(url.prettyUrl());
}
}
diff --git a/src/history/historymanager.cpp b/src/history/historymanager.cpp
index 966487a9..5cd85cd7 100644
--- a/src/history/historymanager.cpp
+++ b/src/history/historymanager.cpp
@@ -65,22 +65,18 @@ static const unsigned int HISTORY_VERSION = 23;
HistoryManager::HistoryManager(QObject *parent)
: QWebHistoryInterface(parent)
, m_saveTimer(new AutoSaver(this))
- , m_historyLimit(30)
- , m_historyModel(0)
- , m_historyFilterModel(0)
+ , m_historyLimit(0)
, m_historyTreeModel(0)
{
kDebug() << "Loading HistoryManager...";
- m_expiredTimer.setSingleShot(true);
- connect(&m_expiredTimer, SIGNAL(timeout()), this, SLOT(checkForExpired()));
connect(this, SIGNAL(entryAdded(const HistoryItem &)), m_saveTimer, SLOT(changeOccurred()));
connect(this, SIGNAL(entryRemoved(const HistoryItem &)), m_saveTimer, SLOT(changeOccurred()));
load();
- m_historyModel = new HistoryModel(this, this);
- m_historyFilterModel = new HistoryFilterModel(m_historyModel, this);
+ HistoryModel *historyModel = new HistoryModel(this, this);
+ m_historyFilterModel = new HistoryFilterModel(historyModel, this);
m_historyTreeModel = new HistoryTreeModel(m_historyFilterModel, this);
// QWebHistoryInterface will delete the history manager
@@ -92,24 +88,17 @@ HistoryManager::HistoryManager(QObject *parent)
HistoryManager::~HistoryManager()
{
m_saveTimer->saveIfNeccessary();
-
- delete m_saveTimer;
-
- delete m_historyModel;
+
delete m_historyFilterModel;
delete m_historyTreeModel;
-}
-
-QList<HistoryItem> HistoryManager::history() const
-{
- return m_history;
+ delete m_saveTimer;
}
bool HistoryManager::historyContains(const QString &url) const
{
- return m_hash.contains(url) && m_hash[url].savedCount>0;
+ return m_historyFilterModel->historyContains(url);
}
@@ -130,7 +119,6 @@ void HistoryManager::addHistoryEntry(const QString &url)
HistoryItem item(cleanUrl.toString(), QDateTime::currentDateTime());
m_history.prepend(item);
- addHistoryHashEntry(item);
emit entryAdded(item);
if (m_history.count() == 1)
@@ -141,14 +129,7 @@ void HistoryManager::addHistoryEntry(const QString &url)
void HistoryManager::setHistory(const QList<HistoryItem> &history, bool loadedAndSorted)
{
m_history = history;
-
- //TODO: is there a way to really memorize the visitCount instead of recount it at startup ?
- m_hash.clear();
- foreach(HistoryItem i, m_history)
- {
- addHistoryHashEntry(i);
- }
-
+
// verify that it is sorted by date
if (!loadedAndSorted)
qSort(m_history.begin(), m_history.end());
@@ -168,24 +149,6 @@ void HistoryManager::setHistory(const QList<HistoryItem> &history, bool loadedAn
}
-HistoryModel *HistoryManager::historyModel() const
-{
- return m_historyModel;
-}
-
-
-HistoryFilterModel *HistoryManager::historyFilterModel() const
-{
- return m_historyFilterModel;
-}
-
-
-HistoryTreeModel *HistoryManager::historyTreeModel() const
-{
- return m_historyTreeModel;
-}
-
-
void HistoryManager::checkForExpired()
{
if (m_historyLimit < 0 || m_history.isEmpty())
@@ -216,44 +179,32 @@ void HistoryManager::checkForExpired()
}
if (nextTimeout > 0)
- m_expiredTimer.start(nextTimeout * 1000);
-}
-
-
-void HistoryManager::addHistoryHashEntry(const HistoryItem &item)
-{
- if (m_hash.contains(item.url))
- {
- m_hash[item.url].visitCount++;
- m_hash[item.url].dateTime = item.dateTime; //store last visit date
- if (!item.title.isEmpty())
- {
- m_hash[item.url].title = item.title; //store last title if not empty
- }
- }
- else
- {
- m_hash[item.url] = HistoryHashItem(item.url, item.dateTime, item.title);
- }
- m_hash[item.url].savedCount++;
+ QTimer::singleShot( nextTimeout * 1000, this, SLOT(checkForExpired()) );
}
void HistoryManager::updateHistoryEntry(const KUrl &url, const QString &title)
{
+ QString urlString = url.url();
+ urlString.remove(QL1S("www."));
+ if(urlString.startsWith(QL1S("http")) && urlString.endsWith(QL1C('/')))
+ urlString.remove(urlString.length()-1,1);
+
for (int i = 0; i < m_history.count(); ++i)
{
- if (url == m_history.at(i).url)
+ QString itemUrl = m_history.at(i).url;
+ itemUrl.remove(QL1S("www."));
+ if(itemUrl.startsWith(QL1S("http")) && itemUrl.endsWith(QL1C('/')))
+ itemUrl.remove(itemUrl.length()-1,1);
+
+ if (urlString == itemUrl)
{
m_history[i].title = title;
+ m_history[i].url = url.url();
m_saveTimer->changeOccurred();
if (m_lastSavedUrl.isEmpty())
m_lastSavedUrl = m_history.at(i).url;
- if (m_hash.contains(url.url()) && !title.isEmpty())
- {
- m_hash[url.url()].title = title;
- }
emit entryUpdated(i);
break;
}
@@ -279,45 +230,24 @@ void HistoryManager::removeHistoryEntry(const KUrl &url, const QString &title)
}
-HistoryHashItem HistoryManager::get(const QString &url)
+QList<HistoryItem> HistoryManager::find(const QString &text)
{
- return m_hash[url];
-}
-
+ QList<HistoryItem> list;
-QList<HistoryHashItem> HistoryManager::find(const QString &text)
-{
- QList<HistoryHashItem> list;
-
- QString url;
- foreach(url, m_hash.keys())
+ QStringList urlKeys = m_historyFilterModel->keys();
+ Q_FOREACH(const QString &url, urlKeys)
{
- if (url.contains(text) || m_hash[url].title.contains(text))
- {
- list << m_hash[url];
- }
+ int index = m_historyFilterModel->historyLocation(url);
+ HistoryItem item = m_history.at(index);
+
+ if(url.contains(text) || item.title.contains(text))
+ list << item;
}
-
+
return list;
}
-int HistoryManager::historyLimit() const
-{
- return m_historyLimit;
-}
-
-
-void HistoryManager::setHistoryLimit(int limit)
-{
- if (m_historyLimit == limit)
- return;
- m_historyLimit = limit;
- checkForExpired();
- m_saveTimer->changeOccurred();
-}
-
-
void HistoryManager::clear()
{
m_history.clear();
@@ -334,13 +264,27 @@ void HistoryManager::loadSettings()
int days;
switch (historyExpire)
{
- case 0: days = 1; break;
- case 1: days = 7; break;
- case 2: days = 14; break;
- case 3: days = 30; break;
- case 4: days = 365; break;
- case 5: days = -1; break;
- default: days = -1;
+ case 0:
+ days = 1;
+ break;
+ case 1:
+ days = 7;
+ break;
+ case 2:
+ days = 14;
+ break;
+ case 3:
+ days = 30;
+ break;
+ case 4:
+ days = 365;
+ break;
+ case 5:
+ days = -1;
+ break;
+ default:
+ days = -1;
+ break;
}
m_historyLimit = days;
}
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<HistoryHashItem> find(const QString &text);
-
- int historyLimit() const;
- void setHistoryLimit(int limit);
+ QList<HistoryItem> find(const QString &text);
- QList<HistoryItem> history() const;
+ QList<HistoryItem> history() const { return m_history; };
void setHistory(const QList<HistoryItem> &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<HistoryItem> m_history;
- QHash<QString, HistoryHashItem> m_hash;
QString m_lastSavedUrl;
- HistoryModel *m_historyModel;
HistoryFilterModel *m_historyFilterModel;
HistoryTreeModel *m_historyTreeModel;
};
diff --git a/src/history/historymodels.cpp b/src/history/historymodels.cpp
index e68eac42..9da755c5 100644
--- a/src/history/historymodels.cpp
+++ b/src/history/historymodels.cpp
@@ -58,13 +58,13 @@
HistoryModel::HistoryModel(HistoryManager *history, QObject *parent)
: QAbstractTableModel(parent)
- , m_history(history)
+ , m_historyManager(history)
{
- Q_ASSERT(m_history);
- connect(m_history, SIGNAL(historyReset()), this, SLOT(historyReset()));
- connect(m_history, SIGNAL(entryRemoved(const HistoryItem &)), this, SLOT(historyReset()));
- connect(m_history, SIGNAL(entryAdded(const HistoryItem &)), this, SLOT(entryAdded()));
- connect(m_history, SIGNAL(entryUpdated(int)), this, SLOT(entryUpdated(int)));
+ Q_ASSERT(m_historyManager);
+ connect(m_historyManager, SIGNAL(historyReset()), this, SLOT(historyReset()));
+ connect(m_historyManager, SIGNAL(entryRemoved(const HistoryItem &)), this, SLOT(historyReset()));
+ connect(m_historyManager, SIGNAL(entryAdded(const HistoryItem &)), this, SLOT(entryAdded()));
+ connect(m_historyManager, SIGNAL(entryUpdated(int)), this, SLOT(entryUpdated(int)));
}
@@ -105,7 +105,7 @@ QVariant HistoryModel::headerData(int section, Qt::Orientation orientation, int
QVariant HistoryModel::data(const QModelIndex &index, int role) const
{
- QList<HistoryItem> lst = m_history->history();
+ QList<HistoryItem> lst = m_historyManager->history();
if (index.row() < 0 || index.row() >= lst.size())
return QVariant();
@@ -165,7 +165,7 @@ int HistoryModel::columnCount(const QModelIndex &parent) const
int HistoryModel::rowCount(const QModelIndex &parent) const
{
- return (parent.isValid()) ? 0 : m_history->history().count();
+ return (parent.isValid()) ? 0 : m_historyManager->history().count();
}
@@ -175,169 +175,18 @@ bool HistoryModel::removeRows(int row, int count, const QModelIndex &parent)
return false;
int lastRow = row + count - 1;
beginRemoveRows(parent, row, lastRow);
- QList<HistoryItem> lst = m_history->history();
+ QList<HistoryItem> lst = m_historyManager->history();
for (int i = lastRow; i >= row; --i)
lst.removeAt(i);
- disconnect(m_history, SIGNAL(historyReset()), this, SLOT(historyReset()));
- m_history->setHistory(lst);
- connect(m_history, SIGNAL(historyReset()), this, SLOT(historyReset()));
+ disconnect(m_historyManager, SIGNAL(historyReset()), this, SLOT(historyReset()));
+ m_historyManager->setHistory(lst);
+ connect(m_historyManager, SIGNAL(historyReset()), this, SLOT(historyReset()));
endRemoveRows();
return true;
}
-
-// -----------------------------------------------------------------------------------------------
-
-
-#define MOVEDROWS 20
-
-
-/*
- Maps the first bunch of items of the source model to the root
-*/
-HistoryMenuModel::HistoryMenuModel(HistoryTreeModel *sourceModel, QObject *parent)
- : QAbstractProxyModel(parent)
- , m_treeModel(sourceModel)
-{
- setSourceModel(sourceModel);
-}
-
-
-int HistoryMenuModel::bumpedRows() const
-{
- QModelIndex first = m_treeModel->index(0, 0);
- if (!first.isValid())
- return 0;
- return qMin(m_treeModel->rowCount(first), MOVEDROWS);
-}
-
-
-int HistoryMenuModel::columnCount(const QModelIndex &parent) const
-{
- return m_treeModel->columnCount(mapToSource(parent));
-}
-
-
-int HistoryMenuModel::rowCount(const QModelIndex &parent) const
-{
- if (parent.column() > 0)
- return 0;
-
- if (!parent.isValid())
- {
- int folders = sourceModel()->rowCount();
- int bumpedItems = bumpedRows();
- if (bumpedItems <= MOVEDROWS
- && bumpedItems == sourceModel()->rowCount(sourceModel()->index(0, 0)))
- --folders;
- return bumpedItems + folders;
- }
-
- if (parent.internalId() == -1)
- {
- if (parent.row() < bumpedRows())
- return 0;
- }
-
- QModelIndex idx = mapToSource(parent);
- int defaultCount = sourceModel()->rowCount(idx);
- if (idx == sourceModel()->index(0, 0))
- return defaultCount - bumpedRows();
- return defaultCount;
-}
-
-
-QModelIndex HistoryMenuModel::mapFromSource(const QModelIndex &sourceIndex) const
-{
- // currently not used or autotested
- Q_ASSERT(false);
- int sr = m_treeModel->mapToSource(sourceIndex).row();
- return createIndex(sourceIndex.row(), sourceIndex.column(), sr);
-}
-
-
-QModelIndex HistoryMenuModel::mapToSource(const QModelIndex &proxyIndex) const
-{
- if (!proxyIndex.isValid())
- return QModelIndex();
-
- if (proxyIndex.internalId() == -1)
- {
- int bumpedItems = bumpedRows();
- if (proxyIndex.row() < bumpedItems)
- return m_treeModel->index(proxyIndex.row(), proxyIndex.column(), m_treeModel->index(0, 0));
- if (bumpedItems <= MOVEDROWS && bumpedItems == sourceModel()->rowCount(m_treeModel->index(0, 0)))
- --bumpedItems;
- return m_treeModel->index(proxyIndex.row() - bumpedItems, proxyIndex.column());
- }
-
- QModelIndex historyIndex = m_treeModel->sourceModel()->index(proxyIndex.internalId(), proxyIndex.column());
- QModelIndex treeIndex = m_treeModel->mapFromSource(historyIndex);
- return treeIndex;
-}
-
-
-QModelIndex HistoryMenuModel::index(int row, int column, const QModelIndex &parent) const
-{
- if (row < 0
- || column < 0 || column >= columnCount(parent)
- || parent.column() > 0)
- return QModelIndex();
- if (!parent.isValid())
- return createIndex(row, column, -1);
-
- QModelIndex treeIndexParent = mapToSource(parent);
-
- int bumpedItems = 0;
- if (treeIndexParent == m_treeModel->index(0, 0))
- bumpedItems = bumpedRows();
- QModelIndex treeIndex = m_treeModel->index(row + bumpedItems, column, treeIndexParent);
- QModelIndex historyIndex = m_treeModel->mapToSource(treeIndex);
- int historyRow = historyIndex.row();
- if (historyRow == -1)
- historyRow = treeIndex.row();
- return createIndex(row, column, historyRow);
-}
-
-
-QModelIndex HistoryMenuModel::parent(const QModelIndex &index) const
-{
- int offset = index.internalId();
- if (offset == -1 || !index.isValid())
- return QModelIndex();
-
- QModelIndex historyIndex = m_treeModel->sourceModel()->index(index.internalId(), 0);
- QModelIndex treeIndex = m_treeModel->mapFromSource(historyIndex);
- QModelIndex treeIndexParent = treeIndex.parent();
-
- int sr = m_treeModel->mapToSource(treeIndexParent).row();
- int bumpedItems = bumpedRows();
- if (bumpedItems <= MOVEDROWS && bumpedItems == sourceModel()->rowCount(sourceModel()->index(0, 0)))
- --bumpedItems;
- return createIndex(bumpedItems + treeIndexParent.row(), treeIndexParent.column(), sr);
-}
-
-
-// --------------------------------------------------------------------------------------------------------------
-
-
-TreeProxyModel::TreeProxyModel(QObject *parent) : QSortFilterProxyModel(parent)
-{
- setSortRole(HistoryModel::DateTimeRole);
- setFilterCaseSensitivity(Qt::CaseInsensitive);
-}
-
-
-bool TreeProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
-{
- if (!source_parent.isValid())
- return true;
- return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
-}
-
-
-// -------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------------------------
HistoryFilterModel::HistoryFilterModel(QAbstractItemModel *sourceModel, QObject *parent)
@@ -559,114 +408,7 @@ bool HistoryFilterModel::removeRows(int row, int count, const QModelIndex &paren
}
-// ------------------------------------------------------------------------------------------------------
-
-
-HistoryCompletionModel::HistoryCompletionModel(QObject *parent)
- : QAbstractProxyModel(parent)
-{
-}
-
-
-QVariant HistoryCompletionModel::data(const QModelIndex &index, int role) const
-{
- if (sourceModel()
- && (role == Qt::EditRole || role == Qt::DisplayRole)
- && index.isValid())
- {
- QModelIndex idx = mapToSource(index);
- idx = idx.sibling(idx.row(), 1);
- QString urlString = idx.data(HistoryModel::UrlStringRole).toString();
- if (index.row() % 2)
- {
- QUrl url = urlString;
- QString s = url.toString(QUrl::RemoveScheme
- | QUrl::RemoveUserInfo
- | QUrl::StripTrailingSlash);
- return s.mid(2); // strip // from the front
- }
- return urlString;
- }
- return QAbstractProxyModel::data(index, role);
-}
-
-
-int HistoryCompletionModel::rowCount(const QModelIndex &parent) const
-{
- return (parent.isValid() || !sourceModel()) ? 0 : sourceModel()->rowCount(parent) * 2;
-}
-
-
-int HistoryCompletionModel::columnCount(const QModelIndex &parent) const
-{
- return (parent.isValid()) ? 0 : 1;
-}
-
-
-QModelIndex HistoryCompletionModel::mapFromSource(const QModelIndex &sourceIndex) const
-{
- int row = sourceIndex.row() * 2;
- return index(row, sourceIndex.column());
-}
-
-
-QModelIndex HistoryCompletionModel::mapToSource(const QModelIndex &proxyIndex) const
-{
- if (!sourceModel())
- return QModelIndex();
- int row = proxyIndex.row() / 2;
- return sourceModel()->index(row, proxyIndex.column());
-}
-
-
-QModelIndex HistoryCompletionModel::index(int row, int column, const QModelIndex &parent) const
-{
- if (row < 0 || row >= rowCount(parent)
- || column < 0 || column >= columnCount(parent))
- return QModelIndex();
- return createIndex(row, column, 0);
-}
-
-
-QModelIndex HistoryCompletionModel::parent(const QModelIndex &) const
-{
- return QModelIndex();
-}
-
-
-void HistoryCompletionModel::setSourceModel(QAbstractItemModel *newSourceModel)
-{
- if (sourceModel())
- {
- disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset()));
- disconnect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)),
- this, SLOT(sourceReset()));
- disconnect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
- this, SLOT(sourceReset()));
- }
-
- QAbstractProxyModel::setSourceModel(newSourceModel);
-
- if (newSourceModel)
- {
- connect(newSourceModel, SIGNAL(modelReset()), this, SLOT(sourceReset()));
- connect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)),
- this, SLOT(sourceReset()));
- connect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
- this, SLOT(sourceReset()));
- }
-
- reset();
-}
-
-
-void HistoryCompletionModel::sourceReset()
-{
- reset();
-}
-
-
-// ------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------------------
HistoryTreeModel::HistoryTreeModel(QAbstractItemModel *sourceModel, QObject *parent)
@@ -977,3 +719,22 @@ void HistoryTreeModel::sourceRowsRemoved(const QModelIndex &parent, int start, i
endRemoveRows();
}
}
+
+
+// ------------------------------------------------------------------------------------------------------------------------------------------
+
+
+
+TreeProxyModel::TreeProxyModel(QObject *parent) : QSortFilterProxyModel(parent)
+{
+ setSortRole(HistoryModel::DateTimeRole);
+ setFilterCaseSensitivity(Qt::CaseInsensitive);
+}
+
+
+bool TreeProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
+{
+ if (!source_parent.isValid())
+ return true;
+ return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
+}
diff --git a/src/history/historymodels.h b/src/history/historymodels.h
index 78691694..b61e8969 100644
--- a/src/history/historymodels.h
+++ b/src/history/historymodels.h
@@ -73,19 +73,19 @@ public:
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
private:
- HistoryManager *m_history;
+ HistoryManager *m_historyManager;
};
// ----------------------------------------------------------------------------------------------------
+
/**
* Proxy model that will remove any duplicate entries.
* Both m_sourceRow and m_historyHash store their offsets not from
* the front of the list, but as offsets from the back.
*
*/
-
class REKONQ_TESTS_EXPORT HistoryFilterModel : public QAbstractProxyModel
{
Q_OBJECT
@@ -95,8 +95,16 @@ public:
inline bool historyContains(const QString &url) const
{
- load(); return m_historyHash.contains(url);
+ load();
+ return m_historyHash.contains(url);
+ }
+
+ inline QList<QString> keys() const
+ {
+ load();
+ return m_historyHash.keys();
}
+
int historyLocation(const QString &url) const;
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const;
@@ -127,72 +135,11 @@ private:
// ----------------------------------------------------------------------------------------------------------------------
-/**
- * The history menu
- * - Removes the first twenty entries and puts them as children of the top level.
- * - If there are less then twenty entries then the first folder is also removed.
- *
- * The mapping is done by knowing that HistoryTreeModel is over a table
- * We store that row offset in our index's private data.
- *
- */
-
-class HistoryMenuModel : public QAbstractProxyModel
-{
- Q_OBJECT
-
-public:
- explicit HistoryMenuModel(HistoryTreeModel *sourceModel, QObject *parent = 0);
-
- int columnCount(const QModelIndex &parent) const;
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- QModelIndex mapFromSource(const QModelIndex & sourceIndex) const;
- QModelIndex mapToSource(const QModelIndex & proxyIndex) const;
- QModelIndex index(int, int, const QModelIndex &parent = QModelIndex()) const;
- QModelIndex parent(const QModelIndex &index = QModelIndex()) const;
-
- int bumpedRows() const;
-
-private:
- HistoryTreeModel *m_treeModel;
-};
-
-
-// ----------------------------------------------------------------------------------------
-
-/**
- * Proxy model for the history model that
- * exposes each url http://www.foo.com and
- * it url starting at the host www.foo.com
- *
- */
-
-class HistoryCompletionModel : public QAbstractProxyModel
-{
- Q_OBJECT
-
-public:
- HistoryCompletionModel(QObject *parent = 0);
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- int columnCount(const QModelIndex &parent = QModelIndex()) const;
- QModelIndex mapFromSource(const QModelIndex &sourceIndex) const;
- QModelIndex mapToSource(const QModelIndex &proxyIndex) const;
- QModelIndex index(int, int, const QModelIndex& = QModelIndex()) const;
- QModelIndex parent(const QModelIndex& index = QModelIndex()) const;
- void setSourceModel(QAbstractItemModel *sourceModel);
-
-private slots:
- void sourceReset();
-
-};
-
-
-// ---------------------------------------------------------------------------------------
/**
* Proxy model for the history model that converts the list
* into a tree, one top level node per day.
+ *
* Used in the HistoryDialog.
*
*/
@@ -232,6 +179,7 @@ private:
// -----------------------------------------------------------------------------------------------------------------
+
/**
* A modified QSortFilterProxyModel that always accepts
* the root nodes in the tree
diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp
index f0fd257b..b762716a 100644
--- a/src/urlbar/urlresolver.cpp
+++ b/src/urlbar/urlresolver.cpp
@@ -313,11 +313,11 @@ UrlSearchList UrlResolver::webSearchesResolution()
// STEP 3 = history completion
UrlSearchList UrlResolver::historyResolution()
{
- QList<HistoryHashItem> found = Application::historyManager()->find(_typedString);
+ QList<HistoryItem> found = Application::historyManager()->find(_typedString);
qSort(found);
UrlSearchList list;
- foreach (HistoryHashItem i, found)
+ foreach (HistoryItem i, found)
{
if (_searchEnginesRegexp.indexIn(i.url) == -1) //filter all urls that are search engine results
{