diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/urlbar/urlresolver.cpp | 38 | ||||
-rw-r--r-- | src/urlbar/urlresolver.h | 13 |
2 files changed, 33 insertions, 18 deletions
diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp index 21e3fe9c..af176a98 100644 --- a/src/urlbar/urlresolver.cpp +++ b/src/urlbar/urlresolver.cpp @@ -140,11 +140,22 @@ UrlSearchList UrlResolver::orderedSearchItems() int firstResults = list.count(); int checkPoint = 9 - firstResults; + UrlSearchList bookmarksList = bookmarksResolution(); + UrlSearchItem privileged = privilegedItem(&bookmarksList); + int bookmarkResults = bookmarksList.count(); + UrlSearchList historyList = historyResolution(); - int historyResults = historyList.count(); + if (privileged.type == UrlSearchItem::Undefined) + { + privileged = privilegedItem(&historyList); + } + + if (privileged.type != UrlSearchItem::Undefined) + { + list.insert(0,privileged); + } - UrlSearchList bookmarksList = bookmarksResolution(); - int bookmarkResults = bookmarksList.count(); + int historyResults = historyList.count(); if (historyResults + bookmarkResults > checkPoint) { @@ -178,8 +189,6 @@ UrlSearchList UrlResolver::orderedSearchItems() list << i; } - list = placeTypedDomaineNameOnTop(list); - return list; } @@ -246,22 +255,19 @@ UrlSearchList UrlResolver::bookmarksResolution() } -UrlSearchList UrlResolver::placeTypedDomaineNameOnTop(UrlSearchList list) +UrlSearchItem UrlResolver::privilegedItem(UrlSearchList* list) { - int i = 0; - bool found = false; - - while(i<list.count() && !found) + int i=0; + while(i<list->count()) { - UrlSearchItem item = list.at(i); + UrlSearchItem item = list->at(i); if (item.url.url().contains("."+_typedString+".") || item.url.url().contains("/"+_typedString+".")) { - list.removeAt(i); - list.insert(0,item); - found = true; + list->removeAt(i); + return item; } i++; } - - return list; + return UrlSearchItem(); } + diff --git a/src/urlbar/urlresolver.h b/src/urlbar/urlresolver.h index 0c7df8c8..2249ea32 100644 --- a/src/urlbar/urlresolver.h +++ b/src/urlbar/urlresolver.h @@ -45,6 +45,7 @@ public: enum types { + Undefined = 0x00000000, Search = 0x00000001, Browse = 0x00000010, History = 0x00000100, @@ -54,7 +55,15 @@ public: int type; KUrl url; QString title; - + + UrlSearchItem(const UrlSearchItem &item) + : type(item.type), url(item.url), title(item.title) + {}; + + UrlSearchItem() + : type(UrlSearchItem::Undefined), url(KUrl()), title("") + {}; + UrlSearchItem(const int &_type, const KUrl &_url, const QString &_title = QString()) : type(_type), url(_url), title(_title) {}; @@ -82,7 +91,7 @@ private: UrlSearchList historyResolution(); UrlSearchList qurlFromUserInputResolution(); UrlSearchList bookmarksResolution(); - UrlSearchList placeTypedDomaineNameOnTop(UrlSearchList list); + UrlSearchItem privilegedItem(UrlSearchList* list); static QRegExp _browseRegexp; }; |