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
&)));
111 connect(m_controller
, SIGNAL(requestUrlChange(const KUrl
&)),
112 this, SLOT(slotRequestUrlChange(const KUrl
&)));
114 connect(m_controller
, SIGNAL(requestContextMenu(const QPoint
&, const QList
<QAction
*>&)),
115 this, SLOT(openContextMenu(const QPoint
&, const QList
<QAction
*>&)));
116 connect(m_controller
, SIGNAL(urlsDropped(const KFileItem
&, const KUrl
&, QDropEvent
*)),
117 this, SLOT(dropUrls(const KFileItem
&, const KUrl
&, QDropEvent
*)));
118 connect(m_controller
, SIGNAL(sortingChanged(DolphinView::Sorting
)),
119 this, SLOT(updateSorting(DolphinView::Sorting
)));
120 connect(m_controller
, SIGNAL(sortOrderChanged(Qt::SortOrder
)),
121 this, SLOT(updateSortOrder(Qt::SortOrder
)));
122 connect(m_controller
, SIGNAL(sortFoldersFirstChanged(bool)),
123 this, SLOT(updateSortFoldersFirst(bool)));
124 connect(m_controller
, SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList
&)),
125 this, SLOT(updateAdditionalInfo(const KFileItemDelegate::InformationList
&)));
126 connect(m_controller
, SIGNAL(itemTriggered(const KFileItem
&)),
127 this, SLOT(triggerItem(const KFileItem
&)));
128 connect(m_controller
, SIGNAL(tabRequested(const KUrl
&)),
129 this, SIGNAL(tabRequested(const KUrl
&)));
130 connect(m_controller
, SIGNAL(activated()),
131 this, SLOT(activate()));
132 connect(m_controller
, SIGNAL(itemEntered(const KFileItem
&)),
133 this, SLOT(showHoverInformation(const KFileItem
&)));
134 connect(m_controller
, SIGNAL(viewportEntered()),
135 this, SLOT(clearHoverInformation()));
137 KDirLister
* dirLister
= m_viewAccessor
.dirLister();
138 connect(dirLister
, SIGNAL(redirection(KUrl
,KUrl
)),
139 this, SLOT(slotRedirection(KUrl
,KUrl
)));
140 connect(dirLister
, SIGNAL(completed()),
141 this, SLOT(slotDirListerCompleted()));
142 connect(dirLister
, SIGNAL(refreshItems(const QList
<QPair
<KFileItem
,KFileItem
>>&)),
143 this, SLOT(slotRefreshItems()));
145 // When a new item has been created by the "Create New..." menu, the item should
146 // get selected and it must be assured that the item will get visible. As the
147 // creation is done asynchronously, several signals must be checked:
148 connect(&DolphinNewMenuObserver::instance(), SIGNAL(itemCreated(const KUrl
&)),
149 this, SLOT(observeCreatedItem(const KUrl
&)));
151 m_selectionChangedTimer
= new QTimer(this);
152 m_selectionChangedTimer
->setSingleShot(true);
153 m_selectionChangedTimer
->setInterval(300);
154 connect(m_selectionChangedTimer
, SIGNAL(timeout()),
155 this, SLOT(emitSelectionChangedSignal()));
157 applyViewProperties();
158 m_topLayout
->addWidget(m_viewAccessor
.layoutTarget());
161 DolphinView::~DolphinView()
165 const KUrl
& DolphinView::url() const
167 return m_controller
->url();
170 KUrl
DolphinView::rootUrl() const
172 const KUrl viewUrl
= url();
173 const KUrl root
= m_viewAccessor
.rootUrl();
174 if (root
.isEmpty() || !root
.isParentOf(viewUrl
)) {
180 void DolphinView::setActive(bool active
)
182 if (active
== m_active
) {
188 QColor color
= KColorScheme(QPalette::Active
, KColorScheme::View
).background().color();
190 emitSelectionChangedSignal();
195 QWidget
* viewport
= m_viewAccessor
.itemView()->viewport();
197 palette
.setColor(viewport
->backgroundRole(), color
);
198 viewport
->setPalette(palette
);
203 m_viewAccessor
.itemView()->setFocus();
207 m_controller
->indicateActivationChange(active
);
210 bool DolphinView::isActive() const
215 void DolphinView::setMode(Mode mode
)
217 if (mode
== m_mode
) {
218 return; // the wished mode is already set
221 const int oldZoomLevel
= m_controller
->zoomLevel();
224 // remember the currently selected items, so that they will
225 // be restored after reloading the directory
226 m_selectedItems
= selectedItems();
230 const KUrl viewPropsUrl
= rootUrl();
231 ViewProperties
props(viewPropsUrl
);
232 props
.setViewMode(m_mode
);
235 // the file item delegate has been recreated, apply the current
236 // additional information manually
237 const KFileItemDelegate::InformationList infoList
= props
.additionalInfo();
238 m_viewAccessor
.itemDelegate()->setShowInformation(infoList
);
239 emit
additionalInfoChanged();
241 // Not all view modes support categorized sorting. Adjust the sorting model
242 // if changing the view mode results in a change of the categorized sorting
244 m_storedCategorizedSorting
= props
.categorizedSorting();
245 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
246 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
247 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
248 emit
categorizedSortingChanged();
253 updateZoomLevel(oldZoomLevel
);
254 loadDirectory(viewPropsUrl
);
257 DolphinView::Mode
DolphinView::mode() const
262 bool DolphinView::showPreview() const
264 return m_showPreview
;
267 bool DolphinView::showHiddenFiles() const
269 return m_viewAccessor
.dirLister()->showingDotFiles();
272 bool DolphinView::categorizedSorting() const
274 // If all view modes would support categorized sorting, returning
275 // m_viewAccessor.proxyModel()->isCategorizedModel() would be the way to go. As
276 // currently only the icons view supports caterized sorting, we remember
277 // the stored view properties state in m_storedCategorizedSorting and
278 // return this state. The application takes care to disable the corresponding
279 // checkbox by checking DolphinView::supportsCategorizedSorting() to indicate
280 // that this setting is not applied to the current view mode.
281 return m_storedCategorizedSorting
;
284 bool DolphinView::supportsCategorizedSorting() const
286 return m_viewAccessor
.supportsCategorizedSorting();
289 bool DolphinView::hasSelection() const
291 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
292 return (view
!= 0) && view
->selectionModel()->hasSelection();
295 void DolphinView::markUrlsAsSelected(const QList
<KUrl
>& urls
)
297 foreach (const KUrl
& url
, urls
) {
298 KFileItem
item(KFileItem::Unknown
, KFileItem::Unknown
, url
);
299 m_selectedItems
.append(item
);
303 KFileItemList
DolphinView::selectedItems() const
305 KFileItemList itemList
;
306 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
311 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
313 const QModelIndexList indexList
= selection
.indexes();
314 foreach (const QModelIndex
&index
, indexList
) {
315 KFileItem item
= m_viewAccessor
.dirModel()->itemForIndex(index
);
316 if (!item
.isNull()) {
317 itemList
.append(item
);
324 KUrl::List
DolphinView::selectedUrls() const
327 const KFileItemList list
= selectedItems();
328 foreach (const KFileItem
&item
, list
) {
329 urls
.append(item
.url());
334 int DolphinView::selectedItemsCount() const
336 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
341 return view
->selectionModel()->selectedIndexes().count();
344 QItemSelectionModel
* DolphinView::selectionModel() const
346 return m_viewAccessor
.itemView()->selectionModel();
349 void DolphinView::setZoomLevel(int level
)
351 if (level
< ZoomLevelInfo::minimumLevel()) {
352 level
= ZoomLevelInfo::minimumLevel();
353 } else if (level
> ZoomLevelInfo::maximumLevel()) {
354 level
= ZoomLevelInfo::maximumLevel();
357 if (level
!= zoomLevel()) {
358 m_controller
->setZoomLevel(level
);
359 emit
zoomLevelChanged(level
);
363 int DolphinView::zoomLevel() const
365 return m_controller
->zoomLevel();
368 void DolphinView::setSorting(Sorting sorting
)
370 if (sorting
!= this->sorting()) {
371 updateSorting(sorting
);
375 DolphinView::Sorting
DolphinView::sorting() const
377 return m_viewAccessor
.proxyModel()->sorting();
380 void DolphinView::setSortOrder(Qt::SortOrder order
)
382 if (sortOrder() != order
) {
383 updateSortOrder(order
);
387 Qt::SortOrder
DolphinView::sortOrder() const
389 return m_viewAccessor
.proxyModel()->sortOrder();
392 void DolphinView::setSortFoldersFirst(bool foldersFirst
)
394 if (sortFoldersFirst() != foldersFirst
) {
395 updateSortFoldersFirst(foldersFirst
);
399 bool DolphinView::sortFoldersFirst() const
401 return m_viewAccessor
.proxyModel()->sortFoldersFirst();
404 void DolphinView::setAdditionalInfo(KFileItemDelegate::InformationList info
)
406 const KUrl viewPropsUrl
= rootUrl();
407 ViewProperties
props(viewPropsUrl
);
408 props
.setAdditionalInfo(info
);
409 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
411 emit
additionalInfoChanged();
413 if (m_viewAccessor
.reloadOnAdditionalInfoChange()) {
414 loadDirectory(viewPropsUrl
);
418 KFileItemDelegate::InformationList
DolphinView::additionalInfo() const
420 return m_viewAccessor
.itemDelegate()->showInformation();
423 void DolphinView::reload()
425 QByteArray viewState
;
426 QDataStream
saveStream(&viewState
, QIODevice::WriteOnly
);
427 saveState(saveStream
);
428 m_selectedItems
= selectedItems();
431 loadDirectory(url(), true);
433 QDataStream
restoreStream(viewState
);
434 restoreState(restoreStream
);
437 void DolphinView::refresh()
439 m_ignoreViewProperties
= false;
441 const bool oldActivationState
= m_active
;
442 const int oldZoomLevel
= m_controller
->zoomLevel();
446 applyViewProperties();
449 setActive(oldActivationState
);
450 updateZoomLevel(oldZoomLevel
);
453 void DolphinView::setNameFilter(const QString
& nameFilter
)
455 m_controller
->setNameFilter(nameFilter
);
458 void DolphinView::calculateItemCount(int& fileCount
,
460 KIO::filesize_t
& totalFileSize
) const
462 foreach (const KFileItem
& item
, m_viewAccessor
.dirLister()->items()) {
467 totalFileSize
+= item
.size();
472 QString
DolphinView::statusBarText() const
477 KIO::filesize_t totalFileSize
= 0;
479 if (hasSelection()) {
480 // give a summary of the status of the selected files
481 const KFileItemList list
= selectedItems();
482 if (list
.isEmpty()) {
483 // when an item is triggered, it is temporary selected but selectedItems()
484 // will return an empty list
488 KFileItemList::const_iterator it
= list
.begin();
489 const KFileItemList::const_iterator end
= list
.end();
491 const KFileItem
& item
= *it
;
496 totalFileSize
+= item
.size();
501 if (folderCount
+ fileCount
== 1) {
502 // if only one item is selected, show the filename
503 const QString name
= list
.first().text();
504 text
= (folderCount
== 1) ? i18nc("@info:status", "<filename>%1</filename> selected", name
) :
505 i18nc("@info:status", "<filename>%1</filename> selected (%2)",
506 name
, KIO::convertSize(totalFileSize
));
508 // at least 2 items are selected
509 const QString foldersText
= i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount
);
510 const QString filesText
= i18ncp("@info:status", "1 File selected", "%1 Files selected", fileCount
);
511 if ((folderCount
> 0) && (fileCount
> 0)) {
512 text
= i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
513 foldersText
, filesText
, KIO::convertSize(totalFileSize
));
514 } else if (fileCount
> 0) {
515 text
= i18nc("@info:status files (size)", "%1 (%2)", filesText
, KIO::convertSize(totalFileSize
));
517 Q_ASSERT(folderCount
> 0);
522 calculateItemCount(fileCount
, folderCount
, totalFileSize
);
523 text
= KIO::itemsSummaryString(fileCount
+ folderCount
,
524 fileCount
, folderCount
,
525 totalFileSize
, true);
531 QList
<QAction
*> DolphinView::versionControlActions(const KFileItemList
& items
) const
533 return m_controller
->versionControlActions(items
);
536 void DolphinView::setUrl(const KUrl
& url
)
538 if (m_controller
->url() == url
) {
542 m_newFileNames
.clear();
544 m_controller
->setUrl(url
); // emits urlChanged, which we forward
545 m_viewAccessor
.prepareUrlChange(url
);
546 applyViewProperties();
549 // When changing the URL there is no need to keep the version
550 // data of the previous URL.
551 m_viewAccessor
.dirModel()->clearVersionData();
553 emit
startedPathLoading(url
);
556 void DolphinView::selectAll()
558 m_viewAccessor
.itemView()->selectAll();
561 void DolphinView::invertSelection()
563 QItemSelectionModel
* selectionModel
= m_viewAccessor
.itemView()->selectionModel();
564 const QAbstractItemModel
* itemModel
= selectionModel
->model();
566 const QModelIndex topLeft
= itemModel
->index(0, 0);
567 const QModelIndex bottomRight
= itemModel
->index(itemModel
->rowCount() - 1,
568 itemModel
->columnCount() - 1);
570 const QItemSelection
selection(topLeft
, bottomRight
);
571 selectionModel
->select(selection
, QItemSelectionModel::Toggle
);
574 void DolphinView::clearSelection()
576 m_viewAccessor
.itemView()->clearSelection();
579 void DolphinView::renameSelectedItems()
581 KFileItemList items
= selectedItems();
582 const int itemCount
= items
.count();
588 // More than one item has been selected for renaming. Open
589 // a rename dialog and rename all items afterwards.
590 QPointer
<RenameDialog
> dialog
= new RenameDialog(this, items
);
591 if (dialog
->exec() == QDialog::Rejected
) {
596 const QString newName
= dialog
->newName();
597 if (newName
.isEmpty()) {
598 emit
errorMessage(dialog
->errorString());
604 // the selection would be invalid after renaming the items, so just clear
608 // TODO: check how this can be integrated into KIO::FileUndoManager/KonqOperations
609 // as one operation instead of n rename operations like it is done now...
610 Q_ASSERT(newName
.contains('#'));
612 // currently the items are sorted by the selection order, resort
613 // them by the file name
614 qSort(items
.begin(), items
.end(), lessThan
);
616 // iterate through all selected items and rename them...
618 foreach (const KFileItem
& item
, items
) {
619 const KUrl
& oldUrl
= item
.url();
621 number
.setNum(index
++);
623 QString name
= newName
;
624 name
.replace('#', number
);
626 if (oldUrl
.fileName() != name
) {
627 KUrl newUrl
= oldUrl
;
628 newUrl
.setFileName(name
);
629 KonqOperations::rename(this, oldUrl
, newUrl
);
632 } else if (DolphinSettings::instance().generalSettings()->renameInline()) {
633 Q_ASSERT(itemCount
== 1);
634 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForItem(items
.first());
635 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
636 m_viewAccessor
.itemView()->edit(proxyIndex
);
638 Q_ASSERT(itemCount
== 1);
640 QPointer
<RenameDialog
> dialog
= new RenameDialog(this, items
);
641 if (dialog
->exec() == QDialog::Rejected
) {
646 const QString newName
= dialog
->newName();
647 if (newName
.isEmpty()) {
648 emit
errorMessage(dialog
->errorString());
654 const KUrl
& oldUrl
= items
.first().url();
655 KUrl newUrl
= oldUrl
;
656 newUrl
.setFileName(newName
);
657 KonqOperations::rename(this, oldUrl
, newUrl
);
660 // assure that the current index remains visible when KDirLister
661 // will notify the view about changed items
662 m_assureVisibleCurrentIndex
= true;
665 void DolphinView::trashSelectedItems()
667 const KUrl::List list
= simplifiedSelectedUrls();
668 KonqOperations::del(this, KonqOperations::TRASH
, list
);
671 void DolphinView::deleteSelectedItems()
673 const KUrl::List list
= simplifiedSelectedUrls();
674 const bool del
= KonqOperations::askDeleteConfirmation(list
,
676 KonqOperations::DEFAULT_CONFIRMATION
,
680 KIO::Job
* job
= KIO::del(list
);
681 connect(job
, SIGNAL(result(KJob
*)),
682 this, SLOT(slotDeleteFileFinished(KJob
*)));
686 void DolphinView::cutSelectedItems()
688 QMimeData
* mimeData
= selectionMimeData();
689 KonqMimeData::addIsCutSelection(mimeData
, true);
690 QApplication::clipboard()->setMimeData(mimeData
);
693 void DolphinView::copySelectedItems()
695 QMimeData
* mimeData
= selectionMimeData();
696 QApplication::clipboard()->setMimeData(mimeData
);
699 void DolphinView::paste()
704 void DolphinView::pasteIntoFolder()
706 const KFileItemList items
= selectedItems();
707 if ((items
.count() == 1) && items
.first().isDir()) {
708 pasteToUrl(items
.first().url());
712 void DolphinView::setShowPreview(bool show
)
714 if (m_showPreview
== show
) {
718 const KUrl viewPropsUrl
= rootUrl();
719 ViewProperties
props(viewPropsUrl
);
720 props
.setShowPreview(show
);
722 m_showPreview
= show
;
723 const int oldZoomLevel
= m_controller
->zoomLevel();
724 emit
showPreviewChanged();
726 // Enabling or disabling the preview might change the icon size of the view.
727 // As the view does not emit a signal when the icon size has been changed,
728 // the used zoom level of the controller must be adjusted manually:
729 updateZoomLevel(oldZoomLevel
);
732 void DolphinView::setShowHiddenFiles(bool show
)
734 if (m_viewAccessor
.dirLister()->showingDotFiles() == show
) {
738 const KUrl viewPropsUrl
= rootUrl();
739 ViewProperties
props(viewPropsUrl
);
740 props
.setShowHiddenFiles(show
);
742 m_viewAccessor
.dirLister()->setShowingDotFiles(show
);
743 emit
showHiddenFilesChanged();
746 void DolphinView::setCategorizedSorting(bool categorized
)
748 if (categorized
== categorizedSorting()) {
752 // setCategorizedSorting(true) may only get invoked
753 // if the view supports categorized sorting
754 Q_ASSERT(!categorized
|| supportsCategorizedSorting());
756 ViewProperties
props(rootUrl());
757 props
.setCategorizedSorting(categorized
);
760 m_storedCategorizedSorting
= categorized
;
761 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
763 emit
categorizedSortingChanged();
766 void DolphinView::toggleSortOrder()
768 const Qt::SortOrder order
= (sortOrder() == Qt::AscendingOrder
) ?
769 Qt::DescendingOrder
:
774 void DolphinView::toggleSortFoldersFirst()
776 setSortFoldersFirst(!sortFoldersFirst());
779 void DolphinView::toggleAdditionalInfo(QAction
* action
)
781 const KFileItemDelegate::Information info
=
782 static_cast<KFileItemDelegate::Information
>(action
->data().toInt());
784 KFileItemDelegate::InformationList list
= additionalInfo();
786 const bool show
= action
->isChecked();
788 const int index
= list
.indexOf(info
);
789 const bool containsInfo
= (index
>= 0);
790 if (show
&& !containsInfo
) {
792 setAdditionalInfo(list
);
793 } else if (!show
&& containsInfo
) {
794 list
.removeAt(index
);
795 setAdditionalInfo(list
);
796 Q_ASSERT(list
.indexOf(info
) < 0);
800 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
802 QWidget::mouseReleaseEvent(event
);
806 bool DolphinView::eventFilter(QObject
* watched
, QEvent
* event
)
808 switch (event
->type()) {
809 case QEvent::FocusIn
:
810 if (watched
== m_viewAccessor
.itemView()) {
811 m_controller
->requestActivation();
815 case QEvent::DragEnter
:
816 if (watched
== m_viewAccessor
.itemView()->viewport()) {
821 case QEvent::KeyPress
:
822 if (watched
== m_viewAccessor
.itemView()) {
823 // clear the selection when Escape has been pressed
824 QKeyEvent
* keyEvent
= static_cast<QKeyEvent
*>(event
);
825 if (keyEvent
->key() == Qt::Key_Escape
) {
832 if (watched
== m_viewAccessor
.itemView()->viewport()) {
833 // Ctrl+wheel events should cause icon zooming, but not if the left mouse button is pressed
834 // (the user is probably trying to scroll during a selection in that case)
835 QWheelEvent
* wheelEvent
= static_cast<QWheelEvent
*>(event
);
836 if (wheelEvent
->modifiers() & Qt::ControlModifier
&& !(wheelEvent
->buttons() & Qt::LeftButton
)) {
837 const int delta
= wheelEvent
->delta();
838 const int level
= zoomLevel();
840 setZoomLevel(level
+ 1);
841 } else if (delta
< 0) {
842 setZoomLevel(level
- 1);
853 return QWidget::eventFilter(watched
, event
);
856 void DolphinView::activate()
861 void DolphinView::triggerItem(const KFileItem
& item
)
863 const Qt::KeyboardModifiers modifier
= QApplication::keyboardModifiers();
864 if ((modifier
& Qt::ShiftModifier
) || (modifier
& Qt::ControlModifier
)) {
865 // items are selected by the user, hence don't trigger the
866 // item specified by 'index'
870 // TODO: the m_isContextMenuOpen check is a workaround for Qt-issue 207192
871 if (item
.isNull() || m_isContextMenuOpen
) {
875 emit
itemTriggered(item
); // caught by DolphinViewContainer or DolphinPart
878 void DolphinView::slotSelectionChanged(const QItemSelection
& selected
, const QItemSelection
& deselected
)
880 const int count
= selectedItemsCount();
881 const bool selectionStateChanged
= ((count
> 0) && (selected
.count() == count
)) ||
882 ((count
== 0) && !deselected
.isEmpty());
884 // If nothing has been selected before and something got selected (or if something
885 // was selected before and now nothing is selected) the selectionChangedSignal must
886 // be emitted asynchronously as fast as possible to update the edit-actions.
887 m_selectionChangedTimer
->setInterval(selectionStateChanged
? 0 : 300);
888 m_selectionChangedTimer
->start();
891 void DolphinView::emitSelectionChangedSignal()
893 emit
selectionChanged(DolphinView::selectedItems());
896 void DolphinView::openContextMenu(const QPoint
& pos
,
897 const QList
<QAction
*>& customActions
)
900 const QModelIndex index
= m_viewAccessor
.itemView()->indexAt(pos
);
901 if (index
.isValid() && (index
.column() == DolphinModel::Name
)) {
902 const QModelIndex dolphinModelIndex
= m_viewAccessor
.proxyModel()->mapToSource(index
);
903 item
= m_viewAccessor
.dirModel()->itemForIndex(dolphinModelIndex
);
906 m_isContextMenuOpen
= true; // TODO: workaround for Qt-issue 207192
907 emit
requestContextMenu(item
, url(), customActions
);
908 m_isContextMenuOpen
= false;
911 void DolphinView::dropUrls(const KFileItem
& destItem
,
912 const KUrl
& destPath
,
915 addNewFileNames(event
->mimeData());
916 DragAndDropHelper::instance().dropUrls(destItem
, destPath
, event
, this);
919 void DolphinView::updateSorting(DolphinView::Sorting sorting
)
921 ViewProperties
props(rootUrl());
922 props
.setSorting(sorting
);
924 m_viewAccessor
.proxyModel()->setSorting(sorting
);
926 emit
sortingChanged(sorting
);
929 void DolphinView::updateSortOrder(Qt::SortOrder order
)
931 ViewProperties
props(rootUrl());
932 props
.setSortOrder(order
);
934 m_viewAccessor
.proxyModel()->setSortOrder(order
);
936 emit
sortOrderChanged(order
);
939 void DolphinView::updateSortFoldersFirst(bool foldersFirst
)
941 ViewProperties
props(rootUrl());
942 props
.setSortFoldersFirst(foldersFirst
);
944 m_viewAccessor
.proxyModel()->setSortFoldersFirst(foldersFirst
);
946 emit
sortFoldersFirstChanged(foldersFirst
);
949 void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList
& info
)
951 ViewProperties
props(rootUrl());
952 props
.setAdditionalInfo(info
);
955 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
957 emit
additionalInfoChanged();
960 void DolphinView::updateAdditionalInfoActions(KActionCollection
* collection
)
962 const bool enable
= (m_mode
== DolphinView::DetailsView
) ||
963 (m_mode
== DolphinView::IconsView
);
965 QAction
* showSizeInfo
= collection
->action("show_size_info");
966 QAction
* showDateInfo
= collection
->action("show_date_info");
967 QAction
* showPermissionsInfo
= collection
->action("show_permissions_info");
968 QAction
* showOwnerInfo
= collection
->action("show_owner_info");
969 QAction
* showGroupInfo
= collection
->action("show_group_info");
970 QAction
* showMimeInfo
= collection
->action("show_mime_info");
972 showSizeInfo
->setChecked(false);
973 showDateInfo
->setChecked(false);
974 showPermissionsInfo
->setChecked(false);
975 showOwnerInfo
->setChecked(false);
976 showGroupInfo
->setChecked(false);
977 showMimeInfo
->setChecked(false);
979 showSizeInfo
->setEnabled(enable
);
980 showDateInfo
->setEnabled(enable
);
981 showPermissionsInfo
->setEnabled(enable
);
982 showOwnerInfo
->setEnabled(enable
);
983 showGroupInfo
->setEnabled(enable
);
984 showMimeInfo
->setEnabled(enable
);
986 foreach (KFileItemDelegate::Information info
, m_viewAccessor
.itemDelegate()->showInformation()) {
988 case KFileItemDelegate::Size
:
989 showSizeInfo
->setChecked(true);
991 case KFileItemDelegate::ModificationTime
:
992 showDateInfo
->setChecked(true);
994 case KFileItemDelegate::Permissions
:
995 showPermissionsInfo
->setChecked(true);
997 case KFileItemDelegate::Owner
:
998 showOwnerInfo
->setChecked(true);
1000 case KFileItemDelegate::OwnerAndGroup
:
1001 showGroupInfo
->setChecked(true);
1003 case KFileItemDelegate::FriendlyMimeType
:
1004 showMimeInfo
->setChecked(true);
1012 QPair
<bool, QString
> DolphinView::pasteInfo() const
1014 return KonqOperations::pasteInfo(url());
1017 void DolphinView::setTabsForFilesEnabled(bool tabsForFiles
)
1019 m_tabsForFiles
= tabsForFiles
;
1022 bool DolphinView::isTabsForFilesEnabled() const
1024 return m_tabsForFiles
;
1027 bool DolphinView::itemsExpandable() const
1029 return m_viewAccessor
.itemsExpandable();
1032 void DolphinView::restoreState(QDataStream
& stream
)
1035 stream
>> m_activeItemUrl
;
1038 stream
>> m_restoredContentsPosition
;
1040 // expanded folders (only relevant for the details view - will be ignored by the view in other view modes)
1041 QSet
<KUrl
> urlsToExpand
;
1042 stream
>> urlsToExpand
;
1043 const DolphinDetailsViewExpander
* expander
= m_viewAccessor
.setExpandedUrls(urlsToExpand
);
1044 if (expander
!= 0) {
1045 m_expanderActive
= true;
1046 connect (expander
, SIGNAL(completed()), this, SLOT(slotLoadingCompleted()));
1049 m_expanderActive
= false;
1053 void DolphinView::saveState(QDataStream
& stream
)
1056 KFileItem currentItem
;
1057 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
1060 const QModelIndex proxyIndex
= view
->currentIndex();
1061 const QModelIndex dirModelIndex
= m_viewAccessor
.proxyModel()->mapToSource(proxyIndex
);
1062 currentItem
= m_viewAccessor
.dirModel()->itemForIndex(dirModelIndex
);
1066 if (!currentItem
.isNull()) {
1067 currentUrl
= currentItem
.url();
1070 stream
<< currentUrl
;
1073 const int x
= view
->horizontalScrollBar()->value();
1074 const int y
= view
->verticalScrollBar()->value();
1075 stream
<< QPoint(x
, y
);
1077 // expanded folders (only relevant for the details view - the set will be empty in other view modes)
1078 stream
<< m_viewAccessor
.expandedUrls();
1081 void DolphinView::observeCreatedItem(const KUrl
& url
)
1083 m_createdItemUrl
= url
;
1084 connect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
1085 this, SLOT(selectAndScrollToCreatedItem()));
1088 void DolphinView::selectAndScrollToCreatedItem()
1090 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_createdItemUrl
);
1091 if (dirIndex
.isValid()) {
1092 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
1093 m_viewAccessor
.itemView()->setCurrentIndex(proxyIndex
);
1096 disconnect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
1097 this, SLOT(selectAndScrollToCreatedItem()));
1098 m_createdItemUrl
= KUrl();
1101 void DolphinView::showHoverInformation(const KFileItem
& item
)
1103 emit
requestItemInfo(item
);
1106 void DolphinView::clearHoverInformation()
1108 emit
requestItemInfo(KFileItem());
1111 void DolphinView::slotDeleteFileFinished(KJob
* job
)
1113 if (job
->error() == 0) {
1114 emit
operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
1115 } else if (job
->error() != KIO::ERR_USER_CANCELED
) {
1116 emit
errorMessage(job
->errorString());
1120 void DolphinView::slotRequestUrlChange(const KUrl
& url
)
1122 emit
requestUrlChange(url
);
1123 m_controller
->setUrl(url
);
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 m_expanderActive
= false;
1214 KDirLister
* dirLister
= m_viewAccessor
.dirLister();
1215 dirLister
->openUrl(url
, reload
? KDirLister::Reload
: KDirLister::NoFlags
);
1217 KDirLister
* rootDirLister
= m_viewAccessor
.rootDirLister();
1218 if (dirLister
!= rootDirLister
) {
1219 // In the case of the column view the root directory lister can be different. Assure
1220 // that it gets synchronized (clients from DolphinView are not aware that internally
1221 // different directory listers are used).
1222 rootDirLister
->openUrl(url
, reload
? KDirLister::Reload
: KDirLister::NoFlags
);
1226 void DolphinView::applyViewProperties()
1228 if (m_ignoreViewProperties
) {
1232 const ViewProperties
props(rootUrl());
1234 const Mode mode
= props
.viewMode();
1235 if (m_mode
!= mode
) {
1236 const int oldZoomLevel
= m_controller
->zoomLevel();
1242 updateZoomLevel(oldZoomLevel
);
1244 if (m_viewAccessor
.itemView() == 0) {
1247 Q_ASSERT(m_viewAccessor
.itemView() != 0);
1248 Q_ASSERT(m_viewAccessor
.itemDelegate() != 0);
1250 const bool showHiddenFiles
= props
.showHiddenFiles();
1251 if (showHiddenFiles
!= m_viewAccessor
.dirLister()->showingDotFiles()) {
1252 m_viewAccessor
.dirLister()->setShowingDotFiles(showHiddenFiles
);
1253 emit
showHiddenFilesChanged();
1256 m_storedCategorizedSorting
= props
.categorizedSorting();
1257 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
1258 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
1259 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
1260 emit
categorizedSortingChanged();
1263 const DolphinView::Sorting sorting
= props
.sorting();
1264 if (sorting
!= m_viewAccessor
.proxyModel()->sorting()) {
1265 m_viewAccessor
.proxyModel()->setSorting(sorting
);
1266 emit
sortingChanged(sorting
);
1269 const Qt::SortOrder sortOrder
= props
.sortOrder();
1270 if (sortOrder
!= m_viewAccessor
.proxyModel()->sortOrder()) {
1271 m_viewAccessor
.proxyModel()->setSortOrder(sortOrder
);
1272 emit
sortOrderChanged(sortOrder
);
1275 const bool sortFoldersFirst
= props
.sortFoldersFirst();
1276 if (sortFoldersFirst
!= m_viewAccessor
.proxyModel()->sortFoldersFirst()) {
1277 m_viewAccessor
.proxyModel()->setSortFoldersFirst(sortFoldersFirst
);
1278 emit
sortFoldersFirstChanged(sortFoldersFirst
);
1281 KFileItemDelegate::InformationList info
= props
.additionalInfo();
1282 if (info
!= m_viewAccessor
.itemDelegate()->showInformation()) {
1283 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
1284 emit
additionalInfoChanged();
1287 const bool showPreview
= props
.showPreview();
1288 if (showPreview
!= m_showPreview
) {
1289 m_showPreview
= showPreview
;
1290 const int oldZoomLevel
= m_controller
->zoomLevel();
1291 emit
showPreviewChanged();
1293 // Enabling or disabling the preview might change the icon size of the view.
1294 // As the view does not emit a signal when the icon size has been changed,
1295 // the used zoom level of the controller must be adjusted manually:
1296 updateZoomLevel(oldZoomLevel
);
1299 if (DolphinSettings::instance().generalSettings()->globalViewProps()) {
1300 // During the lifetime of a DolphinView instance the global view properties
1301 // should not be changed. This allows e. g. to split a view and use different
1302 // view properties for each view.
1303 m_ignoreViewProperties
= true;
1307 void DolphinView::createView()
1311 Q_ASSERT(m_viewAccessor
.itemView() == 0);
1312 m_viewAccessor
.createView(this, m_controller
, m_mode
);
1314 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1315 Q_ASSERT(view
!= 0);
1316 view
->installEventFilter(this);
1317 view
->viewport()->installEventFilter(this);
1319 m_controller
->setItemView(view
);
1321 // When changing the view mode, the selection is lost due to reinstantiating
1322 // a new item view with a custom selection model. Pass the ownership of the
1323 // selection model to DolphinView, so that it can be shared by all item views.
1324 if (m_selectionModel
!= 0) {
1325 view
->setSelectionModel(m_selectionModel
);
1327 m_selectionModel
= view
->selectionModel();
1329 m_selectionModel
->setParent(this);
1330 connect(view
->selectionModel(), SIGNAL(selectionChanged(const QItemSelection
&, const QItemSelection
&)),
1331 this, SLOT(slotSelectionChanged(const QItemSelection
&, const QItemSelection
&)));
1333 setFocusProxy(m_viewAccessor
.layoutTarget());
1334 m_topLayout
->insertWidget(1, m_viewAccessor
.layoutTarget());
1337 void DolphinView::deleteView()
1339 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1341 // It's important to set the keyboard focus to the parent
1342 // before deleting the view: Otherwise when having a split
1343 // view the other view will get the focus and will request
1344 // an activation (see DolphinView::eventFilter()).
1348 m_topLayout
->removeWidget(view
);
1351 // disconnect all signal/slots
1353 m_controller
->disconnect(view
);
1356 m_viewAccessor
.deleteView();
1360 void DolphinView::pasteToUrl(const KUrl
& url
)
1362 addNewFileNames(QApplication::clipboard()->mimeData());
1363 KonqOperations::doPaste(this, url
);
1366 void DolphinView::updateZoomLevel(int oldZoomLevel
)
1368 const int newZoomLevel
= ZoomLevelInfo::zoomLevelForIconSize(m_viewAccessor
.itemView()->iconSize());
1369 if (oldZoomLevel
!= newZoomLevel
) {
1370 m_controller
->setZoomLevel(newZoomLevel
);
1371 emit
zoomLevelChanged(newZoomLevel
);
1375 KUrl::List
DolphinView::simplifiedSelectedUrls() const
1377 KUrl::List list
= selectedUrls();
1378 if (itemsExpandable() ) {
1379 list
= KDirModel::simplifiedUrlList(list
);
1384 QMimeData
* DolphinView::selectionMimeData() const
1386 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
1387 Q_ASSERT((view
!= 0) && (view
->selectionModel() != 0));
1388 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
1389 return m_viewAccessor
.dirModel()->mimeData(selection
.indexes());
1392 void DolphinView::addNewFileNames(const QMimeData
* mimeData
)
1394 const KUrl::List urls
= KUrl::List::fromMimeData(mimeData
);
1395 foreach (const KUrl
& url
, urls
) {
1396 m_newFileNames
.insert(url
.fileName());
1400 DolphinView::ViewAccessor::ViewAccessor(DolphinSortFilterProxyModel
* proxyModel
) :
1403 m_columnsContainer(0),
1404 m_proxyModel(proxyModel
),
1409 DolphinView::ViewAccessor::~ViewAccessor()
1411 delete m_dragSource
;
1415 void DolphinView::ViewAccessor::createView(QWidget
* parent
,
1416 DolphinController
* controller
,
1419 Q_ASSERT(itemView() == 0);
1423 m_iconsView
= new DolphinIconsView(parent
, controller
, m_proxyModel
);
1427 m_detailsView
= new DolphinDetailsView(parent
, controller
, m_proxyModel
);
1431 m_columnsContainer
= new DolphinColumnViewContainer(parent
, controller
);
1439 void DolphinView::ViewAccessor::deleteView()
1441 QAbstractItemView
* view
= itemView();
1443 if (DragAndDropHelper::instance().isDragSource(view
)) {
1444 // The view is a drag source (the feature "Open folders
1445 // during drag operations" is used). Deleting the view
1446 // during an ongoing drag operation is not allowed, so
1447 // this will postponed.
1448 if (m_dragSource
!= 0) {
1449 // the old stored view is obviously not the drag source anymore
1450 m_dragSource
->deleteLater();
1454 m_dragSource
= view
;
1456 view
->deleteLater();
1463 if (m_columnsContainer
!= 0) {
1464 m_columnsContainer
->deleteLater();
1466 m_columnsContainer
= 0;
1470 void DolphinView::ViewAccessor::prepareUrlChange(const KUrl
& url
)
1472 if (m_columnsContainer
!= 0) {
1473 m_columnsContainer
->showColumn(url
);
1477 QAbstractItemView
* DolphinView::ViewAccessor::itemView() const
1479 if (m_iconsView
!= 0) {
1483 if (m_detailsView
!= 0) {
1484 return m_detailsView
;
1487 if (m_columnsContainer
!= 0) {
1488 return m_columnsContainer
->activeColumn();
1494 KFileItemDelegate
* DolphinView::ViewAccessor::itemDelegate() const
1496 return static_cast<KFileItemDelegate
*>(itemView()->itemDelegate());
1499 QWidget
* DolphinView::ViewAccessor::layoutTarget() const
1501 if (m_columnsContainer
!= 0) {
1502 return m_columnsContainer
;
1507 KUrl
DolphinView::ViewAccessor::rootUrl() const
1509 return (m_columnsContainer
!= 0) ? m_columnsContainer
->rootUrl() : KUrl();
1512 KDirLister
* DolphinView::ViewAccessor::rootDirLister() const
1514 return static_cast<DolphinModel
*>(m_proxyModel
->sourceModel())->dirLister();
1517 bool DolphinView::ViewAccessor::supportsCategorizedSorting() const
1519 return m_iconsView
!= 0;
1522 bool DolphinView::ViewAccessor::itemsExpandable() const
1524 return (m_detailsView
!= 0) && m_detailsView
->itemsExpandable();
1528 QSet
<KUrl
> DolphinView::ViewAccessor::expandedUrls() const
1530 if (m_detailsView
!= 0) {
1531 return m_detailsView
->expandedUrls();
1534 return QSet
<KUrl
>();
1537 const DolphinDetailsViewExpander
* DolphinView::ViewAccessor::setExpandedUrls(const QSet
<KUrl
>& urlsToExpand
)
1539 if ((m_detailsView
!= 0) && m_detailsView
->itemsExpandable() && !urlsToExpand
.isEmpty()) {
1540 // Check if another expander is already active and stop it if necessary.
1541 if(!m_detailsViewExpander
.isNull()) {
1542 m_detailsViewExpander
->stop();
1545 m_detailsViewExpander
= new DolphinDetailsViewExpander(m_detailsView
, urlsToExpand
);
1546 return m_detailsViewExpander
;
1553 bool DolphinView::ViewAccessor::reloadOnAdditionalInfoChange() const
1555 // the details view requires no reloading of the directory, as it maps
1556 // the file item delegate info to its columns internally
1557 return m_detailsView
!= 0;
1560 DolphinModel
* DolphinView::ViewAccessor::dirModel() const
1562 return static_cast<DolphinModel
*>(proxyModel()->sourceModel());
1565 DolphinSortFilterProxyModel
* DolphinView::ViewAccessor::proxyModel() const
1567 if (m_columnsContainer
!= 0) {
1568 return static_cast<DolphinSortFilterProxyModel
*>(m_columnsContainer
->activeColumn()->model());
1570 return m_proxyModel
;
1573 KDirLister
* DolphinView::ViewAccessor::dirLister() const
1575 return dirModel()->dirLister();
1578 void DolphinView::slotRedirection(const KUrl
& oldUrl
, const KUrl
& newUrl
)
1580 emit
redirection(oldUrl
, newUrl
);
1581 m_controller
->redirectToUrl(newUrl
); // #186947
1584 void DolphinView::restoreContentsPosition()
1586 if (!m_restoredContentsPosition
.isNull()) {
1587 const int x
= m_restoredContentsPosition
.x();
1588 const int y
= m_restoredContentsPosition
.y();
1589 m_restoredContentsPosition
= QPoint();
1591 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1592 Q_ASSERT(view
!= 0);
1593 view
->horizontalScrollBar()->setValue(x
);
1594 view
->verticalScrollBar()->setValue(y
);
1598 #include "dolphinview.moc"