1 /***************************************************************************
2 * Copyright (C) 2006-2009 by Peter Penz <peter.penz@gmx.at> *
3 * Copyright (C) 2006 by Gregor Kališnik <gregor@podnapisi.net> *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
21 #include "dolphinview.h"
23 #include <QAbstractItemView>
24 #include <QApplication>
27 #include <QItemSelection>
32 #include <kactioncollection.h>
33 #include <kcolorscheme.h>
34 #include <kdirlister.h>
35 #include <kiconeffect.h>
36 #include <kfileitem.h>
38 #include <kio/deletejob.h>
39 #include <kio/netaccess.h>
40 #include <kio/previewjob.h>
43 #include <kmessagebox.h>
44 #include <kmimetyperesolver.h>
45 #include <konq_fileitemcapabilities.h>
46 #include <konq_operations.h>
47 #include <konqmimedata.h>
48 #include <kstringhandler.h>
49 #include <ktoggleaction.h>
52 #include "additionalinfoaccessor.h"
53 #include "dolphinmodel.h"
54 #include "dolphincolumnviewcontainer.h"
55 #include "dolphinviewcontroller.h"
56 #include "dolphindetailsview.h"
57 #include "dolphinfileitemdelegate.h"
58 #include "dolphinnewfilemenuobserver.h"
59 #include "dolphinsortfilterproxymodel.h"
60 #include "dolphin_detailsmodesettings.h"
61 #include "dolphiniconsview.h"
62 #include "dolphin_generalsettings.h"
63 #include "draganddrophelper.h"
64 #include "renamedialog.h"
65 #include "settings/dolphinsettings.h"
66 #include "viewmodecontroller.h"
67 #include "viewproperties.h"
68 #include "zoomlevelinfo.h"
69 #include "dolphindetailsviewexpander.h"
72 * Helper function for sorting items with qSort() in
73 * DolphinView::renameSelectedItems().
75 bool lessThan(const KFileItem
& item1
, const KFileItem
& item2
)
77 return KStringHandler::naturalCompare(item1
.name(), item2
.name()) < 0;
80 DolphinView::DolphinView(QWidget
* parent
,
82 DolphinSortFilterProxyModel
* proxyModel
) :
86 m_storedCategorizedSorting(false),
87 m_tabsForFiles(false),
88 m_isContextMenuOpen(false),
89 m_assureVisibleCurrentIndex(false),
90 m_mode(DolphinView::IconsView
),
92 m_dolphinViewController(0),
93 m_viewModeController(0),
94 m_viewAccessor(proxyModel
),
95 m_selectionChangedTimer(0),
98 m_restoredContentsPosition(),
103 m_topLayout
= new QVBoxLayout(this);
104 m_topLayout
->setSpacing(0);
105 m_topLayout
->setMargin(0);
107 m_dolphinViewController
= new DolphinViewController(this);
109 m_viewModeController
= new ViewModeController(this);
110 m_viewModeController
->setUrl(url
);
112 connect(m_viewModeController
, SIGNAL(urlChanged(const KUrl
&)),
113 this, SIGNAL(urlChanged(const KUrl
&)));
115 connect(m_dolphinViewController
, SIGNAL(requestContextMenu(const QPoint
&, const QList
<QAction
*>&)),
116 this, SLOT(openContextMenu(const QPoint
&, const QList
<QAction
*>&)));
117 connect(m_dolphinViewController
, SIGNAL(urlsDropped(const KFileItem
&, const KUrl
&, QDropEvent
*)),
118 this, SLOT(dropUrls(const KFileItem
&, const KUrl
&, QDropEvent
*)));
119 connect(m_dolphinViewController
, SIGNAL(sortingChanged(DolphinView::Sorting
)),
120 this, SLOT(updateSorting(DolphinView::Sorting
)));
121 connect(m_dolphinViewController
, SIGNAL(sortOrderChanged(Qt::SortOrder
)),
122 this, SLOT(updateSortOrder(Qt::SortOrder
)));
123 connect(m_dolphinViewController
, SIGNAL(sortFoldersFirstChanged(bool)),
124 this, SLOT(updateSortFoldersFirst(bool)));
125 connect(m_dolphinViewController
, SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList
&)),
126 this, SLOT(updateAdditionalInfo(const KFileItemDelegate::InformationList
&)));
127 connect(m_dolphinViewController
, SIGNAL(itemTriggered(const KFileItem
&)),
128 this, SLOT(triggerItem(const KFileItem
&)));
129 connect(m_dolphinViewController
, SIGNAL(tabRequested(const KUrl
&)),
130 this, SIGNAL(tabRequested(const KUrl
&)));
131 connect(m_dolphinViewController
, SIGNAL(activated()),
132 this, SLOT(activate()));
133 connect(m_dolphinViewController
, SIGNAL(itemEntered(const KFileItem
&)),
134 this, SLOT(showHoverInformation(const KFileItem
&)));
135 connect(m_dolphinViewController
, SIGNAL(viewportEntered()),
136 this, SLOT(clearHoverInformation()));
137 connect(m_dolphinViewController
, SIGNAL(urlChangeRequested(KUrl
)),
138 m_viewModeController
, SLOT(setUrl(KUrl
)));
140 KDirLister
* dirLister
= m_viewAccessor
.dirLister();
141 connect(dirLister
, SIGNAL(redirection(KUrl
,KUrl
)),
142 this, SLOT(slotRedirection(KUrl
,KUrl
)));
143 connect(dirLister
, SIGNAL(completed()),
144 this, SLOT(slotDirListerCompleted()));
145 connect(dirLister
, SIGNAL(refreshItems(const QList
<QPair
<KFileItem
,KFileItem
>>&)),
146 this, SLOT(slotRefreshItems()));
148 // When a new item has been created by the "Create New..." menu, the item should
149 // get selected and it must be assured that the item will get visible. As the
150 // creation is done asynchronously, several signals must be checked:
151 connect(&DolphinNewFileMenuObserver::instance(), SIGNAL(itemCreated(const KUrl
&)),
152 this, SLOT(observeCreatedItem(const KUrl
&)));
154 m_selectionChangedTimer
= new QTimer(this);
155 m_selectionChangedTimer
->setSingleShot(true);
156 m_selectionChangedTimer
->setInterval(300);
157 connect(m_selectionChangedTimer
, SIGNAL(timeout()),
158 this, SLOT(emitSelectionChangedSignal()));
160 applyViewProperties();
161 m_topLayout
->addWidget(m_viewAccessor
.layoutTarget());
164 DolphinView::~DolphinView()
168 KUrl
DolphinView::url() const
170 return m_viewModeController
->url();
173 KUrl
DolphinView::rootUrl() const
175 const KUrl viewUrl
= url();
176 const KUrl root
= m_viewAccessor
.rootUrl();
177 if (root
.isEmpty() || !root
.isParentOf(viewUrl
)) {
183 void DolphinView::setActive(bool active
)
185 if (active
== m_active
) {
191 QColor color
= KColorScheme(QPalette::Active
, KColorScheme::View
).background().color();
193 emitSelectionChangedSignal();
198 QWidget
* viewport
= m_viewAccessor
.itemView()->viewport();
200 palette
.setColor(viewport
->backgroundRole(), color
);
201 viewport
->setPalette(palette
);
206 m_viewAccessor
.itemView()->setFocus();
210 m_viewModeController
->indicateActivationChange(active
);
213 bool DolphinView::isActive() const
218 void DolphinView::setMode(Mode mode
)
220 if (mode
== m_mode
) {
221 return; // the wished mode is already set
224 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
227 // remember the currently selected items, so that they will
228 // be restored after reloading the directory
229 m_selectedItems
= selectedItems();
233 const KUrl viewPropsUrl
= rootUrl();
234 ViewProperties
props(viewPropsUrl
);
235 props
.setViewMode(m_mode
);
238 // the file item delegate has been recreated, apply the current
239 // additional information manually
240 const KFileItemDelegate::InformationList infoList
= props
.additionalInfo();
241 m_viewAccessor
.itemDelegate()->setShowInformation(infoList
);
242 emit
additionalInfoChanged();
244 // Not all view modes support categorized sorting. Adjust the sorting model
245 // if changing the view mode results in a change of the categorized sorting
247 m_storedCategorizedSorting
= props
.categorizedSorting();
248 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
249 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
250 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
251 emit
categorizedSortingChanged();
256 updateZoomLevel(oldZoomLevel
);
257 loadDirectory(viewPropsUrl
);
260 DolphinView::Mode
DolphinView::mode() const
265 bool DolphinView::showPreview() const
267 return m_showPreview
;
270 bool DolphinView::showHiddenFiles() const
272 return m_viewAccessor
.dirLister()->showingDotFiles();
275 bool DolphinView::categorizedSorting() const
277 // If all view modes would support categorized sorting, returning
278 // m_viewAccessor.proxyModel()->isCategorizedModel() would be the way to go. As
279 // currently only the icons view supports caterized sorting, we remember
280 // the stored view properties state in m_storedCategorizedSorting and
281 // return this state. The application takes care to disable the corresponding
282 // checkbox by checking DolphinView::supportsCategorizedSorting() to indicate
283 // that this setting is not applied to the current view mode.
284 return m_storedCategorizedSorting
;
287 bool DolphinView::supportsCategorizedSorting() const
289 return m_viewAccessor
.supportsCategorizedSorting();
292 bool DolphinView::hasSelection() const
294 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
295 return (view
!= 0) && view
->selectionModel()->hasSelection();
298 void DolphinView::markUrlsAsSelected(const QList
<KUrl
>& urls
)
300 foreach (const KUrl
& url
, urls
) {
301 KFileItem
item(KFileItem::Unknown
, KFileItem::Unknown
, url
);
302 m_selectedItems
.append(item
);
306 KFileItemList
DolphinView::selectedItems() const
308 KFileItemList itemList
;
309 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
314 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
316 const QModelIndexList indexList
= selection
.indexes();
317 foreach (const QModelIndex
&index
, indexList
) {
318 KFileItem item
= m_viewAccessor
.dirModel()->itemForIndex(index
);
319 if (!item
.isNull()) {
320 itemList
.append(item
);
327 KUrl::List
DolphinView::selectedUrls() const
330 const KFileItemList list
= selectedItems();
331 foreach (const KFileItem
&item
, list
) {
332 urls
.append(item
.url());
337 int DolphinView::selectedItemsCount() const
339 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
344 return view
->selectionModel()->selectedIndexes().count();
347 QItemSelectionModel
* DolphinView::selectionModel() const
349 return m_viewAccessor
.itemView()->selectionModel();
352 void DolphinView::setZoomLevel(int level
)
354 if (level
< ZoomLevelInfo::minimumLevel()) {
355 level
= ZoomLevelInfo::minimumLevel();
356 } else if (level
> ZoomLevelInfo::maximumLevel()) {
357 level
= ZoomLevelInfo::maximumLevel();
360 if (level
!= zoomLevel()) {
361 m_viewModeController
->setZoomLevel(level
);
362 emit
zoomLevelChanged(level
);
366 int DolphinView::zoomLevel() const
368 return m_viewModeController
->zoomLevel();
371 void DolphinView::setSorting(Sorting sorting
)
373 if (sorting
!= this->sorting()) {
374 updateSorting(sorting
);
378 DolphinView::Sorting
DolphinView::sorting() const
380 return m_viewAccessor
.proxyModel()->sorting();
383 void DolphinView::setSortOrder(Qt::SortOrder order
)
385 if (sortOrder() != order
) {
386 updateSortOrder(order
);
390 Qt::SortOrder
DolphinView::sortOrder() const
392 return m_viewAccessor
.proxyModel()->sortOrder();
395 void DolphinView::setSortFoldersFirst(bool foldersFirst
)
397 if (sortFoldersFirst() != foldersFirst
) {
398 updateSortFoldersFirst(foldersFirst
);
402 bool DolphinView::sortFoldersFirst() const
404 return m_viewAccessor
.proxyModel()->sortFoldersFirst();
407 void DolphinView::setAdditionalInfo(KFileItemDelegate::InformationList info
)
409 const KUrl viewPropsUrl
= rootUrl();
410 ViewProperties
props(viewPropsUrl
);
411 props
.setAdditionalInfo(info
);
412 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
414 emit
additionalInfoChanged();
416 if (m_viewAccessor
.reloadOnAdditionalInfoChange()) {
417 loadDirectory(viewPropsUrl
);
421 KFileItemDelegate::InformationList
DolphinView::additionalInfo() const
423 return m_viewAccessor
.itemDelegate()->showInformation();
426 void DolphinView::reload()
428 QByteArray viewState
;
429 QDataStream
saveStream(&viewState
, QIODevice::WriteOnly
);
430 saveState(saveStream
);
431 m_selectedItems
= selectedItems();
434 loadDirectory(url(), true);
436 QDataStream
restoreStream(viewState
);
437 restoreState(restoreStream
);
440 void DolphinView::refresh()
442 const bool oldActivationState
= m_active
;
443 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
447 applyViewProperties();
450 setActive(oldActivationState
);
451 updateZoomLevel(oldZoomLevel
);
454 void DolphinView::setNameFilter(const QString
& nameFilter
)
456 m_viewModeController
->setNameFilter(nameFilter
);
459 void DolphinView::calculateItemCount(int& fileCount
,
461 KIO::filesize_t
& totalFileSize
) const
463 foreach (const KFileItem
& item
, m_viewAccessor
.dirLister()->items()) {
468 totalFileSize
+= item
.size();
473 QString
DolphinView::statusBarText() const
478 KIO::filesize_t totalFileSize
= 0;
480 if (hasSelection()) {
481 // give a summary of the status of the selected files
482 const KFileItemList list
= selectedItems();
483 if (list
.isEmpty()) {
484 // when an item is triggered, it is temporary selected but selectedItems()
485 // will return an empty list
489 KFileItemList::const_iterator it
= list
.begin();
490 const KFileItemList::const_iterator end
= list
.end();
492 const KFileItem
& item
= *it
;
497 totalFileSize
+= item
.size();
502 if (folderCount
+ fileCount
== 1) {
503 // if only one item is selected, show the filename
504 const QString name
= list
.first().text();
505 text
= (folderCount
== 1) ? i18nc("@info:status", "<filename>%1</filename> selected", name
) :
506 i18nc("@info:status", "<filename>%1</filename> selected (%2)",
507 name
, KIO::convertSize(totalFileSize
));
509 // at least 2 items are selected
510 const QString foldersText
= i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount
);
511 const QString filesText
= i18ncp("@info:status", "1 File selected", "%1 Files selected", fileCount
);
512 if ((folderCount
> 0) && (fileCount
> 0)) {
513 text
= i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
514 foldersText
, filesText
, KIO::convertSize(totalFileSize
));
515 } else if (fileCount
> 0) {
516 text
= i18nc("@info:status files (size)", "%1 (%2)", filesText
, KIO::convertSize(totalFileSize
));
518 Q_ASSERT(folderCount
> 0);
523 calculateItemCount(fileCount
, folderCount
, totalFileSize
);
524 text
= KIO::itemsSummaryString(fileCount
+ folderCount
,
525 fileCount
, folderCount
,
526 totalFileSize
, true);
532 QList
<QAction
*> DolphinView::versionControlActions(const KFileItemList
& items
) const
534 return m_dolphinViewController
->versionControlActions(items
);
537 void DolphinView::setUrl(const KUrl
& url
)
539 if (m_viewModeController
->url() == url
) {
543 // The selection model might change in the case of the column view. Disconnect
544 // from the current selection model and reconnect later after the URL switch.
545 QAbstractItemView
* view
= m_viewAccessor
.itemView();
546 disconnect(view
->selectionModel(), SIGNAL(selectionChanged(QItemSelection
, QItemSelection
)),
547 this, SLOT(slotSelectionChanged(QItemSelection
, QItemSelection
)));
549 m_newFileNames
.clear();
551 m_viewModeController
->setUrl(url
); // emits urlChanged, which we forward
552 m_viewAccessor
.prepareUrlChange(url
);
553 applyViewProperties();
556 // When changing the URL there is no need to keep the version
557 // data of the previous URL.
558 m_viewAccessor
.dirModel()->clearVersionData();
560 emit
startedPathLoading(url
);
562 // Reconnect to the (probably) new selection model
563 view
= m_viewAccessor
.itemView();
564 connect(view
->selectionModel(), SIGNAL(selectionChanged(QItemSelection
, QItemSelection
)),
565 this, SLOT(slotSelectionChanged(QItemSelection
, QItemSelection
)));
568 void DolphinView::selectAll()
570 m_viewAccessor
.itemView()->selectAll();
573 void DolphinView::invertSelection()
575 QItemSelectionModel
* selectionModel
= m_viewAccessor
.itemView()->selectionModel();
576 const QAbstractItemModel
* itemModel
= selectionModel
->model();
578 const QModelIndex topLeft
= itemModel
->index(0, 0);
579 const QModelIndex bottomRight
= itemModel
->index(itemModel
->rowCount() - 1,
580 itemModel
->columnCount() - 1);
582 const QItemSelection
selection(topLeft
, bottomRight
);
583 selectionModel
->select(selection
, QItemSelectionModel::Toggle
);
586 void DolphinView::clearSelection()
588 m_viewAccessor
.itemView()->clearSelection();
591 void DolphinView::renameSelectedItems()
593 KFileItemList items
= selectedItems();
594 const int itemCount
= items
.count();
600 // More than one item has been selected for renaming. Open
601 // a rename dialog and rename all items afterwards.
602 QPointer
<RenameDialog
> dialog
= new RenameDialog(this, items
);
603 if (dialog
->exec() == QDialog::Rejected
) {
608 const QString newName
= dialog
->newName();
609 if (newName
.isEmpty()) {
610 emit
errorMessage(dialog
->errorString());
616 // the selection would be invalid after renaming the items, so just clear
620 // TODO: check how this can be integrated into KIO::FileUndoManager/KonqOperations
621 // as one operation instead of n rename operations like it is done now...
622 Q_ASSERT(newName
.contains('#'));
624 // currently the items are sorted by the selection order, resort
625 // them by the file name
626 qSort(items
.begin(), items
.end(), lessThan
);
628 // iterate through all selected items and rename them...
630 foreach (const KFileItem
& item
, items
) {
631 const KUrl
& oldUrl
= item
.url();
633 number
.setNum(index
++);
635 QString name
= newName
;
636 name
.replace('#', number
);
638 if (oldUrl
.fileName() != name
) {
639 KUrl newUrl
= oldUrl
;
640 newUrl
.setFileName(name
);
641 KonqOperations::rename(this, oldUrl
, newUrl
);
644 } else if (DolphinSettings::instance().generalSettings()->renameInline()) {
645 Q_ASSERT(itemCount
== 1);
646 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForItem(items
.first());
647 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
648 m_viewAccessor
.itemView()->edit(proxyIndex
);
650 Q_ASSERT(itemCount
== 1);
652 QPointer
<RenameDialog
> dialog
= new RenameDialog(this, items
);
653 if (dialog
->exec() == QDialog::Rejected
) {
658 const QString newName
= dialog
->newName();
659 if (newName
.isEmpty()) {
660 emit
errorMessage(dialog
->errorString());
666 const KUrl
& oldUrl
= items
.first().url();
667 KUrl newUrl
= oldUrl
;
668 newUrl
.setFileName(newName
);
669 KonqOperations::rename(this, oldUrl
, newUrl
);
672 // assure that the current index remains visible when KDirLister
673 // will notify the view about changed items
674 m_assureVisibleCurrentIndex
= true;
677 void DolphinView::trashSelectedItems()
679 const KUrl::List list
= simplifiedSelectedUrls();
680 KonqOperations::del(this, KonqOperations::TRASH
, list
);
683 void DolphinView::deleteSelectedItems()
685 const KUrl::List list
= simplifiedSelectedUrls();
686 const bool del
= KonqOperations::askDeleteConfirmation(list
,
688 KonqOperations::DEFAULT_CONFIRMATION
,
692 KIO::Job
* job
= KIO::del(list
);
693 connect(job
, SIGNAL(result(KJob
*)),
694 this, SLOT(slotDeleteFileFinished(KJob
*)));
698 void DolphinView::cutSelectedItems()
700 QMimeData
* mimeData
= selectionMimeData();
701 KonqMimeData::addIsCutSelection(mimeData
, true);
702 QApplication::clipboard()->setMimeData(mimeData
);
705 void DolphinView::copySelectedItems()
707 QMimeData
* mimeData
= selectionMimeData();
708 QApplication::clipboard()->setMimeData(mimeData
);
711 void DolphinView::paste()
716 void DolphinView::pasteIntoFolder()
718 const KFileItemList items
= selectedItems();
719 if ((items
.count() == 1) && items
.first().isDir()) {
720 pasteToUrl(items
.first().url());
724 void DolphinView::setShowPreview(bool show
)
726 if (m_showPreview
== show
) {
730 const KUrl viewPropsUrl
= rootUrl();
731 ViewProperties
props(viewPropsUrl
);
732 props
.setShowPreview(show
);
734 m_showPreview
= show
;
735 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
736 emit
showPreviewChanged();
738 // Enabling or disabling the preview might change the icon size of the view.
739 // As the view does not emit a signal when the icon size has been changed,
740 // the used zoom level of the controller must be adjusted manually:
741 updateZoomLevel(oldZoomLevel
);
744 void DolphinView::setShowHiddenFiles(bool show
)
746 if (m_viewAccessor
.dirLister()->showingDotFiles() == show
) {
750 const KUrl viewPropsUrl
= rootUrl();
751 ViewProperties
props(viewPropsUrl
);
752 props
.setShowHiddenFiles(show
);
754 m_viewAccessor
.dirLister()->setShowingDotFiles(show
);
755 emit
showHiddenFilesChanged();
758 void DolphinView::setCategorizedSorting(bool categorized
)
760 if (categorized
== categorizedSorting()) {
764 // setCategorizedSorting(true) may only get invoked
765 // if the view supports categorized sorting
766 Q_ASSERT(!categorized
|| supportsCategorizedSorting());
768 ViewProperties
props(rootUrl());
769 props
.setCategorizedSorting(categorized
);
772 m_storedCategorizedSorting
= categorized
;
773 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
775 emit
categorizedSortingChanged();
778 void DolphinView::toggleSortOrder()
780 const Qt::SortOrder order
= (sortOrder() == Qt::AscendingOrder
) ?
781 Qt::DescendingOrder
:
786 void DolphinView::toggleSortFoldersFirst()
788 setSortFoldersFirst(!sortFoldersFirst());
791 void DolphinView::toggleAdditionalInfo(QAction
* action
)
793 const KFileItemDelegate::Information info
=
794 static_cast<KFileItemDelegate::Information
>(action
->data().toInt());
796 KFileItemDelegate::InformationList list
= additionalInfo();
798 const bool show
= action
->isChecked();
800 const int index
= list
.indexOf(info
);
801 const bool containsInfo
= (index
>= 0);
802 if (show
&& !containsInfo
) {
804 setAdditionalInfo(list
);
805 } else if (!show
&& containsInfo
) {
806 list
.removeAt(index
);
807 setAdditionalInfo(list
);
808 Q_ASSERT(list
.indexOf(info
) < 0);
812 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
814 QWidget::mouseReleaseEvent(event
);
818 bool DolphinView::eventFilter(QObject
* watched
, QEvent
* event
)
820 switch (event
->type()) {
821 case QEvent::FocusIn
:
822 if (watched
== m_viewAccessor
.itemView()) {
823 m_dolphinViewController
->requestActivation();
827 case QEvent::DragEnter
:
828 if (watched
== m_viewAccessor
.itemView()->viewport()) {
833 case QEvent::KeyPress
:
834 if (watched
== m_viewAccessor
.itemView()) {
835 // clear the selection when Escape has been pressed
836 QKeyEvent
* keyEvent
= static_cast<QKeyEvent
*>(event
);
837 if (keyEvent
->key() == Qt::Key_Escape
) {
844 if (watched
== m_viewAccessor
.itemView()->viewport()) {
845 // Ctrl+wheel events should cause icon zooming, but not if the left mouse button is pressed
846 // (the user is probably trying to scroll during a selection in that case)
847 QWheelEvent
* wheelEvent
= static_cast<QWheelEvent
*>(event
);
848 if (wheelEvent
->modifiers() & Qt::ControlModifier
&& !(wheelEvent
->buttons() & Qt::LeftButton
)) {
849 const int delta
= wheelEvent
->delta();
850 const int level
= zoomLevel();
852 setZoomLevel(level
+ 1);
853 } else if (delta
< 0) {
854 setZoomLevel(level
- 1);
865 return QWidget::eventFilter(watched
, event
);
868 void DolphinView::activate()
873 void DolphinView::triggerItem(const KFileItem
& item
)
875 const Qt::KeyboardModifiers modifier
= QApplication::keyboardModifiers();
876 if ((modifier
& Qt::ShiftModifier
) || (modifier
& Qt::ControlModifier
)) {
877 // items are selected by the user, hence don't trigger the
878 // item specified by 'index'
882 // TODO: the m_isContextMenuOpen check is a workaround for Qt-issue 207192
883 if (item
.isNull() || m_isContextMenuOpen
) {
887 emit
itemTriggered(item
); // caught by DolphinViewContainer or DolphinPart
890 void DolphinView::slotSelectionChanged(const QItemSelection
& selected
, const QItemSelection
& deselected
)
892 const int count
= selectedItemsCount();
893 const bool selectionStateChanged
= ((count
> 0) && (selected
.count() == count
)) ||
894 ((count
== 0) && !deselected
.isEmpty());
896 // If nothing has been selected before and something got selected (or if something
897 // was selected before and now nothing is selected) the selectionChangedSignal must
898 // be emitted asynchronously as fast as possible to update the edit-actions.
899 m_selectionChangedTimer
->setInterval(selectionStateChanged
? 0 : 300);
900 m_selectionChangedTimer
->start();
903 void DolphinView::emitSelectionChangedSignal()
905 emit
selectionChanged(DolphinView::selectedItems());
908 void DolphinView::openContextMenu(const QPoint
& pos
,
909 const QList
<QAction
*>& customActions
)
912 const QModelIndex index
= m_viewAccessor
.itemView()->indexAt(pos
);
913 if (index
.isValid() && (index
.column() == DolphinModel::Name
)) {
914 const QModelIndex dolphinModelIndex
= m_viewAccessor
.proxyModel()->mapToSource(index
);
915 item
= m_viewAccessor
.dirModel()->itemForIndex(dolphinModelIndex
);
918 m_isContextMenuOpen
= true; // TODO: workaround for Qt-issue 207192
919 emit
requestContextMenu(item
, url(), customActions
);
920 m_isContextMenuOpen
= false;
923 void DolphinView::dropUrls(const KFileItem
& destItem
,
924 const KUrl
& destPath
,
927 addNewFileNames(event
->mimeData());
928 DragAndDropHelper::instance().dropUrls(destItem
, destPath
, event
, this);
931 void DolphinView::updateSorting(DolphinView::Sorting sorting
)
933 ViewProperties
props(rootUrl());
934 props
.setSorting(sorting
);
936 m_viewAccessor
.proxyModel()->setSorting(sorting
);
938 emit
sortingChanged(sorting
);
941 void DolphinView::updateSortOrder(Qt::SortOrder order
)
943 ViewProperties
props(rootUrl());
944 props
.setSortOrder(order
);
946 m_viewAccessor
.proxyModel()->setSortOrder(order
);
948 emit
sortOrderChanged(order
);
951 void DolphinView::updateSortFoldersFirst(bool foldersFirst
)
953 ViewProperties
props(rootUrl());
954 props
.setSortFoldersFirst(foldersFirst
);
956 m_viewAccessor
.proxyModel()->setSortFoldersFirst(foldersFirst
);
958 emit
sortFoldersFirstChanged(foldersFirst
);
961 void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList
& info
)
963 ViewProperties
props(rootUrl());
964 props
.setAdditionalInfo(info
);
967 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
969 emit
additionalInfoChanged();
972 void DolphinView::updateAdditionalInfoActions(KActionCollection
* collection
)
974 const AdditionalInfoAccessor
& infoAccessor
= AdditionalInfoAccessor::instance();
976 const KFileItemDelegate::InformationList checkedInfo
= m_viewAccessor
.itemDelegate()->showInformation();
977 const KFileItemDelegate::InformationList infoKeys
= infoAccessor
.keys();
979 const bool enable
= (m_mode
== DolphinView::DetailsView
) ||
980 (m_mode
== DolphinView::IconsView
);
982 foreach (const KFileItemDelegate::Information
& info
, infoKeys
) {
983 const QString name
= infoAccessor
.actionCollectionName(info
, AdditionalInfoAccessor::AdditionalInfoType
);
984 QAction
* action
= collection
->action(name
);
985 Q_ASSERT(action
!= 0);
986 action
->setEnabled(enable
);
987 action
->setChecked(checkedInfo
.contains(info
));
991 QPair
<bool, QString
> DolphinView::pasteInfo() const
993 return KonqOperations::pasteInfo(url());
996 void DolphinView::setTabsForFilesEnabled(bool tabsForFiles
)
998 m_tabsForFiles
= tabsForFiles
;
1001 bool DolphinView::isTabsForFilesEnabled() const
1003 return m_tabsForFiles
;
1006 bool DolphinView::itemsExpandable() const
1008 return m_viewAccessor
.itemsExpandable();
1011 void DolphinView::restoreState(QDataStream
& stream
)
1014 stream
>> m_activeItemUrl
;
1017 stream
>> m_restoredContentsPosition
;
1019 // expanded folders (only relevant for the details view - will be ignored by the view in other view modes)
1020 QSet
<KUrl
> urlsToExpand
;
1021 stream
>> urlsToExpand
;
1022 const DolphinDetailsViewExpander
* expander
= m_viewAccessor
.setExpandedUrls(urlsToExpand
);
1023 if (expander
!= 0) {
1024 m_expanderActive
= true;
1025 connect (expander
, SIGNAL(completed()), this, SLOT(slotLoadingCompleted()));
1028 m_expanderActive
= false;
1032 void DolphinView::saveState(QDataStream
& stream
)
1035 KFileItem currentItem
;
1036 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
1039 const QModelIndex proxyIndex
= view
->currentIndex();
1040 const QModelIndex dirModelIndex
= m_viewAccessor
.proxyModel()->mapToSource(proxyIndex
);
1041 currentItem
= m_viewAccessor
.dirModel()->itemForIndex(dirModelIndex
);
1045 if (!currentItem
.isNull()) {
1046 currentUrl
= currentItem
.url();
1049 stream
<< currentUrl
;
1052 const int x
= view
->horizontalScrollBar()->value();
1053 const int y
= view
->verticalScrollBar()->value();
1054 stream
<< QPoint(x
, y
);
1056 // expanded folders (only relevant for the details view - the set will be empty in other view modes)
1057 stream
<< m_viewAccessor
.expandedUrls();
1060 void DolphinView::observeCreatedItem(const KUrl
& url
)
1062 m_createdItemUrl
= url
;
1063 connect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
1064 this, SLOT(selectAndScrollToCreatedItem()));
1067 void DolphinView::selectAndScrollToCreatedItem()
1069 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_createdItemUrl
);
1070 if (dirIndex
.isValid()) {
1071 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
1072 m_viewAccessor
.itemView()->setCurrentIndex(proxyIndex
);
1075 disconnect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
1076 this, SLOT(selectAndScrollToCreatedItem()));
1077 m_createdItemUrl
= KUrl();
1080 void DolphinView::showHoverInformation(const KFileItem
& item
)
1082 emit
requestItemInfo(item
);
1085 void DolphinView::clearHoverInformation()
1087 emit
requestItemInfo(KFileItem());
1090 void DolphinView::slotDeleteFileFinished(KJob
* job
)
1092 if (job
->error() == 0) {
1093 emit
operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
1094 } else if (job
->error() != KIO::ERR_USER_CANCELED
) {
1095 emit
errorMessage(job
->errorString());
1099 void DolphinView::slotDirListerCompleted()
1101 if (!m_expanderActive
) {
1102 slotLoadingCompleted();
1105 if (!m_newFileNames
.isEmpty()) {
1106 // select all newly added items created by a paste operation or
1107 // a drag & drop operation, and clear the previous selection
1108 m_viewAccessor
.itemView()->clearSelection();
1109 const int rowCount
= m_viewAccessor
.proxyModel()->rowCount();
1110 QItemSelection selection
;
1111 for (int row
= 0; row
< rowCount
; ++row
) {
1112 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->index(row
, 0);
1113 const QModelIndex dirIndex
= m_viewAccessor
.proxyModel()->mapToSource(proxyIndex
);
1114 const KUrl url
= m_viewAccessor
.dirModel()->itemForIndex(dirIndex
).url();
1115 if (m_newFileNames
.contains(url
.fileName())) {
1116 selection
.merge(QItemSelection(proxyIndex
, proxyIndex
), QItemSelectionModel::Select
);
1119 m_viewAccessor
.itemView()->selectionModel()->select(selection
, QItemSelectionModel::Select
);
1121 m_newFileNames
.clear();
1125 void DolphinView::slotLoadingCompleted()
1127 m_expanderActive
= false;
1129 if (!m_activeItemUrl
.isEmpty()) {
1130 // assure that the current item remains visible
1131 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_activeItemUrl
);
1132 if (dirIndex
.isValid()) {
1133 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
1134 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1135 const bool clearSelection
= !hasSelection();
1136 view
->setCurrentIndex(proxyIndex
);
1137 if (clearSelection
) {
1138 view
->clearSelection();
1140 m_activeItemUrl
.clear();
1144 if (!m_selectedItems
.isEmpty()) {
1145 const KUrl
& baseUrl
= url();
1147 QItemSelection newSelection
;
1148 foreach(const KFileItem
& item
, m_selectedItems
) {
1149 url
= item
.url().upUrl();
1150 if (baseUrl
.equals(url
, KUrl::CompareWithoutTrailingSlash
)) {
1151 QModelIndex index
= m_viewAccessor
.proxyModel()->mapFromSource(m_viewAccessor
.dirModel()->indexForItem(item
));
1152 newSelection
.select(index
, index
);
1155 m_viewAccessor
.itemView()->selectionModel()->select(newSelection
,
1156 QItemSelectionModel::ClearAndSelect
1157 | QItemSelectionModel::Current
);
1158 m_selectedItems
.clear();
1161 // Restore the contents position. This has to be done using a Qt::QueuedConnection
1162 // because the view might not be in its final state yet.
1163 QMetaObject::invokeMethod(this, "restoreContentsPosition", Qt::QueuedConnection
);
1166 void DolphinView::slotRefreshItems()
1168 if (m_assureVisibleCurrentIndex
) {
1169 m_assureVisibleCurrentIndex
= false;
1170 m_viewAccessor
.itemView()->scrollTo(m_viewAccessor
.itemView()->currentIndex());
1174 void DolphinView::loadDirectory(const KUrl
& url
, bool reload
)
1176 if (!url
.isValid()) {
1177 const QString
location(url
.pathOrUrl());
1178 if (location
.isEmpty()) {
1179 emit
errorMessage(i18nc("@info:status", "The location is empty."));
1181 emit
errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location
));
1186 KDirLister
* dirLister
= m_viewAccessor
.dirLister();
1187 dirLister
->openUrl(url
, reload
? KDirLister::Reload
: KDirLister::NoFlags
);
1190 void DolphinView::applyViewProperties()
1192 const ViewProperties
props(rootUrl());
1194 const Mode mode
= props
.viewMode();
1195 if (m_mode
!= mode
) {
1196 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
1202 updateZoomLevel(oldZoomLevel
);
1204 if (m_viewAccessor
.itemView() == 0) {
1207 Q_ASSERT(m_viewAccessor
.itemView() != 0);
1208 Q_ASSERT(m_viewAccessor
.itemDelegate() != 0);
1210 const bool showHiddenFiles
= props
.showHiddenFiles();
1211 if (showHiddenFiles
!= m_viewAccessor
.dirLister()->showingDotFiles()) {
1212 m_viewAccessor
.dirLister()->setShowingDotFiles(showHiddenFiles
);
1213 emit
showHiddenFilesChanged();
1216 m_storedCategorizedSorting
= props
.categorizedSorting();
1217 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
1218 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
1219 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
1220 emit
categorizedSortingChanged();
1223 const DolphinView::Sorting sorting
= props
.sorting();
1224 if (sorting
!= m_viewAccessor
.proxyModel()->sorting()) {
1225 m_viewAccessor
.proxyModel()->setSorting(sorting
);
1226 emit
sortingChanged(sorting
);
1229 const Qt::SortOrder sortOrder
= props
.sortOrder();
1230 if (sortOrder
!= m_viewAccessor
.proxyModel()->sortOrder()) {
1231 m_viewAccessor
.proxyModel()->setSortOrder(sortOrder
);
1232 emit
sortOrderChanged(sortOrder
);
1235 const bool sortFoldersFirst
= props
.sortFoldersFirst();
1236 if (sortFoldersFirst
!= m_viewAccessor
.proxyModel()->sortFoldersFirst()) {
1237 m_viewAccessor
.proxyModel()->setSortFoldersFirst(sortFoldersFirst
);
1238 emit
sortFoldersFirstChanged(sortFoldersFirst
);
1241 KFileItemDelegate::InformationList info
= props
.additionalInfo();
1242 if (info
!= m_viewAccessor
.itemDelegate()->showInformation()) {
1243 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
1244 emit
additionalInfoChanged();
1247 const bool showPreview
= props
.showPreview();
1248 if (showPreview
!= m_showPreview
) {
1249 m_showPreview
= showPreview
;
1250 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
1251 emit
showPreviewChanged();
1253 // Enabling or disabling the preview might change the icon size of the view.
1254 // As the view does not emit a signal when the icon size has been changed,
1255 // the used zoom level of the controller must be adjusted manually:
1256 updateZoomLevel(oldZoomLevel
);
1260 void DolphinView::createView()
1262 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1263 if ((view
!= 0) && (view
->selectionModel() != 0)) {
1264 disconnect(view
->selectionModel(), SIGNAL(selectionChanged(QItemSelection
, QItemSelection
)),
1265 this, SLOT(slotSelectionChanged(QItemSelection
, QItemSelection
)));
1270 Q_ASSERT(m_viewAccessor
.itemView() == 0);
1271 m_viewAccessor
.createView(this, m_dolphinViewController
, m_viewModeController
, m_mode
);
1273 view
= m_viewAccessor
.itemView();
1274 Q_ASSERT(view
!= 0);
1275 view
->installEventFilter(this);
1276 view
->viewport()->installEventFilter(this);
1278 m_dolphinViewController
->setItemView(view
);
1280 const int zoomLevel
= ZoomLevelInfo::zoomLevelForIconSize(view
->iconSize());
1281 m_viewModeController
->setZoomLevel(zoomLevel
);
1283 connect(view
->selectionModel(), SIGNAL(selectionChanged(QItemSelection
, QItemSelection
)),
1284 this, SLOT(slotSelectionChanged(QItemSelection
, QItemSelection
)));
1286 setFocusProxy(m_viewAccessor
.layoutTarget());
1287 m_topLayout
->insertWidget(1, m_viewAccessor
.layoutTarget());
1290 void DolphinView::deleteView()
1292 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1294 // It's important to set the keyboard focus to the parent
1295 // before deleting the view: Otherwise when having a split
1296 // view the other view will get the focus and will request
1297 // an activation (see DolphinView::eventFilter()).
1301 m_topLayout
->removeWidget(view
);
1304 // disconnect all signal/slots
1306 m_viewModeController
->disconnect(view
);
1309 m_viewAccessor
.deleteView();
1313 void DolphinView::pasteToUrl(const KUrl
& url
)
1315 addNewFileNames(QApplication::clipboard()->mimeData());
1316 KonqOperations::doPaste(this, url
);
1319 void DolphinView::updateZoomLevel(int oldZoomLevel
)
1321 const int newZoomLevel
= ZoomLevelInfo::zoomLevelForIconSize(m_viewAccessor
.itemView()->iconSize());
1322 if (oldZoomLevel
!= newZoomLevel
) {
1323 m_viewModeController
->setZoomLevel(newZoomLevel
);
1324 emit
zoomLevelChanged(newZoomLevel
);
1328 KUrl::List
DolphinView::simplifiedSelectedUrls() const
1330 KUrl::List list
= selectedUrls();
1331 if (itemsExpandable() ) {
1332 list
= KDirModel::simplifiedUrlList(list
);
1337 QMimeData
* DolphinView::selectionMimeData() const
1339 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
1340 Q_ASSERT((view
!= 0) && (view
->selectionModel() != 0));
1341 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
1342 return m_viewAccessor
.dirModel()->mimeData(selection
.indexes());
1345 void DolphinView::addNewFileNames(const QMimeData
* mimeData
)
1347 const KUrl::List urls
= KUrl::List::fromMimeData(mimeData
);
1348 foreach (const KUrl
& url
, urls
) {
1349 m_newFileNames
.insert(url
.fileName());
1353 DolphinView::ViewAccessor::ViewAccessor(DolphinSortFilterProxyModel
* proxyModel
) :
1356 m_columnsContainer(0),
1357 m_proxyModel(proxyModel
),
1362 DolphinView::ViewAccessor::~ViewAccessor()
1364 delete m_dragSource
;
1368 void DolphinView::ViewAccessor::createView(QWidget
* parent
,
1369 DolphinViewController
* dolphinViewController
,
1370 const ViewModeController
* viewModeController
,
1373 Q_ASSERT(itemView() == 0);
1377 m_iconsView
= new DolphinIconsView(parent
,
1378 dolphinViewController
,
1384 m_detailsView
= new DolphinDetailsView(parent
,
1385 dolphinViewController
,
1391 m_columnsContainer
= new DolphinColumnViewContainer(parent
,
1392 dolphinViewController
,
1393 viewModeController
);
1401 void DolphinView::ViewAccessor::deleteView()
1403 QAbstractItemView
* view
= itemView();
1405 if (DragAndDropHelper::instance().isDragSource(view
)) {
1406 // The view is a drag source (the feature "Open folders
1407 // during drag operations" is used). Deleting the view
1408 // during an ongoing drag operation is not allowed, so
1409 // this will postponed.
1410 if (m_dragSource
!= 0) {
1411 // the old stored view is obviously not the drag source anymore
1412 m_dragSource
->deleteLater();
1416 m_dragSource
= view
;
1418 view
->deleteLater();
1425 if (m_columnsContainer
!= 0) {
1426 m_columnsContainer
->deleteLater();
1428 m_columnsContainer
= 0;
1432 void DolphinView::ViewAccessor::prepareUrlChange(const KUrl
& url
)
1434 if (m_columnsContainer
!= 0) {
1435 m_columnsContainer
->showColumn(url
);
1439 QAbstractItemView
* DolphinView::ViewAccessor::itemView() const
1441 if (m_iconsView
!= 0) {
1445 if (m_detailsView
!= 0) {
1446 return m_detailsView
;
1449 if (m_columnsContainer
!= 0) {
1450 return m_columnsContainer
->activeColumn();
1456 KFileItemDelegate
* DolphinView::ViewAccessor::itemDelegate() const
1458 return static_cast<KFileItemDelegate
*>(itemView()->itemDelegate());
1461 QWidget
* DolphinView::ViewAccessor::layoutTarget() const
1463 if (m_columnsContainer
!= 0) {
1464 return m_columnsContainer
;
1469 KUrl
DolphinView::ViewAccessor::rootUrl() const
1471 return (m_columnsContainer
!= 0) ? m_columnsContainer
->rootUrl() : KUrl();
1474 bool DolphinView::ViewAccessor::supportsCategorizedSorting() const
1476 return m_iconsView
!= 0;
1479 bool DolphinView::ViewAccessor::itemsExpandable() const
1481 return (m_detailsView
!= 0) && m_detailsView
->itemsExpandable();
1485 QSet
<KUrl
> DolphinView::ViewAccessor::expandedUrls() const
1487 if (m_detailsView
!= 0) {
1488 return m_detailsView
->expandedUrls();
1491 return QSet
<KUrl
>();
1494 const DolphinDetailsViewExpander
* DolphinView::ViewAccessor::setExpandedUrls(const QSet
<KUrl
>& urlsToExpand
)
1496 if ((m_detailsView
!= 0) && m_detailsView
->itemsExpandable() && !urlsToExpand
.isEmpty()) {
1497 // Check if another expander is already active and stop it if necessary.
1498 if(!m_detailsViewExpander
.isNull()) {
1499 m_detailsViewExpander
->stop();
1502 m_detailsViewExpander
= new DolphinDetailsViewExpander(m_detailsView
, urlsToExpand
);
1503 return m_detailsViewExpander
;
1510 bool DolphinView::ViewAccessor::reloadOnAdditionalInfoChange() const
1512 // the details view requires no reloading of the directory, as it maps
1513 // the file item delegate info to its columns internally
1514 return m_detailsView
!= 0;
1517 DolphinModel
* DolphinView::ViewAccessor::dirModel() const
1519 return static_cast<DolphinModel
*>(proxyModel()->sourceModel());
1522 DolphinSortFilterProxyModel
* DolphinView::ViewAccessor::proxyModel() const
1524 if (m_columnsContainer
!= 0) {
1525 return static_cast<DolphinSortFilterProxyModel
*>(m_columnsContainer
->activeColumn()->model());
1527 return m_proxyModel
;
1530 KDirLister
* DolphinView::ViewAccessor::dirLister() const
1532 return dirModel()->dirLister();
1535 void DolphinView::slotRedirection(const KUrl
& oldUrl
, const KUrl
& newUrl
)
1537 if (oldUrl
.equals(url(), KUrl::CompareWithoutTrailingSlash
)) {
1538 emit
redirection(oldUrl
, newUrl
);
1539 m_viewModeController
->redirectToUrl(newUrl
); // #186947
1543 void DolphinView::restoreContentsPosition()
1545 if (!m_restoredContentsPosition
.isNull()) {
1546 const int x
= m_restoredContentsPosition
.x();
1547 const int y
= m_restoredContentsPosition
.y();
1548 m_restoredContentsPosition
= QPoint();
1550 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1551 Q_ASSERT(view
!= 0);
1552 view
->horizontalScrollBar()->setValue(x
);
1553 view
->verticalScrollBar()->setValue(y
);
1557 #include "dolphinview.moc"