]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinviewcontainer.cpp
Dolphin: port from KonqOperations::doDrop to the new KIO::DropJob
[dolphin.git] / src / dolphinviewcontainer.cpp
1 /***************************************************************************
2 * Copyright (C) 2007 by Peter Penz <peter.penz19@gmail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #include "dolphinviewcontainer.h"
21 #include <KProtocolManager>
22
23 #include <QDropEvent>
24 #include <QTimer>
25 #include <QMimeData>
26 #include <QVBoxLayout>
27
28 #include <KFileItemActions>
29 #include <KFilePlacesModel>
30 #include <KLocalizedString>
31 #include <KIO/PreviewJob>
32 #include <KMessageWidget>
33 #include <KShell>
34 #include <QUrl>
35 #include <KUrlComboBox>
36 #include <KUrlNavigator>
37 #include <KRun>
38
39 #ifdef KActivities_FOUND
40 #endif
41
42 #include "dolphin_generalsettings.h"
43 #include "filterbar/filterbar.h"
44 #include "search/dolphinsearchbox.h"
45 #include "statusbar/dolphinstatusbar.h"
46 #include "views/viewmodecontroller.h"
47 #include "views/viewproperties.h"
48
49 DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
50 QWidget(parent),
51 m_topLayout(0),
52 m_urlNavigator(0),
53 m_searchBox(0),
54 m_messageWidget(0),
55 m_view(0),
56 m_filterBar(0),
57 m_statusBar(0),
58 m_statusBarTimer(0),
59 m_statusBarTimestamp(),
60 m_autoGrabFocus(true)
61 #ifdef KActivities_FOUND
62 , m_activityResourceInstance(0)
63 #endif
64 {
65 hide();
66
67 m_topLayout = new QVBoxLayout(this);
68 m_topLayout->setSpacing(0);
69 m_topLayout->setMargin(0);
70
71 m_urlNavigator = new KUrlNavigator(new KFilePlacesModel(this), url, this);
72 connect(m_urlNavigator, &KUrlNavigator::activated,
73 this, &DolphinViewContainer::activate);
74 connect(m_urlNavigator->editor(), &KUrlComboBox::completionModeChanged,
75 this, &DolphinViewContainer::saveUrlCompletionMode);
76
77 const GeneralSettings* settings = GeneralSettings::self();
78 m_urlNavigator->setUrlEditable(settings->editableUrl());
79 m_urlNavigator->setShowFullPath(settings->showFullPath());
80 m_urlNavigator->setHomeUrl(QUrl::fromLocalFile(settings->homeUrl()));
81 KUrlComboBox* editor = m_urlNavigator->editor();
82 editor->setCompletionMode(KCompletion::CompletionMode(settings->urlCompletionMode()));
83
84 m_searchBox = new DolphinSearchBox(this);
85 m_searchBox->hide();
86 connect(m_searchBox, &DolphinSearchBox::activated, this, &DolphinViewContainer::activate);
87 connect(m_searchBox, &DolphinSearchBox::closeRequest, this, &DolphinViewContainer::closeSearchBox);
88 connect(m_searchBox, &DolphinSearchBox::searchRequest, this, &DolphinViewContainer::startSearching);
89 connect(m_searchBox, &DolphinSearchBox::returnPressed, this, &DolphinViewContainer::requestFocus);
90
91 m_messageWidget = new KMessageWidget(this);
92 m_messageWidget->setCloseButtonVisible(true);
93 m_messageWidget->hide();
94
95 m_view = new DolphinView(url, this);
96 connect(m_view, &DolphinView::urlChanged,
97 m_urlNavigator, &KUrlNavigator::setUrl);
98 connect(m_view, &DolphinView::urlChanged,
99 m_messageWidget, &KMessageWidget::hide);
100 connect(m_view, &DolphinView::directoryLoadingCompleted,
101 m_messageWidget, &KMessageWidget::hide);
102 connect(m_view, &DolphinView::writeStateChanged,
103 this, &DolphinViewContainer::writeStateChanged);
104 connect(m_view, &DolphinView::requestItemInfo,
105 this, &DolphinViewContainer::showItemInfo);
106 connect(m_view, &DolphinView::itemActivated,
107 this, &DolphinViewContainer::slotItemActivated);
108 connect(m_view, &DolphinView::itemsActivated,
109 this, &DolphinViewContainer::slotItemsActivated);
110 connect(m_view, &DolphinView::redirection,
111 this, &DolphinViewContainer::redirect);
112 connect(m_view, &DolphinView::directoryLoadingStarted,
113 this, &DolphinViewContainer::slotDirectoryLoadingStarted);
114 connect(m_view, &DolphinView::directoryLoadingCompleted,
115 this, &DolphinViewContainer::slotDirectoryLoadingCompleted);
116 connect(m_view, &DolphinView::directoryLoadingCanceled,
117 this, &DolphinViewContainer::slotDirectoryLoadingCanceled);
118 connect(m_view, &DolphinView::itemCountChanged,
119 this, &DolphinViewContainer::delayedStatusBarUpdate);
120 connect(m_view, &DolphinView::directoryLoadingProgress,
121 this, &DolphinViewContainer::updateDirectoryLoadingProgress);
122 connect(m_view, &DolphinView::directorySortingProgress,
123 this, &DolphinViewContainer::updateDirectorySortingProgress);
124 connect(m_view, &DolphinView::selectionChanged,
125 this, &DolphinViewContainer::delayedStatusBarUpdate);
126 connect(m_view, &DolphinView::urlAboutToBeChanged,
127 this, &DolphinViewContainer::slotViewUrlAboutToBeChanged);
128 connect(m_view, &DolphinView::errorMessage,
129 this, &DolphinViewContainer::showErrorMessage);
130 connect(m_view, &DolphinView::urlIsFileError,
131 this, &DolphinViewContainer::slotUrlIsFileError);
132 connect(m_view, &DolphinView::activated,
133 this, &DolphinViewContainer::activate);
134
135 connect(m_urlNavigator, &KUrlNavigator::urlAboutToBeChanged,
136 this, &DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged);
137 connect(m_urlNavigator, &KUrlNavigator::urlChanged,
138 this, &DolphinViewContainer::slotUrlNavigatorLocationChanged);
139 connect(m_urlNavigator, &KUrlNavigator::historyChanged,
140 this, &DolphinViewContainer::slotHistoryChanged);
141 connect(m_urlNavigator, &KUrlNavigator::returnPressed,
142 this, &DolphinViewContainer::slotReturnPressed);
143 connect(m_urlNavigator, &KUrlNavigator::urlsDropped,
144 m_view, &DolphinView::dropUrls);
145
146 // Initialize status bar
147 m_statusBar = new DolphinStatusBar(this);
148 m_statusBar->setUrl(m_view->url());
149 m_statusBar->setZoomLevel(m_view->zoomLevel());
150 connect(m_view, &DolphinView::urlChanged,
151 m_statusBar, &DolphinStatusBar::setUrl);
152 connect(m_view, &DolphinView::zoomLevelChanged,
153 m_statusBar, &DolphinStatusBar::setZoomLevel);
154 connect(m_view, &DolphinView::infoMessage,
155 m_statusBar, &DolphinStatusBar::setText);
156 connect(m_view, &DolphinView::operationCompletedMessage,
157 m_statusBar, &DolphinStatusBar::setText);
158 connect(m_statusBar, &DolphinStatusBar::stopPressed,
159 this, &DolphinViewContainer::stopDirectoryLoading);
160 connect(m_statusBar, &DolphinStatusBar::zoomLevelChanged,
161 this, &DolphinViewContainer::slotStatusBarZoomLevelChanged);
162
163 m_statusBarTimer = new QTimer(this);
164 m_statusBarTimer->setSingleShot(true);
165 m_statusBarTimer->setInterval(300);
166 connect(m_statusBarTimer, &QTimer::timeout, this, &DolphinViewContainer::updateStatusBar);
167
168 KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self();
169 connect(undoManager, &KIO::FileUndoManager::jobRecordingFinished,
170 this, &DolphinViewContainer::delayedStatusBarUpdate);
171
172 // Initialize filter bar
173 m_filterBar = new FilterBar(this);
174 m_filterBar->setVisible(settings->filterBar());
175 connect(m_filterBar, &FilterBar::filterChanged,
176 this, &DolphinViewContainer::setNameFilter);
177 connect(m_filterBar, &FilterBar::closeRequest,
178 this, &DolphinViewContainer::closeFilterBar);
179 connect(m_filterBar, &FilterBar::focusViewRequest,
180 this, &DolphinViewContainer::requestFocus);
181 connect(m_view, &DolphinView::urlChanged,
182 m_filterBar, &FilterBar::slotUrlChanged);
183
184 m_topLayout->addWidget(m_urlNavigator);
185 m_topLayout->addWidget(m_searchBox);
186 m_topLayout->addWidget(m_messageWidget);
187 m_topLayout->addWidget(m_view);
188 m_topLayout->addWidget(m_filterBar);
189 m_topLayout->addWidget(m_statusBar);
190
191 setSearchModeEnabled(isSearchUrl(url));
192
193 // Initialize kactivities resource instance
194
195 #ifdef KActivities_FOUND
196 m_activityResourceInstance = new KActivities::ResourceInstance(
197 window()->winId(), url);
198 m_activityResourceInstance->setParent(this);
199 #endif
200 }
201
202 DolphinViewContainer::~DolphinViewContainer()
203 {
204 }
205
206 QUrl DolphinViewContainer::url() const
207 {
208 return m_view->url();
209 }
210
211 void DolphinViewContainer::setActive(bool active)
212 {
213 m_searchBox->setActive(active);
214 m_urlNavigator->setActive(active);
215 m_view->setActive(active);
216
217 #ifdef KActivities_FOUND
218 if (active) {
219 m_activityResourceInstance->notifyFocusedIn();
220 } else {
221 m_activityResourceInstance->notifyFocusedOut();
222 }
223 #endif
224 }
225
226 bool DolphinViewContainer::isActive() const
227 {
228 Q_ASSERT(m_view->isActive() == m_urlNavigator->isActive());
229 return m_view->isActive();
230 }
231
232 void DolphinViewContainer::setAutoGrabFocus(bool grab)
233 {
234 m_autoGrabFocus = grab;
235 }
236
237 bool DolphinViewContainer::autoGrabFocus() const
238 {
239 return m_autoGrabFocus;
240 }
241
242 const DolphinStatusBar* DolphinViewContainer::statusBar() const
243 {
244 return m_statusBar;
245 }
246
247 DolphinStatusBar* DolphinViewContainer::statusBar()
248 {
249 return m_statusBar;
250 }
251
252 const KUrlNavigator* DolphinViewContainer::urlNavigator() const
253 {
254 return m_urlNavigator;
255 }
256
257 KUrlNavigator* DolphinViewContainer::urlNavigator()
258 {
259 return m_urlNavigator;
260 }
261
262 const DolphinView* DolphinViewContainer::view() const
263 {
264 return m_view;
265 }
266
267 DolphinView* DolphinViewContainer::view()
268 {
269 return m_view;
270 }
271
272 void DolphinViewContainer::showMessage(const QString& msg, MessageType type)
273 {
274 if (msg.isEmpty()) {
275 return;
276 }
277
278 m_messageWidget->setText(msg);
279
280 switch (type) {
281 case Information: m_messageWidget->setMessageType(KMessageWidget::Information); break;
282 case Warning: m_messageWidget->setMessageType(KMessageWidget::Warning); break;
283 case Error: m_messageWidget->setMessageType(KMessageWidget::Error); break;
284 default:
285 Q_ASSERT(false);
286 break;
287 }
288
289 m_messageWidget->setWordWrap(false);
290 const int unwrappedWidth = m_messageWidget->sizeHint().width();
291 m_messageWidget->setWordWrap(unwrappedWidth > size().width());
292
293 if (m_messageWidget->isVisible()) {
294 m_messageWidget->hide();
295 }
296 m_messageWidget->animatedShow();
297 }
298
299 void DolphinViewContainer::readSettings()
300 {
301 if (GeneralSettings::modifiedStartupSettings()) {
302 // The startup settings should only get applied if they have been
303 // modified by the user. Otherwise keep the (possibly) different current
304 // settings of the URL navigator and the filterbar.
305 m_urlNavigator->setUrlEditable(GeneralSettings::editableUrl());
306 m_urlNavigator->setShowFullPath(GeneralSettings::showFullPath());
307 m_urlNavigator->setHomeUrl(QUrl::fromLocalFile(GeneralSettings::homeUrl()));
308 setFilterBarVisible(GeneralSettings::filterBar());
309 }
310
311 m_view->readSettings();
312 m_statusBar->readSettings();
313 }
314
315 bool DolphinViewContainer::isFilterBarVisible() const
316 {
317 return m_filterBar->isVisible();
318 }
319
320 void DolphinViewContainer::setSearchModeEnabled(bool enabled)
321 {
322 if (enabled == isSearchModeEnabled()) {
323 if (enabled && !m_searchBox->hasFocus()) {
324 m_searchBox->setFocus();
325 m_searchBox->selectAll();
326 }
327 return;
328 }
329
330 m_searchBox->setVisible(enabled);
331 m_urlNavigator->setVisible(!enabled);
332
333 if (enabled) {
334 const QUrl& locationUrl = m_urlNavigator->locationUrl();
335 m_searchBox->fromSearchUrl(locationUrl);
336 } else {
337 m_view->setViewPropertiesContext(QString());
338
339 // Restore the URL for the URL navigator. If Dolphin has been
340 // started with a search-URL, the home URL is used as fallback.
341 QUrl url = m_searchBox->searchPath();
342 if (url.isEmpty() || !url.isValid() || isSearchUrl(url)) {
343 url = QUrl::fromLocalFile(GeneralSettings::self()->homeUrl());
344 }
345 m_urlNavigator->setLocationUrl(url);
346 }
347 }
348
349 bool DolphinViewContainer::isSearchModeEnabled() const
350 {
351 return m_searchBox->isVisible();
352 }
353
354 QString DolphinViewContainer::placesText() const
355 {
356 QString text;
357
358 if (isSearchModeEnabled()) {
359 text = m_searchBox->searchPath().fileName() + QLatin1String(": ") + m_searchBox->text();
360 } else {
361 text = url().fileName();
362 if (text.isEmpty()) {
363 text = url().host();
364 }
365 }
366
367 return text;
368 }
369
370 void DolphinViewContainer::setUrl(const QUrl& newUrl)
371 {
372 if (newUrl != m_urlNavigator->locationUrl()) {
373 m_urlNavigator->setLocationUrl(newUrl);
374 }
375
376 #ifdef KActivities_FOUND
377 m_activityResourceInstance->setUri(newUrl);
378 #endif
379 }
380
381 void DolphinViewContainer::setFilterBarVisible(bool visible)
382 {
383 Q_ASSERT(m_filterBar);
384 if (visible) {
385 m_filterBar->show();
386 m_filterBar->setFocus();
387 m_filterBar->selectAll();
388 } else {
389 closeFilterBar();
390 }
391 }
392
393 void DolphinViewContainer::delayedStatusBarUpdate()
394 {
395 if (m_statusBarTimer->isActive() && (m_statusBarTimestamp.elapsed() > 2000)) {
396 // No update of the statusbar has been done during the last 2 seconds,
397 // although an update has been requested. Trigger an immediate update.
398 m_statusBarTimer->stop();
399 updateStatusBar();
400 } else {
401 // Invoke updateStatusBar() with a small delay. This assures that
402 // when a lot of delayedStatusBarUpdates() are done in a short time,
403 // no bottleneck is given.
404 m_statusBarTimer->start();
405 }
406 }
407
408 void DolphinViewContainer::updateStatusBar()
409 {
410 m_statusBarTimestamp.start();
411
412 const QString text = m_view->statusBarText();
413 m_statusBar->setDefaultText(text);
414 m_statusBar->resetToDefaultText();
415 }
416
417 void DolphinViewContainer::updateDirectoryLoadingProgress(int percent)
418 {
419 if (m_statusBar->progressText().isEmpty()) {
420 m_statusBar->setProgressText(i18nc("@info:progress", "Loading folder..."));
421 }
422 m_statusBar->setProgress(percent);
423 }
424
425 void DolphinViewContainer::updateDirectorySortingProgress(int percent)
426 {
427 if (m_statusBar->progressText().isEmpty()) {
428 m_statusBar->setProgressText(i18nc("@info:progress", "Sorting..."));
429 }
430 m_statusBar->setProgress(percent);
431 }
432
433 void DolphinViewContainer::slotDirectoryLoadingStarted()
434 {
435 if (isSearchUrl(url())) {
436 // Search KIO-slaves usually don't provide any progress information. Give
437 // a hint to the user that a searching is done:
438 updateStatusBar();
439 m_statusBar->setProgressText(i18nc("@info", "Searching..."));
440 m_statusBar->setProgress(-1);
441 } else {
442 // Trigger an undetermined progress indication. The progress
443 // information in percent will be triggered by the percent() signal
444 // of the directory lister later.
445 updateDirectoryLoadingProgress(-1);
446 }
447 }
448
449 void DolphinViewContainer::slotDirectoryLoadingCompleted()
450 {
451 if (!m_statusBar->progressText().isEmpty()) {
452 m_statusBar->setProgressText(QString());
453 m_statusBar->setProgress(100);
454 }
455
456 if (isSearchUrl(url()) && m_view->itemsCount() == 0) {
457 // The dir lister has been completed on a Baloo-URI and no items have been found. Instead
458 // of showing the default status bar information ("0 items") a more helpful information is given:
459 m_statusBar->setText(i18nc("@info:status", "No items found."));
460 } else {
461 updateStatusBar();
462 }
463 }
464
465 void DolphinViewContainer::slotDirectoryLoadingCanceled()
466 {
467 if (!m_statusBar->progressText().isEmpty()) {
468 m_statusBar->setProgressText(QString());
469 m_statusBar->setProgress(100);
470 }
471
472 m_statusBar->setText(QString());
473 }
474
475 void DolphinViewContainer::slotUrlIsFileError(const QUrl& url)
476 {
477 const KFileItem item(url);
478
479 // Find out if the file can be opened in the view (for example, this is the
480 // case if the file is an archive). The mime type must be known for that.
481 item.determineMimeType();
482 const QUrl& folderUrl = DolphinView::openItemAsFolderUrl(item, true);
483 if (!folderUrl.isEmpty()) {
484 m_view->setUrl(folderUrl);
485 } else {
486 slotItemActivated(item);
487 }
488 }
489
490 void DolphinViewContainer::slotItemActivated(const KFileItem& item)
491 {
492 // It is possible to activate items on inactive views by
493 // drag & drop operations. Assure that activating an item always
494 // results in an active view.
495 m_view->setActive(true);
496
497 const QUrl& url = DolphinView::openItemAsFolderUrl(item, GeneralSettings::browseThroughArchives());
498 if (!url.isEmpty()) {
499 m_view->setUrl(url);
500 return;
501 }
502
503 KRun *run = new KRun(item.targetUrl(), this);
504 run->setShowScriptExecutionPrompt(true);
505 }
506
507 void DolphinViewContainer::slotItemsActivated(const KFileItemList& items)
508 {
509 Q_ASSERT(items.count() >= 2);
510
511 KFileItemActions fileItemActions(this);
512 fileItemActions.runPreferredApplications(items, QString());
513 }
514
515 void DolphinViewContainer::showItemInfo(const KFileItem& item)
516 {
517 if (item.isNull()) {
518 m_statusBar->resetToDefaultText();
519 } else {
520 m_statusBar->setText(item.getStatusBarInfo());
521 }
522 }
523
524 void DolphinViewContainer::closeFilterBar()
525 {
526 m_filterBar->closeFilterBar();
527 m_view->setFocus();
528 emit showFilterBarChanged(false);
529 }
530
531 void DolphinViewContainer::setNameFilter(const QString& nameFilter)
532 {
533 m_view->setNameFilter(nameFilter);
534 delayedStatusBarUpdate();
535 }
536
537 void DolphinViewContainer::activate()
538 {
539 setActive(true);
540 }
541
542 void DolphinViewContainer::slotViewUrlAboutToBeChanged(const QUrl& url)
543 {
544 // URL changes of the view can happen in two ways:
545 // 1. The URL navigator gets changed and will trigger the view to update its URL
546 // 2. The URL of the view gets changed and will trigger the URL navigator to update
547 // its URL (e.g. by clicking on an item)
548 // In this scope the view-state may only get saved in case 2:
549 if (url != m_urlNavigator->locationUrl()) {
550 saveViewState();
551 }
552 }
553
554 void DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged(const QUrl& url)
555 {
556 // URL changes of the view can happen in two ways:
557 // 1. The URL navigator gets changed and will trigger the view to update its URL
558 // 2. The URL of the view gets changed and will trigger the URL navigator to update
559 // its URL (e.g. by clicking on an item)
560 // In this scope the view-state may only get saved in case 1:
561 if (url != m_view->url()) {
562 saveViewState();
563 }
564 }
565
566 void DolphinViewContainer::slotUrlNavigatorLocationChanged(const QUrl& url)
567 {
568 slotReturnPressed();
569
570 if (KProtocolManager::supportsListing(url)) {
571 setSearchModeEnabled(isSearchUrl(url));
572 m_view->setUrl(url);
573
574 if (m_autoGrabFocus && isActive() && !isSearchUrl(url)) {
575 // When an URL has been entered, the view should get the focus.
576 // The focus must be requested asynchronously, as changing the URL might create
577 // a new view widget.
578 QTimer::singleShot(0, this, SLOT(requestFocus()));
579 }
580 } else if (KProtocolManager::isSourceProtocol(url)) {
581 QString app = "konqueror";
582 if (url.scheme().startsWith(QLatin1String("http"))) {
583 showMessage(i18nc("@info:status", // krazy:exclude=qmethods
584 "Dolphin does not support web pages, the web browser has been launched"),
585 Information);
586
587 const KConfigGroup config(KSharedConfig::openConfig("kdeglobals"), "General");
588 const QString browser = config.readEntry("BrowserApplication");
589 if (!browser.isEmpty()) {
590 app = browser;
591 if (app.startsWith('!')) {
592 // a literal command has been configured, remove the '!' prefix
593 app = app.mid(1);
594 }
595 }
596 } else {
597 showMessage(i18nc("@info:status",
598 "Protocol not supported by Dolphin, Konqueror has been launched"),
599 Information);
600 }
601
602 const QString secureUrl = KShell::quoteArg(url.toDisplayString(QUrl::PreferLocalFile));
603 const QString command = app + ' ' + secureUrl;
604 KRun::runCommand(command, app, app, this);
605 } else {
606 showMessage(i18nc("@info:status", "Invalid protocol"), Error);
607 }
608 }
609
610 void DolphinViewContainer::redirect(const QUrl& oldUrl, const QUrl& newUrl)
611 {
612 Q_UNUSED(oldUrl);
613 const bool block = m_urlNavigator->signalsBlocked();
614 m_urlNavigator->blockSignals(true);
615
616 // Assure that the location state is reset for redirection URLs. This
617 // allows to skip redirection URLs when going back or forward in the
618 // URL history.
619 m_urlNavigator->saveLocationState(QByteArray());
620 m_urlNavigator->setLocationUrl(newUrl);
621 setSearchModeEnabled(isSearchUrl(newUrl));
622
623 m_urlNavigator->blockSignals(block);
624 }
625
626 void DolphinViewContainer::requestFocus()
627 {
628 m_view->setFocus();
629 }
630
631 void DolphinViewContainer::saveUrlCompletionMode(KCompletion::CompletionMode completion)
632 {
633 GeneralSettings::setUrlCompletionMode(completion);
634 }
635
636 void DolphinViewContainer::slotHistoryChanged()
637 {
638 QByteArray locationState = m_urlNavigator->locationState();
639 if (!locationState.isEmpty()) {
640 QDataStream stream(&locationState, QIODevice::ReadOnly);
641 m_view->restoreState(stream);
642 }
643 }
644
645 void DolphinViewContainer::slotReturnPressed()
646 {
647 if (!GeneralSettings::editableUrl()) {
648 m_urlNavigator->setUrlEditable(false);
649 }
650 }
651
652 void DolphinViewContainer::startSearching()
653 {
654 const QUrl url = m_searchBox->urlForSearching();
655 if (url.isValid() && !url.isEmpty()) {
656 m_view->setViewPropertiesContext("search");
657 m_urlNavigator->setLocationUrl(url);
658 }
659 }
660
661 void DolphinViewContainer::closeSearchBox()
662 {
663 setSearchModeEnabled(false);
664 }
665
666 void DolphinViewContainer::stopDirectoryLoading()
667 {
668 m_view->stopLoading();
669 m_statusBar->setProgress(100);
670 }
671
672 void DolphinViewContainer::slotStatusBarZoomLevelChanged(int zoomLevel)
673 {
674 m_view->setZoomLevel(zoomLevel);
675 }
676
677 void DolphinViewContainer::showErrorMessage(const QString& msg)
678 {
679 showMessage(msg, Error);
680 }
681
682 bool DolphinViewContainer::isSearchUrl(const QUrl& url) const
683 {
684 return url.scheme().contains("search");
685 }
686
687 void DolphinViewContainer::saveViewState()
688 {
689 QByteArray locationState;
690 QDataStream stream(&locationState, QIODevice::WriteOnly);
691 m_view->saveState(stream);
692 m_urlNavigator->saveLocationState(locationState);
693 }