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 | | ||||
629 | if (url.isLocalFile() && KDesktopFile::isDesktopFile(url.toLocalFile())) { | ||||
630 | KDesktopFile f(url.toLocalFile()); | ||||
631 | | ||||
632 | const KService::Ptr service = KService::serviceByStorageId(f.fileName()); | ||||
633 | | ||||
634 | // Resolve to non-absolute menuId-based URL if possible. | ||||
635 | if (service) { | ||||
636 | const QString &menuId = service->menuId(); | ||||
637 | | ||||
638 | if (!menuId.isEmpty()) { | ||||
639 | resolvedUrl = QUrl(QStringLiteral("applications:") + menuId); | ||||
640 | resolvedUrl.setQuery(url.query()); | ||||
620 | } | 641 | } | ||
642 | } | ||||
643 | } | ||||
644 | | ||||
645 | return resolvedUrl; | ||||
646 | }; | ||||
647 | | ||||
648 | sanitizedA = tryResolveToApplicationsUrl(sanitizedA); | ||||
649 | sanitizedB = tryResolveToApplicationsUrl(sanitizedB); | ||||
621 | 650 | | |||
622 | return (a == b); | 651 | return (sanitizedA == sanitizedB); | ||
623 | } | 652 | } | ||
624 | 653 | | |||
625 | bool appsMatch(const QModelIndex &a, const QModelIndex &b) | 654 | bool appsMatch(const QModelIndex &a, const QModelIndex &b) | ||
626 | { | 655 | { | ||
627 | const QString &aAppId = a.data(AbstractTasksModel::AppId).toString(); | 656 | const QString &aAppId = a.data(AbstractTasksModel::AppId).toString(); | ||
628 | const QString &bAppId = b.data(AbstractTasksModel::AppId).toString(); | 657 | const QString &bAppId = b.data(AbstractTasksModel::AppId).toString(); | ||
629 | 658 | | |||
630 | if (!aAppId.isEmpty() && aAppId == bAppId) { | 659 | 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?