Changeset View
Changeset View
Standalone View
Standalone View
libtaskmanager/tasktools.cpp
Show First 20 Lines • Show All 607 Lines • ▼ Show 20 Line(s) | 598 | if (type.compare(application, Qt::CaseInsensitive) == 0) { | |||
---|---|---|---|---|---|
608 | break; | 608 | break; | ||
609 | } | 609 | } | ||
610 | } | 610 | } | ||
611 | } | 611 | } | ||
612 | 612 | | |||
613 | return QString(""); | 613 | return QString(""); | ||
614 | } | 614 | } | ||
615 | 615 | | |||
616 | bool launcherUrlsMatch(const QUrl &a, const QUrl &b, UrlComparisonMode mode) | 616 | bool launcherUrlsMatch(const QUrl &a, const QUrl &b, UrlComparisonMode mode) | ||
davidedmundson: launcherUrslMatch is in a somewhat hot path that is called a lot.
If we have to do this, fine… | |||||
?
Don't know, I just looked at what the rest of the code dealing with applications: URLs does. broulik: > resolving the launcher to a KService (KService::serviceByMenuId) once in the launcher,
?
>… | |||||
617 | { | 617 | { | ||
618 | QUrl sanitizedA = a; | ||||
619 | QUrl sanitizedB = b; | ||||
620 | | ||||
618 | if (mode == IgnoreQueryItems) { | 621 | if (mode == IgnoreQueryItems) { | ||
619 | return (a.adjusted(QUrl::RemoveQuery) == b.adjusted(QUrl::RemoveQuery)); | 622 | sanitizedA = a.adjusted(QUrl::RemoveQuery); | ||
623 | sanitizedB = b.adjusted(QUrl::RemoveQuery); | ||||
624 | } | ||||
625 | | ||||
626 | auto tryResolveToApplicationsUrl = [](const QUrl &url) -> QUrl { | ||||
627 | QUrl resolvedUrl = url; | ||||
628 | if (url.isLocalFile() && url.fileName().endsWith(QLatin1String(".desktop"))) { | ||||
629 | const KService::Ptr service = KService::serviceByDesktopPath(url.toLocalFile()); | ||||
630 | if (service) { | ||||
631 | // Doing setScheme + setPath results in an invalid URL, hence constructing a new one. | ||||
632 | resolvedUrl = QUrl(QStringLiteral("applications:") + service->menuId()); | ||||
633 | resolvedUrl.setQuery(url.query()); | ||||
634 | } | ||||
620 | } | 635 | } | ||
636 | return resolvedUrl; | ||||
637 | }; | ||||
638 | | ||||
639 | sanitizedA = tryResolveToApplicationsUrl(sanitizedA); | ||||
640 | sanitizedB = tryResolveToApplicationsUrl(sanitizedB); | ||||
621 | 641 | | |||
622 | return (a == b); | 642 | return (sanitizedA == sanitizedB); | ||
623 | } | 643 | } | ||
624 | 644 | | |||
625 | bool appsMatch(const QModelIndex &a, const QModelIndex &b) | 645 | bool appsMatch(const QModelIndex &a, const QModelIndex &b) | ||
626 | { | 646 | { | ||
627 | const QString &aAppId = a.data(AbstractTasksModel::AppId).toString(); | 647 | const QString &aAppId = a.data(AbstractTasksModel::AppId).toString(); | ||
628 | const QString &bAppId = b.data(AbstractTasksModel::AppId).toString(); | 648 | const QString &bAppId = b.data(AbstractTasksModel::AppId).toString(); | ||
629 | 649 | | |||
630 | if (!aAppId.isEmpty() && aAppId == bAppId) { | 650 | if (!aAppId.isEmpty() && aAppId == bAppId) { | ||
▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines |
launcherUrslMatch is in a somewhat hot path that is called a lot.
If we have to do this, fine, but if there's an alternative; such as resolving the launcher to a KService (KService::serviceByMenuId) once in the launcher, that would be IMHO much much better.
Also menuId is built from the filename; (vfolder_menu.cpp:947) (prefix in that line is empty for anything non-supersuper-legacy)
Is there a reason we can't just compare filenames here?