+ KParts::BrowserExtension::ActionGroupMap actionGroups;
+ QList<QAction *> editActions;
+
+ editActions += customActions;
+
+ if (!_item.isNull()) { // only for context menu on one or more items
+ bool sDeleting = true;
+ bool sMoving = true;
+
+ // If the parent directory of the selected item is writable, moving
+ // and deleting are possible.
+ KFileItem parentDir = m_dirLister->rootItem();
+ if (!parentDir.isNull() && !parentDir.isWritable()) {
+ popupFlags |= KParts::BrowserExtension::NoDeletion;
+ sDeleting = false;
+ sMoving = false;
+ }
+
+ if ( sMoving )
+ editActions.append(actionCollection()->action("rename"));
+
+ bool addTrash = false;
+ bool addDel = false;
+
+ bool isIntoTrash = _item.url().protocol() == "trash";
+
+ if ( sMoving && !isIntoTrash && item.isLocalFile() )
+ addTrash = true;
+
+ if ( sDeleting ) {
+ if ( !item.isLocalFile() )
+ addDel = true;
+ else if (QApplication::keyboardModifiers() & Qt::ShiftModifier) {
+ addTrash = false;
+ addDel = true;
+ }
+ else {
+ KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::IncludeGlobals);
+ KConfigGroup configGroup(globalConfig, "KDE");
+ if ( configGroup.readEntry("ShowDeleteCommand", false) )
+ addDel = true;
+ }
+ }
+
+ if (addTrash)
+ editActions.append(actionCollection()->action("move_to_trash"));
+ if (addDel)
+ editActions.append(actionCollection()->action("delete"));
+
+ // Normally KonqPopupMenu only shows the "Create new" subdir in the current view
+ // since otherwise the created file would not be visible.
+ // But in treeview mode we should allow it.
+ if (m_view->itemsExpandable())
+ popupFlags |= KParts::BrowserExtension::ShowCreateDirectory;
+
+ }
+
+ actionGroups.insert("editactions", editActions);
+
+ // TODO: We should change the signature of the slots (and signals) for being able
+ // to tell for which items we want a popup.
+ KFileItemList items = (m_view->selectedItems().count() ? m_view->selectedItems()
+ : KFileItemList() << item);
+ emit m_extension->popupMenu(QCursor::pos(),
+ items,
+ KParts::OpenUrlArguments(),
+ KParts::BrowserArguments(),
+ popupFlags,
+ actionGroups);
+}
+
+void DolphinPart::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl)
+{
+ //kDebug() << oldUrl << newUrl << "currentUrl=" << url();
+ if (oldUrl == url()) {
+ KParts::ReadOnlyPart::setUrl(newUrl);
+ const QString prettyUrl = newUrl.pathOrUrl();
+ emit m_extension->setLocationBarUrl(prettyUrl);
+ }
+}
+
+void DolphinPart::slotRequestUrlChange(const KUrl& url)
+{
+ if (m_view->url() != url) {
+ // If the view URL is not equal to 'url', then an inner URL change has
+ // been done (e. g. by activating an existing column in the column view).
+ openUrl(url);
+ emit m_extension->openUrlNotify();
+ }
+}
+
+////
+
+void DolphinPartBrowserExtension::cut()
+{
+ m_part->view()->cutSelectedItems();
+}
+
+void DolphinPartBrowserExtension::copy()
+{
+ m_part->view()->copySelectedItems();
+}
+
+void DolphinPartBrowserExtension::paste()
+{
+ m_part->view()->paste();
+}
+
+void DolphinPartBrowserExtension::reparseConfiguration()
+{
+ m_part->view()->refresh();
+}
+
+////
+
+void DolphinPart::slotEditMimeType()
+{
+ const KFileItemList items = m_view->selectedItems();
+ if (!items.isEmpty()) {
+ KonqOperations::editMimeType(items.first().mimetype(), m_view);
+ }
+}
+
+void DolphinPart::setCurrentViewMode(const QString& viewModeName)
+{
+ QAction* action = actionCollection()->action(viewModeName);
+ Q_ASSERT(action);
+ action->trigger();
+}
+
+QString DolphinPart::currentViewMode() const
+{
+ return m_actionHandler->currentViewModeActionName();
+}
+
+void DolphinPart::setNameFilter(const QString& nameFilter)
+{
+ // This is the "/home/dfaure/*.diff" kind of name filter (KDirLister::setNameFilter)
+ // which is unrelated to DolphinView::setNameFilter which is substring filtering in a proxy.
+ m_nameFilter = nameFilter;
+ // TODO save/restore name filter in saveState/restoreState like KonqDirPart did in kde3?
+}
+
+void DolphinPart::slotOpenTerminal()
+{
+ QString dir(QDir::homePath());
+
+ KUrl u(url());
+
+ // If the given directory is not local, it can still be the URL of an
+ // ioslave using UDS_LOCAL_PATH which to be converted first.
+ u = KIO::NetAccess::mostLocalUrl(u, widget());
+
+ //If the URL is local after the above conversion, set the directory.
+ if (u.isLocalFile()) {
+ dir = u.path();
+ }
+
+ KToolInvocation::invokeTerminal(QString(), dir);
+}
+
+void DolphinPart::updateNewMenu()
+{
+ // As requested by KNewMenu :
+ m_newMenu->slotCheckUpToDate();
+ // And set the files that the menu apply on :
+ m_newMenu->setPopupFiles(url());
+}
+
+void DolphinPart::updateStatusBar()
+{
+ emit ReadOnlyPart::setStatusBarText(m_view->statusBarText());