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
This commit is contained in:
stippi 2010-03-02 18:56:42 +00:00 committed by Alexandre Deckner
parent 1a52acbc07
commit 0cf34b77b1
1 changed files with 10 additions and 0 deletions

View File

@ -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()));
}