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 "dolphinviewcontroller.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 "viewmodecontroller.h"
66 #include "viewproperties.h"
67 #include "zoomlevelinfo.h"
68 #include "dolphindetailsviewexpander.h"
71 * Helper function for sorting items with qSort() in
72 * DolphinView::renameSelectedItems().
74 bool lessThan(const KFileItem
& item1
, const KFileItem
& item2
)
76 return KStringHandler::naturalCompare(item1
.name(), item2
.name()) < 0;
79 DolphinView::DolphinView(QWidget
* parent
,
81 DolphinSortFilterProxyModel
* proxyModel
) :
85 m_storedCategorizedSorting(false),
86 m_tabsForFiles(false),
87 m_isContextMenuOpen(false),
88 m_ignoreViewProperties(false),
89 m_assureVisibleCurrentIndex(false),
90 m_mode(DolphinView::IconsView
),
92 m_dolphinViewController(0),
93 m_viewModeController(0),
94 m_viewAccessor(proxyModel
),
96 m_selectionChangedTimer(0),
99 m_restoredContentsPosition(),
104 m_topLayout
= new QVBoxLayout(this);
105 m_topLayout
->setSpacing(0);
106 m_topLayout
->setMargin(0);
108 m_dolphinViewController
= new DolphinViewController(this);
110 m_viewModeController
= new ViewModeController(this);
111 m_viewModeController
->setUrl(url
);
113 connect(m_viewModeController
, SIGNAL(urlChanged(const KUrl
&)),
114 this, SIGNAL(urlChanged(const KUrl
&)));
116 connect(m_dolphinViewController
, SIGNAL(requestContextMenu(const QPoint
&, const QList
<QAction
*>&)),
117 this, SLOT(openContextMenu(const QPoint
&, const QList
<QAction
*>&)));
118 connect(m_dolphinViewController
, SIGNAL(urlsDropped(const KFileItem
&, const KUrl
&, QDropEvent
*)),
119 this, SLOT(dropUrls(const KFileItem
&, const KUrl
&, QDropEvent
*)));
120 connect(m_dolphinViewController
, SIGNAL(sortingChanged(DolphinView::Sorting
)),
121 this, SLOT(updateSorting(DolphinView::Sorting
)));
122 connect(m_dolphinViewController
, SIGNAL(sortOrderChanged(Qt::SortOrder
)),
123 this, SLOT(updateSortOrder(Qt::SortOrder
)));
124 connect(m_dolphinViewController
, SIGNAL(sortFoldersFirstChanged(bool)),
125 this, SLOT(updateSortFoldersFirst(bool)));
126 connect(m_dolphinViewController
, SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList
&)),
127 this, SLOT(updateAdditionalInfo(const KFileItemDelegate::InformationList
&)));
128 connect(m_dolphinViewController
, SIGNAL(itemTriggered(const KFileItem
&)),
129 this, SLOT(triggerItem(const KFileItem
&)));
130 connect(m_dolphinViewController
, SIGNAL(tabRequested(const KUrl
&)),
131 this, SIGNAL(tabRequested(const KUrl
&)));
132 connect(m_dolphinViewController
, SIGNAL(activated()),
133 this, SLOT(activate()));
134 connect(m_dolphinViewController
, SIGNAL(itemEntered(const KFileItem
&)),
135 this, SLOT(showHoverInformation(const KFileItem
&)));
136 connect(m_dolphinViewController
, SIGNAL(viewportEntered()),
137 this, SLOT(clearHoverInformation()));
138 connect(m_dolphinViewController
, SIGNAL(urlChangeRequested(KUrl
)),
139 m_viewModeController
, SLOT(setUrl(KUrl
)));
141 KDirLister
* dirLister
= m_viewAccessor
.dirLister();
142 connect(dirLister
, SIGNAL(redirection(KUrl
,KUrl
)),
143 this, SLOT(slotRedirection(KUrl
,KUrl
)));
144 connect(dirLister
, SIGNAL(completed()),
145 this, SLOT(slotDirListerCompleted()));
146 connect(dirLister
, SIGNAL(refreshItems(const QList
<QPair
<KFileItem
,KFileItem
>>&)),
147 this, SLOT(slotRefreshItems()));
149 // When a new item has been created by the "Create New..." menu, the item should
150 // get selected and it must be assured that the item will get visible. As the
151 // creation is done asynchronously, several signals must be checked:
152 connect(&DolphinNewMenuObserver::instance(), SIGNAL(itemCreated(const KUrl
&)),
153 this, SLOT(observeCreatedItem(const KUrl
&)));
155 m_selectionChangedTimer
= new QTimer(this);
156 m_selectionChangedTimer
->setSingleShot(true);
157 m_selectionChangedTimer
->setInterval(300);
158 connect(m_selectionChangedTimer
, SIGNAL(timeout()),
159 this, SLOT(emitSelectionChangedSignal()));
161 applyViewProperties();
162 m_topLayout
->addWidget(m_viewAccessor
.layoutTarget());
165 DolphinView::~DolphinView()
169 KUrl
DolphinView::url() const
171 return m_viewModeController
->url();
174 KUrl
DolphinView::rootUrl() const
176 const KUrl viewUrl
= url();
177 const KUrl root
= m_viewAccessor
.rootUrl();
178 if (root
.isEmpty() || !root
.isParentOf(viewUrl
)) {
184 void DolphinView::setActive(bool active
)
186 if (active
== m_active
) {
192 QColor color
= KColorScheme(QPalette::Active
, KColorScheme::View
).background().color();
194 emitSelectionChangedSignal();
199 QWidget
* viewport
= m_viewAccessor
.itemView()->viewport();
201 palette
.setColor(viewport
->backgroundRole(), color
);
202 viewport
->setPalette(palette
);
207 m_viewAccessor
.itemView()->setFocus();
211 m_viewModeController
->indicateActivationChange(active
);
214 bool DolphinView::isActive() const
219 void DolphinView::setMode(Mode mode
)
221 if (mode
== m_mode
) {
222 return; // the wished mode is already set
225 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
228 // remember the currently selected items, so that they will
229 // be restored after reloading the directory
230 m_selectedItems
= selectedItems();
234 const KUrl viewPropsUrl
= rootUrl();
235 ViewProperties
props(viewPropsUrl
);
236 props
.setViewMode(m_mode
);
239 // the file item delegate has been recreated, apply the current
240 // additional information manually
241 const KFileItemDelegate::InformationList infoList
= props
.additionalInfo();
242 m_viewAccessor
.itemDelegate()->setShowInformation(infoList
);
243 emit
additionalInfoChanged();
245 // Not all view modes support categorized sorting. Adjust the sorting model
246 // if changing the view mode results in a change of the categorized sorting
248 m_storedCategorizedSorting
= props
.categorizedSorting();
249 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
250 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
251 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
252 emit
categorizedSortingChanged();
257 updateZoomLevel(oldZoomLevel
);
258 loadDirectory(viewPropsUrl
);
261 DolphinView::Mode
DolphinView::mode() const
266 bool DolphinView::showPreview() const
268 return m_showPreview
;
271 bool DolphinView::showHiddenFiles() const
273 return m_viewAccessor
.dirLister()->showingDotFiles();
276 bool DolphinView::categorizedSorting() const
278 // If all view modes would support categorized sorting, returning
279 // m_viewAccessor.proxyModel()->isCategorizedModel() would be the way to go. As
280 // currently only the icons view supports caterized sorting, we remember
281 // the stored view properties state in m_storedCategorizedSorting and
282 // return this state. The application takes care to disable the corresponding
283 // checkbox by checking DolphinView::supportsCategorizedSorting() to indicate
284 // that this setting is not applied to the current view mode.
285 return m_storedCategorizedSorting
;
288 bool DolphinView::supportsCategorizedSorting() const
290 return m_viewAccessor
.supportsCategorizedSorting();
293 bool DolphinView::hasSelection() const
295 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
296 return (view
!= 0) && view
->selectionModel()->hasSelection();
299 void DolphinView::markUrlsAsSelected(const QList
<KUrl
>& urls
)
301 foreach (const KUrl
& url
, urls
) {
302 KFileItem
item(KFileItem::Unknown
, KFileItem::Unknown
, url
);
303 m_selectedItems
.append(item
);
307 KFileItemList
DolphinView::selectedItems() const
309 KFileItemList itemList
;
310 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
315 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
317 const QModelIndexList indexList
= selection
.indexes();
318 foreach (const QModelIndex
&index
, indexList
) {
319 KFileItem item
= m_viewAccessor
.dirModel()->itemForIndex(index
);
320 if (!item
.isNull()) {
321 itemList
.append(item
);
328 KUrl::List
DolphinView::selectedUrls() const
331 const KFileItemList list
= selectedItems();
332 foreach (const KFileItem
&item
, list
) {
333 urls
.append(item
.url());
338 int DolphinView::selectedItemsCount() const
340 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
345 return view
->selectionModel()->selectedIndexes().count();
348 QItemSelectionModel
* DolphinView::selectionModel() const
350 return m_viewAccessor
.itemView()->selectionModel();
353 void DolphinView::setZoomLevel(int level
)
355 if (level
< ZoomLevelInfo::minimumLevel()) {
356 level
= ZoomLevelInfo::minimumLevel();
357 } else if (level
> ZoomLevelInfo::maximumLevel()) {
358 level
= ZoomLevelInfo::maximumLevel();
361 if (level
!= zoomLevel()) {
362 m_viewModeController
->setZoomLevel(level
);
363 emit
zoomLevelChanged(level
);
367 int DolphinView::zoomLevel() const
369 return m_viewModeController
->zoomLevel();
372 void DolphinView::setSorting(Sorting sorting
)
374 if (sorting
!= this->sorting()) {
375 updateSorting(sorting
);
379 DolphinView::Sorting
DolphinView::sorting() const
381 return m_viewAccessor
.proxyModel()->sorting();
384 void DolphinView::setSortOrder(Qt::SortOrder order
)
386 if (sortOrder() != order
) {
387 updateSortOrder(order
);
391 Qt::SortOrder
DolphinView::sortOrder() const
393 return m_viewAccessor
.proxyModel()->sortOrder();
396 void DolphinView::setSortFoldersFirst(bool foldersFirst
)
398 if (sortFoldersFirst() != foldersFirst
) {
399 updateSortFoldersFirst(foldersFirst
);
403 bool DolphinView::sortFoldersFirst() const
405 return m_viewAccessor
.proxyModel()->sortFoldersFirst();
408 void DolphinView::setAdditionalInfo(KFileItemDelegate::InformationList info
)
410 const KUrl viewPropsUrl
= rootUrl();
411 ViewProperties
props(viewPropsUrl
);
412 props
.setAdditionalInfo(info
);
413 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
415 emit
additionalInfoChanged();
417 if (m_viewAccessor
.reloadOnAdditionalInfoChange()) {
418 loadDirectory(viewPropsUrl
);
422 KFileItemDelegate::InformationList
DolphinView::additionalInfo() const
424 return m_viewAccessor
.itemDelegate()->showInformation();
427 void DolphinView::reload()
429 QByteArray viewState
;
430 QDataStream
saveStream(&viewState
, QIODevice::WriteOnly
);
431 saveState(saveStream
);
432 m_selectedItems
= selectedItems();
435 loadDirectory(url(), true);
437 QDataStream
restoreStream(viewState
);
438 restoreState(restoreStream
);
441 void DolphinView::refresh()
443 m_ignoreViewProperties
= false;
445 const bool oldActivationState
= m_active
;
446 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
450 applyViewProperties();
453 setActive(oldActivationState
);
454 updateZoomLevel(oldZoomLevel
);
457 void DolphinView::setNameFilter(const QString
& nameFilter
)
459 m_viewModeController
->setNameFilter(nameFilter
);
462 void DolphinView::calculateItemCount(int& fileCount
,
464 KIO::filesize_t
& totalFileSize
) const
466 foreach (const KFileItem
& item
, m_viewAccessor
.dirLister()->items()) {
471 totalFileSize
+= item
.size();
476 QString
DolphinView::statusBarText() const
481 KIO::filesize_t totalFileSize
= 0;
483 if (hasSelection()) {
484 // give a summary of the status of the selected files
485 const KFileItemList list
= selectedItems();
486 if (list
.isEmpty()) {
487 // when an item is triggered, it is temporary selected but selectedItems()
488 // will return an empty list
492 KFileItemList::const_iterator it
= list
.begin();
493 const KFileItemList::const_iterator end
= list
.end();
495 const KFileItem
& item
= *it
;
500 totalFileSize
+= item
.size();
505 if (folderCount
+ fileCount
== 1) {
506 // if only one item is selected, show the filename
507 const QString name
= list
.first().text();
508 text
= (folderCount
== 1) ? i18nc("@info:status", "<filename>%1</filename> selected", name
) :
509 i18nc("@info:status", "<filename>%1</filename> selected (%2)",
510 name
, KIO::convertSize(totalFileSize
));
512 // at least 2 items are selected
513 const QString foldersText
= i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount
);
514 const QString filesText
= i18ncp("@info:status", "1 File selected", "%1 Files selected", fileCount
);
515 if ((folderCount
> 0) && (fileCount
> 0)) {
516 text
= i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
517 foldersText
, filesText
, KIO::convertSize(totalFileSize
));
518 } else if (fileCount
> 0) {
519 text
= i18nc("@info:status files (size)", "%1 (%2)", filesText
, KIO::convertSize(totalFileSize
));
521 Q_ASSERT(folderCount
> 0);
526 calculateItemCount(fileCount
, folderCount
, totalFileSize
);
527 text
= KIO::itemsSummaryString(fileCount
+ folderCount
,
528 fileCount
, folderCount
,
529 totalFileSize
, true);
535 QList
<QAction
*> DolphinView::versionControlActions(const KFileItemList
& items
) const
537 return m_dolphinViewController
->versionControlActions(items
);
540 void DolphinView::setUrl(const KUrl
& url
)
542 if (m_viewModeController
->url() != url
) {
543 m_newFileNames
.clear();
545 m_viewModeController
->setUrl(url
); // emits urlChanged, which we forward
546 m_viewAccessor
.prepareUrlChange(url
);
547 applyViewProperties();
550 // When changing the URL there is no need to keep the version
551 // data of the previous URL.
552 m_viewAccessor
.dirModel()->clearVersionData();
554 emit
startedPathLoading(url
);
557 // the selection model might have changed in the case of a column view
558 QItemSelectionModel
* selectionModel
= m_viewAccessor
.itemView()->selectionModel();
559 if (m_selectionModel
!= selectionModel
) {
560 disconnect(m_selectionModel
, SIGNAL(selectionChanged(QItemSelection
, QItemSelection
)),
561 this, SLOT(slotSelectionChanged(QItemSelection
, QItemSelection
)));
562 m_selectionModel
= selectionModel
;
563 connect(m_selectionModel
, SIGNAL(selectionChanged(QItemSelection
, QItemSelection
)),
564 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 bool enable
= (m_mode
== DolphinView::DetailsView
) ||
975 (m_mode
== DolphinView::IconsView
);
977 QAction
* showSizeInfo
= collection
->action("show_size_info");
978 QAction
* showDateInfo
= collection
->action("show_date_info");
979 QAction
* showPermissionsInfo
= collection
->action("show_permissions_info");
980 QAction
* showOwnerInfo
= collection
->action("show_owner_info");
981 QAction
* showGroupInfo
= collection
->action("show_group_info");
982 QAction
* showMimeInfo
= collection
->action("show_mime_info");
984 showSizeInfo
->setChecked(false);
985 showDateInfo
->setChecked(false);
986 showPermissionsInfo
->setChecked(false);
987 showOwnerInfo
->setChecked(false);
988 showGroupInfo
->setChecked(false);
989 showMimeInfo
->setChecked(false);
991 showSizeInfo
->setEnabled(enable
);
992 showDateInfo
->setEnabled(enable
);
993 showPermissionsInfo
->setEnabled(enable
);
994 showOwnerInfo
->setEnabled(enable
);
995 showGroupInfo
->setEnabled(enable
);
996 showMimeInfo
->setEnabled(enable
);
998 foreach (KFileItemDelegate::Information info
, m_viewAccessor
.itemDelegate()->showInformation()) {
1000 case KFileItemDelegate::Size
:
1001 showSizeInfo
->setChecked(true);
1003 case KFileItemDelegate::ModificationTime
:
1004 showDateInfo
->setChecked(true);
1006 case KFileItemDelegate::Permissions
:
1007 showPermissionsInfo
->setChecked(true);
1009 case KFileItemDelegate::Owner
:
1010 showOwnerInfo
->setChecked(true);
1012 case KFileItemDelegate::OwnerAndGroup
:
1013 showGroupInfo
->setChecked(true);
1015 case KFileItemDelegate::FriendlyMimeType
:
1016 showMimeInfo
->setChecked(true);
1024 QPair
<bool, QString
> DolphinView::pasteInfo() const
1026 return KonqOperations::pasteInfo(url());
1029 void DolphinView::setTabsForFilesEnabled(bool tabsForFiles
)
1031 m_tabsForFiles
= tabsForFiles
;
1034 bool DolphinView::isTabsForFilesEnabled() const
1036 return m_tabsForFiles
;
1039 bool DolphinView::itemsExpandable() const
1041 return m_viewAccessor
.itemsExpandable();
1044 void DolphinView::restoreState(QDataStream
& stream
)
1047 stream
>> m_activeItemUrl
;
1050 stream
>> m_restoredContentsPosition
;
1052 // expanded folders (only relevant for the details view - will be ignored by the view in other view modes)
1053 QSet
<KUrl
> urlsToExpand
;
1054 stream
>> urlsToExpand
;
1055 const DolphinDetailsViewExpander
* expander
= m_viewAccessor
.setExpandedUrls(urlsToExpand
);
1056 if (expander
!= 0) {
1057 m_expanderActive
= true;
1058 connect (expander
, SIGNAL(completed()), this, SLOT(slotLoadingCompleted()));
1061 m_expanderActive
= false;
1065 void DolphinView::saveState(QDataStream
& stream
)
1068 KFileItem currentItem
;
1069 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
1072 const QModelIndex proxyIndex
= view
->currentIndex();
1073 const QModelIndex dirModelIndex
= m_viewAccessor
.proxyModel()->mapToSource(proxyIndex
);
1074 currentItem
= m_viewAccessor
.dirModel()->itemForIndex(dirModelIndex
);
1078 if (!currentItem
.isNull()) {
1079 currentUrl
= currentItem
.url();
1082 stream
<< currentUrl
;
1085 const int x
= view
->horizontalScrollBar()->value();
1086 const int y
= view
->verticalScrollBar()->value();
1087 stream
<< QPoint(x
, y
);
1089 // expanded folders (only relevant for the details view - the set will be empty in other view modes)
1090 stream
<< m_viewAccessor
.expandedUrls();
1093 void DolphinView::observeCreatedItem(const KUrl
& url
)
1095 m_createdItemUrl
= url
;
1096 connect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
1097 this, SLOT(selectAndScrollToCreatedItem()));
1100 void DolphinView::selectAndScrollToCreatedItem()
1102 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_createdItemUrl
);
1103 if (dirIndex
.isValid()) {
1104 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
1105 m_viewAccessor
.itemView()->setCurrentIndex(proxyIndex
);
1108 disconnect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
1109 this, SLOT(selectAndScrollToCreatedItem()));
1110 m_createdItemUrl
= KUrl();
1113 void DolphinView::showHoverInformation(const KFileItem
& item
)
1115 emit
requestItemInfo(item
);
1118 void DolphinView::clearHoverInformation()
1120 emit
requestItemInfo(KFileItem());
1123 void DolphinView::slotDeleteFileFinished(KJob
* job
)
1125 if (job
->error() == 0) {
1126 emit
operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
1127 } else if (job
->error() != KIO::ERR_USER_CANCELED
) {
1128 emit
errorMessage(job
->errorString());
1132 void DolphinView::slotDirListerCompleted()
1134 if (!m_expanderActive
) {
1135 slotLoadingCompleted();
1138 if (!m_newFileNames
.isEmpty()) {
1139 // select all newly added items created by a paste operation or
1140 // a drag & drop operation
1141 const int rowCount
= m_viewAccessor
.proxyModel()->rowCount();
1142 QItemSelection selection
;
1143 for (int row
= 0; row
< rowCount
; ++row
) {
1144 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->index(row
, 0);
1145 const QModelIndex dirIndex
= m_viewAccessor
.proxyModel()->mapToSource(proxyIndex
);
1146 const KUrl url
= m_viewAccessor
.dirModel()->itemForIndex(dirIndex
).url();
1147 if (m_newFileNames
.contains(url
.fileName())) {
1148 selection
.merge(QItemSelection(proxyIndex
, proxyIndex
), QItemSelectionModel::Select
);
1151 m_viewAccessor
.itemView()->selectionModel()->select(selection
, QItemSelectionModel::Select
);
1153 m_newFileNames
.clear();
1157 void DolphinView::slotLoadingCompleted()
1159 m_expanderActive
= false;
1161 if (!m_activeItemUrl
.isEmpty()) {
1162 // assure that the current item remains visible
1163 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_activeItemUrl
);
1164 if (dirIndex
.isValid()) {
1165 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
1166 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1167 const bool clearSelection
= !hasSelection();
1168 view
->setCurrentIndex(proxyIndex
);
1169 if (clearSelection
) {
1170 view
->clearSelection();
1172 m_activeItemUrl
.clear();
1176 if (!m_selectedItems
.isEmpty()) {
1177 const KUrl
& baseUrl
= url();
1179 QItemSelection newSelection
;
1180 foreach(const KFileItem
& item
, m_selectedItems
) {
1181 url
= item
.url().upUrl();
1182 if (baseUrl
.equals(url
, KUrl::CompareWithoutTrailingSlash
)) {
1183 QModelIndex index
= m_viewAccessor
.proxyModel()->mapFromSource(m_viewAccessor
.dirModel()->indexForItem(item
));
1184 newSelection
.select(index
, index
);
1187 m_viewAccessor
.itemView()->selectionModel()->select(newSelection
,
1188 QItemSelectionModel::ClearAndSelect
1189 | QItemSelectionModel::Current
);
1190 m_selectedItems
.clear();
1193 // Restore the contents position. This has to be done using a Qt::QueuedConnection
1194 // because the view might not be in its final state yet.
1195 QMetaObject::invokeMethod(this, "restoreContentsPosition", Qt::QueuedConnection
);
1198 void DolphinView::slotRefreshItems()
1200 if (m_assureVisibleCurrentIndex
) {
1201 m_assureVisibleCurrentIndex
= false;
1202 m_viewAccessor
.itemView()->scrollTo(m_viewAccessor
.itemView()->currentIndex());
1206 void DolphinView::loadDirectory(const KUrl
& url
, bool reload
)
1208 if (!url
.isValid()) {
1209 const QString
location(url
.pathOrUrl());
1210 if (location
.isEmpty()) {
1211 emit
errorMessage(i18nc("@info:status", "The location is empty."));
1213 emit
errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location
));
1218 KDirLister
* dirLister
= m_viewAccessor
.dirLister();
1219 dirLister
->openUrl(url
, reload
? KDirLister::Reload
: KDirLister::NoFlags
);
1222 void DolphinView::applyViewProperties()
1224 if (m_ignoreViewProperties
) {
1228 const ViewProperties
props(rootUrl());
1230 const Mode mode
= props
.viewMode();
1231 if (m_mode
!= mode
) {
1232 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
1238 updateZoomLevel(oldZoomLevel
);
1240 if (m_viewAccessor
.itemView() == 0) {
1243 Q_ASSERT(m_viewAccessor
.itemView() != 0);
1244 Q_ASSERT(m_viewAccessor
.itemDelegate() != 0);
1246 const bool showHiddenFiles
= props
.showHiddenFiles();
1247 if (showHiddenFiles
!= m_viewAccessor
.dirLister()->showingDotFiles()) {
1248 m_viewAccessor
.dirLister()->setShowingDotFiles(showHiddenFiles
);
1249 emit
showHiddenFilesChanged();
1252 m_storedCategorizedSorting
= props
.categorizedSorting();
1253 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
1254 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
1255 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
1256 emit
categorizedSortingChanged();
1259 const DolphinView::Sorting sorting
= props
.sorting();
1260 if (sorting
!= m_viewAccessor
.proxyModel()->sorting()) {
1261 m_viewAccessor
.proxyModel()->setSorting(sorting
);
1262 emit
sortingChanged(sorting
);
1265 const Qt::SortOrder sortOrder
= props
.sortOrder();
1266 if (sortOrder
!= m_viewAccessor
.proxyModel()->sortOrder()) {
1267 m_viewAccessor
.proxyModel()->setSortOrder(sortOrder
);
1268 emit
sortOrderChanged(sortOrder
);
1271 const bool sortFoldersFirst
= props
.sortFoldersFirst();
1272 if (sortFoldersFirst
!= m_viewAccessor
.proxyModel()->sortFoldersFirst()) {
1273 m_viewAccessor
.proxyModel()->setSortFoldersFirst(sortFoldersFirst
);
1274 emit
sortFoldersFirstChanged(sortFoldersFirst
);
1277 KFileItemDelegate::InformationList info
= props
.additionalInfo();
1278 if (info
!= m_viewAccessor
.itemDelegate()->showInformation()) {
1279 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
1280 emit
additionalInfoChanged();
1283 const bool showPreview
= props
.showPreview();
1284 if (showPreview
!= m_showPreview
) {
1285 m_showPreview
= showPreview
;
1286 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
1287 emit
showPreviewChanged();
1289 // Enabling or disabling the preview might change the icon size of the view.
1290 // As the view does not emit a signal when the icon size has been changed,
1291 // the used zoom level of the controller must be adjusted manually:
1292 updateZoomLevel(oldZoomLevel
);
1295 if (DolphinSettings::instance().generalSettings()->globalViewProps()) {
1296 // During the lifetime of a DolphinView instance the global view properties
1297 // should not be changed. This allows e. g. to split a view and use different
1298 // view properties for each view.
1299 m_ignoreViewProperties
= true;
1303 void DolphinView::createView()
1307 Q_ASSERT(m_viewAccessor
.itemView() == 0);
1308 m_viewAccessor
.createView(this, m_dolphinViewController
, m_viewModeController
, m_mode
);
1310 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1311 Q_ASSERT(view
!= 0);
1312 view
->installEventFilter(this);
1313 view
->viewport()->installEventFilter(this);
1315 m_dolphinViewController
->setItemView(view
);
1317 // When changing the view mode, the selection is lost due to reinstantiating
1318 // a new item view with a custom selection model. Pass the ownership of the
1319 // selection model to DolphinView, so that it can be shared by all item views.
1320 if (m_selectionModel
!= 0) {
1321 view
->setSelectionModel(m_selectionModel
);
1323 m_selectionModel
= view
->selectionModel();
1325 m_selectionModel
->setParent(this);
1326 connect(m_selectionModel
, SIGNAL(selectionChanged(QItemSelection
, QItemSelection
)),
1327 this, SLOT(slotSelectionChanged(QItemSelection
, QItemSelection
)));
1329 setFocusProxy(m_viewAccessor
.layoutTarget());
1330 m_topLayout
->insertWidget(1, m_viewAccessor
.layoutTarget());
1333 void DolphinView::deleteView()
1335 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1337 // It's important to set the keyboard focus to the parent
1338 // before deleting the view: Otherwise when having a split
1339 // view the other view will get the focus and will request
1340 // an activation (see DolphinView::eventFilter()).
1344 m_topLayout
->removeWidget(view
);
1347 // disconnect all signal/slots
1349 m_viewModeController
->disconnect(view
);
1352 m_viewAccessor
.deleteView();
1356 void DolphinView::pasteToUrl(const KUrl
& url
)
1358 addNewFileNames(QApplication::clipboard()->mimeData());
1359 KonqOperations::doPaste(this, url
);
1362 void DolphinView::updateZoomLevel(int oldZoomLevel
)
1364 const int newZoomLevel
= ZoomLevelInfo::zoomLevelForIconSize(m_viewAccessor
.itemView()->iconSize());
1365 if (oldZoomLevel
!= newZoomLevel
) {
1366 m_viewModeController
->setZoomLevel(newZoomLevel
);
1367 emit
zoomLevelChanged(newZoomLevel
);
1371 KUrl::List
DolphinView::simplifiedSelectedUrls() const
1373 KUrl::List list
= selectedUrls();
1374 if (itemsExpandable() ) {
1375 list
= KDirModel::simplifiedUrlList(list
);
1380 QMimeData
* DolphinView::selectionMimeData() const
1382 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
1383 Q_ASSERT((view
!= 0) && (view
->selectionModel() != 0));
1384 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
1385 return m_viewAccessor
.dirModel()->mimeData(selection
.indexes());
1388 void DolphinView::addNewFileNames(const QMimeData
* mimeData
)
1390 const KUrl::List urls
= KUrl::List::fromMimeData(mimeData
);
1391 foreach (const KUrl
& url
, urls
) {
1392 m_newFileNames
.insert(url
.fileName());
1396 DolphinView::ViewAccessor::ViewAccessor(DolphinSortFilterProxyModel
* proxyModel
) :
1399 m_columnsContainer(0),
1400 m_proxyModel(proxyModel
),
1405 DolphinView::ViewAccessor::~ViewAccessor()
1407 delete m_dragSource
;
1411 void DolphinView::ViewAccessor::createView(QWidget
* parent
,
1412 DolphinViewController
* dolphinViewController
,
1413 const ViewModeController
* viewModeController
,
1416 Q_ASSERT(itemView() == 0);
1420 m_iconsView
= new DolphinIconsView(parent
,
1421 dolphinViewController
,
1427 m_detailsView
= new DolphinDetailsView(parent
,
1428 dolphinViewController
,
1434 m_columnsContainer
= new DolphinColumnViewContainer(parent
,
1435 dolphinViewController
,
1436 viewModeController
);
1444 void DolphinView::ViewAccessor::deleteView()
1446 QAbstractItemView
* view
= itemView();
1448 if (DragAndDropHelper::instance().isDragSource(view
)) {
1449 // The view is a drag source (the feature "Open folders
1450 // during drag operations" is used). Deleting the view
1451 // during an ongoing drag operation is not allowed, so
1452 // this will postponed.
1453 if (m_dragSource
!= 0) {
1454 // the old stored view is obviously not the drag source anymore
1455 m_dragSource
->deleteLater();
1459 m_dragSource
= view
;
1461 view
->deleteLater();
1468 if (m_columnsContainer
!= 0) {
1469 m_columnsContainer
->deleteLater();
1471 m_columnsContainer
= 0;
1475 void DolphinView::ViewAccessor::prepareUrlChange(const KUrl
& url
)
1477 if (m_columnsContainer
!= 0) {
1478 m_columnsContainer
->showColumn(url
);
1482 QAbstractItemView
* DolphinView::ViewAccessor::itemView() const
1484 if (m_iconsView
!= 0) {
1488 if (m_detailsView
!= 0) {
1489 return m_detailsView
;
1492 if (m_columnsContainer
!= 0) {
1493 return m_columnsContainer
->activeColumn();
1499 KFileItemDelegate
* DolphinView::ViewAccessor::itemDelegate() const
1501 return static_cast<KFileItemDelegate
*>(itemView()->itemDelegate());
1504 QWidget
* DolphinView::ViewAccessor::layoutTarget() const
1506 if (m_columnsContainer
!= 0) {
1507 return m_columnsContainer
;
1512 KUrl
DolphinView::ViewAccessor::rootUrl() const
1514 return (m_columnsContainer
!= 0) ? m_columnsContainer
->rootUrl() : KUrl();
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_viewModeController
->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"