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