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 "dolphinmodel.h"
53 #include "dolphincolumnviewcontainer.h"
54 #include "dolphincontroller.h"
55 #include "dolphindetailsview.h"
56 #include "dolphinfileitemdelegate.h"
57 #include "dolphinnewmenuobserver.h"
58 #include "dolphinsortfilterproxymodel.h"
59 #include "dolphin_detailsmodesettings.h"
60 #include "dolphiniconsview.h"
61 #include "dolphin_generalsettings.h"
62 #include "draganddrophelper.h"
63 #include "renamedialog.h"
64 #include "settings/dolphinsettings.h"
65 #include "viewproperties.h"
66 #include "zoomlevelinfo.h"
67 #include "dolphindetailsviewexpander.h"
70 * Helper function for sorting items with qSort() in
71 * DolphinView::renameSelectedItems().
73 bool lessThan(const KFileItem
& item1
, const KFileItem
& item2
)
75 return KStringHandler::naturalCompare(item1
.name(), item2
.name()) < 0;
78 DolphinView::DolphinView(QWidget
* parent
,
80 DolphinSortFilterProxyModel
* proxyModel
) :
84 m_storedCategorizedSorting(false),
85 m_tabsForFiles(false),
86 m_isContextMenuOpen(false),
87 m_ignoreViewProperties(false),
88 m_assureVisibleCurrentIndex(false),
89 m_mode(DolphinView::IconsView
),
92 m_viewAccessor(proxyModel
),
94 m_selectionChangedTimer(0),
97 m_restoredContentsPosition(),
102 m_topLayout
= new QVBoxLayout(this);
103 m_topLayout
->setSpacing(0);
104 m_topLayout
->setMargin(0);
106 m_controller
= new DolphinController(this);
107 m_controller
->setUrl(url
);
109 connect(m_controller
, SIGNAL(urlChanged(const KUrl
&)),
110 this, SIGNAL(urlChanged(const KUrl
&)));
112 connect(m_controller
, SIGNAL(requestContextMenu(const QPoint
&, const QList
<QAction
*>&)),
113 this, SLOT(openContextMenu(const QPoint
&, const QList
<QAction
*>&)));
114 connect(m_controller
, SIGNAL(urlsDropped(const KFileItem
&, const KUrl
&, QDropEvent
*)),
115 this, SLOT(dropUrls(const KFileItem
&, const KUrl
&, QDropEvent
*)));
116 connect(m_controller
, SIGNAL(sortingChanged(DolphinView::Sorting
)),
117 this, SLOT(updateSorting(DolphinView::Sorting
)));
118 connect(m_controller
, SIGNAL(sortOrderChanged(Qt::SortOrder
)),
119 this, SLOT(updateSortOrder(Qt::SortOrder
)));
120 connect(m_controller
, SIGNAL(sortFoldersFirstChanged(bool)),
121 this, SLOT(updateSortFoldersFirst(bool)));
122 connect(m_controller
, SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList
&)),
123 this, SLOT(updateAdditionalInfo(const KFileItemDelegate::InformationList
&)));
124 connect(m_controller
, SIGNAL(itemTriggered(const KFileItem
&)),
125 this, SLOT(triggerItem(const KFileItem
&)));
126 connect(m_controller
, SIGNAL(tabRequested(const KUrl
&)),
127 this, SIGNAL(tabRequested(const KUrl
&)));
128 connect(m_controller
, SIGNAL(activated()),
129 this, SLOT(activate()));
130 connect(m_controller
, SIGNAL(itemEntered(const KFileItem
&)),
131 this, SLOT(showHoverInformation(const KFileItem
&)));
132 connect(m_controller
, SIGNAL(viewportEntered()),
133 this, SLOT(clearHoverInformation()));
135 KDirLister
* dirLister
= m_viewAccessor
.dirLister();
136 connect(dirLister
, SIGNAL(redirection(KUrl
,KUrl
)),
137 this, SLOT(slotRedirection(KUrl
,KUrl
)));
138 connect(dirLister
, SIGNAL(completed()),
139 this, SLOT(slotDirListerCompleted()));
140 connect(dirLister
, SIGNAL(refreshItems(const QList
<QPair
<KFileItem
,KFileItem
>>&)),
141 this, SLOT(slotRefreshItems()));
143 // When a new item has been created by the "Create New..." menu, the item should
144 // get selected and it must be assured that the item will get visible. As the
145 // creation is done asynchronously, several signals must be checked:
146 connect(&DolphinNewMenuObserver::instance(), SIGNAL(itemCreated(const KUrl
&)),
147 this, SLOT(observeCreatedItem(const KUrl
&)));
149 m_selectionChangedTimer
= new QTimer(this);
150 m_selectionChangedTimer
->setSingleShot(true);
151 m_selectionChangedTimer
->setInterval(300);
152 connect(m_selectionChangedTimer
, SIGNAL(timeout()),
153 this, SLOT(emitSelectionChangedSignal()));
155 applyViewProperties();
156 m_topLayout
->addWidget(m_viewAccessor
.layoutTarget());
159 DolphinView::~DolphinView()
163 const KUrl
& DolphinView::url() const
165 return m_controller
->url();
168 KUrl
DolphinView::rootUrl() const
170 const KUrl viewUrl
= url();
171 const KUrl root
= m_viewAccessor
.rootUrl();
172 if (root
.isEmpty() || !root
.isParentOf(viewUrl
)) {
178 void DolphinView::setActive(bool active
)
180 if (active
== m_active
) {
186 QColor color
= KColorScheme(QPalette::Active
, KColorScheme::View
).background().color();
188 emitSelectionChangedSignal();
193 QWidget
* viewport
= m_viewAccessor
.itemView()->viewport();
195 palette
.setColor(viewport
->backgroundRole(), color
);
196 viewport
->setPalette(palette
);
201 m_viewAccessor
.itemView()->setFocus();
205 m_controller
->indicateActivationChange(active
);
208 bool DolphinView::isActive() const
213 void DolphinView::setMode(Mode mode
)
215 if (mode
== m_mode
) {
216 return; // the wished mode is already set
219 const int oldZoomLevel
= m_controller
->zoomLevel();
222 // remember the currently selected items, so that they will
223 // be restored after reloading the directory
224 m_selectedItems
= selectedItems();
228 const KUrl viewPropsUrl
= rootUrl();
229 ViewProperties
props(viewPropsUrl
);
230 props
.setViewMode(m_mode
);
233 // the file item delegate has been recreated, apply the current
234 // additional information manually
235 const KFileItemDelegate::InformationList infoList
= props
.additionalInfo();
236 m_viewAccessor
.itemDelegate()->setShowInformation(infoList
);
237 emit
additionalInfoChanged();
239 // Not all view modes support categorized sorting. Adjust the sorting model
240 // if changing the view mode results in a change of the categorized sorting
242 m_storedCategorizedSorting
= props
.categorizedSorting();
243 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
244 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
245 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
246 emit
categorizedSortingChanged();
251 updateZoomLevel(oldZoomLevel
);
252 loadDirectory(viewPropsUrl
);
255 DolphinView::Mode
DolphinView::mode() const
260 bool DolphinView::showPreview() const
262 return m_showPreview
;
265 bool DolphinView::showHiddenFiles() const
267 return m_viewAccessor
.dirLister()->showingDotFiles();
270 bool DolphinView::categorizedSorting() const
272 // If all view modes would support categorized sorting, returning
273 // m_viewAccessor.proxyModel()->isCategorizedModel() would be the way to go. As
274 // currently only the icons view supports caterized sorting, we remember
275 // the stored view properties state in m_storedCategorizedSorting and
276 // return this state. The application takes care to disable the corresponding
277 // checkbox by checking DolphinView::supportsCategorizedSorting() to indicate
278 // that this setting is not applied to the current view mode.
279 return m_storedCategorizedSorting
;
282 bool DolphinView::supportsCategorizedSorting() const
284 return m_viewAccessor
.supportsCategorizedSorting();
287 bool DolphinView::hasSelection() const
289 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
290 return (view
!= 0) && view
->selectionModel()->hasSelection();
293 void DolphinView::markUrlsAsSelected(const QList
<KUrl
>& urls
)
295 foreach (const KUrl
& url
, urls
) {
296 KFileItem
item(KFileItem::Unknown
, KFileItem::Unknown
, url
);
297 m_selectedItems
.append(item
);
301 KFileItemList
DolphinView::selectedItems() const
303 KFileItemList itemList
;
304 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
309 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
311 const QModelIndexList indexList
= selection
.indexes();
312 foreach (const QModelIndex
&index
, indexList
) {
313 KFileItem item
= m_viewAccessor
.dirModel()->itemForIndex(index
);
314 if (!item
.isNull()) {
315 itemList
.append(item
);
322 KUrl::List
DolphinView::selectedUrls() const
325 const KFileItemList list
= selectedItems();
326 foreach (const KFileItem
&item
, list
) {
327 urls
.append(item
.url());
332 int DolphinView::selectedItemsCount() const
334 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
339 return view
->selectionModel()->selectedIndexes().count();
342 QItemSelectionModel
* DolphinView::selectionModel() const
344 return m_viewAccessor
.itemView()->selectionModel();
347 void DolphinView::setZoomLevel(int level
)
349 if (level
< ZoomLevelInfo::minimumLevel()) {
350 level
= ZoomLevelInfo::minimumLevel();
351 } else if (level
> ZoomLevelInfo::maximumLevel()) {
352 level
= ZoomLevelInfo::maximumLevel();
355 if (level
!= zoomLevel()) {
356 m_controller
->setZoomLevel(level
);
357 emit
zoomLevelChanged(level
);
361 int DolphinView::zoomLevel() const
363 return m_controller
->zoomLevel();
366 void DolphinView::setSorting(Sorting sorting
)
368 if (sorting
!= this->sorting()) {
369 updateSorting(sorting
);
373 DolphinView::Sorting
DolphinView::sorting() const
375 return m_viewAccessor
.proxyModel()->sorting();
378 void DolphinView::setSortOrder(Qt::SortOrder order
)
380 if (sortOrder() != order
) {
381 updateSortOrder(order
);
385 Qt::SortOrder
DolphinView::sortOrder() const
387 return m_viewAccessor
.proxyModel()->sortOrder();
390 void DolphinView::setSortFoldersFirst(bool foldersFirst
)
392 if (sortFoldersFirst() != foldersFirst
) {
393 updateSortFoldersFirst(foldersFirst
);
397 bool DolphinView::sortFoldersFirst() const
399 return m_viewAccessor
.proxyModel()->sortFoldersFirst();
402 void DolphinView::setAdditionalInfo(KFileItemDelegate::InformationList info
)
404 const KUrl viewPropsUrl
= rootUrl();
405 ViewProperties
props(viewPropsUrl
);
406 props
.setAdditionalInfo(info
);
407 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
409 emit
additionalInfoChanged();
411 if (m_viewAccessor
.reloadOnAdditionalInfoChange()) {
412 loadDirectory(viewPropsUrl
);
416 KFileItemDelegate::InformationList
DolphinView::additionalInfo() const
418 return m_viewAccessor
.itemDelegate()->showInformation();
421 void DolphinView::reload()
423 QByteArray viewState
;
424 QDataStream
saveStream(&viewState
, QIODevice::WriteOnly
);
425 saveState(saveStream
);
426 m_selectedItems
= selectedItems();
429 loadDirectory(url(), true);
431 QDataStream
restoreStream(viewState
);
432 restoreState(restoreStream
);
435 void DolphinView::refresh()
437 m_ignoreViewProperties
= false;
439 const bool oldActivationState
= m_active
;
440 const int oldZoomLevel
= m_controller
->zoomLevel();
444 applyViewProperties();
447 setActive(oldActivationState
);
448 updateZoomLevel(oldZoomLevel
);
451 void DolphinView::setNameFilter(const QString
& nameFilter
)
453 m_controller
->setNameFilter(nameFilter
);
456 void DolphinView::calculateItemCount(int& fileCount
,
458 KIO::filesize_t
& totalFileSize
) const
460 foreach (const KFileItem
& item
, m_viewAccessor
.dirLister()->items()) {
465 totalFileSize
+= item
.size();
470 QString
DolphinView::statusBarText() const
475 KIO::filesize_t totalFileSize
= 0;
477 if (hasSelection()) {
478 // give a summary of the status of the selected files
479 const KFileItemList list
= selectedItems();
480 if (list
.isEmpty()) {
481 // when an item is triggered, it is temporary selected but selectedItems()
482 // will return an empty list
486 KFileItemList::const_iterator it
= list
.begin();
487 const KFileItemList::const_iterator end
= list
.end();
489 const KFileItem
& item
= *it
;
494 totalFileSize
+= item
.size();
499 if (folderCount
+ fileCount
== 1) {
500 // if only one item is selected, show the filename
501 const QString name
= list
.first().text();
502 text
= (folderCount
== 1) ? i18nc("@info:status", "<filename>%1</filename> selected", name
) :
503 i18nc("@info:status", "<filename>%1</filename> selected (%2)",
504 name
, KIO::convertSize(totalFileSize
));
506 // at least 2 items are selected
507 const QString foldersText
= i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount
);
508 const QString filesText
= i18ncp("@info:status", "1 File selected", "%1 Files selected", fileCount
);
509 if ((folderCount
> 0) && (fileCount
> 0)) {
510 text
= i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
511 foldersText
, filesText
, KIO::convertSize(totalFileSize
));
512 } else if (fileCount
> 0) {
513 text
= i18nc("@info:status files (size)", "%1 (%2)", filesText
, KIO::convertSize(totalFileSize
));
515 Q_ASSERT(folderCount
> 0);
520 calculateItemCount(fileCount
, folderCount
, totalFileSize
);
521 text
= KIO::itemsSummaryString(fileCount
+ folderCount
,
522 fileCount
, folderCount
,
523 totalFileSize
, true);
529 QList
<QAction
*> DolphinView::versionControlActions(const KFileItemList
& items
) const
531 return m_controller
->versionControlActions(items
);
534 void DolphinView::setUrl(const KUrl
& url
)
536 if (m_controller
->url() != url
) {
537 m_newFileNames
.clear();
539 m_controller
->setUrl(url
); // emits urlChanged, which we forward
540 m_viewAccessor
.prepareUrlChange(url
);
541 applyViewProperties();
544 // When changing the URL there is no need to keep the version
545 // data of the previous URL.
546 m_viewAccessor
.dirModel()->clearVersionData();
548 emit
startedPathLoading(url
);
551 // the selection model might have changed in the case of a column view
552 QItemSelectionModel
* selectionModel
= m_viewAccessor
.itemView()->selectionModel();
553 if (m_selectionModel
!= selectionModel
) {
554 disconnect(m_selectionModel
, SIGNAL(selectionChanged(QItemSelection
, QItemSelection
)),
555 this, SLOT(slotSelectionChanged(QItemSelection
, QItemSelection
)));
556 m_selectionModel
= selectionModel
;
557 connect(m_selectionModel
, SIGNAL(selectionChanged(QItemSelection
, QItemSelection
)),
558 this, SLOT(slotSelectionChanged(QItemSelection
, QItemSelection
)));
562 void DolphinView::selectAll()
564 m_viewAccessor
.itemView()->selectAll();
567 void DolphinView::invertSelection()
569 QItemSelectionModel
* selectionModel
= m_viewAccessor
.itemView()->selectionModel();
570 const QAbstractItemModel
* itemModel
= selectionModel
->model();
572 const QModelIndex topLeft
= itemModel
->index(0, 0);
573 const QModelIndex bottomRight
= itemModel
->index(itemModel
->rowCount() - 1,
574 itemModel
->columnCount() - 1);
576 const QItemSelection
selection(topLeft
, bottomRight
);
577 selectionModel
->select(selection
, QItemSelectionModel::Toggle
);
580 void DolphinView::clearSelection()
582 m_viewAccessor
.itemView()->clearSelection();
585 void DolphinView::renameSelectedItems()
587 KFileItemList items
= selectedItems();
588 const int itemCount
= items
.count();
594 // More than one item has been selected for renaming. Open
595 // a rename dialog and rename all items afterwards.
596 QPointer
<RenameDialog
> dialog
= new RenameDialog(this, items
);
597 if (dialog
->exec() == QDialog::Rejected
) {
602 const QString newName
= dialog
->newName();
603 if (newName
.isEmpty()) {
604 emit
errorMessage(dialog
->errorString());
610 // the selection would be invalid after renaming the items, so just clear
614 // TODO: check how this can be integrated into KIO::FileUndoManager/KonqOperations
615 // as one operation instead of n rename operations like it is done now...
616 Q_ASSERT(newName
.contains('#'));
618 // currently the items are sorted by the selection order, resort
619 // them by the file name
620 qSort(items
.begin(), items
.end(), lessThan
);
622 // iterate through all selected items and rename them...
624 foreach (const KFileItem
& item
, items
) {
625 const KUrl
& oldUrl
= item
.url();
627 number
.setNum(index
++);
629 QString name
= newName
;
630 name
.replace('#', number
);
632 if (oldUrl
.fileName() != name
) {
633 KUrl newUrl
= oldUrl
;
634 newUrl
.setFileName(name
);
635 KonqOperations::rename(this, oldUrl
, newUrl
);
638 } else if (DolphinSettings::instance().generalSettings()->renameInline()) {
639 Q_ASSERT(itemCount
== 1);
640 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForItem(items
.first());
641 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
642 m_viewAccessor
.itemView()->edit(proxyIndex
);
644 Q_ASSERT(itemCount
== 1);
646 QPointer
<RenameDialog
> dialog
= new RenameDialog(this, items
);
647 if (dialog
->exec() == QDialog::Rejected
) {
652 const QString newName
= dialog
->newName();
653 if (newName
.isEmpty()) {
654 emit
errorMessage(dialog
->errorString());
660 const KUrl
& oldUrl
= items
.first().url();
661 KUrl newUrl
= oldUrl
;
662 newUrl
.setFileName(newName
);
663 KonqOperations::rename(this, oldUrl
, newUrl
);
666 // assure that the current index remains visible when KDirLister
667 // will notify the view about changed items
668 m_assureVisibleCurrentIndex
= true;
671 void DolphinView::trashSelectedItems()
673 const KUrl::List list
= simplifiedSelectedUrls();
674 KonqOperations::del(this, KonqOperations::TRASH
, list
);
677 void DolphinView::deleteSelectedItems()
679 const KUrl::List list
= simplifiedSelectedUrls();
680 const bool del
= KonqOperations::askDeleteConfirmation(list
,
682 KonqOperations::DEFAULT_CONFIRMATION
,
686 KIO::Job
* job
= KIO::del(list
);
687 connect(job
, SIGNAL(result(KJob
*)),
688 this, SLOT(slotDeleteFileFinished(KJob
*)));
692 void DolphinView::cutSelectedItems()
694 QMimeData
* mimeData
= selectionMimeData();
695 KonqMimeData::addIsCutSelection(mimeData
, true);
696 QApplication::clipboard()->setMimeData(mimeData
);
699 void DolphinView::copySelectedItems()
701 QMimeData
* mimeData
= selectionMimeData();
702 QApplication::clipboard()->setMimeData(mimeData
);
705 void DolphinView::paste()
710 void DolphinView::pasteIntoFolder()
712 const KFileItemList items
= selectedItems();
713 if ((items
.count() == 1) && items
.first().isDir()) {
714 pasteToUrl(items
.first().url());
718 void DolphinView::setShowPreview(bool show
)
720 if (m_showPreview
== show
) {
724 const KUrl viewPropsUrl
= rootUrl();
725 ViewProperties
props(viewPropsUrl
);
726 props
.setShowPreview(show
);
728 m_showPreview
= show
;
729 const int oldZoomLevel
= m_controller
->zoomLevel();
730 emit
showPreviewChanged();
732 // Enabling or disabling the preview might change the icon size of the view.
733 // As the view does not emit a signal when the icon size has been changed,
734 // the used zoom level of the controller must be adjusted manually:
735 updateZoomLevel(oldZoomLevel
);
738 void DolphinView::setShowHiddenFiles(bool show
)
740 if (m_viewAccessor
.dirLister()->showingDotFiles() == show
) {
744 const KUrl viewPropsUrl
= rootUrl();
745 ViewProperties
props(viewPropsUrl
);
746 props
.setShowHiddenFiles(show
);
748 m_viewAccessor
.dirLister()->setShowingDotFiles(show
);
749 emit
showHiddenFilesChanged();
752 void DolphinView::setCategorizedSorting(bool categorized
)
754 if (categorized
== categorizedSorting()) {
758 // setCategorizedSorting(true) may only get invoked
759 // if the view supports categorized sorting
760 Q_ASSERT(!categorized
|| supportsCategorizedSorting());
762 ViewProperties
props(rootUrl());
763 props
.setCategorizedSorting(categorized
);
766 m_storedCategorizedSorting
= categorized
;
767 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
769 emit
categorizedSortingChanged();
772 void DolphinView::toggleSortOrder()
774 const Qt::SortOrder order
= (sortOrder() == Qt::AscendingOrder
) ?
775 Qt::DescendingOrder
:
780 void DolphinView::toggleSortFoldersFirst()
782 setSortFoldersFirst(!sortFoldersFirst());
785 void DolphinView::toggleAdditionalInfo(QAction
* action
)
787 const KFileItemDelegate::Information info
=
788 static_cast<KFileItemDelegate::Information
>(action
->data().toInt());
790 KFileItemDelegate::InformationList list
= additionalInfo();
792 const bool show
= action
->isChecked();
794 const int index
= list
.indexOf(info
);
795 const bool containsInfo
= (index
>= 0);
796 if (show
&& !containsInfo
) {
798 setAdditionalInfo(list
);
799 } else if (!show
&& containsInfo
) {
800 list
.removeAt(index
);
801 setAdditionalInfo(list
);
802 Q_ASSERT(list
.indexOf(info
) < 0);
806 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
808 QWidget::mouseReleaseEvent(event
);
812 bool DolphinView::eventFilter(QObject
* watched
, QEvent
* event
)
814 switch (event
->type()) {
815 case QEvent::FocusIn
:
816 if (watched
== m_viewAccessor
.itemView()) {
817 m_controller
->requestActivation();
821 case QEvent::DragEnter
:
822 if (watched
== m_viewAccessor
.itemView()->viewport()) {
827 case QEvent::KeyPress
:
828 if (watched
== m_viewAccessor
.itemView()) {
829 // clear the selection when Escape has been pressed
830 QKeyEvent
* keyEvent
= static_cast<QKeyEvent
*>(event
);
831 if (keyEvent
->key() == Qt::Key_Escape
) {
838 if (watched
== m_viewAccessor
.itemView()->viewport()) {
839 // Ctrl+wheel events should cause icon zooming, but not if the left mouse button is pressed
840 // (the user is probably trying to scroll during a selection in that case)
841 QWheelEvent
* wheelEvent
= static_cast<QWheelEvent
*>(event
);
842 if (wheelEvent
->modifiers() & Qt::ControlModifier
&& !(wheelEvent
->buttons() & Qt::LeftButton
)) {
843 const int delta
= wheelEvent
->delta();
844 const int level
= zoomLevel();
846 setZoomLevel(level
+ 1);
847 } else if (delta
< 0) {
848 setZoomLevel(level
- 1);
859 return QWidget::eventFilter(watched
, event
);
862 void DolphinView::activate()
867 void DolphinView::triggerItem(const KFileItem
& item
)
869 const Qt::KeyboardModifiers modifier
= QApplication::keyboardModifiers();
870 if ((modifier
& Qt::ShiftModifier
) || (modifier
& Qt::ControlModifier
)) {
871 // items are selected by the user, hence don't trigger the
872 // item specified by 'index'
876 // TODO: the m_isContextMenuOpen check is a workaround for Qt-issue 207192
877 if (item
.isNull() || m_isContextMenuOpen
) {
881 emit
itemTriggered(item
); // caught by DolphinViewContainer or DolphinPart
884 void DolphinView::slotSelectionChanged(const QItemSelection
& selected
, const QItemSelection
& deselected
)
886 const int count
= selectedItemsCount();
887 const bool selectionStateChanged
= ((count
> 0) && (selected
.count() == count
)) ||
888 ((count
== 0) && !deselected
.isEmpty());
890 // If nothing has been selected before and something got selected (or if something
891 // was selected before and now nothing is selected) the selectionChangedSignal must
892 // be emitted asynchronously as fast as possible to update the edit-actions.
893 m_selectionChangedTimer
->setInterval(selectionStateChanged
? 0 : 300);
894 m_selectionChangedTimer
->start();
897 void DolphinView::emitSelectionChangedSignal()
899 emit
selectionChanged(DolphinView::selectedItems());
902 void DolphinView::openContextMenu(const QPoint
& pos
,
903 const QList
<QAction
*>& customActions
)
906 const QModelIndex index
= m_viewAccessor
.itemView()->indexAt(pos
);
907 if (index
.isValid() && (index
.column() == DolphinModel::Name
)) {
908 const QModelIndex dolphinModelIndex
= m_viewAccessor
.proxyModel()->mapToSource(index
);
909 item
= m_viewAccessor
.dirModel()->itemForIndex(dolphinModelIndex
);
912 m_isContextMenuOpen
= true; // TODO: workaround for Qt-issue 207192
913 emit
requestContextMenu(item
, url(), customActions
);
914 m_isContextMenuOpen
= false;
917 void DolphinView::dropUrls(const KFileItem
& destItem
,
918 const KUrl
& destPath
,
921 addNewFileNames(event
->mimeData());
922 DragAndDropHelper::instance().dropUrls(destItem
, destPath
, event
, this);
925 void DolphinView::updateSorting(DolphinView::Sorting sorting
)
927 ViewProperties
props(rootUrl());
928 props
.setSorting(sorting
);
930 m_viewAccessor
.proxyModel()->setSorting(sorting
);
932 emit
sortingChanged(sorting
);
935 void DolphinView::updateSortOrder(Qt::SortOrder order
)
937 ViewProperties
props(rootUrl());
938 props
.setSortOrder(order
);
940 m_viewAccessor
.proxyModel()->setSortOrder(order
);
942 emit
sortOrderChanged(order
);
945 void DolphinView::updateSortFoldersFirst(bool foldersFirst
)
947 ViewProperties
props(rootUrl());
948 props
.setSortFoldersFirst(foldersFirst
);
950 m_viewAccessor
.proxyModel()->setSortFoldersFirst(foldersFirst
);
952 emit
sortFoldersFirstChanged(foldersFirst
);
955 void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList
& info
)
957 ViewProperties
props(rootUrl());
958 props
.setAdditionalInfo(info
);
961 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
963 emit
additionalInfoChanged();
966 void DolphinView::updateAdditionalInfoActions(KActionCollection
* collection
)
968 const bool enable
= (m_mode
== DolphinView::DetailsView
) ||
969 (m_mode
== DolphinView::IconsView
);
971 QAction
* showSizeInfo
= collection
->action("show_size_info");
972 QAction
* showDateInfo
= collection
->action("show_date_info");
973 QAction
* showPermissionsInfo
= collection
->action("show_permissions_info");
974 QAction
* showOwnerInfo
= collection
->action("show_owner_info");
975 QAction
* showGroupInfo
= collection
->action("show_group_info");
976 QAction
* showMimeInfo
= collection
->action("show_mime_info");
978 showSizeInfo
->setChecked(false);
979 showDateInfo
->setChecked(false);
980 showPermissionsInfo
->setChecked(false);
981 showOwnerInfo
->setChecked(false);
982 showGroupInfo
->setChecked(false);
983 showMimeInfo
->setChecked(false);
985 showSizeInfo
->setEnabled(enable
);
986 showDateInfo
->setEnabled(enable
);
987 showPermissionsInfo
->setEnabled(enable
);
988 showOwnerInfo
->setEnabled(enable
);
989 showGroupInfo
->setEnabled(enable
);
990 showMimeInfo
->setEnabled(enable
);
992 foreach (KFileItemDelegate::Information info
, m_viewAccessor
.itemDelegate()->showInformation()) {
994 case KFileItemDelegate::Size
:
995 showSizeInfo
->setChecked(true);
997 case KFileItemDelegate::ModificationTime
:
998 showDateInfo
->setChecked(true);
1000 case KFileItemDelegate::Permissions
:
1001 showPermissionsInfo
->setChecked(true);
1003 case KFileItemDelegate::Owner
:
1004 showOwnerInfo
->setChecked(true);
1006 case KFileItemDelegate::OwnerAndGroup
:
1007 showGroupInfo
->setChecked(true);
1009 case KFileItemDelegate::FriendlyMimeType
:
1010 showMimeInfo
->setChecked(true);
1018 QPair
<bool, QString
> DolphinView::pasteInfo() const
1020 return KonqOperations::pasteInfo(url());
1023 void DolphinView::setTabsForFilesEnabled(bool tabsForFiles
)
1025 m_tabsForFiles
= tabsForFiles
;
1028 bool DolphinView::isTabsForFilesEnabled() const
1030 return m_tabsForFiles
;
1033 bool DolphinView::itemsExpandable() const
1035 return m_viewAccessor
.itemsExpandable();
1038 void DolphinView::restoreState(QDataStream
& stream
)
1041 stream
>> m_activeItemUrl
;
1044 stream
>> m_restoredContentsPosition
;
1046 // expanded folders (only relevant for the details view - will be ignored by the view in other view modes)
1047 QSet
<KUrl
> urlsToExpand
;
1048 stream
>> urlsToExpand
;
1049 const DolphinDetailsViewExpander
* expander
= m_viewAccessor
.setExpandedUrls(urlsToExpand
);
1050 if (expander
!= 0) {
1051 m_expanderActive
= true;
1052 connect (expander
, SIGNAL(completed()), this, SLOT(slotLoadingCompleted()));
1055 m_expanderActive
= false;
1059 void DolphinView::saveState(QDataStream
& stream
)
1062 KFileItem currentItem
;
1063 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
1066 const QModelIndex proxyIndex
= view
->currentIndex();
1067 const QModelIndex dirModelIndex
= m_viewAccessor
.proxyModel()->mapToSource(proxyIndex
);
1068 currentItem
= m_viewAccessor
.dirModel()->itemForIndex(dirModelIndex
);
1072 if (!currentItem
.isNull()) {
1073 currentUrl
= currentItem
.url();
1076 stream
<< currentUrl
;
1079 const int x
= view
->horizontalScrollBar()->value();
1080 const int y
= view
->verticalScrollBar()->value();
1081 stream
<< QPoint(x
, y
);
1083 // expanded folders (only relevant for the details view - the set will be empty in other view modes)
1084 stream
<< m_viewAccessor
.expandedUrls();
1087 void DolphinView::observeCreatedItem(const KUrl
& url
)
1089 m_createdItemUrl
= url
;
1090 connect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
1091 this, SLOT(selectAndScrollToCreatedItem()));
1094 void DolphinView::selectAndScrollToCreatedItem()
1096 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_createdItemUrl
);
1097 if (dirIndex
.isValid()) {
1098 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
1099 m_viewAccessor
.itemView()->setCurrentIndex(proxyIndex
);
1102 disconnect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
1103 this, SLOT(selectAndScrollToCreatedItem()));
1104 m_createdItemUrl
= KUrl();
1107 void DolphinView::showHoverInformation(const KFileItem
& item
)
1109 emit
requestItemInfo(item
);
1112 void DolphinView::clearHoverInformation()
1114 emit
requestItemInfo(KFileItem());
1117 void DolphinView::slotDeleteFileFinished(KJob
* job
)
1119 if (job
->error() == 0) {
1120 emit
operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
1121 } else if (job
->error() != KIO::ERR_USER_CANCELED
) {
1122 emit
errorMessage(job
->errorString());
1126 void DolphinView::slotDirListerCompleted()
1128 if (!m_expanderActive
) {
1129 slotLoadingCompleted();
1132 if (!m_newFileNames
.isEmpty()) {
1133 // select all newly added items created by a paste operation or
1134 // a drag & drop operation
1135 const int rowCount
= m_viewAccessor
.proxyModel()->rowCount();
1136 QItemSelection selection
;
1137 for (int row
= 0; row
< rowCount
; ++row
) {
1138 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->index(row
, 0);
1139 const QModelIndex dirIndex
= m_viewAccessor
.proxyModel()->mapToSource(proxyIndex
);
1140 const KUrl url
= m_viewAccessor
.dirModel()->itemForIndex(dirIndex
).url();
1141 if (m_newFileNames
.contains(url
.fileName())) {
1142 selection
.merge(QItemSelection(proxyIndex
, proxyIndex
), QItemSelectionModel::Select
);
1145 m_viewAccessor
.itemView()->selectionModel()->select(selection
, QItemSelectionModel::Select
);
1147 m_newFileNames
.clear();
1151 void DolphinView::slotLoadingCompleted()
1153 m_expanderActive
= false;
1155 if (!m_activeItemUrl
.isEmpty()) {
1156 // assure that the current item remains visible
1157 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_activeItemUrl
);
1158 if (dirIndex
.isValid()) {
1159 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
1160 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1161 const bool clearSelection
= !hasSelection();
1162 view
->setCurrentIndex(proxyIndex
);
1163 if (clearSelection
) {
1164 view
->clearSelection();
1166 m_activeItemUrl
.clear();
1170 if (!m_selectedItems
.isEmpty()) {
1171 const KUrl
& baseUrl
= url();
1173 QItemSelection newSelection
;
1174 foreach(const KFileItem
& item
, m_selectedItems
) {
1175 url
= item
.url().upUrl();
1176 if (baseUrl
.equals(url
, KUrl::CompareWithoutTrailingSlash
)) {
1177 QModelIndex index
= m_viewAccessor
.proxyModel()->mapFromSource(m_viewAccessor
.dirModel()->indexForItem(item
));
1178 newSelection
.select(index
, index
);
1181 m_viewAccessor
.itemView()->selectionModel()->select(newSelection
,
1182 QItemSelectionModel::ClearAndSelect
1183 | QItemSelectionModel::Current
);
1184 m_selectedItems
.clear();
1187 // Restore the contents position. This has to be done using a Qt::QueuedConnection
1188 // because the view might not be in its final state yet.
1189 QMetaObject::invokeMethod(this, "restoreContentsPosition", Qt::QueuedConnection
);
1192 void DolphinView::slotRefreshItems()
1194 if (m_assureVisibleCurrentIndex
) {
1195 m_assureVisibleCurrentIndex
= false;
1196 m_viewAccessor
.itemView()->scrollTo(m_viewAccessor
.itemView()->currentIndex());
1200 void DolphinView::loadDirectory(const KUrl
& url
, bool reload
)
1202 if (!url
.isValid()) {
1203 const QString
location(url
.pathOrUrl());
1204 if (location
.isEmpty()) {
1205 emit
errorMessage(i18nc("@info:status", "The location is empty."));
1207 emit
errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location
));
1212 KDirLister
* dirLister
= m_viewAccessor
.dirLister();
1213 dirLister
->openUrl(url
, reload
? KDirLister::Reload
: KDirLister::NoFlags
);
1216 void DolphinView::applyViewProperties()
1218 if (m_ignoreViewProperties
) {
1222 const ViewProperties
props(rootUrl());
1224 const Mode mode
= props
.viewMode();
1225 if (m_mode
!= mode
) {
1226 const int oldZoomLevel
= m_controller
->zoomLevel();
1232 updateZoomLevel(oldZoomLevel
);
1234 if (m_viewAccessor
.itemView() == 0) {
1237 Q_ASSERT(m_viewAccessor
.itemView() != 0);
1238 Q_ASSERT(m_viewAccessor
.itemDelegate() != 0);
1240 const bool showHiddenFiles
= props
.showHiddenFiles();
1241 if (showHiddenFiles
!= m_viewAccessor
.dirLister()->showingDotFiles()) {
1242 m_viewAccessor
.dirLister()->setShowingDotFiles(showHiddenFiles
);
1243 emit
showHiddenFilesChanged();
1246 m_storedCategorizedSorting
= props
.categorizedSorting();
1247 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
1248 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
1249 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
1250 emit
categorizedSortingChanged();
1253 const DolphinView::Sorting sorting
= props
.sorting();
1254 if (sorting
!= m_viewAccessor
.proxyModel()->sorting()) {
1255 m_viewAccessor
.proxyModel()->setSorting(sorting
);
1256 emit
sortingChanged(sorting
);
1259 const Qt::SortOrder sortOrder
= props
.sortOrder();
1260 if (sortOrder
!= m_viewAccessor
.proxyModel()->sortOrder()) {
1261 m_viewAccessor
.proxyModel()->setSortOrder(sortOrder
);
1262 emit
sortOrderChanged(sortOrder
);
1265 const bool sortFoldersFirst
= props
.sortFoldersFirst();
1266 if (sortFoldersFirst
!= m_viewAccessor
.proxyModel()->sortFoldersFirst()) {
1267 m_viewAccessor
.proxyModel()->setSortFoldersFirst(sortFoldersFirst
);
1268 emit
sortFoldersFirstChanged(sortFoldersFirst
);
1271 KFileItemDelegate::InformationList info
= props
.additionalInfo();
1272 if (info
!= m_viewAccessor
.itemDelegate()->showInformation()) {
1273 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
1274 emit
additionalInfoChanged();
1277 const bool showPreview
= props
.showPreview();
1278 if (showPreview
!= m_showPreview
) {
1279 m_showPreview
= showPreview
;
1280 const int oldZoomLevel
= m_controller
->zoomLevel();
1281 emit
showPreviewChanged();
1283 // Enabling or disabling the preview might change the icon size of the view.
1284 // As the view does not emit a signal when the icon size has been changed,
1285 // the used zoom level of the controller must be adjusted manually:
1286 updateZoomLevel(oldZoomLevel
);
1289 if (DolphinSettings::instance().generalSettings()->globalViewProps()) {
1290 // During the lifetime of a DolphinView instance the global view properties
1291 // should not be changed. This allows e. g. to split a view and use different
1292 // view properties for each view.
1293 m_ignoreViewProperties
= true;
1297 void DolphinView::createView()
1301 Q_ASSERT(m_viewAccessor
.itemView() == 0);
1302 m_viewAccessor
.createView(this, m_controller
, m_mode
);
1304 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1305 Q_ASSERT(view
!= 0);
1306 view
->installEventFilter(this);
1307 view
->viewport()->installEventFilter(this);
1309 m_controller
->setItemView(view
);
1311 // When changing the view mode, the selection is lost due to reinstantiating
1312 // a new item view with a custom selection model. Pass the ownership of the
1313 // selection model to DolphinView, so that it can be shared by all item views.
1314 if (m_selectionModel
!= 0) {
1315 view
->setSelectionModel(m_selectionModel
);
1317 m_selectionModel
= view
->selectionModel();
1319 m_selectionModel
->setParent(this);
1320 connect(m_selectionModel
, SIGNAL(selectionChanged(QItemSelection
, QItemSelection
)),
1321 this, SLOT(slotSelectionChanged(QItemSelection
, QItemSelection
)));
1323 setFocusProxy(m_viewAccessor
.layoutTarget());
1324 m_topLayout
->insertWidget(1, m_viewAccessor
.layoutTarget());
1327 void DolphinView::deleteView()
1329 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1331 // It's important to set the keyboard focus to the parent
1332 // before deleting the view: Otherwise when having a split
1333 // view the other view will get the focus and will request
1334 // an activation (see DolphinView::eventFilter()).
1338 m_topLayout
->removeWidget(view
);
1341 // disconnect all signal/slots
1343 m_controller
->disconnect(view
);
1346 m_viewAccessor
.deleteView();
1350 void DolphinView::pasteToUrl(const KUrl
& url
)
1352 addNewFileNames(QApplication::clipboard()->mimeData());
1353 KonqOperations::doPaste(this, url
);
1356 void DolphinView::updateZoomLevel(int oldZoomLevel
)
1358 const int newZoomLevel
= ZoomLevelInfo::zoomLevelForIconSize(m_viewAccessor
.itemView()->iconSize());
1359 if (oldZoomLevel
!= newZoomLevel
) {
1360 m_controller
->setZoomLevel(newZoomLevel
);
1361 emit
zoomLevelChanged(newZoomLevel
);
1365 KUrl::List
DolphinView::simplifiedSelectedUrls() const
1367 KUrl::List list
= selectedUrls();
1368 if (itemsExpandable() ) {
1369 list
= KDirModel::simplifiedUrlList(list
);
1374 QMimeData
* DolphinView::selectionMimeData() const
1376 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
1377 Q_ASSERT((view
!= 0) && (view
->selectionModel() != 0));
1378 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
1379 return m_viewAccessor
.dirModel()->mimeData(selection
.indexes());
1382 void DolphinView::addNewFileNames(const QMimeData
* mimeData
)
1384 const KUrl::List urls
= KUrl::List::fromMimeData(mimeData
);
1385 foreach (const KUrl
& url
, urls
) {
1386 m_newFileNames
.insert(url
.fileName());
1390 DolphinView::ViewAccessor::ViewAccessor(DolphinSortFilterProxyModel
* proxyModel
) :
1393 m_columnsContainer(0),
1394 m_proxyModel(proxyModel
),
1399 DolphinView::ViewAccessor::~ViewAccessor()
1401 delete m_dragSource
;
1405 void DolphinView::ViewAccessor::createView(QWidget
* parent
,
1406 DolphinController
* controller
,
1409 Q_ASSERT(itemView() == 0);
1413 m_iconsView
= new DolphinIconsView(parent
, controller
, m_proxyModel
);
1417 m_detailsView
= new DolphinDetailsView(parent
, controller
, m_proxyModel
);
1421 m_columnsContainer
= new DolphinColumnViewContainer(parent
, controller
);
1429 void DolphinView::ViewAccessor::deleteView()
1431 QAbstractItemView
* view
= itemView();
1433 if (DragAndDropHelper::instance().isDragSource(view
)) {
1434 // The view is a drag source (the feature "Open folders
1435 // during drag operations" is used). Deleting the view
1436 // during an ongoing drag operation is not allowed, so
1437 // this will postponed.
1438 if (m_dragSource
!= 0) {
1439 // the old stored view is obviously not the drag source anymore
1440 m_dragSource
->deleteLater();
1444 m_dragSource
= view
;
1446 view
->deleteLater();
1453 if (m_columnsContainer
!= 0) {
1454 m_columnsContainer
->deleteLater();
1456 m_columnsContainer
= 0;
1460 void DolphinView::ViewAccessor::prepareUrlChange(const KUrl
& url
)
1462 if (m_columnsContainer
!= 0) {
1463 m_columnsContainer
->showColumn(url
);
1467 QAbstractItemView
* DolphinView::ViewAccessor::itemView() const
1469 if (m_iconsView
!= 0) {
1473 if (m_detailsView
!= 0) {
1474 return m_detailsView
;
1477 if (m_columnsContainer
!= 0) {
1478 return m_columnsContainer
->activeColumn();
1484 KFileItemDelegate
* DolphinView::ViewAccessor::itemDelegate() const
1486 return static_cast<KFileItemDelegate
*>(itemView()->itemDelegate());
1489 QWidget
* DolphinView::ViewAccessor::layoutTarget() const
1491 if (m_columnsContainer
!= 0) {
1492 return m_columnsContainer
;
1497 KUrl
DolphinView::ViewAccessor::rootUrl() const
1499 return (m_columnsContainer
!= 0) ? m_columnsContainer
->rootUrl() : KUrl();
1502 bool DolphinView::ViewAccessor::supportsCategorizedSorting() const
1504 return m_iconsView
!= 0;
1507 bool DolphinView::ViewAccessor::itemsExpandable() const
1509 return (m_detailsView
!= 0) && m_detailsView
->itemsExpandable();
1513 QSet
<KUrl
> DolphinView::ViewAccessor::expandedUrls() const
1515 if (m_detailsView
!= 0) {
1516 return m_detailsView
->expandedUrls();
1519 return QSet
<KUrl
>();
1522 const DolphinDetailsViewExpander
* DolphinView::ViewAccessor::setExpandedUrls(const QSet
<KUrl
>& urlsToExpand
)
1524 if ((m_detailsView
!= 0) && m_detailsView
->itemsExpandable() && !urlsToExpand
.isEmpty()) {
1525 // Check if another expander is already active and stop it if necessary.
1526 if(!m_detailsViewExpander
.isNull()) {
1527 m_detailsViewExpander
->stop();
1530 m_detailsViewExpander
= new DolphinDetailsViewExpander(m_detailsView
, urlsToExpand
);
1531 return m_detailsViewExpander
;
1538 bool DolphinView::ViewAccessor::reloadOnAdditionalInfoChange() const
1540 // the details view requires no reloading of the directory, as it maps
1541 // the file item delegate info to its columns internally
1542 return m_detailsView
!= 0;
1545 DolphinModel
* DolphinView::ViewAccessor::dirModel() const
1547 return static_cast<DolphinModel
*>(proxyModel()->sourceModel());
1550 DolphinSortFilterProxyModel
* DolphinView::ViewAccessor::proxyModel() const
1552 if (m_columnsContainer
!= 0) {
1553 return static_cast<DolphinSortFilterProxyModel
*>(m_columnsContainer
->activeColumn()->model());
1555 return m_proxyModel
;
1558 KDirLister
* DolphinView::ViewAccessor::dirLister() const
1560 return dirModel()->dirLister();
1563 void DolphinView::slotRedirection(const KUrl
& oldUrl
, const KUrl
& newUrl
)
1565 emit
redirection(oldUrl
, newUrl
);
1566 m_controller
->redirectToUrl(newUrl
); // #186947
1569 void DolphinView::restoreContentsPosition()
1571 if (!m_restoredContentsPosition
.isNull()) {
1572 const int x
= m_restoredContentsPosition
.x();
1573 const int y
= m_restoredContentsPosition
.y();
1574 m_restoredContentsPosition
= QPoint();
1576 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1577 Q_ASSERT(view
!= 0);
1578 view
->horizontalScrollBar()->setValue(x
);
1579 view
->verticalScrollBar()->setValue(y
);
1583 #include "dolphinview.moc"