+void DolphinViewContainer::showItemInfo(const KFileItem& item)
+{
+ if (item.isNull()) {
+ m_statusBar->resetToDefaultText();
+ } else {
+ const QString text = item.isDir() ? item.text() : item.getStatusBarInfo();
+ m_statusBar->setText(text);
+ }
+}
+
+void DolphinViewContainer::closeFilterBar()
+{
+ m_filterBar->hide();
+ m_filterBar->clear();
+ m_view->setFocus();
+ emit showFilterBarChanged(false);
+}
+
+void DolphinViewContainer::setNameFilter(const QString& nameFilter)
+{
+ m_view->setNameFilter(nameFilter);
+ delayedStatusBarUpdate();
+}
+
+void DolphinViewContainer::activate()
+{
+ setActive(true);
+}
+
+void DolphinViewContainer::slotViewUrlAboutToBeChanged(const KUrl& url)
+{
+ // URL changes of the view can happen in two ways:
+ // 1. The URL navigator gets changed and will trigger the view to update its URL
+ // 2. The URL of the view gets changed and will trigger the URL navigator to update
+ // its URL (e.g. by clicking on an item)
+ // In this scope the view-state may only get saved in case 2:
+ if (url != m_urlNavigator->locationUrl()) {
+ saveViewState();
+ }
+}
+
+void DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged(const KUrl& url)
+{
+ // URL changes of the view can happen in two ways:
+ // 1. The URL navigator gets changed and will trigger the view to update its URL
+ // 2. The URL of the view gets changed and will trigger the URL navigator to update
+ // its URL (e.g. by clicking on an item)
+ // In this scope the view-state may only get saved in case 1:
+ if (url != m_view->url()) {
+ saveViewState();
+ }
+}
+
+void DolphinViewContainer::slotUrlNavigatorLocationChanged(const KUrl& url)
+{
+ if (KProtocolManager::supportsListing(url)) {
+ setSearchModeEnabled(isSearchUrl(url));
+ m_view->setUrl(url);
+
+ if (m_autoGrabFocus && isActive() && !isSearchUrl(url)) {
+ // When an URL has been entered, the view should get the focus.
+ // The focus must be requested asynchronously, as changing the URL might create
+ // a new view widget.
+ QTimer::singleShot(0, this, SLOT(requestFocus()));
+ }
+ } else if (KProtocolManager::isSourceProtocol(url)) {
+ QString app = "konqueror";
+ if (url.protocol().startsWith(QLatin1String("http"))) {
+ showMessage(i18nc("@info:status", // krazy:exclude=qmethods
+ "Dolphin does not support web pages, the web browser has been launched"),
+ Information);
+
+ const KConfigGroup config(KSharedConfig::openConfig("kdeglobals"), "General");
+ const QString browser = config.readEntry("BrowserApplication");
+ if (!browser.isEmpty()) {
+ app = browser;
+ if (app.startsWith('!')) {
+ // a literal command has been configured, remove the '!' prefix
+ app = app.mid(1);
+ }
+ }
+ } else {
+ showMessage(i18nc("@info:status",
+ "Protocol not supported by Dolphin, Konqueror has been launched"),
+ Information);
+ }
+
+ const QString secureUrl = KShell::quoteArg(url.pathOrUrl());
+ const QString command = app + ' ' + secureUrl;
+ KRun::runCommand(command, app, app, this);
+ } else {
+ showMessage(i18nc("@info:status", "Invalid protocol"), Error);
+ }
+}
+
+void DolphinViewContainer::dropUrls(const KUrl& destination, QDropEvent* event)
+{
+ const QString error = DragAndDropHelper::dropUrls(KFileItem(), destination, event);
+ if (!error.isEmpty()) {
+ showMessage(error, Error);
+ }
+}
+
+void DolphinViewContainer::redirect(const KUrl& oldUrl, const KUrl& newUrl)
+{
+ Q_UNUSED(oldUrl);
+ const bool block = m_urlNavigator->signalsBlocked();
+ m_urlNavigator->blockSignals(true);
+
+ // Assure that the location state is reset for redirection URLs. This
+ // allows to skip redirection URLs when going back or forward in the
+ // URL history.
+ m_urlNavigator->saveLocationState(QByteArray());
+ m_urlNavigator->setLocationUrl(newUrl);
+ setSearchModeEnabled(isSearchUrl(newUrl));
+
+ m_urlNavigator->blockSignals(block);
+}
+
+void DolphinViewContainer::requestFocus()
+{
+ m_view->setFocus();
+}
+
+void DolphinViewContainer::saveUrlCompletionMode(KGlobalSettings::Completion completion)
+{
+ GeneralSettings::setUrlCompletionMode(completion);
+}
+
+void DolphinViewContainer::slotHistoryChanged()
+{
+ QByteArray locationState = m_urlNavigator->locationState();
+ if (!locationState.isEmpty()) {
+ QDataStream stream(&locationState, QIODevice::ReadOnly);
+ m_view->restoreState(stream);
+ }
+}
+
+void DolphinViewContainer::startSearching()
+{
+ const KUrl url = m_searchBox->urlForSearching();
+ if (url.isValid() && !url.isEmpty()) {
+ m_view->setViewPropertiesContext("search");
+ m_urlNavigator->setLocationUrl(url);
+ }
+}
+
+void DolphinViewContainer::closeSearchBox()
+{
+ setSearchModeEnabled(false);
+}
+
+void DolphinViewContainer::stopDirectoryLoading()
+{
+ m_view->stopLoading();
+ m_statusBar->setProgress(100);
+}
+
+void DolphinViewContainer::slotStatusBarZoomLevelChanged(int zoomLevel)
+{
+ m_view->setZoomLevel(zoomLevel);
+}
+
+void DolphinViewContainer::showErrorMessage(const QString& msg)
+{
+ showMessage(msg, Error);
+}
+
+bool DolphinViewContainer::isSearchUrl(const KUrl& url) const
+{
+ const QString protocol = url.protocol();
+ return protocol.contains("search") || (protocol == QLatin1String("nepomuk"));
+}
+
+void DolphinViewContainer::saveViewState()
+{
+ QByteArray locationState;
+ QDataStream stream(&locationState, QIODevice::WriteOnly);
+ m_view->saveState(stream);
+ m_urlNavigator->saveLocationState(locationState);
+}
+