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 "dolphinnewmenuobserver.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_ignoreViewProperties(false),
90 m_assureVisibleCurrentIndex(false),
91 m_mode(DolphinView::IconsView
),
93 m_dolphinViewController(0),
94 m_viewModeController(0),
95 m_viewAccessor(proxyModel
),
96 m_selectionChangedTimer(0),
99 m_restoredContentsPosition(),
104 m_topLayout
= new QVBoxLayout(this);
105 m_topLayout
->setSpacing(0);
106 m_topLayout
->setMargin(0);
108 m_dolphinViewController
= new DolphinViewController(this);
110 m_viewModeController
= new ViewModeController(this);
111 m_viewModeController
->setUrl(url
);
113 connect(m_viewModeController
, SIGNAL(urlChanged(const KUrl
&)),
114 this, SIGNAL(urlChanged(const KUrl
&)));
116 connect(m_dolphinViewController
, SIGNAL(requestContextMenu(const QPoint
&, const QList
<QAction
*>&)),
117 this, SLOT(openContextMenu(const QPoint
&, const QList
<QAction
*>&)));
118 connect(m_dolphinViewController
, SIGNAL(urlsDropped(const KFileItem
&, const KUrl
&, QDropEvent
*)),
119 this, SLOT(dropUrls(const KFileItem
&, const KUrl
&, QDropEvent
*)));
120 connect(m_dolphinViewController
, SIGNAL(sortingChanged(DolphinView::Sorting
)),
121 this, SLOT(updateSorting(DolphinView::Sorting
)));
122 connect(m_dolphinViewController
, SIGNAL(sortOrderChanged(Qt::SortOrder
)),
123 this, SLOT(updateSortOrder(Qt::SortOrder
)));
124 connect(m_dolphinViewController
, SIGNAL(sortFoldersFirstChanged(bool)),
125 this, SLOT(updateSortFoldersFirst(bool)));
126 connect(m_dolphinViewController
, SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList
&)),
127 this, SLOT(updateAdditionalInfo(const KFileItemDelegate::InformationList
&)));
128 connect(m_dolphinViewController
, SIGNAL(itemTriggered(const KFileItem
&)),
129 this, SLOT(triggerItem(const KFileItem
&)));
130 connect(m_dolphinViewController
, SIGNAL(tabRequested(const KUrl
&)),
131 this, SIGNAL(tabRequested(const KUrl
&)));
132 connect(m_dolphinViewController
, SIGNAL(activated()),
133 this, SLOT(activate()));
134 connect(m_dolphinViewController
, SIGNAL(itemEntered(const KFileItem
&)),
135 this, SLOT(showHoverInformation(const KFileItem
&)));
136 connect(m_dolphinViewController
, SIGNAL(viewportEntered()),
137 this, SLOT(clearHoverInformation()));
138 connect(m_dolphinViewController
, SIGNAL(urlChangeRequested(KUrl
)),
139 m_viewModeController
, SLOT(setUrl(KUrl
)));
141 KDirLister
* dirLister
= m_viewAccessor
.dirLister();
142 connect(dirLister
, SIGNAL(redirection(KUrl
,KUrl
)),
143 this, SLOT(slotRedirection(KUrl
,KUrl
)));
144 connect(dirLister
, SIGNAL(completed()),
145 this, SLOT(slotDirListerCompleted()));
146 connect(dirLister
, SIGNAL(refreshItems(const QList
<QPair
<KFileItem
,KFileItem
>>&)),
147 this, SLOT(slotRefreshItems()));
149 // When a new item has been created by the "Create New..." menu, the item should
150 // get selected and it must be assured that the item will get visible. As the
151 // creation is done asynchronously, several signals must be checked:
152 connect(&DolphinNewMenuObserver::instance(), SIGNAL(itemCreated(const KUrl
&)),
153 this, SLOT(observeCreatedItem(const KUrl
&)));
155 m_selectionChangedTimer
= new QTimer(this);
156 m_selectionChangedTimer
->setSingleShot(true);
157 m_selectionChangedTimer
->setInterval(300);
158 connect(m_selectionChangedTimer
, SIGNAL(timeout()),
159 this, SLOT(emitSelectionChangedSignal()));
161 applyViewProperties();
162 m_topLayout
->addWidget(m_viewAccessor
.layoutTarget());
165 DolphinView::~DolphinView()
169 KUrl
DolphinView::url() const
171 return m_viewModeController
->url();
174 KUrl
DolphinView::rootUrl() const
176 const KUrl viewUrl
= url();
177 const KUrl root
= m_viewAccessor
.rootUrl();
178 if (root
.isEmpty() || !root
.isParentOf(viewUrl
)) {
184 void DolphinView::setActive(bool active
)
186 if (active
== m_active
) {
192 QColor color
= KColorScheme(QPalette::Active
, KColorScheme::View
).background().color();
194 emitSelectionChangedSignal();
199 QWidget
* viewport
= m_viewAccessor
.itemView()->viewport();
201 palette
.setColor(viewport
->backgroundRole(), color
);
202 viewport
->setPalette(palette
);
207 m_viewAccessor
.itemView()->setFocus();
211 m_viewModeController
->indicateActivationChange(active
);
214 bool DolphinView::isActive() const
219 void DolphinView::setMode(Mode mode
)
221 if (mode
== m_mode
) {
222 return; // the wished mode is already set
225 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
228 // remember the currently selected items, so that they will
229 // be restored after reloading the directory
230 m_selectedItems
= selectedItems();
234 const KUrl viewPropsUrl
= rootUrl();
235 ViewProperties
props(viewPropsUrl
);
236 props
.setViewMode(m_mode
);
239 // the file item delegate has been recreated, apply the current
240 // additional information manually
241 const KFileItemDelegate::InformationList infoList
= props
.additionalInfo();
242 m_viewAccessor
.itemDelegate()->setShowInformation(infoList
);
243 emit
additionalInfoChanged();
245 // Not all view modes support categorized sorting. Adjust the sorting model
246 // if changing the view mode results in a change of the categorized sorting
248 m_storedCategorizedSorting
= props
.categorizedSorting();
249 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
250 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
251 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
252 emit
categorizedSortingChanged();
257 updateZoomLevel(oldZoomLevel
);
258 loadDirectory(viewPropsUrl
);
261 DolphinView::Mode
DolphinView::mode() const
266 bool DolphinView::showPreview() const
268 return m_showPreview
;
271 bool DolphinView::showHiddenFiles() const
273 return m_viewAccessor
.dirLister()->showingDotFiles();
276 bool DolphinView::categorizedSorting() const
278 // If all view modes would support categorized sorting, returning
279 // m_viewAccessor.proxyModel()->isCategorizedModel() would be the way to go. As
280 // currently only the icons view supports caterized sorting, we remember
281 // the stored view properties state in m_storedCategorizedSorting and
282 // return this state. The application takes care to disable the corresponding
283 // checkbox by checking DolphinView::supportsCategorizedSorting() to indicate
284 // that this setting is not applied to the current view mode.
285 return m_storedCategorizedSorting
;
288 bool DolphinView::supportsCategorizedSorting() const
290 return m_viewAccessor
.supportsCategorizedSorting();
293 bool DolphinView::hasSelection() const
295 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
296 return (view
!= 0) && view
->selectionModel()->hasSelection();
299 void DolphinView::markUrlsAsSelected(const QList
<KUrl
>& urls
)
301 foreach (const KUrl
& url
, urls
) {
302 KFileItem
item(KFileItem::Unknown
, KFileItem::Unknown
, url
);
303 m_selectedItems
.append(item
);
307 KFileItemList
DolphinView::selectedItems() const
309 KFileItemList itemList
;
310 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
315 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
317 const QModelIndexList indexList
= selection
.indexes();
318 foreach (const QModelIndex
&index
, indexList
) {
319 KFileItem item
= m_viewAccessor
.dirModel()->itemForIndex(index
);
320 if (!item
.isNull()) {
321 itemList
.append(item
);
328 KUrl::List
DolphinView::selectedUrls() const
331 const KFileItemList list
= selectedItems();
332 foreach (const KFileItem
&item
, list
) {
333 urls
.append(item
.url());
338 int DolphinView::selectedItemsCount() const
340 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
345 return view
->selectionModel()->selectedIndexes().count();
348 QItemSelectionModel
* DolphinView::selectionModel() const
350 return m_viewAccessor
.itemView()->selectionModel();
353 void DolphinView::setZoomLevel(int level
)
355 if (level
< ZoomLevelInfo::minimumLevel()) {
356 level
= ZoomLevelInfo::minimumLevel();
357 } else if (level
> ZoomLevelInfo::maximumLevel()) {
358 level
= ZoomLevelInfo::maximumLevel();
361 if (level
!= zoomLevel()) {
362 m_viewModeController
->setZoomLevel(level
);
363 emit
zoomLevelChanged(level
);
367 int DolphinView::zoomLevel() const
369 return m_viewModeController
->zoomLevel();
372 void DolphinView::setSorting(Sorting sorting
)
374 if (sorting
!= this->sorting()) {
375 updateSorting(sorting
);
379 DolphinView::Sorting
DolphinView::sorting() const
381 return m_viewAccessor
.proxyModel()->sorting();
384 void DolphinView::setSortOrder(Qt::SortOrder order
)
386 if (sortOrder() != order
) {
387 updateSortOrder(order
);
391 Qt::SortOrder
DolphinView::sortOrder() const
393 return m_viewAccessor
.proxyModel()->sortOrder();
396 void DolphinView::setSortFoldersFirst(bool foldersFirst
)
398 if (sortFoldersFirst() != foldersFirst
) {
399 updateSortFoldersFirst(foldersFirst
);
403 bool DolphinView::sortFoldersFirst() const
405 return m_viewAccessor
.proxyModel()->sortFoldersFirst();
408 void DolphinView::setAdditionalInfo(KFileItemDelegate::InformationList info
)
410 const KUrl viewPropsUrl
= rootUrl();
411 ViewProperties
props(viewPropsUrl
);
412 props
.setAdditionalInfo(info
);
413 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
415 emit
additionalInfoChanged();
417 if (m_viewAccessor
.reloadOnAdditionalInfoChange()) {
418 loadDirectory(viewPropsUrl
);
422 KFileItemDelegate::InformationList
DolphinView::additionalInfo() const
424 return m_viewAccessor
.itemDelegate()->showInformation();
427 void DolphinView::reload()
429 QByteArray viewState
;
430 QDataStream
saveStream(&viewState
, QIODevice::WriteOnly
);
431 saveState(saveStream
);
432 m_selectedItems
= selectedItems();
435 loadDirectory(url(), true);
437 QDataStream
restoreStream(viewState
);
438 restoreState(restoreStream
);
441 void DolphinView::refresh()
443 m_ignoreViewProperties
= false;
445 const bool oldActivationState
= m_active
;
446 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
450 applyViewProperties();
453 setActive(oldActivationState
);
454 updateZoomLevel(oldZoomLevel
);
457 void DolphinView::setNameFilter(const QString
& nameFilter
)
459 m_viewModeController
->setNameFilter(nameFilter
);
462 void DolphinView::calculateItemCount(int& fileCount
,
464 KIO::filesize_t
& totalFileSize
) const
466 foreach (const KFileItem
& item
, m_viewAccessor
.dirLister()->items()) {
471 totalFileSize
+= item
.size();
476 QString
DolphinView::statusBarText() const
481 KIO::filesize_t totalFileSize
= 0;
483 if (hasSelection()) {
484 // give a summary of the status of the selected files
485 const KFileItemList list
= selectedItems();
486 if (list
.isEmpty()) {
487 // when an item is triggered, it is temporary selected but selectedItems()
488 // will return an empty list
492 KFileItemList::const_iterator it
= list
.begin();
493 const KFileItemList::const_iterator end
= list
.end();
495 const KFileItem
& item
= *it
;
500 totalFileSize
+= item
.size();
505 if (folderCount
+ fileCount
== 1) {
506 // if only one item is selected, show the filename
507 const QString name
= list
.first().text();
508 text
= (folderCount
== 1) ? i18nc("@info:status", "<filename>%1</filename> selected", name
) :
509 i18nc("@info:status", "<filename>%1</filename> selected (%2)",
510 name
, KIO::convertSize(totalFileSize
));
512 // at least 2 items are selected
513 const QString foldersText
= i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount
);
514 const QString filesText
= i18ncp("@info:status", "1 File selected", "%1 Files selected", fileCount
);
515 if ((folderCount
> 0) && (fileCount
> 0)) {
516 text
= i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
517 foldersText
, filesText
, KIO::convertSize(totalFileSize
));
518 } else if (fileCount
> 0) {
519 text
= i18nc("@info:status files (size)", "%1 (%2)", filesText
, KIO::convertSize(totalFileSize
));
521 Q_ASSERT(folderCount
> 0);
526 calculateItemCount(fileCount
, folderCount
, totalFileSize
);
527 text
= KIO::itemsSummaryString(fileCount
+ folderCount
,
528 fileCount
, folderCount
,
529 totalFileSize
, true);
535 QList
<QAction
*> DolphinView::versionControlActions(const KFileItemList
& items
) const
537 return m_dolphinViewController
->versionControlActions(items
);
540 void DolphinView::setUrl(const KUrl
& url
)
542 if (m_viewModeController
->url() == url
) {
546 // The selection model might change in the case of the column view. Disconnect
547 // from the current selection model and reconnect later after the URL switch.
548 QAbstractItemView
* view
= m_viewAccessor
.itemView();
549 disconnect(view
->selectionModel(), SIGNAL(selectionChanged(QItemSelection
, QItemSelection
)),
550 this, SLOT(slotSelectionChanged(QItemSelection
, QItemSelection
)));
552 m_newFileNames
.clear();
554 m_viewModeController
->setUrl(url
); // emits urlChanged, which we forward
555 m_viewAccessor
.prepareUrlChange(url
);
556 applyViewProperties();
559 // When changing the URL there is no need to keep the version
560 // data of the previous URL.
561 m_viewAccessor
.dirModel()->clearVersionData();
563 emit
startedPathLoading(url
);
565 // Reconnect to the (probably) new selection model
566 view
= m_viewAccessor
.itemView();
567 connect(view
->selectionModel(), SIGNAL(selectionChanged(QItemSelection
, QItemSelection
)),
568 this, SLOT(slotSelectionChanged(QItemSelection
, QItemSelection
)));
571 void DolphinView::selectAll()
573 m_viewAccessor
.itemView()->selectAll();
576 void DolphinView::invertSelection()
578 QItemSelectionModel
* selectionModel
= m_viewAccessor
.itemView()->selectionModel();
579 const QAbstractItemModel
* itemModel
= selectionModel
->model();
581 const QModelIndex topLeft
= itemModel
->index(0, 0);
582 const QModelIndex bottomRight
= itemModel
->index(itemModel
->rowCount() - 1,
583 itemModel
->columnCount() - 1);
585 const QItemSelection
selection(topLeft
, bottomRight
);
586 selectionModel
->select(selection
, QItemSelectionModel::Toggle
);
589 void DolphinView::clearSelection()
591 m_viewAccessor
.itemView()->clearSelection();
594 void DolphinView::renameSelectedItems()
596 KFileItemList items
= selectedItems();
597 const int itemCount
= items
.count();
603 // More than one item has been selected for renaming. Open
604 // a rename dialog and rename all items afterwards.
605 QPointer
<RenameDialog
> dialog
= new RenameDialog(this, items
);
606 if (dialog
->exec() == QDialog::Rejected
) {
611 const QString newName
= dialog
->newName();
612 if (newName
.isEmpty()) {
613 emit
errorMessage(dialog
->errorString());
619 // the selection would be invalid after renaming the items, so just clear
623 // TODO: check how this can be integrated into KIO::FileUndoManager/KonqOperations
624 // as one operation instead of n rename operations like it is done now...
625 Q_ASSERT(newName
.contains('#'));
627 // currently the items are sorted by the selection order, resort
628 // them by the file name
629 qSort(items
.begin(), items
.end(), lessThan
);
631 // iterate through all selected items and rename them...
633 foreach (const KFileItem
& item
, items
) {
634 const KUrl
& oldUrl
= item
.url();
636 number
.setNum(index
++);
638 QString name
= newName
;
639 name
.replace('#', number
);
641 if (oldUrl
.fileName() != name
) {
642 KUrl newUrl
= oldUrl
;
643 newUrl
.setFileName(name
);
644 KonqOperations::rename(this, oldUrl
, newUrl
);
647 } else if (DolphinSettings::instance().generalSettings()->renameInline()) {
648 Q_ASSERT(itemCount
== 1);
649 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForItem(items
.first());
650 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
651 m_viewAccessor
.itemView()->edit(proxyIndex
);
653 Q_ASSERT(itemCount
== 1);
655 QPointer
<RenameDialog
> dialog
= new RenameDialog(this, items
);
656 if (dialog
->exec() == QDialog::Rejected
) {
661 const QString newName
= dialog
->newName();
662 if (newName
.isEmpty()) {
663 emit
errorMessage(dialog
->errorString());
669 const KUrl
& oldUrl
= items
.first().url();
670 KUrl newUrl
= oldUrl
;
671 newUrl
.setFileName(newName
);
672 KonqOperations::rename(this, oldUrl
, newUrl
);
675 // assure that the current index remains visible when KDirLister
676 // will notify the view about changed items
677 m_assureVisibleCurrentIndex
= true;
680 void DolphinView::trashSelectedItems()
682 const KUrl::List list
= simplifiedSelectedUrls();
683 KonqOperations::del(this, KonqOperations::TRASH
, list
);
686 void DolphinView::deleteSelectedItems()
688 const KUrl::List list
= simplifiedSelectedUrls();
689 const bool del
= KonqOperations::askDeleteConfirmation(list
,
691 KonqOperations::DEFAULT_CONFIRMATION
,
695 KIO::Job
* job
= KIO::del(list
);
696 connect(job
, SIGNAL(result(KJob
*)),
697 this, SLOT(slotDeleteFileFinished(KJob
*)));
701 void DolphinView::cutSelectedItems()
703 QMimeData
* mimeData
= selectionMimeData();
704 KonqMimeData::addIsCutSelection(mimeData
, true);
705 QApplication::clipboard()->setMimeData(mimeData
);
708 void DolphinView::copySelectedItems()
710 QMimeData
* mimeData
= selectionMimeData();
711 QApplication::clipboard()->setMimeData(mimeData
);
714 void DolphinView::paste()
719 void DolphinView::pasteIntoFolder()
721 const KFileItemList items
= selectedItems();
722 if ((items
.count() == 1) && items
.first().isDir()) {
723 pasteToUrl(items
.first().url());
727 void DolphinView::setShowPreview(bool show
)
729 if (m_showPreview
== show
) {
733 const KUrl viewPropsUrl
= rootUrl();
734 ViewProperties
props(viewPropsUrl
);
735 props
.setShowPreview(show
);
737 m_showPreview
= show
;
738 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
739 emit
showPreviewChanged();
741 // Enabling or disabling the preview might change the icon size of the view.
742 // As the view does not emit a signal when the icon size has been changed,
743 // the used zoom level of the controller must be adjusted manually:
744 updateZoomLevel(oldZoomLevel
);
747 void DolphinView::setShowHiddenFiles(bool show
)
749 if (m_viewAccessor
.dirLister()->showingDotFiles() == show
) {
753 const KUrl viewPropsUrl
= rootUrl();
754 ViewProperties
props(viewPropsUrl
);
755 props
.setShowHiddenFiles(show
);
757 m_viewAccessor
.dirLister()->setShowingDotFiles(show
);
758 emit
showHiddenFilesChanged();
761 void DolphinView::setCategorizedSorting(bool categorized
)
763 if (categorized
== categorizedSorting()) {
767 // setCategorizedSorting(true) may only get invoked
768 // if the view supports categorized sorting
769 Q_ASSERT(!categorized
|| supportsCategorizedSorting());
771 ViewProperties
props(rootUrl());
772 props
.setCategorizedSorting(categorized
);
775 m_storedCategorizedSorting
= categorized
;
776 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
778 emit
categorizedSortingChanged();
781 void DolphinView::toggleSortOrder()
783 const Qt::SortOrder order
= (sortOrder() == Qt::AscendingOrder
) ?
784 Qt::DescendingOrder
:
789 void DolphinView::toggleSortFoldersFirst()
791 setSortFoldersFirst(!sortFoldersFirst());
794 void DolphinView::toggleAdditionalInfo(QAction
* action
)
796 const KFileItemDelegate::Information info
=
797 static_cast<KFileItemDelegate::Information
>(action
->data().toInt());
799 KFileItemDelegate::InformationList list
= additionalInfo();
801 const bool show
= action
->isChecked();
803 const int index
= list
.indexOf(info
);
804 const bool containsInfo
= (index
>= 0);
805 if (show
&& !containsInfo
) {
807 setAdditionalInfo(list
);
808 } else if (!show
&& containsInfo
) {
809 list
.removeAt(index
);
810 setAdditionalInfo(list
);
811 Q_ASSERT(list
.indexOf(info
) < 0);
815 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
817 QWidget::mouseReleaseEvent(event
);
821 bool DolphinView::eventFilter(QObject
* watched
, QEvent
* event
)
823 switch (event
->type()) {
824 case QEvent::FocusIn
:
825 if (watched
== m_viewAccessor
.itemView()) {
826 m_dolphinViewController
->requestActivation();
830 case QEvent::DragEnter
:
831 if (watched
== m_viewAccessor
.itemView()->viewport()) {
836 case QEvent::KeyPress
:
837 if (watched
== m_viewAccessor
.itemView()) {
838 // clear the selection when Escape has been pressed
839 QKeyEvent
* keyEvent
= static_cast<QKeyEvent
*>(event
);
840 if (keyEvent
->key() == Qt::Key_Escape
) {
847 if (watched
== m_viewAccessor
.itemView()->viewport()) {
848 // Ctrl+wheel events should cause icon zooming, but not if the left mouse button is pressed
849 // (the user is probably trying to scroll during a selection in that case)
850 QWheelEvent
* wheelEvent
= static_cast<QWheelEvent
*>(event
);
851 if (wheelEvent
->modifiers() & Qt::ControlModifier
&& !(wheelEvent
->buttons() & Qt::LeftButton
)) {
852 const int delta
= wheelEvent
->delta();
853 const int level
= zoomLevel();
855 setZoomLevel(level
+ 1);
856 } else if (delta
< 0) {
857 setZoomLevel(level
- 1);
868 return QWidget::eventFilter(watched
, event
);
871 void DolphinView::activate()
876 void DolphinView::triggerItem(const KFileItem
& item
)
878 const Qt::KeyboardModifiers modifier
= QApplication::keyboardModifiers();
879 if ((modifier
& Qt::ShiftModifier
) || (modifier
& Qt::ControlModifier
)) {
880 // items are selected by the user, hence don't trigger the
881 // item specified by 'index'
885 // TODO: the m_isContextMenuOpen check is a workaround for Qt-issue 207192
886 if (item
.isNull() || m_isContextMenuOpen
) {
890 emit
itemTriggered(item
); // caught by DolphinViewContainer or DolphinPart
893 void DolphinView::slotSelectionChanged(const QItemSelection
& selected
, const QItemSelection
& deselected
)
895 const int count
= selectedItemsCount();
896 const bool selectionStateChanged
= ((count
> 0) && (selected
.count() == count
)) ||
897 ((count
== 0) && !deselected
.isEmpty());
899 // If nothing has been selected before and something got selected (or if something
900 // was selected before and now nothing is selected) the selectionChangedSignal must
901 // be emitted asynchronously as fast as possible to update the edit-actions.
902 m_selectionChangedTimer
->setInterval(selectionStateChanged
? 0 : 300);
903 m_selectionChangedTimer
->start();
906 void DolphinView::emitSelectionChangedSignal()
908 emit
selectionChanged(DolphinView::selectedItems());
911 void DolphinView::openContextMenu(const QPoint
& pos
,
912 const QList
<QAction
*>& customActions
)
915 const QModelIndex index
= m_viewAccessor
.itemView()->indexAt(pos
);
916 if (index
.isValid() && (index
.column() == DolphinModel::Name
)) {
917 const QModelIndex dolphinModelIndex
= m_viewAccessor
.proxyModel()->mapToSource(index
);
918 item
= m_viewAccessor
.dirModel()->itemForIndex(dolphinModelIndex
);
921 m_isContextMenuOpen
= true; // TODO: workaround for Qt-issue 207192
922 emit
requestContextMenu(item
, url(), customActions
);
923 m_isContextMenuOpen
= false;
926 void DolphinView::dropUrls(const KFileItem
& destItem
,
927 const KUrl
& destPath
,
930 addNewFileNames(event
->mimeData());
931 DragAndDropHelper::instance().dropUrls(destItem
, destPath
, event
, this);
934 void DolphinView::updateSorting(DolphinView::Sorting sorting
)
936 ViewProperties
props(rootUrl());
937 props
.setSorting(sorting
);
939 m_viewAccessor
.proxyModel()->setSorting(sorting
);
941 emit
sortingChanged(sorting
);
944 void DolphinView::updateSortOrder(Qt::SortOrder order
)
946 ViewProperties
props(rootUrl());
947 props
.setSortOrder(order
);
949 m_viewAccessor
.proxyModel()->setSortOrder(order
);
951 emit
sortOrderChanged(order
);
954 void DolphinView::updateSortFoldersFirst(bool foldersFirst
)
956 ViewProperties
props(rootUrl());
957 props
.setSortFoldersFirst(foldersFirst
);
959 m_viewAccessor
.proxyModel()->setSortFoldersFirst(foldersFirst
);
961 emit
sortFoldersFirstChanged(foldersFirst
);
964 void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList
& info
)
966 ViewProperties
props(rootUrl());
967 props
.setAdditionalInfo(info
);
970 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
972 emit
additionalInfoChanged();
975 void DolphinView::updateAdditionalInfoActions(KActionCollection
* collection
)
977 const AdditionalInfoAccessor
& infoAccessor
= AdditionalInfoAccessor::instance();
979 const KFileItemDelegate::InformationList checkedInfo
= m_viewAccessor
.itemDelegate()->showInformation();
980 const KFileItemDelegate::InformationList infoKeys
= infoAccessor
.keys();
982 const bool enable
= (m_mode
== DolphinView::DetailsView
) ||
983 (m_mode
== DolphinView::IconsView
);
985 foreach (const KFileItemDelegate::Information
& info
, infoKeys
) {
986 const QString name
= infoAccessor
.actionCollectionName(info
, AdditionalInfoAccessor::AdditionalInfoType
);
987 QAction
* action
= collection
->action(name
);
988 Q_ASSERT(action
!= 0);
989 action
->setEnabled(enable
);
990 action
->setChecked(checkedInfo
.contains(info
));
994 QPair
<bool, QString
> DolphinView::pasteInfo() const
996 return KonqOperations::pasteInfo(url());
999 void DolphinView::setTabsForFilesEnabled(bool tabsForFiles
)
1001 m_tabsForFiles
= tabsForFiles
;
1004 bool DolphinView::isTabsForFilesEnabled() const
1006 return m_tabsForFiles
;
1009 bool DolphinView::itemsExpandable() const
1011 return m_viewAccessor
.itemsExpandable();
1014 void DolphinView::restoreState(QDataStream
& stream
)
1017 stream
>> m_activeItemUrl
;
1020 stream
>> m_restoredContentsPosition
;
1022 // expanded folders (only relevant for the details view - will be ignored by the view in other view modes)
1023 QSet
<KUrl
> urlsToExpand
;
1024 stream
>> urlsToExpand
;
1025 const DolphinDetailsViewExpander
* expander
= m_viewAccessor
.setExpandedUrls(urlsToExpand
);
1026 if (expander
!= 0) {
1027 m_expanderActive
= true;
1028 connect (expander
, SIGNAL(completed()), this, SLOT(slotLoadingCompleted()));
1031 m_expanderActive
= false;
1035 void DolphinView::saveState(QDataStream
& stream
)
1038 KFileItem currentItem
;
1039 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
1042 const QModelIndex proxyIndex
= view
->currentIndex();
1043 const QModelIndex dirModelIndex
= m_viewAccessor
.proxyModel()->mapToSource(proxyIndex
);
1044 currentItem
= m_viewAccessor
.dirModel()->itemForIndex(dirModelIndex
);
1048 if (!currentItem
.isNull()) {
1049 currentUrl
= currentItem
.url();
1052 stream
<< currentUrl
;
1055 const int x
= view
->horizontalScrollBar()->value();
1056 const int y
= view
->verticalScrollBar()->value();
1057 stream
<< QPoint(x
, y
);
1059 // expanded folders (only relevant for the details view - the set will be empty in other view modes)
1060 stream
<< m_viewAccessor
.expandedUrls();
1063 void DolphinView::observeCreatedItem(const KUrl
& url
)
1065 m_createdItemUrl
= url
;
1066 connect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
1067 this, SLOT(selectAndScrollToCreatedItem()));
1070 void DolphinView::selectAndScrollToCreatedItem()
1072 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_createdItemUrl
);
1073 if (dirIndex
.isValid()) {
1074 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
1075 m_viewAccessor
.itemView()->setCurrentIndex(proxyIndex
);
1078 disconnect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
1079 this, SLOT(selectAndScrollToCreatedItem()));
1080 m_createdItemUrl
= KUrl();
1083 void DolphinView::showHoverInformation(const KFileItem
& item
)
1085 emit
requestItemInfo(item
);
1088 void DolphinView::clearHoverInformation()
1090 emit
requestItemInfo(KFileItem());
1093 void DolphinView::slotDeleteFileFinished(KJob
* job
)
1095 if (job
->error() == 0) {
1096 emit
operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
1097 } else if (job
->error() != KIO::ERR_USER_CANCELED
) {
1098 emit
errorMessage(job
->errorString());
1102 void DolphinView::slotDirListerCompleted()
1104 if (!m_expanderActive
) {
1105 slotLoadingCompleted();
1108 if (!m_newFileNames
.isEmpty()) {
1109 // select all newly added items created by a paste operation or
1110 // a drag & drop operation, and clear the previous selection
1111 m_viewAccessor
.itemView()->clearSelection();
1112 const int rowCount
= m_viewAccessor
.proxyModel()->rowCount();
1113 QItemSelection selection
;
1114 for (int row
= 0; row
< rowCount
; ++row
) {
1115 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->index(row
, 0);
1116 const QModelIndex dirIndex
= m_viewAccessor
.proxyModel()->mapToSource(proxyIndex
);
1117 const KUrl url
= m_viewAccessor
.dirModel()->itemForIndex(dirIndex
).url();
1118 if (m_newFileNames
.contains(url
.fileName())) {
1119 selection
.merge(QItemSelection(proxyIndex
, proxyIndex
), QItemSelectionModel::Select
);
1122 m_viewAccessor
.itemView()->selectionModel()->select(selection
, QItemSelectionModel::Select
);
1124 m_newFileNames
.clear();
1128 void DolphinView::slotLoadingCompleted()
1130 m_expanderActive
= false;
1132 if (!m_activeItemUrl
.isEmpty()) {
1133 // assure that the current item remains visible
1134 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_activeItemUrl
);
1135 if (dirIndex
.isValid()) {
1136 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
1137 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1138 const bool clearSelection
= !hasSelection();
1139 view
->setCurrentIndex(proxyIndex
);
1140 if (clearSelection
) {
1141 view
->clearSelection();
1143 m_activeItemUrl
.clear();
1147 if (!m_selectedItems
.isEmpty()) {
1148 const KUrl
& baseUrl
= url();
1150 QItemSelection newSelection
;
1151 foreach(const KFileItem
& item
, m_selectedItems
) {
1152 url
= item
.url().upUrl();
1153 if (baseUrl
.equals(url
, KUrl::CompareWithoutTrailingSlash
)) {
1154 QModelIndex index
= m_viewAccessor
.proxyModel()->mapFromSource(m_viewAccessor
.dirModel()->indexForItem(item
));
1155 newSelection
.select(index
, index
);
1158 m_viewAccessor
.itemView()->selectionModel()->select(newSelection
,
1159 QItemSelectionModel::ClearAndSelect
1160 | QItemSelectionModel::Current
);
1161 m_selectedItems
.clear();
1164 // Restore the contents position. This has to be done using a Qt::QueuedConnection
1165 // because the view might not be in its final state yet.
1166 QMetaObject::invokeMethod(this, "restoreContentsPosition", Qt::QueuedConnection
);
1169 void DolphinView::slotRefreshItems()
1171 if (m_assureVisibleCurrentIndex
) {
1172 m_assureVisibleCurrentIndex
= false;
1173 m_viewAccessor
.itemView()->scrollTo(m_viewAccessor
.itemView()->currentIndex());
1177 void DolphinView::loadDirectory(const KUrl
& url
, bool reload
)
1179 if (!url
.isValid()) {
1180 const QString
location(url
.pathOrUrl());
1181 if (location
.isEmpty()) {
1182 emit
errorMessage(i18nc("@info:status", "The location is empty."));
1184 emit
errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location
));
1189 KDirLister
* dirLister
= m_viewAccessor
.dirLister();
1190 dirLister
->openUrl(url
, reload
? KDirLister::Reload
: KDirLister::NoFlags
);
1193 void DolphinView::applyViewProperties()
1195 if (m_ignoreViewProperties
) {
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
);
1266 if (DolphinSettings::instance().generalSettings()->globalViewProps()) {
1267 // During the lifetime of a DolphinView instance the global view properties
1268 // should not be changed. This allows e. g. to split a view and use different
1269 // view properties for each view.
1270 m_ignoreViewProperties
= true;
1274 void DolphinView::createView()
1276 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1277 if ((view
!= 0) && (view
->selectionModel() != 0)) {
1278 disconnect(view
->selectionModel(), SIGNAL(selectionChanged(QItemSelection
, QItemSelection
)),
1279 this, SLOT(slotSelectionChanged(QItemSelection
, QItemSelection
)));
1284 Q_ASSERT(m_viewAccessor
.itemView() == 0);
1285 m_viewAccessor
.createView(this, m_dolphinViewController
, m_viewModeController
, m_mode
);
1287 view
= m_viewAccessor
.itemView();
1288 Q_ASSERT(view
!= 0);
1289 view
->installEventFilter(this);
1290 view
->viewport()->installEventFilter(this);
1292 m_dolphinViewController
->setItemView(view
);
1294 const int zoomLevel
= ZoomLevelInfo::zoomLevelForIconSize(view
->iconSize());
1295 m_viewModeController
->setZoomLevel(zoomLevel
);
1297 connect(view
->selectionModel(), SIGNAL(selectionChanged(QItemSelection
, QItemSelection
)),
1298 this, SLOT(slotSelectionChanged(QItemSelection
, QItemSelection
)));
1300 setFocusProxy(m_viewAccessor
.layoutTarget());
1301 m_topLayout
->insertWidget(1, m_viewAccessor
.layoutTarget());
1304 void DolphinView::deleteView()
1306 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1308 // It's important to set the keyboard focus to the parent
1309 // before deleting the view: Otherwise when having a split
1310 // view the other view will get the focus and will request
1311 // an activation (see DolphinView::eventFilter()).
1315 m_topLayout
->removeWidget(view
);
1318 // disconnect all signal/slots
1320 m_viewModeController
->disconnect(view
);
1323 m_viewAccessor
.deleteView();
1327 void DolphinView::pasteToUrl(const KUrl
& url
)
1329 addNewFileNames(QApplication::clipboard()->mimeData());
1330 KonqOperations::doPaste(this, url
);
1333 void DolphinView::updateZoomLevel(int oldZoomLevel
)
1335 const int newZoomLevel
= ZoomLevelInfo::zoomLevelForIconSize(m_viewAccessor
.itemView()->iconSize());
1336 if (oldZoomLevel
!= newZoomLevel
) {
1337 m_viewModeController
->setZoomLevel(newZoomLevel
);
1338 emit
zoomLevelChanged(newZoomLevel
);
1342 KUrl::List
DolphinView::simplifiedSelectedUrls() const
1344 KUrl::List list
= selectedUrls();
1345 if (itemsExpandable() ) {
1346 list
= KDirModel::simplifiedUrlList(list
);
1351 QMimeData
* DolphinView::selectionMimeData() const
1353 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
1354 Q_ASSERT((view
!= 0) && (view
->selectionModel() != 0));
1355 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
1356 return m_viewAccessor
.dirModel()->mimeData(selection
.indexes());
1359 void DolphinView::addNewFileNames(const QMimeData
* mimeData
)
1361 const KUrl::List urls
= KUrl::List::fromMimeData(mimeData
);
1362 foreach (const KUrl
& url
, urls
) {
1363 m_newFileNames
.insert(url
.fileName());
1367 DolphinView::ViewAccessor::ViewAccessor(DolphinSortFilterProxyModel
* proxyModel
) :
1370 m_columnsContainer(0),
1371 m_proxyModel(proxyModel
),
1376 DolphinView::ViewAccessor::~ViewAccessor()
1378 delete m_dragSource
;
1382 void DolphinView::ViewAccessor::createView(QWidget
* parent
,
1383 DolphinViewController
* dolphinViewController
,
1384 const ViewModeController
* viewModeController
,
1387 Q_ASSERT(itemView() == 0);
1391 m_iconsView
= new DolphinIconsView(parent
,
1392 dolphinViewController
,
1398 m_detailsView
= new DolphinDetailsView(parent
,
1399 dolphinViewController
,
1405 m_columnsContainer
= new DolphinColumnViewContainer(parent
,
1406 dolphinViewController
,
1407 viewModeController
);
1415 void DolphinView::ViewAccessor::deleteView()
1417 QAbstractItemView
* view
= itemView();
1419 if (DragAndDropHelper::instance().isDragSource(view
)) {
1420 // The view is a drag source (the feature "Open folders
1421 // during drag operations" is used). Deleting the view
1422 // during an ongoing drag operation is not allowed, so
1423 // this will postponed.
1424 if (m_dragSource
!= 0) {
1425 // the old stored view is obviously not the drag source anymore
1426 m_dragSource
->deleteLater();
1430 m_dragSource
= view
;
1432 view
->deleteLater();
1439 if (m_columnsContainer
!= 0) {
1440 m_columnsContainer
->deleteLater();
1442 m_columnsContainer
= 0;
1446 void DolphinView::ViewAccessor::prepareUrlChange(const KUrl
& url
)
1448 if (m_columnsContainer
!= 0) {
1449 m_columnsContainer
->showColumn(url
);
1453 QAbstractItemView
* DolphinView::ViewAccessor::itemView() const
1455 if (m_iconsView
!= 0) {
1459 if (m_detailsView
!= 0) {
1460 return m_detailsView
;
1463 if (m_columnsContainer
!= 0) {
1464 return m_columnsContainer
->activeColumn();
1470 KFileItemDelegate
* DolphinView::ViewAccessor::itemDelegate() const
1472 return static_cast<KFileItemDelegate
*>(itemView()->itemDelegate());
1475 QWidget
* DolphinView::ViewAccessor::layoutTarget() const
1477 if (m_columnsContainer
!= 0) {
1478 return m_columnsContainer
;
1483 KUrl
DolphinView::ViewAccessor::rootUrl() const
1485 return (m_columnsContainer
!= 0) ? m_columnsContainer
->rootUrl() : KUrl();
1488 bool DolphinView::ViewAccessor::supportsCategorizedSorting() const
1490 return m_iconsView
!= 0;
1493 bool DolphinView::ViewAccessor::itemsExpandable() const
1495 return (m_detailsView
!= 0) && m_detailsView
->itemsExpandable();
1499 QSet
<KUrl
> DolphinView::ViewAccessor::expandedUrls() const
1501 if (m_detailsView
!= 0) {
1502 return m_detailsView
->expandedUrls();
1505 return QSet
<KUrl
>();
1508 const DolphinDetailsViewExpander
* DolphinView::ViewAccessor::setExpandedUrls(const QSet
<KUrl
>& urlsToExpand
)
1510 if ((m_detailsView
!= 0) && m_detailsView
->itemsExpandable() && !urlsToExpand
.isEmpty()) {
1511 // Check if another expander is already active and stop it if necessary.
1512 if(!m_detailsViewExpander
.isNull()) {
1513 m_detailsViewExpander
->stop();
1516 m_detailsViewExpander
= new DolphinDetailsViewExpander(m_detailsView
, urlsToExpand
);
1517 return m_detailsViewExpander
;
1524 bool DolphinView::ViewAccessor::reloadOnAdditionalInfoChange() const
1526 // the details view requires no reloading of the directory, as it maps
1527 // the file item delegate info to its columns internally
1528 return m_detailsView
!= 0;
1531 DolphinModel
* DolphinView::ViewAccessor::dirModel() const
1533 return static_cast<DolphinModel
*>(proxyModel()->sourceModel());
1536 DolphinSortFilterProxyModel
* DolphinView::ViewAccessor::proxyModel() const
1538 if (m_columnsContainer
!= 0) {
1539 return static_cast<DolphinSortFilterProxyModel
*>(m_columnsContainer
->activeColumn()->model());
1541 return m_proxyModel
;
1544 KDirLister
* DolphinView::ViewAccessor::dirLister() const
1546 return dirModel()->dirLister();
1549 void DolphinView::slotRedirection(const KUrl
& oldUrl
, const KUrl
& newUrl
)
1551 if (oldUrl
.equals(url(), KUrl::CompareWithoutTrailingSlash
)) {
1552 emit
redirection(oldUrl
, newUrl
);
1553 m_viewModeController
->redirectToUrl(newUrl
); // #186947
1557 void DolphinView::restoreContentsPosition()
1559 if (!m_restoredContentsPosition
.isNull()) {
1560 const int x
= m_restoredContentsPosition
.x();
1561 const int y
= m_restoredContentsPosition
.y();
1562 m_restoredContentsPosition
= QPoint();
1564 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1565 Q_ASSERT(view
!= 0);
1566 view
->horizontalScrollBar()->setValue(x
);
1567 view
->verticalScrollBar()->setValue(y
);
1571 #include "dolphinview.moc"