1 /***************************************************************************
2 * Copyright (C) 2006-2009 by Peter Penz <peter.penz@gmx.at> *
3 * Copyright (C) 2006 by Gregor Kališnik <gregor@podnapisi.net> *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
21 #include "dolphinview.h"
23 #include <QAbstractItemView>
24 #include <QApplication>
27 #include <QItemSelection>
32 #include <kactioncollection.h>
33 #include <kcolorscheme.h>
34 #include <kdirlister.h>
35 #include <kiconeffect.h>
36 #include <kfileitem.h>
38 #include <kio/deletejob.h>
39 #include <kio/netaccess.h>
40 #include <kio/previewjob.h>
43 #include <kmessagebox.h>
44 #include <kmimetyperesolver.h>
45 #include <konq_fileitemcapabilities.h>
46 #include <konq_operations.h>
47 #include <konqmimedata.h>
48 #include <kstringhandler.h>
49 #include <ktoggleaction.h>
52 #include "additionalinfoaccessor.h"
53 #include "dolphinmodel.h"
54 #include "dolphincolumnviewcontainer.h"
55 #include "dolphinviewcontroller.h"
56 #include "dolphindetailsview.h"
57 #include "dolphinfileitemdelegate.h"
58 #include "dolphinnewfilemenuobserver.h"
59 #include "dolphinsortfilterproxymodel.h"
60 #include "dolphin_detailsmodesettings.h"
61 #include "dolphiniconsview.h"
62 #include "dolphin_generalsettings.h"
63 #include "draganddrophelper.h"
64 #include "renamedialog.h"
65 #include "settings/dolphinsettings.h"
66 #include "viewmodecontroller.h"
67 #include "viewproperties.h"
68 #include "zoomlevelinfo.h"
69 #include "dolphindetailsviewexpander.h"
72 * Helper function for sorting items with qSort() in
73 * DolphinView::renameSelectedItems().
75 bool lessThan(const KFileItem
& item1
, const KFileItem
& item2
)
77 return KStringHandler::naturalCompare(item1
.name(), item2
.name()) < 0;
80 DolphinView::DolphinView(QWidget
* parent
,
82 DolphinSortFilterProxyModel
* proxyModel
) :
86 m_storedCategorizedSorting(false),
87 m_tabsForFiles(false),
88 m_isContextMenuOpen(false),
89 m_assureVisibleCurrentIndex(false),
90 m_mode(DolphinView::IconsView
),
92 m_dolphinViewController(0),
93 m_viewModeController(0),
94 m_viewAccessor(proxyModel
),
95 m_selectionChangedTimer(0),
98 m_restoredContentsPosition(),
103 m_topLayout
= new QVBoxLayout(this);
104 m_topLayout
->setSpacing(0);
105 m_topLayout
->setMargin(0);
107 m_dolphinViewController
= new DolphinViewController(this);
109 m_viewModeController
= new ViewModeController(this);
110 m_viewModeController
->setUrl(url
);
112 connect(m_viewModeController
, SIGNAL(urlChanged(const KUrl
&)),
113 this, SIGNAL(urlChanged(const KUrl
&)));
115 connect(m_dolphinViewController
, SIGNAL(requestContextMenu(const QPoint
&, const QList
<QAction
*>&)),
116 this, SLOT(openContextMenu(const QPoint
&, const QList
<QAction
*>&)));
117 connect(m_dolphinViewController
, SIGNAL(urlsDropped(const KFileItem
&, const KUrl
&, QDropEvent
*)),
118 this, SLOT(dropUrls(const KFileItem
&, const KUrl
&, QDropEvent
*)));
119 connect(m_dolphinViewController
, SIGNAL(sortingChanged(DolphinView::Sorting
)),
120 this, SLOT(updateSorting(DolphinView::Sorting
)));
121 connect(m_dolphinViewController
, SIGNAL(sortOrderChanged(Qt::SortOrder
)),
122 this, SLOT(updateSortOrder(Qt::SortOrder
)));
123 connect(m_dolphinViewController
, SIGNAL(sortFoldersFirstChanged(bool)),
124 this, SLOT(updateSortFoldersFirst(bool)));
125 connect(m_dolphinViewController
, SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList
&)),
126 this, SLOT(updateAdditionalInfo(const KFileItemDelegate::InformationList
&)));
127 connect(m_dolphinViewController
, SIGNAL(itemTriggered(const KFileItem
&)),
128 this, SLOT(triggerItem(const KFileItem
&)));
129 connect(m_dolphinViewController
, SIGNAL(tabRequested(const KUrl
&)),
130 this, SIGNAL(tabRequested(const KUrl
&)));
131 connect(m_dolphinViewController
, SIGNAL(activated()),
132 this, SLOT(activate()));
133 connect(m_dolphinViewController
, SIGNAL(itemEntered(const KFileItem
&)),
134 this, SLOT(showHoverInformation(const KFileItem
&)));
135 connect(m_dolphinViewController
, SIGNAL(viewportEntered()),
136 this, SLOT(clearHoverInformation()));
137 connect(m_dolphinViewController
, SIGNAL(urlChangeRequested(KUrl
)),
138 m_viewModeController
, SLOT(setUrl(KUrl
)));
140 KDirLister
* dirLister
= m_viewAccessor
.dirLister();
141 connect(dirLister
, SIGNAL(redirection(KUrl
,KUrl
)),
142 this, SLOT(slotRedirection(KUrl
,KUrl
)));
143 connect(dirLister
, SIGNAL(completed()),
144 this, SLOT(slotDirListerCompleted()));
145 connect(dirLister
, SIGNAL(refreshItems(const QList
<QPair
<KFileItem
,KFileItem
>>&)),
146 this, SLOT(slotRefreshItems()));
148 // When a new item has been created by the "Create New..." menu, the item should
149 // get selected and it must be assured that the item will get visible. As the
150 // creation is done asynchronously, several signals must be checked:
151 connect(&DolphinNewFileMenuObserver::instance(), SIGNAL(itemCreated(const KUrl
&)),
152 this, SLOT(observeCreatedItem(const KUrl
&)));
154 m_selectionChangedTimer
= new QTimer(this);
155 m_selectionChangedTimer
->setSingleShot(true);
156 m_selectionChangedTimer
->setInterval(300);
157 connect(m_selectionChangedTimer
, SIGNAL(timeout()),
158 this, SLOT(emitSelectionChangedSignal()));
160 applyViewProperties();
161 m_topLayout
->addWidget(m_viewAccessor
.layoutTarget());
164 DolphinView::~DolphinView()
168 KUrl
DolphinView::url() const
170 return m_viewModeController
->url();
173 KUrl
DolphinView::rootUrl() const
175 const KUrl viewUrl
= url();
176 const KUrl root
= m_viewAccessor
.rootUrl();
177 if (root
.isEmpty() || !root
.isParentOf(viewUrl
)) {
183 void DolphinView::setActive(bool active
)
185 if (active
== m_active
) {
191 QColor color
= KColorScheme(QPalette::Active
, KColorScheme::View
).background().color();
193 emitSelectionChangedSignal();
198 QWidget
* viewport
= m_viewAccessor
.itemView()->viewport();
200 palette
.setColor(viewport
->backgroundRole(), color
);
201 viewport
->setPalette(palette
);
206 m_viewAccessor
.itemView()->setFocus();
210 m_viewModeController
->indicateActivationChange(active
);
213 bool DolphinView::isActive() const
218 void DolphinView::setMode(Mode mode
)
220 if (mode
== m_mode
) {
221 return; // the wished mode is already set
224 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
227 // remember the currently selected items, so that they will
228 // be restored after reloading the directory
229 m_selectedItems
= selectedItems();
233 const KUrl viewPropsUrl
= rootUrl();
234 ViewProperties
props(viewPropsUrl
);
235 props
.setViewMode(m_mode
);
238 // the file item delegate has been recreated, apply the current
239 // additional information manually
240 const KFileItemDelegate::InformationList infoList
= props
.additionalInfo();
241 m_viewAccessor
.itemDelegate()->setShowInformation(infoList
);
242 emit
additionalInfoChanged();
244 // Not all view modes support categorized sorting. Adjust the sorting model
245 // if changing the view mode results in a change of the categorized sorting
247 m_storedCategorizedSorting
= props
.categorizedSorting();
248 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
249 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
250 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
251 emit
categorizedSortingChanged();
256 updateZoomLevel(oldZoomLevel
);
257 loadDirectory(viewPropsUrl
);
260 DolphinView::Mode
DolphinView::mode() const
265 bool DolphinView::showPreview() const
267 return m_showPreview
;
270 bool DolphinView::showHiddenFiles() const
272 return m_viewAccessor
.dirLister()->showingDotFiles();
275 bool DolphinView::categorizedSorting() const
277 // If all view modes would support categorized sorting, returning
278 // m_viewAccessor.proxyModel()->isCategorizedModel() would be the way to go. As
279 // currently only the icons view supports caterized sorting, we remember
280 // the stored view properties state in m_storedCategorizedSorting and
281 // return this state. The application takes care to disable the corresponding
282 // checkbox by checking DolphinView::supportsCategorizedSorting() to indicate
283 // that this setting is not applied to the current view mode.
284 return m_storedCategorizedSorting
;
287 bool DolphinView::supportsCategorizedSorting() const
289 return m_viewAccessor
.supportsCategorizedSorting();
292 bool DolphinView::hasSelection() const
294 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
295 return (view
!= 0) && view
->selectionModel()->hasSelection();
298 void DolphinView::markUrlsAsSelected(const QList
<KUrl
>& urls
)
300 foreach (const KUrl
& url
, urls
) {
301 KFileItem
item(KFileItem::Unknown
, KFileItem::Unknown
, url
);
302 m_selectedItems
.append(item
);
306 KFileItemList
DolphinView::selectedItems() const
308 KFileItemList itemList
;
309 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
314 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
316 const QModelIndexList indexList
= selection
.indexes();
317 foreach (const QModelIndex
&index
, indexList
) {
318 KFileItem item
= m_viewAccessor
.dirModel()->itemForIndex(index
);
319 if (!item
.isNull()) {
320 itemList
.append(item
);
327 KUrl::List
DolphinView::selectedUrls() const
330 const KFileItemList list
= selectedItems();
331 foreach (const KFileItem
&item
, list
) {
332 urls
.append(item
.url());
337 int DolphinView::selectedItemsCount() const
339 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
344 return view
->selectionModel()->selectedIndexes().count();
347 QItemSelectionModel
* DolphinView::selectionModel() const
349 return m_viewAccessor
.itemView()->selectionModel();
352 void DolphinView::setZoomLevel(int level
)
354 if (level
< ZoomLevelInfo::minimumLevel()) {
355 level
= ZoomLevelInfo::minimumLevel();
356 } else if (level
> ZoomLevelInfo::maximumLevel()) {
357 level
= ZoomLevelInfo::maximumLevel();
360 if (level
!= zoomLevel()) {
361 m_viewModeController
->setZoomLevel(level
);
362 emit
zoomLevelChanged(level
);
366 int DolphinView::zoomLevel() const
368 return m_viewModeController
->zoomLevel();
371 void DolphinView::setSorting(Sorting sorting
)
373 if (sorting
!= this->sorting()) {
374 updateSorting(sorting
);
378 DolphinView::Sorting
DolphinView::sorting() const
380 return m_viewAccessor
.proxyModel()->sorting();
383 void DolphinView::setSortOrder(Qt::SortOrder order
)
385 if (sortOrder() != order
) {
386 updateSortOrder(order
);
390 Qt::SortOrder
DolphinView::sortOrder() const
392 return m_viewAccessor
.proxyModel()->sortOrder();
395 void DolphinView::setSortFoldersFirst(bool foldersFirst
)
397 if (sortFoldersFirst() != foldersFirst
) {
398 updateSortFoldersFirst(foldersFirst
);
402 bool DolphinView::sortFoldersFirst() const
404 return m_viewAccessor
.proxyModel()->sortFoldersFirst();
407 void DolphinView::setAdditionalInfo(KFileItemDelegate::InformationList info
)
409 const KUrl viewPropsUrl
= rootUrl();
410 ViewProperties
props(viewPropsUrl
);
411 props
.setAdditionalInfo(info
);
412 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
414 emit
additionalInfoChanged();
416 if (m_viewAccessor
.reloadOnAdditionalInfoChange()) {
417 loadDirectory(viewPropsUrl
);
421 KFileItemDelegate::InformationList
DolphinView::additionalInfo() const
423 return m_viewAccessor
.itemDelegate()->showInformation();
426 void DolphinView::reload()
428 QByteArray viewState
;
429 QDataStream
saveStream(&viewState
, QIODevice::WriteOnly
);
430 saveState(saveStream
);
431 m_selectedItems
= selectedItems();
434 loadDirectory(url(), true);
436 QDataStream
restoreStream(viewState
);
437 restoreState(restoreStream
);
440 void DolphinView::stopLoading()
442 m_viewAccessor
.dirLister()->stop();
445 void DolphinView::refresh()
447 const bool oldActivationState
= m_active
;
448 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
452 applyViewProperties();
455 setActive(oldActivationState
);
456 updateZoomLevel(oldZoomLevel
);
459 void DolphinView::setNameFilter(const QString
& nameFilter
)
461 m_viewModeController
->setNameFilter(nameFilter
);
464 void DolphinView::calculateItemCount(int& fileCount
,
466 KIO::filesize_t
& totalFileSize
) const
468 foreach (const KFileItem
& item
, m_viewAccessor
.dirLister()->items()) {
473 totalFileSize
+= item
.size();
478 QString
DolphinView::statusBarText() const
483 KIO::filesize_t totalFileSize
= 0;
485 if (hasSelection()) {
486 // give a summary of the status of the selected files
487 const KFileItemList list
= selectedItems();
488 if (list
.isEmpty()) {
489 // when an item is triggered, it is temporary selected but selectedItems()
490 // will return an empty list
494 KFileItemList::const_iterator it
= list
.begin();
495 const KFileItemList::const_iterator end
= list
.end();
497 const KFileItem
& item
= *it
;
502 totalFileSize
+= item
.size();
507 if (folderCount
+ fileCount
== 1) {
508 // if only one item is selected, show the filename
509 const QString name
= list
.first().text();
510 text
= (folderCount
== 1) ? i18nc("@info:status", "<filename>%1</filename> selected", name
) :
511 i18nc("@info:status", "<filename>%1</filename> selected (%2)",
512 name
, KIO::convertSize(totalFileSize
));
514 // at least 2 items are selected
515 const QString foldersText
= i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount
);
516 const QString filesText
= i18ncp("@info:status", "1 File selected", "%1 Files selected", fileCount
);
517 if ((folderCount
> 0) && (fileCount
> 0)) {
518 text
= i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
519 foldersText
, filesText
, KIO::convertSize(totalFileSize
));
520 } else if (fileCount
> 0) {
521 text
= i18nc("@info:status files (size)", "%1 (%2)", filesText
, KIO::convertSize(totalFileSize
));
523 Q_ASSERT(folderCount
> 0);
528 calculateItemCount(fileCount
, folderCount
, totalFileSize
);
529 text
= KIO::itemsSummaryString(fileCount
+ folderCount
,
530 fileCount
, folderCount
,
531 totalFileSize
, true);
537 QList
<QAction
*> DolphinView::versionControlActions(const KFileItemList
& items
) const
539 return m_dolphinViewController
->versionControlActions(items
);
542 void DolphinView::setUrl(const KUrl
& url
)
544 if (m_viewModeController
->url() == url
) {
548 // The selection model might change in the case of the column view. Disconnect
549 // from the current selection model and reconnect later after the URL switch.
550 QAbstractItemView
* view
= m_viewAccessor
.itemView();
551 disconnect(view
->selectionModel(), SIGNAL(selectionChanged(QItemSelection
, QItemSelection
)),
552 this, SLOT(slotSelectionChanged(QItemSelection
, QItemSelection
)));
554 m_newFileNames
.clear();
556 m_viewModeController
->setUrl(url
); // emits urlChanged, which we forward
557 m_viewAccessor
.prepareUrlChange(url
);
558 applyViewProperties();
561 // When changing the URL there is no need to keep the version
562 // data of the previous URL.
563 m_viewAccessor
.dirModel()->clearVersionData();
565 emit
startedPathLoading(url
);
567 // Reconnect to the (probably) new selection model
568 view
= m_viewAccessor
.itemView();
569 connect(view
->selectionModel(), SIGNAL(selectionChanged(QItemSelection
, QItemSelection
)),
570 this, SLOT(slotSelectionChanged(QItemSelection
, QItemSelection
)));
573 void DolphinView::selectAll()
575 m_viewAccessor
.itemView()->selectAll();
578 void DolphinView::invertSelection()
580 QItemSelectionModel
* selectionModel
= m_viewAccessor
.itemView()->selectionModel();
581 const QAbstractItemModel
* itemModel
= selectionModel
->model();
583 const QModelIndex topLeft
= itemModel
->index(0, 0);
584 const QModelIndex bottomRight
= itemModel
->index(itemModel
->rowCount() - 1,
585 itemModel
->columnCount() - 1);
587 const QItemSelection
selection(topLeft
, bottomRight
);
588 selectionModel
->select(selection
, QItemSelectionModel::Toggle
);
591 void DolphinView::clearSelection()
593 m_viewAccessor
.itemView()->clearSelection();
596 void DolphinView::renameSelectedItems()
598 KFileItemList items
= selectedItems();
599 const int itemCount
= items
.count();
605 // More than one item has been selected for renaming. Open
606 // a rename dialog and rename all items afterwards.
607 QPointer
<RenameDialog
> dialog
= new RenameDialog(this, items
);
608 if (dialog
->exec() == QDialog::Rejected
) {
613 const QString newName
= dialog
->newName();
614 if (newName
.isEmpty()) {
615 emit
errorMessage(dialog
->errorString());
621 // the selection would be invalid after renaming the items, so just clear
625 // TODO: check how this can be integrated into KIO::FileUndoManager/KonqOperations
626 // as one operation instead of n rename operations like it is done now...
627 Q_ASSERT(newName
.contains('#'));
629 // currently the items are sorted by the selection order, resort
630 // them by the file name
631 qSort(items
.begin(), items
.end(), lessThan
);
633 // iterate through all selected items and rename them...
635 foreach (const KFileItem
& item
, items
) {
636 const KUrl
& oldUrl
= item
.url();
638 number
.setNum(index
++);
640 QString name
= newName
;
641 name
.replace('#', number
);
643 if (oldUrl
.fileName() != name
) {
644 KUrl newUrl
= oldUrl
;
645 newUrl
.setFileName(name
);
646 KonqOperations::rename(this, oldUrl
, newUrl
);
649 } else if (DolphinSettings::instance().generalSettings()->renameInline()) {
650 Q_ASSERT(itemCount
== 1);
651 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForItem(items
.first());
652 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
653 m_viewAccessor
.itemView()->edit(proxyIndex
);
655 Q_ASSERT(itemCount
== 1);
657 QPointer
<RenameDialog
> dialog
= new RenameDialog(this, items
);
658 if (dialog
->exec() == QDialog::Rejected
) {
663 const QString newName
= dialog
->newName();
664 if (newName
.isEmpty()) {
665 emit
errorMessage(dialog
->errorString());
671 const KUrl
& oldUrl
= items
.first().url();
672 KUrl newUrl
= oldUrl
;
673 newUrl
.setFileName(newName
);
674 KonqOperations::rename(this, oldUrl
, newUrl
);
677 // assure that the current index remains visible when KDirLister
678 // will notify the view about changed items
679 m_assureVisibleCurrentIndex
= true;
682 void DolphinView::trashSelectedItems()
684 const KUrl::List list
= simplifiedSelectedUrls();
685 KonqOperations::del(this, KonqOperations::TRASH
, list
);
688 void DolphinView::deleteSelectedItems()
690 const KUrl::List list
= simplifiedSelectedUrls();
691 const bool del
= KonqOperations::askDeleteConfirmation(list
,
693 KonqOperations::DEFAULT_CONFIRMATION
,
697 KIO::Job
* job
= KIO::del(list
);
698 connect(job
, SIGNAL(result(KJob
*)),
699 this, SLOT(slotDeleteFileFinished(KJob
*)));
703 void DolphinView::cutSelectedItems()
705 QMimeData
* mimeData
= selectionMimeData();
706 KonqMimeData::addIsCutSelection(mimeData
, true);
707 QApplication::clipboard()->setMimeData(mimeData
);
710 void DolphinView::copySelectedItems()
712 QMimeData
* mimeData
= selectionMimeData();
713 QApplication::clipboard()->setMimeData(mimeData
);
716 void DolphinView::paste()
721 void DolphinView::pasteIntoFolder()
723 const KFileItemList items
= selectedItems();
724 if ((items
.count() == 1) && items
.first().isDir()) {
725 pasteToUrl(items
.first().url());
729 void DolphinView::setShowPreview(bool show
)
731 if (m_showPreview
== show
) {
735 const KUrl viewPropsUrl
= rootUrl();
736 ViewProperties
props(viewPropsUrl
);
737 props
.setShowPreview(show
);
739 m_showPreview
= show
;
740 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
741 emit
showPreviewChanged();
743 // Enabling or disabling the preview might change the icon size of the view.
744 // As the view does not emit a signal when the icon size has been changed,
745 // the used zoom level of the controller must be adjusted manually:
746 updateZoomLevel(oldZoomLevel
);
749 void DolphinView::setShowHiddenFiles(bool show
)
751 if (m_viewAccessor
.dirLister()->showingDotFiles() == show
) {
755 const KUrl viewPropsUrl
= rootUrl();
756 ViewProperties
props(viewPropsUrl
);
757 props
.setShowHiddenFiles(show
);
759 m_viewAccessor
.dirLister()->setShowingDotFiles(show
);
760 emit
showHiddenFilesChanged();
763 void DolphinView::setCategorizedSorting(bool categorized
)
765 if (categorized
== categorizedSorting()) {
769 // setCategorizedSorting(true) may only get invoked
770 // if the view supports categorized sorting
771 Q_ASSERT(!categorized
|| supportsCategorizedSorting());
773 ViewProperties
props(rootUrl());
774 props
.setCategorizedSorting(categorized
);
777 m_storedCategorizedSorting
= categorized
;
778 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
780 emit
categorizedSortingChanged();
783 void DolphinView::toggleSortOrder()
785 const Qt::SortOrder order
= (sortOrder() == Qt::AscendingOrder
) ?
786 Qt::DescendingOrder
:
791 void DolphinView::toggleSortFoldersFirst()
793 setSortFoldersFirst(!sortFoldersFirst());
796 void DolphinView::toggleAdditionalInfo(QAction
* action
)
798 const KFileItemDelegate::Information info
=
799 static_cast<KFileItemDelegate::Information
>(action
->data().toInt());
801 KFileItemDelegate::InformationList list
= additionalInfo();
803 const bool show
= action
->isChecked();
805 const int index
= list
.indexOf(info
);
806 const bool containsInfo
= (index
>= 0);
807 if (show
&& !containsInfo
) {
809 setAdditionalInfo(list
);
810 } else if (!show
&& containsInfo
) {
811 list
.removeAt(index
);
812 setAdditionalInfo(list
);
813 Q_ASSERT(list
.indexOf(info
) < 0);
817 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
819 QWidget::mouseReleaseEvent(event
);
823 bool DolphinView::eventFilter(QObject
* watched
, QEvent
* event
)
825 switch (event
->type()) {
826 case QEvent::FocusIn
:
827 if (watched
== m_viewAccessor
.itemView()) {
828 m_dolphinViewController
->requestActivation();
832 case QEvent::DragEnter
:
833 if (watched
== m_viewAccessor
.itemView()->viewport()) {
838 case QEvent::KeyPress
:
839 if (watched
== m_viewAccessor
.itemView()) {
840 // clear the selection when Escape has been pressed
841 QKeyEvent
* keyEvent
= static_cast<QKeyEvent
*>(event
);
842 if (keyEvent
->key() == Qt::Key_Escape
) {
849 if (watched
== m_viewAccessor
.itemView()->viewport()) {
850 // Ctrl+wheel events should cause icon zooming, but not if the left mouse button is pressed
851 // (the user is probably trying to scroll during a selection in that case)
852 QWheelEvent
* wheelEvent
= static_cast<QWheelEvent
*>(event
);
853 if (wheelEvent
->modifiers() & Qt::ControlModifier
&& !(wheelEvent
->buttons() & Qt::LeftButton
)) {
854 const int delta
= wheelEvent
->delta();
855 const int level
= zoomLevel();
857 setZoomLevel(level
+ 1);
858 } else if (delta
< 0) {
859 setZoomLevel(level
- 1);
870 return QWidget::eventFilter(watched
, event
);
873 void DolphinView::activate()
878 void DolphinView::triggerItem(const KFileItem
& item
)
880 const Qt::KeyboardModifiers modifier
= QApplication::keyboardModifiers();
881 if ((modifier
& Qt::ShiftModifier
) || (modifier
& Qt::ControlModifier
)) {
882 // items are selected by the user, hence don't trigger the
883 // item specified by 'index'
887 // TODO: the m_isContextMenuOpen check is a workaround for Qt-issue 207192
888 if (item
.isNull() || m_isContextMenuOpen
) {
892 emit
itemTriggered(item
); // caught by DolphinViewContainer or DolphinPart
895 void DolphinView::slotSelectionChanged(const QItemSelection
& selected
, const QItemSelection
& deselected
)
897 const int count
= selectedItemsCount();
898 const bool selectionStateChanged
= ((count
> 0) && (selected
.count() == count
)) ||
899 ((count
== 0) && !deselected
.isEmpty());
901 // If nothing has been selected before and something got selected (or if something
902 // was selected before and now nothing is selected) the selectionChangedSignal must
903 // be emitted asynchronously as fast as possible to update the edit-actions.
904 m_selectionChangedTimer
->setInterval(selectionStateChanged
? 0 : 300);
905 m_selectionChangedTimer
->start();
908 void DolphinView::emitSelectionChangedSignal()
910 emit
selectionChanged(DolphinView::selectedItems());
913 void DolphinView::openContextMenu(const QPoint
& pos
,
914 const QList
<QAction
*>& customActions
)
917 const QModelIndex index
= m_viewAccessor
.itemView()->indexAt(pos
);
918 if (index
.isValid() && (index
.column() == DolphinModel::Name
)) {
919 const QModelIndex dolphinModelIndex
= m_viewAccessor
.proxyModel()->mapToSource(index
);
920 item
= m_viewAccessor
.dirModel()->itemForIndex(dolphinModelIndex
);
923 m_isContextMenuOpen
= true; // TODO: workaround for Qt-issue 207192
924 emit
requestContextMenu(item
, url(), customActions
);
925 m_isContextMenuOpen
= false;
928 void DolphinView::dropUrls(const KFileItem
& destItem
,
929 const KUrl
& destPath
,
932 addNewFileNames(event
->mimeData());
933 DragAndDropHelper::instance().dropUrls(destItem
, destPath
, event
, this);
936 void DolphinView::updateSorting(DolphinView::Sorting sorting
)
938 ViewProperties
props(rootUrl());
939 props
.setSorting(sorting
);
941 m_viewAccessor
.proxyModel()->setSorting(sorting
);
943 emit
sortingChanged(sorting
);
946 void DolphinView::updateSortOrder(Qt::SortOrder order
)
948 ViewProperties
props(rootUrl());
949 props
.setSortOrder(order
);
951 m_viewAccessor
.proxyModel()->setSortOrder(order
);
953 emit
sortOrderChanged(order
);
956 void DolphinView::updateSortFoldersFirst(bool foldersFirst
)
958 ViewProperties
props(rootUrl());
959 props
.setSortFoldersFirst(foldersFirst
);
961 m_viewAccessor
.proxyModel()->setSortFoldersFirst(foldersFirst
);
963 emit
sortFoldersFirstChanged(foldersFirst
);
966 void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList
& info
)
968 ViewProperties
props(rootUrl());
969 props
.setAdditionalInfo(info
);
972 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
974 emit
additionalInfoChanged();
977 void DolphinView::updateAdditionalInfoActions(KActionCollection
* collection
)
979 const AdditionalInfoAccessor
& infoAccessor
= AdditionalInfoAccessor::instance();
981 const KFileItemDelegate::InformationList checkedInfo
= m_viewAccessor
.itemDelegate()->showInformation();
982 const KFileItemDelegate::InformationList infoKeys
= infoAccessor
.keys();
984 const bool enable
= (m_mode
== DolphinView::DetailsView
) ||
985 (m_mode
== DolphinView::IconsView
);
987 foreach (const KFileItemDelegate::Information
& info
, infoKeys
) {
988 const QString name
= infoAccessor
.actionCollectionName(info
, AdditionalInfoAccessor::AdditionalInfoType
);
989 QAction
* action
= collection
->action(name
);
990 Q_ASSERT(action
!= 0);
991 action
->setEnabled(enable
);
992 action
->setChecked(checkedInfo
.contains(info
));
996 QPair
<bool, QString
> DolphinView::pasteInfo() const
998 return KonqOperations::pasteInfo(url());
1001 void DolphinView::setTabsForFilesEnabled(bool tabsForFiles
)
1003 m_tabsForFiles
= tabsForFiles
;
1006 bool DolphinView::isTabsForFilesEnabled() const
1008 return m_tabsForFiles
;
1011 bool DolphinView::itemsExpandable() const
1013 return m_viewAccessor
.itemsExpandable();
1016 void DolphinView::restoreState(QDataStream
& stream
)
1019 stream
>> m_activeItemUrl
;
1022 stream
>> m_restoredContentsPosition
;
1024 // expanded folders (only relevant for the details view - will be ignored by the view in other view modes)
1025 QSet
<KUrl
> urlsToExpand
;
1026 stream
>> urlsToExpand
;
1027 const DolphinDetailsViewExpander
* expander
= m_viewAccessor
.setExpandedUrls(urlsToExpand
);
1028 if (expander
!= 0) {
1029 m_expanderActive
= true;
1030 connect (expander
, SIGNAL(completed()), this, SLOT(slotLoadingCompleted()));
1033 m_expanderActive
= false;
1037 void DolphinView::saveState(QDataStream
& stream
)
1040 KFileItem currentItem
;
1041 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
1044 const QModelIndex proxyIndex
= view
->currentIndex();
1045 const QModelIndex dirModelIndex
= m_viewAccessor
.proxyModel()->mapToSource(proxyIndex
);
1046 currentItem
= m_viewAccessor
.dirModel()->itemForIndex(dirModelIndex
);
1050 if (!currentItem
.isNull()) {
1051 currentUrl
= currentItem
.url();
1054 stream
<< currentUrl
;
1057 const int x
= view
->horizontalScrollBar()->value();
1058 const int y
= view
->verticalScrollBar()->value();
1059 stream
<< QPoint(x
, y
);
1061 // expanded folders (only relevant for the details view - the set will be empty in other view modes)
1062 stream
<< m_viewAccessor
.expandedUrls();
1065 void DolphinView::observeCreatedItem(const KUrl
& url
)
1067 m_createdItemUrl
= url
;
1068 connect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
1069 this, SLOT(selectAndScrollToCreatedItem()));
1072 void DolphinView::selectAndScrollToCreatedItem()
1074 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_createdItemUrl
);
1075 if (dirIndex
.isValid()) {
1076 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
1077 m_viewAccessor
.itemView()->setCurrentIndex(proxyIndex
);
1080 disconnect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
1081 this, SLOT(selectAndScrollToCreatedItem()));
1082 m_createdItemUrl
= KUrl();
1085 void DolphinView::showHoverInformation(const KFileItem
& item
)
1087 emit
requestItemInfo(item
);
1090 void DolphinView::clearHoverInformation()
1092 emit
requestItemInfo(KFileItem());
1095 void DolphinView::slotDeleteFileFinished(KJob
* job
)
1097 if (job
->error() == 0) {
1098 emit
operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
1099 } else if (job
->error() != KIO::ERR_USER_CANCELED
) {
1100 emit
errorMessage(job
->errorString());
1104 void DolphinView::slotDirListerCompleted()
1106 if (!m_expanderActive
) {
1107 slotLoadingCompleted();
1110 if (!m_newFileNames
.isEmpty()) {
1111 // select all newly added items created by a paste operation or
1112 // a drag & drop operation, and clear the previous selection
1113 m_viewAccessor
.itemView()->clearSelection();
1114 const int rowCount
= m_viewAccessor
.proxyModel()->rowCount();
1115 QItemSelection selection
;
1116 for (int row
= 0; row
< rowCount
; ++row
) {
1117 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->index(row
, 0);
1118 const QModelIndex dirIndex
= m_viewAccessor
.proxyModel()->mapToSource(proxyIndex
);
1119 const KUrl url
= m_viewAccessor
.dirModel()->itemForIndex(dirIndex
).url();
1120 if (m_newFileNames
.contains(url
.fileName())) {
1121 selection
.merge(QItemSelection(proxyIndex
, proxyIndex
), QItemSelectionModel::Select
);
1124 m_viewAccessor
.itemView()->selectionModel()->select(selection
, QItemSelectionModel::Select
);
1126 m_newFileNames
.clear();
1130 void DolphinView::slotLoadingCompleted()
1132 m_expanderActive
= false;
1134 if (!m_activeItemUrl
.isEmpty()) {
1135 // assure that the current item remains visible
1136 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_activeItemUrl
);
1137 if (dirIndex
.isValid()) {
1138 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
1139 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1140 const bool clearSelection
= !hasSelection();
1141 view
->setCurrentIndex(proxyIndex
);
1142 if (clearSelection
) {
1143 view
->clearSelection();
1145 m_activeItemUrl
.clear();
1149 if (!m_selectedItems
.isEmpty()) {
1150 const KUrl
& baseUrl
= url();
1152 QItemSelection newSelection
;
1153 foreach(const KFileItem
& item
, m_selectedItems
) {
1154 url
= item
.url().upUrl();
1155 if (baseUrl
.equals(url
, KUrl::CompareWithoutTrailingSlash
)) {
1156 QModelIndex index
= m_viewAccessor
.proxyModel()->mapFromSource(m_viewAccessor
.dirModel()->indexForItem(item
));
1157 newSelection
.select(index
, index
);
1160 m_viewAccessor
.itemView()->selectionModel()->select(newSelection
,
1161 QItemSelectionModel::ClearAndSelect
1162 | QItemSelectionModel::Current
);
1163 m_selectedItems
.clear();
1166 // Restore the contents position. This has to be done using a Qt::QueuedConnection
1167 // because the view might not be in its final state yet.
1168 QMetaObject::invokeMethod(this, "restoreContentsPosition", Qt::QueuedConnection
);
1170 emit
finishedPathLoading(url());
1173 void DolphinView::slotRefreshItems()
1175 if (m_assureVisibleCurrentIndex
) {
1176 m_assureVisibleCurrentIndex
= false;
1177 m_viewAccessor
.itemView()->scrollTo(m_viewAccessor
.itemView()->currentIndex());
1181 void DolphinView::loadDirectory(const KUrl
& url
, bool reload
)
1183 if (!url
.isValid()) {
1184 const QString
location(url
.pathOrUrl());
1185 if (location
.isEmpty()) {
1186 emit
errorMessage(i18nc("@info:status", "The location is empty."));
1188 emit
errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location
));
1193 KDirLister
* dirLister
= m_viewAccessor
.dirLister();
1194 dirLister
->openUrl(url
, reload
? KDirLister::Reload
: KDirLister::NoFlags
);
1197 void DolphinView::applyViewProperties()
1199 const ViewProperties
props(rootUrl());
1201 const Mode mode
= props
.viewMode();
1202 if (m_mode
!= mode
) {
1203 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
1209 updateZoomLevel(oldZoomLevel
);
1211 if (m_viewAccessor
.itemView() == 0) {
1214 Q_ASSERT(m_viewAccessor
.itemView() != 0);
1215 Q_ASSERT(m_viewAccessor
.itemDelegate() != 0);
1217 const bool showHiddenFiles
= props
.showHiddenFiles();
1218 if (showHiddenFiles
!= m_viewAccessor
.dirLister()->showingDotFiles()) {
1219 m_viewAccessor
.dirLister()->setShowingDotFiles(showHiddenFiles
);
1220 emit
showHiddenFilesChanged();
1223 m_storedCategorizedSorting
= props
.categorizedSorting();
1224 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
1225 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
1226 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
1227 emit
categorizedSortingChanged();
1230 const DolphinView::Sorting sorting
= props
.sorting();
1231 if (sorting
!= m_viewAccessor
.proxyModel()->sorting()) {
1232 m_viewAccessor
.proxyModel()->setSorting(sorting
);
1233 emit
sortingChanged(sorting
);
1236 const Qt::SortOrder sortOrder
= props
.sortOrder();
1237 if (sortOrder
!= m_viewAccessor
.proxyModel()->sortOrder()) {
1238 m_viewAccessor
.proxyModel()->setSortOrder(sortOrder
);
1239 emit
sortOrderChanged(sortOrder
);
1242 const bool sortFoldersFirst
= props
.sortFoldersFirst();
1243 if (sortFoldersFirst
!= m_viewAccessor
.proxyModel()->sortFoldersFirst()) {
1244 m_viewAccessor
.proxyModel()->setSortFoldersFirst(sortFoldersFirst
);
1245 emit
sortFoldersFirstChanged(sortFoldersFirst
);
1248 KFileItemDelegate::InformationList info
= props
.additionalInfo();
1249 if (info
!= m_viewAccessor
.itemDelegate()->showInformation()) {
1250 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
1251 emit
additionalInfoChanged();
1254 const bool showPreview
= props
.showPreview();
1255 if (showPreview
!= m_showPreview
) {
1256 m_showPreview
= showPreview
;
1257 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
1258 emit
showPreviewChanged();
1260 // Enabling or disabling the preview might change the icon size of the view.
1261 // As the view does not emit a signal when the icon size has been changed,
1262 // the used zoom level of the controller must be adjusted manually:
1263 updateZoomLevel(oldZoomLevel
);
1267 void DolphinView::createView()
1269 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1270 if ((view
!= 0) && (view
->selectionModel() != 0)) {
1271 disconnect(view
->selectionModel(), SIGNAL(selectionChanged(QItemSelection
, QItemSelection
)),
1272 this, SLOT(slotSelectionChanged(QItemSelection
, QItemSelection
)));
1277 Q_ASSERT(m_viewAccessor
.itemView() == 0);
1278 m_viewAccessor
.createView(this, m_dolphinViewController
, m_viewModeController
, m_mode
);
1280 view
= m_viewAccessor
.itemView();
1281 Q_ASSERT(view
!= 0);
1282 view
->installEventFilter(this);
1283 view
->viewport()->installEventFilter(this);
1285 m_dolphinViewController
->setItemView(view
);
1287 const int zoomLevel
= ZoomLevelInfo::zoomLevelForIconSize(view
->iconSize());
1288 m_viewModeController
->setZoomLevel(zoomLevel
);
1290 connect(view
->selectionModel(), SIGNAL(selectionChanged(QItemSelection
, QItemSelection
)),
1291 this, SLOT(slotSelectionChanged(QItemSelection
, QItemSelection
)));
1293 setFocusProxy(m_viewAccessor
.layoutTarget());
1294 m_topLayout
->insertWidget(1, m_viewAccessor
.layoutTarget());
1297 void DolphinView::deleteView()
1299 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1301 // It's important to set the keyboard focus to the parent
1302 // before deleting the view: Otherwise when having a split
1303 // view the other view will get the focus and will request
1304 // an activation (see DolphinView::eventFilter()).
1308 m_topLayout
->removeWidget(view
);
1311 // disconnect all signal/slots
1313 m_viewModeController
->disconnect(view
);
1316 m_viewAccessor
.deleteView();
1320 void DolphinView::pasteToUrl(const KUrl
& url
)
1322 addNewFileNames(QApplication::clipboard()->mimeData());
1323 KonqOperations::doPaste(this, url
);
1326 void DolphinView::updateZoomLevel(int oldZoomLevel
)
1328 const int newZoomLevel
= ZoomLevelInfo::zoomLevelForIconSize(m_viewAccessor
.itemView()->iconSize());
1329 if (oldZoomLevel
!= newZoomLevel
) {
1330 m_viewModeController
->setZoomLevel(newZoomLevel
);
1331 emit
zoomLevelChanged(newZoomLevel
);
1335 KUrl::List
DolphinView::simplifiedSelectedUrls() const
1337 KUrl::List list
= selectedUrls();
1338 if (itemsExpandable() ) {
1339 list
= KDirModel::simplifiedUrlList(list
);
1344 QMimeData
* DolphinView::selectionMimeData() const
1346 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
1347 Q_ASSERT((view
!= 0) && (view
->selectionModel() != 0));
1348 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
1349 return m_viewAccessor
.dirModel()->mimeData(selection
.indexes());
1352 void DolphinView::addNewFileNames(const QMimeData
* mimeData
)
1354 const KUrl::List urls
= KUrl::List::fromMimeData(mimeData
);
1355 foreach (const KUrl
& url
, urls
) {
1356 m_newFileNames
.insert(url
.fileName());
1360 DolphinView::ViewAccessor::ViewAccessor(DolphinSortFilterProxyModel
* proxyModel
) :
1363 m_columnsContainer(0),
1364 m_proxyModel(proxyModel
),
1369 DolphinView::ViewAccessor::~ViewAccessor()
1371 delete m_dragSource
;
1375 void DolphinView::ViewAccessor::createView(QWidget
* parent
,
1376 DolphinViewController
* dolphinViewController
,
1377 const ViewModeController
* viewModeController
,
1380 Q_ASSERT(itemView() == 0);
1384 m_iconsView
= new DolphinIconsView(parent
,
1385 dolphinViewController
,
1391 m_detailsView
= new DolphinDetailsView(parent
,
1392 dolphinViewController
,
1398 m_columnsContainer
= new DolphinColumnViewContainer(parent
,
1399 dolphinViewController
,
1400 viewModeController
);
1408 void DolphinView::ViewAccessor::deleteView()
1410 QAbstractItemView
* view
= itemView();
1412 if (DragAndDropHelper::instance().isDragSource(view
)) {
1413 // The view is a drag source (the feature "Open folders
1414 // during drag operations" is used). Deleting the view
1415 // during an ongoing drag operation is not allowed, so
1416 // this will postponed.
1417 if (m_dragSource
!= 0) {
1418 // the old stored view is obviously not the drag source anymore
1419 m_dragSource
->deleteLater();
1423 m_dragSource
= view
;
1425 view
->deleteLater();
1432 if (m_columnsContainer
!= 0) {
1433 m_columnsContainer
->deleteLater();
1435 m_columnsContainer
= 0;
1439 void DolphinView::ViewAccessor::prepareUrlChange(const KUrl
& url
)
1441 if (m_columnsContainer
!= 0) {
1442 m_columnsContainer
->showColumn(url
);
1446 QAbstractItemView
* DolphinView::ViewAccessor::itemView() const
1448 if (m_iconsView
!= 0) {
1452 if (m_detailsView
!= 0) {
1453 return m_detailsView
;
1456 if (m_columnsContainer
!= 0) {
1457 return m_columnsContainer
->activeColumn();
1463 KFileItemDelegate
* DolphinView::ViewAccessor::itemDelegate() const
1465 return static_cast<KFileItemDelegate
*>(itemView()->itemDelegate());
1468 QWidget
* DolphinView::ViewAccessor::layoutTarget() const
1470 if (m_columnsContainer
!= 0) {
1471 return m_columnsContainer
;
1476 KUrl
DolphinView::ViewAccessor::rootUrl() const
1478 return (m_columnsContainer
!= 0) ? m_columnsContainer
->rootUrl() : KUrl();
1481 bool DolphinView::ViewAccessor::supportsCategorizedSorting() const
1483 return m_iconsView
!= 0;
1486 bool DolphinView::ViewAccessor::itemsExpandable() const
1488 return (m_detailsView
!= 0) && m_detailsView
->itemsExpandable();
1492 QSet
<KUrl
> DolphinView::ViewAccessor::expandedUrls() const
1494 if (m_detailsView
!= 0) {
1495 return m_detailsView
->expandedUrls();
1498 return QSet
<KUrl
>();
1501 const DolphinDetailsViewExpander
* DolphinView::ViewAccessor::setExpandedUrls(const QSet
<KUrl
>& urlsToExpand
)
1503 if ((m_detailsView
!= 0) && m_detailsView
->itemsExpandable() && !urlsToExpand
.isEmpty()) {
1504 // Check if another expander is already active and stop it if necessary.
1505 if(!m_detailsViewExpander
.isNull()) {
1506 m_detailsViewExpander
->stop();
1509 m_detailsViewExpander
= new DolphinDetailsViewExpander(m_detailsView
, urlsToExpand
);
1510 return m_detailsViewExpander
;
1517 bool DolphinView::ViewAccessor::reloadOnAdditionalInfoChange() const
1519 // the details view requires no reloading of the directory, as it maps
1520 // the file item delegate info to its columns internally
1521 return m_detailsView
!= 0;
1524 DolphinModel
* DolphinView::ViewAccessor::dirModel() const
1526 return static_cast<DolphinModel
*>(proxyModel()->sourceModel());
1529 DolphinSortFilterProxyModel
* DolphinView::ViewAccessor::proxyModel() const
1531 if (m_columnsContainer
!= 0) {
1532 return static_cast<DolphinSortFilterProxyModel
*>(m_columnsContainer
->activeColumn()->model());
1534 return m_proxyModel
;
1537 KDirLister
* DolphinView::ViewAccessor::dirLister() const
1539 return dirModel()->dirLister();
1542 void DolphinView::slotRedirection(const KUrl
& oldUrl
, const KUrl
& newUrl
)
1544 if (oldUrl
.equals(url(), KUrl::CompareWithoutTrailingSlash
)) {
1545 emit
redirection(oldUrl
, newUrl
);
1546 m_viewModeController
->redirectToUrl(newUrl
); // #186947
1550 void DolphinView::restoreContentsPosition()
1552 if (!m_restoredContentsPosition
.isNull()) {
1553 const int x
= m_restoredContentsPosition
.x();
1554 const int y
= m_restoredContentsPosition
.y();
1555 m_restoredContentsPosition
= QPoint();
1557 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1558 Q_ASSERT(view
!= 0);
1559 view
->horizontalScrollBar()->setValue(x
);
1560 view
->verticalScrollBar()->setValue(y
);
1564 #include "dolphinview.moc"