- 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;
+}
+
+QAction* DolphinContextMenu::createPasteAction()
+{
+ QAction* action = 0;
+ const bool isDir = !m_fileInfo.isNull() && m_fileInfo.isDir();
+ if (isDir && (m_selectedItems.count() == 1)) {
+ action = new QAction(KIcon("edit-paste"), i18nc("@action:inmenu", "Paste Into Folder"), this);
+ const QMimeData* mimeData = QApplication::clipboard()->mimeData();
+ const KUrl::List pasteData = KUrl::List::fromMimeData(mimeData);
+ action->setEnabled(!pasteData.isEmpty() && capabilities().supportsWriting());
+ connect(action, SIGNAL(triggered()), m_mainWindow, SLOT(pasteIntoFolder()));