- QList<QAction*> openWithActions;
- if (insertOpenWithItems) {
- // fill the 'Open with' sub menu with application types
- const KMimeType::Ptr mimePtr = KMimeType::findByUrl(m_fileInfo.url());
- KService::List offers = KMimeTypeTrader::self()->query(mimePtr->name(),
- "Application",
- "Type == 'Application'");
- if (offers.count() > 0) {
- KService::List::Iterator it;
- KMenu* openWithMenu = new KMenu(i18nc("@title:menu", "Open With"));
- for (it = offers.begin(); it != offers.end(); ++it) {
- // The offer list from the KTrader returns duplicate
- // application entries. Although this seems to be a configuration
- // problem outside the scope of Dolphin, duplicated entries just
- // will be skipped here.
- const QString appName((*it)->name());
- if (!containsEntry(openWithMenu, appName)) {
- const KIcon icon((*it)->icon());
- QAction* action = openWithMenu->addAction(icon, appName);
- openWithVector.append(*it);
- openWithActions << action;
- }
- }
-
- openWithMenu->addSeparator();
- QAction* action = openWithMenu->addAction(i18nc("@action:inmenu Open With", "&Other..."));
-
- openWithActions << action;
- popup->addMenu(openWithMenu);
- } else {
- // No applications are registered, hence just offer
- // a "Open With..." item instead of a sub menu containing
- // only one entry.
- QAction* action = popup->addAction(i18nc("@title:menu", "Open With..."));
- openWithActions << action;
+QString DolphinContextMenu::placesName(const KUrl& url) const
+{
+ QString name = url.fileName();
+ if (name.isEmpty()) {
+ name = url.host();
+ }
+ return name;
+}
+
+bool DolphinContextMenu::placeExists(const KUrl& url) const
+{
+ const KFilePlacesModel* placesModel = DolphinSettings::instance().placesModel();
+ const int count = placesModel->rowCount();
+
+ for (int i = 0; i < count; ++i) {
+ const QModelIndex index = placesModel->index(i, 0);
+
+ if (url.equals(placesModel->url(index), KUrl::CompareWithoutTrailingSlash)) {
+ return true;