+ KParts::OpenUrlArguments args;
+ args.setMimeType(item.mimetype());
+
+ // Ideally, konqueror should be changed to not require trustedSource for directory views,
+ // since the idea was not to need BrowserArguments for non-browser stuff...
+ KParts::BrowserArguments browserArgs;
+ browserArgs.trustedSource = true;
+ emit m_extension->openUrlRequest(item.targetUrl(), args, browserArgs);
+}
+
+void DolphinPart::createNewWindow(const KUrl& url)
+{
+ // TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
+ // should be moved into DolphinPart::slotItemTriggered()
+ KFileItem item(S_IFDIR, (mode_t)-1, url);
+ KParts::OpenUrlArguments args;
+ args.setMimeType(item.mimetype());
+ emit m_extension->createNewWindow(url, args);
+}
+
+void DolphinPart::slotOpenContextMenu(const KFileItem& _item,
+ const KUrl&,
+ const QList<QAction*>& customActions)
+{
+ KParts::BrowserExtension::PopupFlags popupFlags = KParts::BrowserExtension::DefaultPopupItems
+ | KParts::BrowserExtension::ShowProperties
+ | KParts::BrowserExtension::ShowUrlOperations;
+
+ KFileItem item(_item);
+
+ if (item.isNull()) { // viewport context menu
+ popupFlags |= KParts::BrowserExtension::ShowNavigationItems | KParts::BrowserExtension::ShowUp;
+ item = m_dirLister->rootItem();
+ if (item.isNull())
+ item = KFileItem( S_IFDIR, (mode_t)-1, url() );
+ }
+
+ 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?