From a2cb9efc54c78c47e41196f0121ca00255a4a7ab Mon Sep 17 00:00:00 2001 From: lionelc Date: Tue, 30 Mar 2010 11:37:25 +0200 Subject: add title for history items --- src/bookmarks/bookmarksmanager.cpp | 5 +++++ src/history/historymanager.cpp | 26 +++++++++++++++++++++++++- src/history/historymanager.h | 2 ++ src/urlbar/urlresolver.cpp | 2 +- 4 files changed, 33 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/bookmarks/bookmarksmanager.cpp b/src/bookmarks/bookmarksmanager.cpp index 9c3201e6..95adf387 100644 --- a/src/bookmarks/bookmarksmanager.cpp +++ b/src/bookmarks/bookmarksmanager.cpp @@ -330,6 +330,11 @@ QString BookmarkProvider::titleForBookmarkUrl(QString url) bookmark = bookGroup.next(bookmark); } + if (title.isEmpty()) + { + title = url; + } + return title; } diff --git a/src/history/historymanager.cpp b/src/history/historymanager.cpp index 39c128f4..7aded714 100644 --- a/src/history/historymanager.cpp +++ b/src/history/historymanager.cpp @@ -362,7 +362,7 @@ void HistoryManager::load() // Add item to completion object QString _url = item.url; - _url.remove(QRegExp("^http://|/$")); + //_url.remove(QRegExp("^http://|/$")); m_completion->addItem(_url); } if (needToSort) @@ -504,3 +504,27 @@ bool HistoryManager::clearDownloadsHistory() QFile downloadFile(downloadFilePath); return downloadFile.remove(); } + + +QString HistoryManager::titleForHistoryUrl(QString url) +{ + QString title = ""; + + int i = 0; + while (i< history().count() && title.isEmpty()) + { + if (history().at(i).url == url) + { + title = history().at(i).title; + } + i++; + } + + if (title.isEmpty()) + { + title = url; + } + + return title; +} + diff --git a/src/history/historymanager.h b/src/history/historymanager.h index 8fc5c30e..9a844672 100644 --- a/src/history/historymanager.h +++ b/src/history/historymanager.h @@ -141,6 +141,8 @@ public: void updateHistoryEntry(const KUrl &url, const QString &title); void removeHistoryEntry(const KUrl &url, const QString &title = QString()); + QString titleForHistoryUrl(QString url); + int historyLimit() const; void setHistoryLimit(int limit); diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp index 5593f566..3877a6c2 100644 --- a/src/urlbar/urlresolver.cpp +++ b/src/urlbar/urlresolver.cpp @@ -181,7 +181,7 @@ UrlSearchList UrlResolver::historyResolution() QStringList historyResults = historyCompletion->substringCompletion(_urlString); Q_FOREACH(const QString &s, historyResults) { - UrlSearchItem it(s, s, QString("view-history")); + UrlSearchItem it(s, Application::historyManager()->titleForHistoryUrl(s), QString("view-history")); list << it; } -- cgit v1.2.1