Locator: Fix handling of prefix with empty input

For example: "f ", "m ".

Broken by b6e4e966f4.

Change-Id: Ic1e389c52579c86479e2c066eadfb4aaf4b66700
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2016-01-03 16:12:31 +02:00
committed by Orgad Shaneh
parent 98cb40903b
commit 16b1430d2a

View File

@@ -464,25 +464,27 @@ void LocatorWidget::showPopupNow()
QList<ILocatorFilter *> LocatorWidget::filtersFor(const QString &text, QString &searchText)
{
const QString trimmedText = text.trimmed();
QList<ILocatorFilter *> filters = m_locatorPlugin->filters();
const int whiteSpace = trimmedText.indexOf(QLatin1Char(' '));
QString prefix;
if (whiteSpace >= 0)
prefix = trimmedText.left(whiteSpace);
if (!prefix.isEmpty()) {
prefix = prefix.toLower();
const int length = text.size();
int firstNonSpace;
for (firstNonSpace = 0; firstNonSpace < length; ++firstNonSpace) {
if (!text.at(firstNonSpace).isSpace())
break;
}
const int whiteSpace = text.indexOf(QChar::Space, firstNonSpace);
const QList<ILocatorFilter *> filters = m_locatorPlugin->filters();
if (whiteSpace >= 0) {
const QString prefix = text.mid(firstNonSpace, whiteSpace - firstNonSpace).toLower();
QList<ILocatorFilter *> prefixFilters;
foreach (ILocatorFilter *filter, filters) {
if (prefix == filter->shortcutString()) {
searchText = trimmedText.mid(whiteSpace).trimmed();
searchText = text.mid(whiteSpace).trimmed();
prefixFilters << filter;
}
}
if (!prefixFilters.isEmpty())
return prefixFilters;
}
searchText = trimmedText;
searchText = text.trimmed();
QList<ILocatorFilter *> activeFilters;
foreach (ILocatorFilter *filter, filters)
if (filter->isIncludedByDefault())