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 <konq_fileitemcapabilities.h>
45 #include <konq_operations.h>
46 #include <konqmimedata.h>
47 #include <ktoggleaction.h>
50 #include "additionalinfoaccessor.h"
51 #include "dolphinmodel.h"
52 #include "dolphincolumnviewcontainer.h"
53 #include "dolphinviewcontroller.h"
54 #include "dolphindetailsview.h"
55 #include "dolphinfileitemdelegate.h"
56 #include "dolphinnewfilemenuobserver.h"
57 #include "dolphinsortfilterproxymodel.h"
58 #include "dolphin_detailsmodesettings.h"
59 #include "dolphiniconsview.h"
60 #include "dolphin_generalsettings.h"
61 #include "draganddrophelper.h"
62 #include "renamedialog.h"
63 #include "settings/dolphinsettings.h"
64 #include "viewmodecontroller.h"
65 #include "viewproperties.h"
66 #include "zoomlevelinfo.h"
67 #include "dolphindetailsviewexpander.h"
69 DolphinView::DolphinView(QWidget
* parent
,
71 DolphinSortFilterProxyModel
* proxyModel
) :
75 m_storedCategorizedSorting(false),
76 m_tabsForFiles(false),
77 m_isContextMenuOpen(false),
78 m_assureVisibleCurrentIndex(false),
79 m_mode(DolphinView::IconsView
),
81 m_dolphinViewController(0),
82 m_viewModeController(0),
83 m_viewAccessor(proxyModel
),
84 m_selectionChangedTimer(0),
86 m_restoredContentsPosition(),
91 m_topLayout
= new QVBoxLayout(this);
92 m_topLayout
->setSpacing(0);
93 m_topLayout
->setMargin(0);
95 m_dolphinViewController
= new DolphinViewController(this);
97 m_viewModeController
= new ViewModeController(this);
98 m_viewModeController
->setUrl(url
);
100 connect(m_viewModeController
, SIGNAL(urlChanged(const KUrl
&)),
101 this, SIGNAL(urlChanged(const KUrl
&)));
103 connect(m_dolphinViewController
, SIGNAL(requestContextMenu(const QPoint
&, const QList
<QAction
*>&)),
104 this, SLOT(openContextMenu(const QPoint
&, const QList
<QAction
*>&)));
105 connect(m_dolphinViewController
, SIGNAL(urlsDropped(const KFileItem
&, const KUrl
&, QDropEvent
*)),
106 this, SLOT(dropUrls(const KFileItem
&, const KUrl
&, QDropEvent
*)));
107 connect(m_dolphinViewController
, SIGNAL(sortingChanged(DolphinView::Sorting
)),
108 this, SLOT(updateSorting(DolphinView::Sorting
)));
109 connect(m_dolphinViewController
, SIGNAL(sortOrderChanged(Qt::SortOrder
)),
110 this, SLOT(updateSortOrder(Qt::SortOrder
)));
111 connect(m_dolphinViewController
, SIGNAL(sortFoldersFirstChanged(bool)),
112 this, SLOT(updateSortFoldersFirst(bool)));
113 connect(m_dolphinViewController
, SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList
&)),
114 this, SLOT(updateAdditionalInfo(const KFileItemDelegate::InformationList
&)));
115 connect(m_dolphinViewController
, SIGNAL(itemTriggered(const KFileItem
&)),
116 this, SLOT(triggerItem(const KFileItem
&)));
117 connect(m_dolphinViewController
, SIGNAL(tabRequested(const KUrl
&)),
118 this, SIGNAL(tabRequested(const KUrl
&)));
119 connect(m_dolphinViewController
, SIGNAL(activated()),
120 this, SLOT(activate()));
121 connect(m_dolphinViewController
, SIGNAL(itemEntered(const KFileItem
&)),
122 this, SLOT(showHoverInformation(const KFileItem
&)));
123 connect(m_dolphinViewController
, SIGNAL(viewportEntered()),
124 this, SLOT(clearHoverInformation()));
125 connect(m_dolphinViewController
, SIGNAL(urlChangeRequested(KUrl
)),
126 m_viewModeController
, SLOT(setUrl(KUrl
)));
128 // When a new item has been created by the "Create New..." menu, the item should
129 // get selected and it must be assured that the item will get visible. As the
130 // creation is done asynchronously, several signals must be checked:
131 connect(&DolphinNewFileMenuObserver::instance(), SIGNAL(itemCreated(const KUrl
&)),
132 this, SLOT(observeCreatedItem(const KUrl
&)));
134 m_selectionChangedTimer
= new QTimer(this);
135 m_selectionChangedTimer
->setSingleShot(true);
136 m_selectionChangedTimer
->setInterval(300);
137 connect(m_selectionChangedTimer
, SIGNAL(timeout()),
138 this, SLOT(emitSelectionChangedSignal()));
140 applyViewProperties();
141 m_topLayout
->addWidget(m_viewAccessor
.layoutTarget());
144 DolphinView::~DolphinView()
148 KUrl
DolphinView::url() const
150 return m_viewModeController
->url();
153 KUrl
DolphinView::rootUrl() const
155 const KUrl viewUrl
= url();
156 const KUrl root
= m_viewAccessor
.rootUrl();
157 if (root
.isEmpty() || !root
.isParentOf(viewUrl
)) {
163 void DolphinView::setActive(bool active
)
165 if (active
== m_active
) {
171 QColor color
= KColorScheme(QPalette::Active
, KColorScheme::View
).background().color();
173 emitSelectionChangedSignal();
178 QWidget
* viewport
= m_viewAccessor
.itemView()->viewport();
180 palette
.setColor(viewport
->backgroundRole(), color
);
181 viewport
->setPalette(palette
);
186 m_viewAccessor
.itemView()->setFocus();
190 m_viewModeController
->indicateActivationChange(active
);
193 bool DolphinView::isActive() const
198 void DolphinView::setMode(Mode mode
)
200 if (mode
== m_mode
) {
201 return; // the wished mode is already set
204 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
207 // remember the currently selected items, so that they will
208 // be restored after reloading the directory
209 m_selectedItems
= selectedItems();
213 const KUrl viewPropsUrl
= rootUrl();
214 ViewProperties
props(viewPropsUrl
);
215 props
.setViewMode(m_mode
);
218 // the file item delegate has been recreated, apply the current
219 // additional information manually
220 const KFileItemDelegate::InformationList infoList
= props
.additionalInfo();
221 m_viewAccessor
.itemDelegate()->setShowInformation(infoList
);
222 emit
additionalInfoChanged();
224 // Not all view modes support categorized sorting. Adjust the sorting model
225 // if changing the view mode results in a change of the categorized sorting
227 m_storedCategorizedSorting
= props
.categorizedSorting();
228 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
229 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
230 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
231 emit
categorizedSortingChanged();
236 updateZoomLevel(oldZoomLevel
);
237 loadDirectory(viewPropsUrl
);
240 DolphinView::Mode
DolphinView::mode() const
245 bool DolphinView::showPreview() const
247 return m_showPreview
;
250 bool DolphinView::showHiddenFiles() const
252 return m_viewAccessor
.dirLister()->showingDotFiles();
255 bool DolphinView::categorizedSorting() const
257 // If all view modes would support categorized sorting, returning
258 // m_viewAccessor.proxyModel()->isCategorizedModel() would be the way to go. As
259 // currently only the icons view supports caterized sorting, we remember
260 // the stored view properties state in m_storedCategorizedSorting and
261 // return this state. The application takes care to disable the corresponding
262 // checkbox by checking DolphinView::supportsCategorizedSorting() to indicate
263 // that this setting is not applied to the current view mode.
264 return m_storedCategorizedSorting
;
267 bool DolphinView::supportsCategorizedSorting() const
269 return m_viewAccessor
.supportsCategorizedSorting();
272 KFileItemList
DolphinView::items() const
274 return m_viewAccessor
.dirLister()->items();
277 KFileItemList
DolphinView::selectedItems() const
279 KFileItemList itemList
;
280 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
285 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
287 const QModelIndexList indexList
= selection
.indexes();
288 foreach (const QModelIndex
&index
, indexList
) {
289 KFileItem item
= m_viewAccessor
.dirModel()->itemForIndex(index
);
290 if (!item
.isNull()) {
291 itemList
.append(item
);
298 int DolphinView::selectedItemsCount() const
300 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
305 return view
->selectionModel()->selectedIndexes().count();
308 void DolphinView::markUrlsAsSelected(const QList
<KUrl
>& urls
)
310 foreach (const KUrl
& url
, urls
) {
311 KFileItem
item(KFileItem::Unknown
, KFileItem::Unknown
, url
);
312 m_selectedItems
.append(item
);
316 void DolphinView::setItemSelectionEnabled(const QRegExp
& pattern
, bool enabled
)
318 const QItemSelection matchingIndexes
= childrenMatchingPattern(QModelIndex(), pattern
);
319 const QItemSelectionModel::SelectionFlags command
= enabled
320 ? QItemSelectionModel::Select
321 : QItemSelectionModel::Deselect
;
322 m_viewAccessor
.itemView()->selectionModel()->select(matchingIndexes
, command
);
325 void DolphinView::setZoomLevel(int level
)
327 if (level
< ZoomLevelInfo::minimumLevel()) {
328 level
= ZoomLevelInfo::minimumLevel();
329 } else if (level
> ZoomLevelInfo::maximumLevel()) {
330 level
= ZoomLevelInfo::maximumLevel();
333 if (level
!= zoomLevel()) {
334 m_viewModeController
->setZoomLevel(level
);
335 emit
zoomLevelChanged(level
);
339 int DolphinView::zoomLevel() const
341 return m_viewModeController
->zoomLevel();
344 void DolphinView::setSorting(Sorting sorting
)
346 if (sorting
!= this->sorting()) {
347 updateSorting(sorting
);
351 DolphinView::Sorting
DolphinView::sorting() const
353 return m_viewAccessor
.proxyModel()->sorting();
356 void DolphinView::setSortOrder(Qt::SortOrder order
)
358 if (sortOrder() != order
) {
359 updateSortOrder(order
);
363 Qt::SortOrder
DolphinView::sortOrder() const
365 return m_viewAccessor
.proxyModel()->sortOrder();
368 void DolphinView::setSortFoldersFirst(bool foldersFirst
)
370 if (sortFoldersFirst() != foldersFirst
) {
371 updateSortFoldersFirst(foldersFirst
);
375 bool DolphinView::sortFoldersFirst() const
377 return m_viewAccessor
.proxyModel()->sortFoldersFirst();
380 void DolphinView::setAdditionalInfo(KFileItemDelegate::InformationList info
)
382 const KUrl viewPropsUrl
= rootUrl();
383 ViewProperties
props(viewPropsUrl
);
384 props
.setAdditionalInfo(info
);
385 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
387 emit
additionalInfoChanged();
389 if (m_viewAccessor
.reloadOnAdditionalInfoChange()) {
390 loadDirectory(viewPropsUrl
);
394 KFileItemDelegate::InformationList
DolphinView::additionalInfo() const
396 return m_viewAccessor
.itemDelegate()->showInformation();
399 void DolphinView::reload()
401 QByteArray viewState
;
402 QDataStream
saveStream(&viewState
, QIODevice::WriteOnly
);
403 saveState(saveStream
);
404 m_selectedItems
= selectedItems();
407 loadDirectory(url(), true);
409 QDataStream
restoreStream(viewState
);
410 restoreState(restoreStream
);
413 void DolphinView::stopLoading()
415 m_viewAccessor
.dirLister()->stop();
418 void DolphinView::refresh()
420 const bool oldActivationState
= m_active
;
421 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
425 applyViewProperties();
428 setActive(oldActivationState
);
429 updateZoomLevel(oldZoomLevel
);
432 void DolphinView::setNameFilter(const QString
& nameFilter
)
434 m_viewModeController
->setNameFilter(nameFilter
);
437 void DolphinView::calculateItemCount(int& fileCount
,
439 KIO::filesize_t
& totalFileSize
) const
441 foreach (const KFileItem
& item
, m_viewAccessor
.dirLister()->items()) {
446 totalFileSize
+= item
.size();
451 QString
DolphinView::statusBarText() const
456 KIO::filesize_t totalFileSize
= 0;
458 if (hasSelection()) {
459 // give a summary of the status of the selected files
460 const KFileItemList list
= selectedItems();
461 if (list
.isEmpty()) {
462 // when an item is triggered, it is temporary selected but selectedItems()
463 // will return an empty list
467 KFileItemList::const_iterator it
= list
.begin();
468 const KFileItemList::const_iterator end
= list
.end();
470 const KFileItem
& item
= *it
;
475 totalFileSize
+= item
.size();
480 if (folderCount
+ fileCount
== 1) {
481 // if only one item is selected, show the filename
482 const QString name
= list
.first().text();
483 text
= (folderCount
== 1) ? i18nc("@info:status", "<filename>%1</filename> selected", name
) :
484 i18nc("@info:status", "<filename>%1</filename> selected (%2)",
485 name
, KIO::convertSize(totalFileSize
));
487 // at least 2 items are selected
488 const QString foldersText
= i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount
);
489 const QString filesText
= i18ncp("@info:status", "1 File selected", "%1 Files selected", fileCount
);
490 if ((folderCount
> 0) && (fileCount
> 0)) {
491 text
= i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
492 foldersText
, filesText
, KIO::convertSize(totalFileSize
));
493 } else if (fileCount
> 0) {
494 text
= i18nc("@info:status files (size)", "%1 (%2)", filesText
, KIO::convertSize(totalFileSize
));
496 Q_ASSERT(folderCount
> 0);
501 calculateItemCount(fileCount
, folderCount
, totalFileSize
);
502 text
= KIO::itemsSummaryString(fileCount
+ folderCount
,
503 fileCount
, folderCount
,
504 totalFileSize
, true);
510 QList
<QAction
*> DolphinView::versionControlActions(const KFileItemList
& items
) const
512 return m_dolphinViewController
->versionControlActions(items
);
515 void DolphinView::setUrl(const KUrl
& url
)
517 if (m_viewModeController
->url() == url
) {
521 const bool hadSelection
= hasSelection();
523 // The selection model and directory lister might change in the case of the column view:
524 disconnectViewAccessor();
526 m_newFileNames
.clear();
528 m_viewModeController
->setUrl(url
); // emits urlChanged, which we forward
529 m_viewAccessor
.prepareUrlChange(url
);
530 applyViewProperties();
532 // When changing the URL there is no need to keep the version
533 // data of the previous URL.
534 m_viewAccessor
.dirModel()->clearVersionData();
536 // Reconnect to the (probably) new selection model and directory lister
537 connectViewAccessor();
540 if (hadSelection
|| hasSelection()) {
541 emitSelectionChangedSignal();
545 void DolphinView::selectAll()
547 m_viewAccessor
.itemView()->selectAll();
550 void DolphinView::invertSelection()
552 QItemSelectionModel
* selectionModel
= m_viewAccessor
.itemView()->selectionModel();
553 const QAbstractItemModel
* itemModel
= selectionModel
->model();
555 const QModelIndex topLeft
= itemModel
->index(0, 0);
556 const QModelIndex bottomRight
= itemModel
->index(itemModel
->rowCount() - 1,
557 itemModel
->columnCount() - 1);
559 const QItemSelection
selection(topLeft
, bottomRight
);
560 selectionModel
->select(selection
, QItemSelectionModel::Toggle
);
563 void DolphinView::clearSelection()
565 m_viewAccessor
.itemView()->clearSelection();
568 void DolphinView::renameSelectedItems()
570 KFileItemList items
= selectedItems();
571 const int itemCount
= items
.count();
576 if ((itemCount
== 1) && DolphinSettings::instance().generalSettings()->renameInline()) {
577 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForItem(items
.first());
578 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
579 m_viewAccessor
.itemView()->edit(proxyIndex
);
581 RenameDialog
* dialog
= new RenameDialog(this, items
);
582 dialog
->setAttribute(Qt::WA_DeleteOnClose
);
585 dialog
->activateWindow();
589 void DolphinView::trashSelectedItems()
591 const KUrl::List list
= simplifiedSelectedUrls();
592 KonqOperations::del(this, KonqOperations::TRASH
, list
);
595 void DolphinView::deleteSelectedItems()
597 const KUrl::List list
= simplifiedSelectedUrls();
598 const bool del
= KonqOperations::askDeleteConfirmation(list
,
600 KonqOperations::DEFAULT_CONFIRMATION
,
604 KIO::Job
* job
= KIO::del(list
);
605 connect(job
, SIGNAL(result(KJob
*)),
606 this, SLOT(slotDeleteFileFinished(KJob
*)));
610 void DolphinView::cutSelectedItems()
612 QMimeData
* mimeData
= selectionMimeData();
613 KonqMimeData::addIsCutSelection(mimeData
, true);
614 QApplication::clipboard()->setMimeData(mimeData
);
617 void DolphinView::copySelectedItems()
619 QMimeData
* mimeData
= selectionMimeData();
620 QApplication::clipboard()->setMimeData(mimeData
);
623 void DolphinView::paste()
628 void DolphinView::pasteIntoFolder()
630 const KFileItemList items
= selectedItems();
631 if ((items
.count() == 1) && items
.first().isDir()) {
632 pasteToUrl(items
.first().url());
636 void DolphinView::setShowPreview(bool show
)
638 if (m_showPreview
== show
) {
642 const KUrl viewPropsUrl
= rootUrl();
643 ViewProperties
props(viewPropsUrl
);
644 props
.setShowPreview(show
);
646 m_showPreview
= show
;
647 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
648 emit
showPreviewChanged();
650 // Enabling or disabling the preview might change the icon size of the view.
651 // As the view does not emit a signal when the icon size has been changed,
652 // the used zoom level of the controller must be adjusted manually:
653 updateZoomLevel(oldZoomLevel
);
656 void DolphinView::setShowHiddenFiles(bool show
)
658 if (m_viewAccessor
.dirLister()->showingDotFiles() == show
) {
662 const KUrl viewPropsUrl
= rootUrl();
663 ViewProperties
props(viewPropsUrl
);
664 props
.setShowHiddenFiles(show
);
666 m_viewAccessor
.dirLister()->setShowingDotFiles(show
);
667 emit
showHiddenFilesChanged();
670 void DolphinView::setCategorizedSorting(bool categorized
)
672 if (categorized
== categorizedSorting()) {
676 // setCategorizedSorting(true) may only get invoked
677 // if the view supports categorized sorting
678 Q_ASSERT(!categorized
|| supportsCategorizedSorting());
680 ViewProperties
props(rootUrl());
681 props
.setCategorizedSorting(categorized
);
684 m_storedCategorizedSorting
= categorized
;
685 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
687 emit
categorizedSortingChanged();
690 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
692 QWidget::mouseReleaseEvent(event
);
696 bool DolphinView::eventFilter(QObject
* watched
, QEvent
* event
)
698 switch (event
->type()) {
699 case QEvent::FocusIn
:
700 if (watched
== m_viewAccessor
.itemView()) {
701 m_dolphinViewController
->requestActivation();
705 case QEvent::DragEnter
:
706 if (watched
== m_viewAccessor
.itemView()->viewport()) {
711 case QEvent::KeyPress
:
712 if (watched
== m_viewAccessor
.itemView()) {
713 // clear the selection when Escape has been pressed
714 QKeyEvent
* keyEvent
= static_cast<QKeyEvent
*>(event
);
715 if (keyEvent
->key() == Qt::Key_Escape
) {
722 if (watched
== m_viewAccessor
.itemView()->viewport()) {
723 // Ctrl+wheel events should cause icon zooming, but not if the left mouse button is pressed
724 // (the user is probably trying to scroll during a selection in that case)
725 QWheelEvent
* wheelEvent
= static_cast<QWheelEvent
*>(event
);
726 if (wheelEvent
->modifiers() & Qt::ControlModifier
&& !(wheelEvent
->buttons() & Qt::LeftButton
)) {
727 const int delta
= wheelEvent
->delta();
728 const int level
= zoomLevel();
730 setZoomLevel(level
+ 1);
731 } else if (delta
< 0) {
732 setZoomLevel(level
- 1);
743 return QWidget::eventFilter(watched
, event
);
746 void DolphinView::activate()
751 void DolphinView::triggerItem(const KFileItem
& item
)
753 const Qt::KeyboardModifiers modifier
= QApplication::keyboardModifiers();
754 if ((modifier
& Qt::ShiftModifier
) || (modifier
& Qt::ControlModifier
)) {
755 // items are selected by the user, hence don't trigger the
756 // item specified by 'index'
760 // TODO: the m_isContextMenuOpen check is a workaround for Qt-issue 207192
761 if (item
.isNull() || m_isContextMenuOpen
) {
765 emit
itemTriggered(item
); // caught by DolphinViewContainer or DolphinPart
768 void DolphinView::slotSelectionChanged(const QItemSelection
& selected
, const QItemSelection
& deselected
)
770 const int count
= selectedItemsCount();
771 const bool selectionStateChanged
= ((count
> 0) && (selected
.count() == count
)) ||
772 ((count
== 0) && !deselected
.isEmpty());
774 // If nothing has been selected before and something got selected (or if something
775 // was selected before and now nothing is selected) the selectionChangedSignal must
776 // be emitted asynchronously as fast as possible to update the edit-actions.
777 m_selectionChangedTimer
->setInterval(selectionStateChanged
? 0 : 300);
778 m_selectionChangedTimer
->start();
781 void DolphinView::emitSelectionChangedSignal()
783 m_selectionChangedTimer
->stop();
784 emit
selectionChanged(selectedItems());
787 void DolphinView::openContextMenu(const QPoint
& pos
,
788 const QList
<QAction
*>& customActions
)
791 const QModelIndex index
= m_viewAccessor
.itemView()->indexAt(pos
);
792 if (index
.isValid() && (index
.column() == DolphinModel::Name
)) {
793 const QModelIndex dolphinModelIndex
= m_viewAccessor
.proxyModel()->mapToSource(index
);
794 item
= m_viewAccessor
.dirModel()->itemForIndex(dolphinModelIndex
);
797 m_isContextMenuOpen
= true; // TODO: workaround for Qt-issue 207192
798 emit
requestContextMenu(item
, url(), customActions
);
799 m_isContextMenuOpen
= false;
802 void DolphinView::dropUrls(const KFileItem
& destItem
,
803 const KUrl
& destPath
,
806 addNewFileNames(event
->mimeData());
807 DragAndDropHelper::instance().dropUrls(destItem
, destPath
, event
, this);
810 void DolphinView::updateSorting(DolphinView::Sorting sorting
)
812 ViewProperties
props(rootUrl());
813 props
.setSorting(sorting
);
815 m_viewAccessor
.proxyModel()->setSorting(sorting
);
817 emit
sortingChanged(sorting
);
820 void DolphinView::updateSortOrder(Qt::SortOrder order
)
822 ViewProperties
props(rootUrl());
823 props
.setSortOrder(order
);
825 m_viewAccessor
.proxyModel()->setSortOrder(order
);
827 emit
sortOrderChanged(order
);
830 void DolphinView::updateSortFoldersFirst(bool foldersFirst
)
832 ViewProperties
props(rootUrl());
833 props
.setSortFoldersFirst(foldersFirst
);
835 m_viewAccessor
.proxyModel()->setSortFoldersFirst(foldersFirst
);
837 emit
sortFoldersFirstChanged(foldersFirst
);
840 void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList
& info
)
842 ViewProperties
props(rootUrl());
843 props
.setAdditionalInfo(info
);
846 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
848 emit
additionalInfoChanged();
851 void DolphinView::updateAdditionalInfoActions(KActionCollection
* collection
)
853 const AdditionalInfoAccessor
& infoAccessor
= AdditionalInfoAccessor::instance();
855 const KFileItemDelegate::InformationList checkedInfo
= m_viewAccessor
.itemDelegate()->showInformation();
856 const KFileItemDelegate::InformationList infoKeys
= infoAccessor
.keys();
858 const bool enable
= (m_mode
== DolphinView::DetailsView
) ||
859 (m_mode
== DolphinView::IconsView
);
861 foreach (const KFileItemDelegate::Information
& info
, infoKeys
) {
862 const QString name
= infoAccessor
.actionCollectionName(info
, AdditionalInfoAccessor::AdditionalInfoType
);
863 QAction
* action
= collection
->action(name
);
864 Q_ASSERT(action
!= 0);
865 action
->setEnabled(enable
);
866 action
->setChecked(checkedInfo
.contains(info
));
870 QPair
<bool, QString
> DolphinView::pasteInfo() const
872 return KonqOperations::pasteInfo(url());
875 void DolphinView::setTabsForFilesEnabled(bool tabsForFiles
)
877 m_tabsForFiles
= tabsForFiles
;
880 bool DolphinView::isTabsForFilesEnabled() const
882 return m_tabsForFiles
;
885 bool DolphinView::itemsExpandable() const
887 return m_viewAccessor
.itemsExpandable();
890 void DolphinView::restoreState(QDataStream
& stream
)
892 // Restore the URL of the current item that had the keyboard focus
893 stream
>> m_activeItemUrl
;
895 // Restore the root URL
898 m_viewAccessor
.setRootUrl(rootUrl
);
900 // Restore the view position
901 stream
>> m_restoredContentsPosition
;
903 // Restore expanded folders (only relevant for the details view - will be ignored by the view in other view modes)
904 QSet
<KUrl
> urlsToExpand
;
905 stream
>> urlsToExpand
;
906 const DolphinDetailsViewExpander
* expander
= m_viewAccessor
.setExpandedUrls(urlsToExpand
);
908 m_expanderActive
= true;
909 connect (expander
, SIGNAL(completed()), this, SLOT(slotLoadingCompleted()));
912 m_expanderActive
= false;
916 void DolphinView::saveState(QDataStream
& stream
)
918 // Save the URL of the current item that has the keyboard focus
919 KFileItem currentItem
;
920 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
923 const QModelIndex proxyIndex
= view
->currentIndex();
924 const QModelIndex dirModelIndex
= m_viewAccessor
.proxyModel()->mapToSource(proxyIndex
);
925 currentItem
= m_viewAccessor
.dirModel()->itemForIndex(dirModelIndex
);
929 if (!currentItem
.isNull()) {
930 currentItemUrl
= currentItem
.url();
933 stream
<< currentItemUrl
;
936 stream
<< m_viewAccessor
.rootUrl();
938 // Save view position
939 const int x
= view
->horizontalScrollBar()->value();
940 const int y
= view
->verticalScrollBar()->value();
941 stream
<< QPoint(x
, y
);
943 // Save expanded folders (only relevant for the details view - the set will be empty in other view modes)
944 stream
<< m_viewAccessor
.expandedUrls();
947 bool DolphinView::hasSelection() const
949 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
950 return (view
!= 0) && view
->selectionModel()->hasSelection();
953 void DolphinView::observeCreatedItem(const KUrl
& url
)
955 m_createdItemUrl
= url
;
956 connect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
957 this, SLOT(selectAndScrollToCreatedItem()));
960 void DolphinView::selectAndScrollToCreatedItem()
962 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_createdItemUrl
);
963 if (dirIndex
.isValid()) {
964 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
965 m_viewAccessor
.itemView()->setCurrentIndex(proxyIndex
);
968 disconnect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
969 this, SLOT(selectAndScrollToCreatedItem()));
970 m_createdItemUrl
= KUrl();
973 void DolphinView::showHoverInformation(const KFileItem
& item
)
975 emit
requestItemInfo(item
);
978 void DolphinView::clearHoverInformation()
980 emit
requestItemInfo(KFileItem());
983 void DolphinView::slotDeleteFileFinished(KJob
* job
)
985 if (job
->error() == 0) {
986 emit
operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
987 } else if (job
->error() != KIO::ERR_USER_CANCELED
) {
988 emit
errorMessage(job
->errorString());
992 void DolphinView::slotDirListerCompleted()
994 if (!m_expanderActive
) {
995 slotLoadingCompleted();
998 if (!m_newFileNames
.isEmpty()) {
999 // select all newly added items created by a paste operation or
1000 // a drag & drop operation, and clear the previous selection
1001 m_viewAccessor
.itemView()->clearSelection();
1002 const int rowCount
= m_viewAccessor
.proxyModel()->rowCount();
1003 QItemSelection selection
;
1004 for (int row
= 0; row
< rowCount
; ++row
) {
1005 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->index(row
, 0);
1006 const QModelIndex dirIndex
= m_viewAccessor
.proxyModel()->mapToSource(proxyIndex
);
1007 const KUrl url
= m_viewAccessor
.dirModel()->itemForIndex(dirIndex
).url();
1008 if (m_newFileNames
.contains(url
.fileName())) {
1009 selection
.merge(QItemSelection(proxyIndex
, proxyIndex
), QItemSelectionModel::Select
);
1012 m_viewAccessor
.itemView()->selectionModel()->select(selection
, QItemSelectionModel::Select
);
1014 m_newFileNames
.clear();
1018 void DolphinView::slotLoadingCompleted()
1020 m_expanderActive
= false;
1022 if (!m_activeItemUrl
.isEmpty()) {
1023 // assure that the current item remains visible
1024 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_activeItemUrl
);
1025 if (dirIndex
.isValid()) {
1026 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
1027 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1028 const bool clearSelection
= !hasSelection();
1029 view
->setCurrentIndex(proxyIndex
);
1030 if (clearSelection
) {
1031 view
->clearSelection();
1033 m_activeItemUrl
.clear();
1037 if (!m_selectedItems
.isEmpty()) {
1038 const KUrl
& baseUrl
= url();
1040 QItemSelection newSelection
;
1041 foreach(const KFileItem
& item
, m_selectedItems
) {
1042 url
= item
.url().upUrl();
1043 if (baseUrl
.equals(url
, KUrl::CompareWithoutTrailingSlash
)) {
1044 QModelIndex index
= m_viewAccessor
.proxyModel()->mapFromSource(m_viewAccessor
.dirModel()->indexForItem(item
));
1045 newSelection
.select(index
, index
);
1048 m_viewAccessor
.itemView()->selectionModel()->select(newSelection
,
1049 QItemSelectionModel::ClearAndSelect
1050 | QItemSelectionModel::Current
);
1051 m_selectedItems
.clear();
1054 // Restore the contents position. This has to be done using a Qt::QueuedConnection
1055 // because the view might not be in its final state yet.
1056 QMetaObject::invokeMethod(this, "restoreContentsPosition", Qt::QueuedConnection
);
1058 emit
finishedPathLoading(url());
1061 void DolphinView::slotRefreshItems()
1063 if (m_assureVisibleCurrentIndex
) {
1064 m_assureVisibleCurrentIndex
= false;
1065 m_viewAccessor
.itemView()->scrollTo(m_viewAccessor
.itemView()->currentIndex());
1069 void DolphinView::loadDirectory(const KUrl
& url
, bool reload
)
1071 if (!url
.isValid()) {
1072 const QString
location(url
.pathOrUrl());
1073 if (location
.isEmpty()) {
1074 emit
errorMessage(i18nc("@info:status", "The location is empty."));
1076 emit
errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location
));
1081 KDirLister
* dirLister
= m_viewAccessor
.dirLister();
1082 dirLister
->openUrl(url
, reload
? KDirLister::Reload
: KDirLister::NoFlags
);
1085 void DolphinView::applyViewProperties()
1087 const ViewProperties
props(rootUrl());
1089 const Mode mode
= props
.viewMode();
1090 if (m_mode
!= mode
) {
1091 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
1097 updateZoomLevel(oldZoomLevel
);
1099 if (m_viewAccessor
.itemView() == 0) {
1103 Q_ASSERT(m_viewAccessor
.itemView() != 0);
1104 Q_ASSERT(m_viewAccessor
.itemDelegate() != 0);
1106 const bool showHiddenFiles
= props
.showHiddenFiles();
1107 if (showHiddenFiles
!= m_viewAccessor
.dirLister()->showingDotFiles()) {
1108 m_viewAccessor
.dirLister()->setShowingDotFiles(showHiddenFiles
);
1109 emit
showHiddenFilesChanged();
1112 m_storedCategorizedSorting
= props
.categorizedSorting();
1113 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
1114 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
1115 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
1116 emit
categorizedSortingChanged();
1119 const DolphinView::Sorting sorting
= props
.sorting();
1120 if (sorting
!= m_viewAccessor
.proxyModel()->sorting()) {
1121 m_viewAccessor
.proxyModel()->setSorting(sorting
);
1122 emit
sortingChanged(sorting
);
1125 const Qt::SortOrder sortOrder
= props
.sortOrder();
1126 if (sortOrder
!= m_viewAccessor
.proxyModel()->sortOrder()) {
1127 m_viewAccessor
.proxyModel()->setSortOrder(sortOrder
);
1128 emit
sortOrderChanged(sortOrder
);
1131 const bool sortFoldersFirst
= props
.sortFoldersFirst();
1132 if (sortFoldersFirst
!= m_viewAccessor
.proxyModel()->sortFoldersFirst()) {
1133 m_viewAccessor
.proxyModel()->setSortFoldersFirst(sortFoldersFirst
);
1134 emit
sortFoldersFirstChanged(sortFoldersFirst
);
1137 KFileItemDelegate::InformationList info
= props
.additionalInfo();
1138 if (info
!= m_viewAccessor
.itemDelegate()->showInformation()) {
1139 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
1140 emit
additionalInfoChanged();
1143 const bool showPreview
= props
.showPreview();
1144 if (showPreview
!= m_showPreview
) {
1145 m_showPreview
= showPreview
;
1146 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
1147 emit
showPreviewChanged();
1149 // Enabling or disabling the preview might change the icon size of the view.
1150 // As the view does not emit a signal when the icon size has been changed,
1151 // the used zoom level of the controller must be adjusted manually:
1152 updateZoomLevel(oldZoomLevel
);
1156 void DolphinView::createView()
1160 Q_ASSERT(m_viewAccessor
.itemView() == 0);
1161 Q_ASSERT(m_dolphinViewController
->itemView() == 0);
1162 m_viewAccessor
.createView(this, m_dolphinViewController
, m_viewModeController
, m_mode
);
1164 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1165 Q_ASSERT(view
!= 0);
1166 view
->installEventFilter(this);
1167 view
->viewport()->installEventFilter(this);
1169 m_dolphinViewController
->setItemView(view
);
1171 const int zoomLevel
= ZoomLevelInfo::zoomLevelForIconSize(view
->iconSize());
1172 m_viewModeController
->setZoomLevel(zoomLevel
);
1174 connectViewAccessor();
1176 setFocusProxy(m_viewAccessor
.layoutTarget());
1177 m_topLayout
->insertWidget(1, m_viewAccessor
.layoutTarget());
1180 void DolphinView::deleteView()
1182 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1183 Q_ASSERT((m_dolphinViewController
->itemView() == 0) || (m_dolphinViewController
->itemView() == view
));
1184 m_dolphinViewController
->setItemView(0);
1187 disconnectViewAccessor();
1189 // It's important to set the keyboard focus to the parent
1190 // before deleting the view: Otherwise when having a split
1191 // view the other view will get the focus and will request
1192 // an activation (see DolphinView::eventFilter()).
1196 m_viewModeController
->disconnect(view
);
1198 m_viewAccessor
.deleteView();
1202 void DolphinView::pasteToUrl(const KUrl
& url
)
1204 addNewFileNames(QApplication::clipboard()->mimeData());
1205 KonqOperations::doPaste(this, url
);
1208 void DolphinView::updateZoomLevel(int oldZoomLevel
)
1210 const int newZoomLevel
= ZoomLevelInfo::zoomLevelForIconSize(m_viewAccessor
.itemView()->iconSize());
1211 if (oldZoomLevel
!= newZoomLevel
) {
1212 m_viewModeController
->setZoomLevel(newZoomLevel
);
1213 emit
zoomLevelChanged(newZoomLevel
);
1217 KUrl::List
DolphinView::simplifiedSelectedUrls() const
1221 const KFileItemList items
= selectedItems();
1222 foreach (const KFileItem
&item
, items
) {
1223 urls
.append(item
.url());
1227 if (itemsExpandable()) {
1228 urls
= KDirModel::simplifiedUrlList(urls
);
1234 QMimeData
* DolphinView::selectionMimeData() const
1236 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
1237 Q_ASSERT((view
!= 0) && (view
->selectionModel() != 0));
1238 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
1239 return m_viewAccessor
.dirModel()->mimeData(selection
.indexes());
1242 void DolphinView::addNewFileNames(const QMimeData
* mimeData
)
1244 const KUrl::List urls
= KUrl::List::fromMimeData(mimeData
);
1245 foreach (const KUrl
& url
, urls
) {
1246 m_newFileNames
.insert(url
.fileName());
1250 QItemSelection
DolphinView::childrenMatchingPattern(const QModelIndex
& parent
, const QRegExp
& pattern
) const
1252 QItemSelection matchingIndexes
;
1253 const DolphinSortFilterProxyModel
* proxyModel
= m_viewAccessor
.proxyModel();
1254 const DolphinModel
* dolphinModel
= m_viewAccessor
.dirModel();
1256 const int rowCount
= proxyModel
->rowCount(parent
);
1258 for (int row
= 0; row
< rowCount
; ++row
) {
1259 QModelIndex index
= proxyModel
->index(row
, 0, parent
);
1260 QModelIndex sourceIndex
= proxyModel
->mapToSource(index
);
1262 if (sourceIndex
.isValid() && pattern
.exactMatch(dolphinModel
->data(sourceIndex
).toString())) {
1263 matchingIndexes
+= QItemSelectionRange(index
);
1266 if (proxyModel
->hasChildren(index
)) {
1267 matchingIndexes
+= childrenMatchingPattern(index
, pattern
);
1271 return matchingIndexes
;
1274 void DolphinView::connectViewAccessor()
1276 KDirLister
* dirLister
= m_viewAccessor
.dirLister();
1277 connect(dirLister
, SIGNAL(redirection(KUrl
,KUrl
)),
1278 this, SLOT(slotRedirection(KUrl
,KUrl
)));
1279 connect(dirLister
, SIGNAL(started(KUrl
)),
1280 this, SIGNAL(startedPathLoading(KUrl
)));
1281 connect(dirLister
, SIGNAL(completed()),
1282 this, SLOT(slotDirListerCompleted()));
1283 connect(dirLister
, SIGNAL(refreshItems(const QList
<QPair
<KFileItem
,KFileItem
>>&)),
1284 this, SLOT(slotRefreshItems()));
1286 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1287 connect(view
->selectionModel(), SIGNAL(selectionChanged(QItemSelection
, QItemSelection
)),
1288 this, SLOT(slotSelectionChanged(QItemSelection
, QItemSelection
)));
1291 void DolphinView::disconnectViewAccessor()
1293 KDirLister
* dirLister
= m_viewAccessor
.dirLister();
1294 disconnect(dirLister
, SIGNAL(redirection(KUrl
,KUrl
)),
1295 this, SLOT(slotRedirection(KUrl
,KUrl
)));
1296 disconnect(dirLister
, SIGNAL(started(KUrl
)),
1297 this, SIGNAL(startedPathLoading(KUrl
)));
1298 disconnect(dirLister
, SIGNAL(completed()),
1299 this, SLOT(slotDirListerCompleted()));
1300 disconnect(dirLister
, SIGNAL(refreshItems(const QList
<QPair
<KFileItem
,KFileItem
>>&)),
1301 this, SLOT(slotRefreshItems()));
1303 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1304 disconnect(view
->selectionModel(), SIGNAL(selectionChanged(QItemSelection
, QItemSelection
)),
1305 this, SLOT(slotSelectionChanged(QItemSelection
, QItemSelection
)));
1308 DolphinView::ViewAccessor::ViewAccessor(DolphinSortFilterProxyModel
* proxyModel
) :
1312 m_columnsContainer(0),
1313 m_proxyModel(proxyModel
),
1318 DolphinView::ViewAccessor::~ViewAccessor()
1320 delete m_dragSource
;
1324 void DolphinView::ViewAccessor::createView(QWidget
* parent
,
1325 DolphinViewController
* dolphinViewController
,
1326 const ViewModeController
* viewModeController
,
1329 Q_ASSERT(itemView() == 0);
1333 m_iconsView
= new DolphinIconsView(parent
,
1334 dolphinViewController
,
1340 m_detailsView
= new DolphinDetailsView(parent
,
1341 dolphinViewController
,
1347 m_columnsContainer
= new DolphinColumnViewContainer(parent
,
1348 dolphinViewController
,
1349 viewModeController
);
1350 if (!m_rootUrl
.isEmpty() && m_rootUrl
.isParentOf(viewModeController
->url())) {
1351 // The column-view must show several columns starting with m_rootUrl as
1352 // first column and viewModeController->url() as last column.
1353 m_columnsContainer
->showColumn(m_rootUrl
);
1354 m_columnsContainer
->showColumn(viewModeController
->url());
1363 void DolphinView::ViewAccessor::deleteView()
1365 if (m_columnsContainer
!= 0) {
1366 m_columnsContainer
->close();
1367 m_columnsContainer
->disconnect();
1368 m_columnsContainer
->deleteLater();
1369 m_columnsContainer
= 0;
1371 QAbstractItemView
* view
= itemView();
1376 if (DragAndDropHelper::instance().isDragSource(view
)) {
1377 // The view is a drag source (the feature "Open folders
1378 // during drag operations" is used). Deleting the view
1379 // during an ongoing drag operation is not allowed, so
1380 // this will postponed.
1381 if (m_dragSource
!= 0) {
1382 // the old stored view is obviously not the drag source anymore
1383 m_dragSource
->deleteLater();
1387 m_dragSource
= view
;
1389 view
->deleteLater();
1399 void DolphinView::ViewAccessor::prepareUrlChange(const KUrl
& url
)
1401 if (m_columnsContainer
!= 0) {
1402 m_columnsContainer
->showColumn(url
);
1406 QAbstractItemView
* DolphinView::ViewAccessor::itemView() const
1408 if (m_iconsView
!= 0) {
1412 if (m_detailsView
!= 0) {
1413 return m_detailsView
;
1416 if (m_columnsContainer
!= 0) {
1417 return m_columnsContainer
->activeColumn();
1423 KFileItemDelegate
* DolphinView::ViewAccessor::itemDelegate() const
1425 return static_cast<KFileItemDelegate
*>(itemView()->itemDelegate());
1428 QWidget
* DolphinView::ViewAccessor::layoutTarget() const
1430 if (m_columnsContainer
!= 0) {
1431 return m_columnsContainer
;
1436 void DolphinView::ViewAccessor::setRootUrl(const KUrl
& rootUrl
)
1438 m_rootUrl
= rootUrl
;
1441 KUrl
DolphinView::ViewAccessor::rootUrl() const
1443 return (m_columnsContainer
!= 0) ? m_columnsContainer
->rootUrl() : m_rootUrl
;
1446 bool DolphinView::ViewAccessor::supportsCategorizedSorting() const
1448 return m_iconsView
!= 0;
1451 bool DolphinView::ViewAccessor::itemsExpandable() const
1453 return (m_detailsView
!= 0) && m_detailsView
->itemsExpandable();
1456 QSet
<KUrl
> DolphinView::ViewAccessor::expandedUrls() const
1458 if (m_detailsView
!= 0) {
1459 return m_detailsView
->expandedUrls();
1462 return QSet
<KUrl
>();
1465 const DolphinDetailsViewExpander
* DolphinView::ViewAccessor::setExpandedUrls(const QSet
<KUrl
>& urlsToExpand
)
1467 if ((m_detailsView
!= 0) && m_detailsView
->itemsExpandable() && !urlsToExpand
.isEmpty()) {
1468 // Check if another expander is already active and stop it if necessary.
1469 if(!m_detailsViewExpander
.isNull()) {
1470 m_detailsViewExpander
->stop();
1473 m_detailsViewExpander
= new DolphinDetailsViewExpander(m_detailsView
, urlsToExpand
);
1474 return m_detailsViewExpander
;
1481 bool DolphinView::ViewAccessor::reloadOnAdditionalInfoChange() const
1483 // the details view requires no reloading of the directory, as it maps
1484 // the file item delegate info to its columns internally
1485 return m_detailsView
!= 0;
1488 DolphinModel
* DolphinView::ViewAccessor::dirModel() const
1490 return static_cast<DolphinModel
*>(proxyModel()->sourceModel());
1493 DolphinSortFilterProxyModel
* DolphinView::ViewAccessor::proxyModel() const
1495 if (m_columnsContainer
!= 0) {
1496 return static_cast<DolphinSortFilterProxyModel
*>(m_columnsContainer
->activeColumn()->model());
1498 return m_proxyModel
;
1501 KDirLister
* DolphinView::ViewAccessor::dirLister() const
1503 return dirModel()->dirLister();
1506 void DolphinView::slotRedirection(const KUrl
& oldUrl
, const KUrl
& newUrl
)
1508 if (oldUrl
.equals(url(), KUrl::CompareWithoutTrailingSlash
)) {
1509 emit
redirection(oldUrl
, newUrl
);
1510 m_viewModeController
->redirectToUrl(newUrl
); // #186947
1514 void DolphinView::restoreContentsPosition()
1516 if (!m_restoredContentsPosition
.isNull()) {
1517 const int x
= m_restoredContentsPosition
.x();
1518 const int y
= m_restoredContentsPosition
.y();
1519 m_restoredContentsPosition
= QPoint();
1521 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1522 Q_ASSERT(view
!= 0);
1523 view
->horizontalScrollBar()->setValue(x
);
1524 view
->verticalScrollBar()->setValue(y
);
1528 #include "dolphinview.moc"