Changeset View
Changeset View
Standalone View
Standalone View
runners/appstream/appstreamrunner.cpp
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | |||||
50 | } | 50 | } | ||
51 | 51 | | |||
52 | static QIcon componentIcon(const AppStream::Component &comp) | 52 | static QIcon componentIcon(const AppStream::Component &comp) | ||
53 | { | 53 | { | ||
54 | QIcon ret; | 54 | QIcon ret; | ||
55 | const auto icons = comp.icons(); | 55 | const auto icons = comp.icons(); | ||
56 | if (icons.isEmpty()) { | 56 | if (icons.isEmpty()) { | ||
57 | ret = QIcon::fromTheme(QStringLiteral("package-x-generic")); | 57 | ret = QIcon::fromTheme(QStringLiteral("package-x-generic")); | ||
58 | } else foreach(const AppStream::Icon &icon, icons) { | 58 | } else for (const AppStream::Icon &icon : icons) { | ||
59 | QStringList stock; | 59 | QStringList stock; | ||
60 | switch(icon.kind()) { | 60 | switch(icon.kind()) { | ||
61 | case AppStream::Icon::KindLocal: | 61 | case AppStream::Icon::KindLocal: | ||
62 | ret.addFile(icon.url().toLocalFile(), icon.size()); | 62 | ret.addFile(icon.url().toLocalFile(), icon.size()); | ||
63 | break; | 63 | break; | ||
64 | case AppStream::Icon::KindCached: | 64 | case AppStream::Icon::KindCached: | ||
65 | ret.addFile(icon.url().toLocalFile(), icon.size()); | 65 | ret.addFile(icon.url().toLocalFile(), icon.size()); | ||
66 | break; | 66 | break; | ||
Show All 10 Lines | |||||
77 | return ret; | 77 | return ret; | ||
78 | } | 78 | } | ||
79 | 79 | | |||
80 | void InstallerRunner::match(Plasma::RunnerContext &context) | 80 | void InstallerRunner::match(Plasma::RunnerContext &context) | ||
81 | { | 81 | { | ||
82 | if(context.query().size() <= 2) | 82 | if(context.query().size() <= 2) | ||
83 | return; | 83 | return; | ||
84 | 84 | | |||
85 | auto components = findComponentsByString(context.query()); | 85 | const auto components = findComponentsByString(context.query()); | ||
86 | 86 | | |||
87 | foreach(const AppStream::Component &component, components) { | 87 | for (const AppStream::Component &component : components) { | ||
88 | if (component.kind() != AppStream::Component::KindDesktopApp) | 88 | if (component.kind() != AppStream::Component::KindDesktopApp) | ||
89 | continue; | 89 | continue; | ||
90 | 90 | | |||
91 | const auto idWithoutDesktop = component.id().remove(".desktop"); | 91 | const auto idWithoutDesktop = component.id().remove(".desktop"); | ||
92 | const auto serviceQuery = QStringLiteral("exist Exec and (('%1' =~ DesktopEntryName) or '%2' =~ DesktopEntryName)").arg(component.id(), idWithoutDesktop); | 92 | const auto serviceQuery = QStringLiteral("exist Exec and (('%1' =~ DesktopEntryName) or '%2' =~ DesktopEntryName)").arg(component.id(), idWithoutDesktop); | ||
93 | const auto servicesFound = KServiceTypeTrader::self()->query(QStringLiteral("Application"), serviceQuery); | 93 | const auto servicesFound = KServiceTypeTrader::self()->query(QStringLiteral("Application"), serviceQuery); | ||
94 | if (!servicesFound.isEmpty()) | 94 | if (!servicesFound.isEmpty()) | ||
95 | continue; | 95 | continue; | ||
Show All 38 Lines |