From 0cf34b77b1bcdb6e2d4b0d527026f0f47e4588f3 Mon Sep 17 00:00:00 2001 From: stippi Date: Tue, 2 Mar 2010 18:56:42 +0000 Subject: [PATCH] Ok, the most simplistic way to avoid having too many similars in the autocompletion choices is to find the "base url" (I am taking the string between :// and the next /) and avoid adding any more urls with the same base URL. Seems to work reasonably well. If anyone has any smarter ideas, please speak up! :-) git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@269 94f232f2-1747-11df-bad5-a5bfde151594 --- src/apps/webpositive/BrowserWindow.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/apps/webpositive/BrowserWindow.cpp b/src/apps/webpositive/BrowserWindow.cpp index 8ffbfd8797..12008f1362 100644 --- a/src/apps/webpositive/BrowserWindow.cpp +++ b/src/apps/webpositive/BrowserWindow.cpp @@ -109,6 +109,8 @@ class BrowsingHistoryChoiceModel : public BAutoCompleter::ChoiceModel { if (!history->Lock()) return; + BString lastBaseURL; + count = history->countItems(); for (int32 i = 0; i < count; i++) { BrowsingHistoryItem item = history->historyItemAt(i); @@ -116,6 +118,14 @@ class BrowsingHistoryChoiceModel : public BAutoCompleter::ChoiceModel { int32 matchPos = choiceText.IFindFirst(pattern); if (matchPos < 0) continue; + if (lastBaseURL.Length() > 0 + && choiceText.FindFirst(lastBaseURL) >= 0) { + continue; + } + int32 baseURLStart = choiceText.FindFirst("://") + 3; + int32 baseURLEnd = choiceText.FindFirst("/", baseURLStart + 1); + lastBaseURL.SetTo(choiceText.String() + baseURLStart, + baseURLEnd - baseURLStart); fChoices.AddItem(new BAutoCompleter::Choice(choiceText, choiceText, matchPos, pattern.Length())); }