summaryrefslogtreecommitdiff
path: root/src/history
diff options
context:
space:
mode:
Diffstat (limited to 'src/history')
-rw-r--r--src/history/historymanager.cpp33
-rw-r--r--src/history/historymanager.h19
-rw-r--r--src/history/historymodels.h4
3 files changed, 33 insertions, 23 deletions
diff --git a/src/history/historymanager.cpp b/src/history/historymanager.cpp
index b6096b55..9138ab10 100644
--- a/src/history/historymanager.cpp
+++ b/src/history/historymanager.cpp
@@ -115,17 +115,17 @@ void HistoryManager::addHistoryEntry(const QString &url)
QString checkUrlString = cleanUrl.toString();
HistoryItem item;
-
+
// NOTE
// check if the url has just been visited.
// if so, remove previous entry from history, update and prepend it
- if(historyContains(checkUrlString))
+ if (historyContains(checkUrlString))
{
int index = m_historyFilterModel->historyLocation(checkUrlString);
item = m_history.at(index);
m_history.removeOne(item);
emit entryRemoved(item);
-
+
item.dateTime = QDateTime::currentDateTime();
item.visitCount++;
}
@@ -133,10 +133,10 @@ void HistoryManager::addHistoryEntry(const QString &url)
{
item = HistoryItem(checkUrlString, QDateTime::currentDateTime());
}
-
+
m_history.prepend(item);
emit entryAdded(item);
-
+
if (m_history.count() == 1)
checkForExpired();
}
@@ -195,7 +195,7 @@ void HistoryManager::checkForExpired()
}
if (nextTimeout > 0)
- QTimer::singleShot( nextTimeout * 1000, this, SLOT(checkForExpired()) );
+ QTimer::singleShot(nextTimeout * 1000, this, SLOT(checkForExpired()));
}
@@ -203,15 +203,15 @@ 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);
+ if (urlString.startsWith(QL1S("http")) && urlString.endsWith(QL1C('/')))
+ urlString.remove(urlString.length() - 1, 1);
for (int i = 0; i < m_history.count(); ++i)
{
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 (itemUrl.startsWith(QL1S("http")) && itemUrl.endsWith(QL1C('/')))
+ itemUrl.remove(itemUrl.length() - 1, 1);
if (urlString == itemUrl)
{
@@ -258,10 +258,11 @@ QList<HistoryItem> HistoryManager::find(const QString &text)
QStringList words = text.split(' ');
bool matches = true;
- foreach (const QString &word, words)
+ foreach(const QString &word, words)
{
if (!url.contains(word, Qt::CaseInsensitive)
- && !item.title.contains(word, Qt::CaseInsensitive)) {
+ && !item.title.contains(word, Qt::CaseInsensitive))
+ {
matches = false;
break;
}
@@ -347,9 +348,9 @@ void HistoryManager::load()
buffer.open(QIODevice::ReadOnly);
quint32 version;
stream >> version;
-
+
HistoryItem item;
-
+
switch (version)
{
case HISTORY_VERSION: // default case
@@ -365,11 +366,11 @@ void HistoryManager::load()
stream >> item.title;
item.visitCount = 1;
break;
-
+
default:
continue;
};
-
+
if (!item.dateTime.isValid())
continue;
diff --git a/src/history/historymanager.h b/src/history/historymanager.h
index 72a1f12a..a7a7661e 100644
--- a/src/history/historymanager.h
+++ b/src/history/historymanager.h
@@ -70,7 +70,7 @@ public:
inline bool operator==(const HistoryItem &other) const
{
return other.title == title
- && other.url == url
+ && other.url == url
&& other.dateTime == dateTime;
}
@@ -120,13 +120,22 @@ public:
QList<HistoryItem> find(const QString &text);
- QList<HistoryItem> history() const { return m_history; };
+ 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
- HistoryFilterModel *historyFilterModel() const { return m_historyFilterModel; };
- HistoryTreeModel *historyTreeModel() const { return m_historyTreeModel; };
-
+ HistoryFilterModel *historyFilterModel() const
+ {
+ return m_historyFilterModel;
+ };
+ HistoryTreeModel *historyTreeModel() const
+ {
+ return m_historyTreeModel;
+ };
+
Q_SIGNALS:
void historyReset();
void entryAdded(const HistoryItem &item);
diff --git a/src/history/historymodels.h b/src/history/historymodels.h
index 50689392..8cb1a5dd 100644
--- a/src/history/historymodels.h
+++ b/src/history/historymodels.h
@@ -65,14 +65,14 @@ public Q_SLOTS:
void historyReset();
void entryAdded();
void entryUpdated(int offset);
-
+
public:
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
-
+
private:
HistoryManager *m_historyManager;
};