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:
parent
1a52acbc07
commit
0cf34b77b1
|
@ -109,6 +109,8 @@ class BrowsingHistoryChoiceModel : public BAutoCompleter::ChoiceModel {
|
||||||
if (!history->Lock())
|
if (!history->Lock())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
BString lastBaseURL;
|
||||||
|
|
||||||
count = history->countItems();
|
count = history->countItems();
|
||||||
for (int32 i = 0; i < count; i++) {
|
for (int32 i = 0; i < count; i++) {
|
||||||
BrowsingHistoryItem item = history->historyItemAt(i);
|
BrowsingHistoryItem item = history->historyItemAt(i);
|
||||||
|
@ -116,6 +118,14 @@ class BrowsingHistoryChoiceModel : public BAutoCompleter::ChoiceModel {
|
||||||
int32 matchPos = choiceText.IFindFirst(pattern);
|
int32 matchPos = choiceText.IFindFirst(pattern);
|
||||||
if (matchPos < 0)
|
if (matchPos < 0)
|
||||||
continue;
|
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,
|
fChoices.AddItem(new BAutoCompleter::Choice(choiceText,
|
||||||
choiceText, matchPos, pattern.Length()));
|
choiceText, matchPos, pattern.Length()));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue