Changeset View
Changeset View
Standalone View
Standalone View
addons/project/kateprojecttreeviewcontextmenu.cpp
Show First 20 Lines • Show All 85 Lines • ▼ Show 20 Line(s) | 77 | { | |||
---|---|---|---|---|---|
86 | QAction *copyAction = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-copy")), i18n("Copy File Path")); | 86 | QAction *copyAction = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-copy")), i18n("Copy File Path")); | ||
87 | 87 | | |||
88 | /** | 88 | /** | ||
89 | * Handle "open with", | 89 | * Handle "open with", | ||
90 | * find correct mimetype to query for possible applications | 90 | * find correct mimetype to query for possible applications | ||
91 | */ | 91 | */ | ||
92 | QMenu *openWithMenu = menu.addMenu(i18n("Open With")); | 92 | QMenu *openWithMenu = menu.addMenu(i18n("Open With")); | ||
93 | QMimeType mimeType = QMimeDatabase().mimeTypeForFile(filename); | 93 | QMimeType mimeType = QMimeDatabase().mimeTypeForFile(filename); | ||
94 | KService::List offers = KMimeTypeTrader::self()->query(mimeType.name(), QStringLiteral("Application")); | 94 | const KService::List offers = KMimeTypeTrader::self()->query(mimeType.name(), QStringLiteral("Application")); | ||
95 | // For each one, insert a menu item... | 95 | // For each one, insert a menu item... | ||
96 | for (KService::List::Iterator it = offers.begin(); it != offers.end(); ++it) { | 96 | for (const auto& service : offers) { | ||
97 | KService::Ptr service = *it; | | |||
98 | if (service->name() == QStringLiteral("Kate")) { | 97 | if (service->name() == QStringLiteral("Kate")) { | ||
99 | continue; // omit Kate | 98 | continue; // omit Kate | ||
100 | } | 99 | } | ||
101 | QAction *action = openWithMenu->addAction(QIcon::fromTheme(service->icon()), service->name()); | 100 | QAction *action = openWithMenu->addAction(QIcon::fromTheme(service->icon()), service->name()); | ||
102 | action->setData(service->entryPath()); | 101 | action->setData(service->entryPath()); | ||
103 | } | 102 | } | ||
104 | // Perhaps disable menu, if no entries | 103 | // Perhaps disable menu, if no entries | ||
105 | openWithMenu->setEnabled(!openWithMenu->isEmpty()); | 104 | openWithMenu->setEnabled(!openWithMenu->isEmpty()); | ||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |