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