From a2aa033e21d1746b5479836e8d8363dcb4654d8a Mon Sep 17 00:00:00 2001 From: lionelc Date: Tue, 30 Mar 2010 19:45:27 +0200 Subject: manage common item of bookmarks and history --- src/urlbar/urlresolver.cpp | 27 +++++++++++++++++++++++++-- src/urlbar/urlresolver.h | 2 ++ 2 files changed, 27 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp index 3877a6c2..ef071c30 100644 --- a/src/urlbar/urlresolver.cpp +++ b/src/urlbar/urlresolver.cpp @@ -53,6 +53,10 @@ // 4 ."kuriikwsfilter" // 5. "fixhosturifilter" +bool UrlSearchItem::operator==(UrlSearchItem i) +{ + return url==i.url; +} UrlResolver::UrlResolver(const QString &typedUrl) : _urlString(typedUrl) @@ -97,8 +101,27 @@ UrlSearchList UrlResolver::orderedSearchItems() historyList = historyList.mid(0,3); bookmarksList = bookmarksList.mid(0,3); } - list << historyList; - list << bookmarksList; + + QList common; + + foreach (UrlSearchItem i, historyList) + { + if (!bookmarksList.contains(i)) + list << i; + else + common << i; + } + + foreach (UrlSearchItem i, common) + { + list << i; + } + + foreach (UrlSearchItem i, bookmarksList) + { + if (!common.contains(i)) + list << i; + } } return list; diff --git a/src/urlbar/urlresolver.h b/src/urlbar/urlresolver.h index 3033fc38..54b96d63 100644 --- a/src/urlbar/urlresolver.h +++ b/src/urlbar/urlresolver.h @@ -43,6 +43,8 @@ public: UrlSearchItem(const QString &_url, const QString &_title = QString(), const QString &_icon = QString()) : url(_url), title(_title), icon(_icon) {}; + + bool operator==(UrlSearchItem i); }; typedef QList UrlSearchList; -- cgit v1.2.1