+void DolphinPart::slotCompleted(const KUrl& url)
+{
+ Q_UNUSED(url)
+ emit completed();
+}
+
+void DolphinPart::slotCanceled(const KUrl& url)
+{
+ slotCompleted(url);
+}
+
+void DolphinPart::slotMessage(const QString& msg)
+{
+ emit setStatusBarText(msg);
+}
+
+void DolphinPart::slotErrorMessage(const QString& msg)
+{
+ KMessageBox::error(m_view, msg);
+}
+
+void DolphinPart::slotRequestItemInfo(const KFileItem& item)
+{
+ emit m_extension->mouseOverInfo(item);
+ if (item.isNull()) {
+ updateStatusBar();
+ } else {
+ ReadOnlyPart::setStatusBarText(item.getStatusBarInfo());
+ }
+}
+
+void DolphinPart::slotItemTriggered(const KFileItem& item)
+{
+ 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()
+ emit m_extension->createNewWindow(url);
+}
+
+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() );
+ else
+ item.setUrl(url()); // ensure we use the view url, not the canonical path (#213799)
+ }
+
+ // 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;
+ if (m_view->selectedItems().isEmpty()) {
+ items.append(item);
+ } else {
+ items = m_view->selectedItems();
+ }
+
+ KFileItemListProperties capabilities(items);
+
+ KParts::BrowserExtension::ActionGroupMap actionGroups;
+ QList<QAction *> editActions;
+ editActions += m_view->versionControlActions(m_view->selectedItems());
+ editActions += customActions;
+
+ if (!_item.isNull()) { // only for context menu on one or more items
+ bool supportsDeleting = capabilities.supportsDeleting();
+ bool supportsMoving = capabilities.supportsMoving();
+
+ if (!supportsDeleting) {
+ popupFlags |= KParts::BrowserExtension::NoDeletion;
+ }
+
+ if (supportsMoving) {
+ editActions.append(actionCollection()->action("rename"));
+ }
+
+ bool addTrash = capabilities.isLocal() && supportsMoving;
+ bool addDel = false;
+ if (supportsDeleting) {
+ 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");
+ addDel = configGroup.readEntry("ShowDeleteCommand", false);
+ }
+ }
+
+ if (addTrash)
+ editActions.append(actionCollection()->action("move_to_trash"));
+ if (addDel)
+ editActions.append(actionCollection()->action("delete"));
+
+ // Normally KonqPopupMenu only shows the "Create new" submenu 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);
+
+ 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.equals(url(), KUrl::CompareWithoutTrailingSlash /* #207572 */)) {
+ KParts::ReadOnlyPart::setUrl(newUrl);
+ const QString prettyUrl = newUrl.pathOrUrl();
+ emit m_extension->setLocationBarUrl(prettyUrl);
+ }
+}
+
+////
+
+void DolphinPartBrowserExtension::restoreState(QDataStream &stream)
+{
+ KParts::BrowserExtension::restoreState(stream);
+ m_part->view()->restoreState(stream);
+}
+
+void DolphinPartBrowserExtension::saveState(QDataStream &stream)
+{
+ KParts::BrowserExtension::saveState(stream);
+ m_part->view()->saveState(stream);
+}
+
+void DolphinPartBrowserExtension::cut()
+{
+ m_part->view()->cutSelectedItems();
+}
+
+void DolphinPartBrowserExtension::copy()
+{
+ m_part->view()->copySelectedItems();
+}
+
+void DolphinPartBrowserExtension::paste()
+{
+ m_part->view()->paste();
+}
+
+void DolphinPartBrowserExtension::pasteTo(const KUrl&)
+{
+ m_part->view()->pasteIntoFolder();
+}
+
+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::slotSelectItemsMatchingPattern()
+{
+ openSelectionDialog(i18nc("@title:window", "Select"),
+ i18n("Select all items matching this pattern:"),
+ QItemSelectionModel::Select);
+}
+
+void DolphinPart::slotUnselectItemsMatchingPattern()
+{
+ openSelectionDialog(i18nc("@title:window", "Unselect"),
+ i18n("Unselect all items matching this pattern:"),
+ QItemSelectionModel::Deselect);
+}
+
+void DolphinPart::openSelectionDialog(const QString& title, const QString& text, QItemSelectionModel::SelectionFlags command)
+{
+ bool okClicked;
+ QString pattern = KInputDialog::getText(title, text, "*", &okClicked, m_view);
+
+ if (okClicked && !pattern.isEmpty()) {
+ QRegExp patternRegExp(pattern, Qt::CaseSensitive, QRegExp::Wildcard);
+ QItemSelection matchingIndexes = childrenMatchingPattern(QModelIndex(), patternRegExp);
+ m_view->selectionModel()->select(matchingIndexes, command);
+ }
+}
+
+QItemSelection DolphinPart::childrenMatchingPattern(const QModelIndex& parent, const QRegExp& patternRegExp)
+{
+ QItemSelection matchingIndexes;
+ int numRows = m_proxyModel->rowCount(parent);
+
+ for (int row = 0; row < numRows; row++) {
+ QModelIndex index = m_proxyModel->index(row, 0, parent);
+ QModelIndex sourceIndex = m_proxyModel->mapToSource(index);
+
+ if (sourceIndex.isValid() && patternRegExp.exactMatch(m_dolphinModel->data(sourceIndex).toString())) {
+ matchingIndexes += QItemSelectionRange(index);
+ }
+
+ if (m_proxyModel->hasChildren(index)) {
+ matchingIndexes += childrenMatchingPattern(index, patternRegExp);
+ }
+ }
+
+ return matchingIndexes;
+}
+
+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.toLocalFile();
+ }
+
+ KToolInvocation::invokeTerminal(QString(), dir);
+}
+
+void DolphinPart::updateNewMenu()
+{
+ // As requested by KNewFileMenu :
+ m_newMenu->checkUpToDate();
+ m_newMenu->setViewShowsHiddenFiles(m_view->showHiddenFiles());
+ // And set the files that the menu apply on :
+ m_newMenu->setPopupFiles(url());
+}
+
+void DolphinPart::updateStatusBar()
+{
+ emit ReadOnlyPart::setStatusBarText(m_view->statusBarText());
+}
+
+void DolphinPart::updateProgress(int percent)
+{
+ m_extension->loadingProgress(percent);
+}
+
+void DolphinPart::createDirectory()
+{
+ m_newMenu->setViewShowsHiddenFiles(m_view->showHiddenFiles());
+ m_newMenu->setPopupFiles(url());
+ m_newMenu->createDirectory();
+}
+
+void DolphinPart::setFilesToSelect(const KUrl::List& files)
+{
+ m_view->markUrlsAsSelected(files);
+}
+