Changeset View
Changeset View
Standalone View
Standalone View
runners/services/servicerunner.cpp
Show First 20 Lines • Show All 354 Lines • ▼ Show 20 Line(s) | 352 | foreach (const KService::Ptr &service, services) { | |||
---|---|---|---|---|---|
355 | } | 355 | } | ||
356 | 356 | | |||
357 | foreach (const KServiceAction &action, service->actions()) { | 357 | foreach (const KServiceAction &action, service->actions()) { | ||
358 | if (action.text().isEmpty() || action.exec().isEmpty() || hasSeen(action)) { | 358 | if (action.text().isEmpty() || action.exec().isEmpty() || hasSeen(action)) { | ||
359 | continue; | 359 | continue; | ||
360 | } | 360 | } | ||
361 | seen(action); | 361 | seen(action); | ||
362 | 362 | | |||
363 | 363 | const int matchIndex = action.text().indexOf(term, 0, Qt::CaseInsensitive); | |||
364 | if (!action.text().contains(term, Qt::CaseInsensitive)) { | 364 | if (matchIndex < 0) { | ||
365 | continue; | 365 | continue; | ||
366 | } | 366 | } | ||
367 | 367 | | |||
368 | Plasma::QueryMatch match(m_runner); | 368 | Plasma::QueryMatch match(m_runner); | ||
369 | match.setType(Plasma::QueryMatch::HelperMatch); | 369 | match.setType(Plasma::QueryMatch::HelperMatch); | ||
370 | if (!action.icon().isEmpty()) { | 370 | if (!action.icon().isEmpty()) { | ||
371 | match.setIconName(action.icon()); | 371 | match.setIconName(action.icon()); | ||
372 | } else { | 372 | } else { | ||
373 | match.setIconName(service->icon()); | 373 | match.setIconName(service->icon()); | ||
374 | } | 374 | } | ||
375 | match.setText(i18nc("Jump list search result, %1 is action (eg. open new tab), %2 is application (eg. browser)", | 375 | match.setText(i18nc("Jump list search result, %1 is action (eg. open new tab), %2 is application (eg. browser)", | ||
376 | "%1 - %2", action.text(), service->name())); | 376 | "%1 - %2", action.text(), service->name())); | ||
377 | match.setData(action.exec()); | 377 | match.setData(action.exec()); | ||
378 | 378 | | |||
379 | qreal relevance = 0.5; | 379 | qreal relevance = 0.5; | ||
380 | if (action.text().startsWith(term, Qt::CaseInsensitive)) { | 380 | if (matchIndex == 0) { | ||
381 | relevance += 0.05; | 381 | relevance += 0.05; | ||
382 | } | 382 | } | ||
383 | 383 | | |||
384 | match.setRelevance(relevance); | 384 | match.setRelevance(relevance); | ||
385 | 385 | | |||
386 | matches << match; | 386 | matches << match; | ||
387 | } | 387 | } | ||
388 | } | 388 | } | ||
▲ Show 20 Lines • Show All 97 Lines • Show Last 20 Lines |