1 /***************************************************************************
2 * Copyright (C) 2006 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 <QApplication>
26 #include <QItemSelection>
31 #include <kactioncollection.h>
32 #include <kcolorscheme.h>
33 #include <kdirlister.h>
34 #include <kiconeffect.h>
35 #include <kfileitem.h>
37 #include <kio/deletejob.h>
38 #include <kio/netaccess.h>
39 #include <kio/previewjob.h>
42 #include <kmessagebox.h>
43 #include <kmimetyperesolver.h>
44 #include <konq_fileitemcapabilities.h>
45 #include <konq_operations.h>
46 #include <konqmimedata.h>
47 #include <kstringhandler.h>
48 #include <ktoggleaction.h>
51 #include "dolphinmodel.h"
52 #include "dolphincolumnviewcontainer.h"
53 #include "dolphincontroller.h"
54 #include "dolphindetailsview.h"
55 #include "dolphinfileitemdelegate.h"
56 #include "dolphinnewmenuobserver.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 "folderexpander.h"
63 #include "renamedialog.h"
64 #include "settings/dolphinsettings.h"
65 #include "versioncontrolobserver.h"
66 #include "viewproperties.h"
67 #include "zoomlevelinfo.h"
70 * Helper function for sorting items with qSort() in
71 * DolphinView::renameSelectedItems().
73 bool lessThan(const KFileItem
& item1
, const KFileItem
& item2
)
75 return KStringHandler::naturalCompare(item1
.name(), item2
.name()) < 0;
78 DolphinView::DolphinView(QWidget
* parent
,
80 DolphinSortFilterProxyModel
* proxyModel
) :
84 m_loadingDirectory(false),
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
),
93 m_fileItemDelegate(0),
94 m_viewAccessor(proxyModel
),
95 m_selectionChangedTimer(0),
96 m_versionControlObserver(0),
102 m_expandedDragSource(0)
104 m_topLayout
= new QVBoxLayout(this);
105 m_topLayout
->setSpacing(0);
106 m_topLayout
->setMargin(0);
108 m_controller
= new DolphinController(this);
109 m_controller
->setUrl(url
);
111 connect(m_controller
, SIGNAL(urlChanged(const KUrl
&)),
112 this, SIGNAL(urlChanged(const KUrl
&)));
113 connect(m_controller
, SIGNAL(requestUrlChange(const KUrl
&)),
114 this, SLOT(slotRequestUrlChange(const KUrl
&)));
116 connect(m_controller
, SIGNAL(requestContextMenu(const QPoint
&, const QList
<QAction
*>&)),
117 this, SLOT(openContextMenu(const QPoint
&, const QList
<QAction
*>&)));
118 connect(m_controller
, SIGNAL(urlsDropped(const KFileItem
&, const KUrl
&, QDropEvent
*)),
119 this, SLOT(dropUrls(const KFileItem
&, const KUrl
&, QDropEvent
*)));
120 connect(m_controller
, SIGNAL(sortingChanged(DolphinView::Sorting
)),
121 this, SLOT(updateSorting(DolphinView::Sorting
)));
122 connect(m_controller
, SIGNAL(sortOrderChanged(Qt::SortOrder
)),
123 this, SLOT(updateSortOrder(Qt::SortOrder
)));
124 connect(m_controller
, SIGNAL(sortFoldersFirstChanged(bool)),
125 this, SLOT(updateSortFoldersFirst(bool)));
126 connect(m_controller
, SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList
&)),
127 this, SLOT(updateAdditionalInfo(const KFileItemDelegate::InformationList
&)));
128 connect(m_controller
, SIGNAL(itemTriggered(const KFileItem
&)),
129 this, SLOT(triggerItem(const KFileItem
&)));
130 connect(m_controller
, SIGNAL(tabRequested(const KUrl
&)),
131 this, SIGNAL(tabRequested(const KUrl
&)));
132 connect(m_controller
, SIGNAL(activated()),
133 this, SLOT(activate()));
134 connect(m_controller
, SIGNAL(itemEntered(const KFileItem
&)),
135 this, SLOT(showHoverInformation(const KFileItem
&)));
136 connect(m_controller
, SIGNAL(viewportEntered()),
137 this, SLOT(clearHoverInformation()));
139 KDirLister
* dirLister
= m_viewAccessor
.dirLister();
140 connect(dirLister
, SIGNAL(redirection(KUrl
, KUrl
)),
141 this, SIGNAL(redirection(KUrl
, KUrl
)));
142 connect(dirLister
, SIGNAL(completed()),
143 this, SLOT(slotDirListerCompleted()));
144 connect(dirLister
, SIGNAL(refreshItems(const QList
<QPair
<KFileItem
,KFileItem
>>&)),
145 this, SLOT(slotRefreshItems()));
147 // When a new item has been created by the "Create New..." menu, the item should
148 // get selected and it must be assured that the item will get visible. As the
149 // creation is done asynchronously, several signals must be checked:
150 connect(&DolphinNewMenuObserver::instance(), SIGNAL(itemCreated(const KUrl
&)),
151 this, SLOT(observeCreatedItem(const KUrl
&)));
153 applyViewProperties();
154 m_topLayout
->addWidget(m_viewAccessor
.itemView());
157 DolphinView::~DolphinView()
159 delete m_expandedDragSource
;
160 m_expandedDragSource
= 0;
163 const KUrl
& DolphinView::url() const
165 return m_controller
->url();
168 KUrl
DolphinView::rootUrl() const
170 const KUrl viewUrl
= url();
171 const KUrl root
= m_viewAccessor
.rootUrl();
172 if (root
.isEmpty() || !root
.isParentOf(viewUrl
)) {
178 void DolphinView::setActive(bool active
)
180 if (active
== m_active
) {
186 QColor color
= KColorScheme(QPalette::Active
, KColorScheme::View
).background().color();
188 emitSelectionChangedSignal();
193 QWidget
* viewport
= m_viewAccessor
.itemView()->viewport();
195 palette
.setColor(viewport
->backgroundRole(), color
);
196 viewport
->setPalette(palette
);
201 m_viewAccessor
.itemView()->setFocus();
205 m_controller
->indicateActivationChange(active
);
208 bool DolphinView::isActive() const
213 void DolphinView::setMode(Mode mode
)
215 if (mode
== m_mode
) {
216 return; // the wished mode is already set
219 const int oldZoomLevel
= m_controller
->zoomLevel();
224 const KUrl viewPropsUrl
= rootUrl();
225 ViewProperties
props(viewPropsUrl
);
226 props
.setViewMode(m_mode
);
229 // the file item delegate has been recreated, apply the current
230 // additional information manually
231 const KFileItemDelegate::InformationList infoList
= props
.additionalInfo();
232 m_fileItemDelegate
->setShowInformation(infoList
);
233 emit
additionalInfoChanged();
235 // Not all view modes support categorized sorting. Adjust the sorting model
236 // if changing the view mode results in a change of the categorized sorting
238 m_storedCategorizedSorting
= props
.categorizedSorting();
239 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
240 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
241 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
242 emit
categorizedSortingChanged();
247 updateZoomLevel(oldZoomLevel
);
249 loadDirectory(viewPropsUrl
);
253 DolphinView::Mode
DolphinView::mode() const
258 bool DolphinView::showPreview() const
260 return m_showPreview
;
263 bool DolphinView::showHiddenFiles() const
265 return m_viewAccessor
.dirLister()->showingDotFiles();
268 bool DolphinView::categorizedSorting() const
270 // If all view modes would support categorized sorting, returning
271 // m_viewAccessor.proxyModel()->isCategorizedModel() would be the way to go. As
272 // currently only the icons view supports caterized sorting, we remember
273 // the stored view properties state in m_storedCategorizedSorting and
274 // return this state. The application takes care to disable the corresponding
275 // checkbox by checking DolphinView::supportsCategorizedSorting() to indicate
276 // that this setting is not applied to the current view mode.
277 return m_storedCategorizedSorting
;
280 bool DolphinView::supportsCategorizedSorting() const
282 return m_viewAccessor
.supportsCategorizedSorting();
285 void DolphinView::selectAll()
287 QAbstractItemView
* view
= m_viewAccessor
.itemView();
288 // TODO: there seems to be a bug in QAbstractItemView::selectAll(); if
289 // the Ctrl-key is pressed (e. g. for Ctrl+A), selectAll() inverts the
290 // selection instead of selecting all items. This is bypassed for KDE 4.0
291 // by invoking clearSelection() first.
292 view
->clearSelection();
296 void DolphinView::invertSelection()
298 QItemSelectionModel
* selectionModel
= m_viewAccessor
.itemView()->selectionModel();
299 const QAbstractItemModel
* itemModel
= selectionModel
->model();
301 const QModelIndex topLeft
= itemModel
->index(0, 0);
302 const QModelIndex bottomRight
= itemModel
->index(itemModel
->rowCount() - 1,
303 itemModel
->columnCount() - 1);
305 const QItemSelection
selection(topLeft
, bottomRight
);
306 selectionModel
->select(selection
, QItemSelectionModel::Toggle
);
309 bool DolphinView::hasSelection() const
311 return m_viewAccessor
.itemView()->selectionModel()->hasSelection();
314 void DolphinView::clearSelection()
316 QItemSelectionModel
* selModel
= m_viewAccessor
.itemView()->selectionModel();
317 const QModelIndex currentIndex
= selModel
->currentIndex();
318 selModel
->setCurrentIndex(currentIndex
, QItemSelectionModel::Current
|
319 QItemSelectionModel::Clear
);
320 m_selectedItems
.clear();
323 KFileItemList
DolphinView::selectedItems() const
325 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
327 // Our view has a selection, we will map them back to the DolphinModel
328 // and then fill the KFileItemList.
329 Q_ASSERT((view
!= 0) && (view
->selectionModel() != 0));
331 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
332 KFileItemList itemList
;
334 const QModelIndexList indexList
= selection
.indexes();
335 foreach (const QModelIndex
&index
, indexList
) {
336 KFileItem item
= m_viewAccessor
.dirModel()->itemForIndex(index
);
337 if (!item
.isNull()) {
338 itemList
.append(item
);
345 KUrl::List
DolphinView::selectedUrls() const
348 const KFileItemList list
= selectedItems();
349 foreach (const KFileItem
&item
, list
) {
350 urls
.append(item
.url());
355 int DolphinView::selectedItemsCount() const
357 return m_viewAccessor
.itemView()->selectionModel()->selectedIndexes().count();
360 void DolphinView::setContentsPosition(int x
, int y
)
362 QAbstractItemView
* view
= m_viewAccessor
.itemView();
363 view
->horizontalScrollBar()->setValue(x
);
364 view
->verticalScrollBar()->setValue(y
);
366 m_loadingDirectory
= false;
369 QPoint
DolphinView::contentsPosition() const
371 const int x
= m_viewAccessor
.itemView()->horizontalScrollBar()->value();
372 const int y
= m_viewAccessor
.itemView()->verticalScrollBar()->value();
376 void DolphinView::setZoomLevel(int level
)
378 if (level
< ZoomLevelInfo::minimumLevel()) {
379 level
= ZoomLevelInfo::minimumLevel();
380 } else if (level
> ZoomLevelInfo::maximumLevel()) {
381 level
= ZoomLevelInfo::maximumLevel();
384 if (level
!= zoomLevel()) {
385 m_controller
->setZoomLevel(level
);
386 emit
zoomLevelChanged(level
);
390 int DolphinView::zoomLevel() const
392 return m_controller
->zoomLevel();
395 void DolphinView::setSorting(Sorting sorting
)
397 if (sorting
!= this->sorting()) {
398 updateSorting(sorting
);
402 DolphinView::Sorting
DolphinView::sorting() const
404 return m_viewAccessor
.proxyModel()->sorting();
407 void DolphinView::setSortOrder(Qt::SortOrder order
)
409 if (sortOrder() != order
) {
410 updateSortOrder(order
);
414 Qt::SortOrder
DolphinView::sortOrder() const
416 return m_viewAccessor
.proxyModel()->sortOrder();
419 void DolphinView::setSortFoldersFirst(bool foldersFirst
)
421 if (sortFoldersFirst() != foldersFirst
) {
422 updateSortFoldersFirst(foldersFirst
);
426 bool DolphinView::sortFoldersFirst() const
428 return m_viewAccessor
.proxyModel()->sortFoldersFirst();
431 void DolphinView::setAdditionalInfo(KFileItemDelegate::InformationList info
)
433 const KUrl viewPropsUrl
= rootUrl();
434 ViewProperties
props(viewPropsUrl
);
435 props
.setAdditionalInfo(info
);
436 m_fileItemDelegate
->setShowInformation(info
);
438 emit
additionalInfoChanged();
440 if (m_viewAccessor
.reloadOnAdditionalInfoChange()) {
441 loadDirectory(viewPropsUrl
);
445 KFileItemDelegate::InformationList
DolphinView::additionalInfo() const
447 return m_fileItemDelegate
->showInformation();
450 void DolphinView::reload()
453 loadDirectory(url(), true);
456 void DolphinView::refresh()
458 m_ignoreViewProperties
= false;
460 const bool oldActivationState
= m_active
;
461 const int oldZoomLevel
= m_controller
->zoomLevel();
465 applyViewProperties();
468 setActive(oldActivationState
);
469 updateZoomLevel(oldZoomLevel
);
472 void DolphinView::updateView(const KUrl
& url
, const KUrl
& rootUrl
)
474 Q_UNUSED(rootUrl
); // TODO: remove after columnview-cleanup has been finished
476 if (m_controller
->url() == url
) {
480 m_controller
->setUrl(url
); // emits urlChanged, which we forward
481 if (m_viewAccessor
.prepareUrlChange(url
)) {
484 applyViewProperties();
487 // When changing the URL there is no need to keep the version
488 // data of the previous URL.
489 m_viewAccessor
.dirModel()->clearVersionData();
491 emit
startedPathLoading(url
);
494 void DolphinView::setNameFilter(const QString
& nameFilter
)
496 m_controller
->setNameFilter(nameFilter
);
499 void DolphinView::calculateItemCount(int& fileCount
,
501 KIO::filesize_t
& totalFileSize
) const
503 foreach (const KFileItem
& item
, m_viewAccessor
.dirLister()->items()) {
508 totalFileSize
+= item
.size();
513 QString
DolphinView::statusBarText() const
518 KIO::filesize_t totalFileSize
= 0;
520 if (hasSelection()) {
521 // give a summary of the status of the selected files
522 const KFileItemList list
= selectedItems();
523 if (list
.isEmpty()) {
524 // when an item is triggered, it is temporary selected but selectedItems()
525 // will return an empty list
529 KFileItemList::const_iterator it
= list
.begin();
530 const KFileItemList::const_iterator end
= list
.end();
532 const KFileItem
& item
= *it
;
537 totalFileSize
+= item
.size();
542 if (folderCount
+ fileCount
== 1) {
543 // if only one item is selected, show the filename
544 const QString name
= list
.first().name();
545 text
= (folderCount
== 1) ? i18nc("@info:status", "<filename>%1</filename> selected", name
) :
546 i18nc("@info:status", "<filename>%1</filename> selected (%2)",
547 name
, KIO::convertSize(totalFileSize
));
549 // at least 2 items are selected
550 const QString foldersText
= i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount
);
551 const QString filesText
= i18ncp("@info:status", "1 File selected", "%1 Files selected", fileCount
);
552 if ((folderCount
> 0) && (fileCount
> 0)) {
553 text
= i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
554 foldersText
, filesText
, KIO::convertSize(totalFileSize
));
555 } else if (fileCount
> 0) {
556 text
= i18nc("@info:status files (size)", "%1 (%2)", filesText
, KIO::convertSize(totalFileSize
));
558 Q_ASSERT(folderCount
> 0);
563 calculateItemCount(fileCount
, folderCount
, totalFileSize
);
564 text
= KIO::itemsSummaryString(fileCount
+ folderCount
,
565 fileCount
, folderCount
,
566 totalFileSize
, true);
572 QList
<QAction
*> DolphinView::versionControlActions(const KFileItemList
& items
) const
574 return items
.isEmpty()
575 ? m_versionControlObserver
->contextMenuActions(url().path(KUrl::AddTrailingSlash
))
576 : m_versionControlObserver
->contextMenuActions(items
);
579 void DolphinView::setUrl(const KUrl
& url
)
581 m_newFileNames
.clear();
582 updateView(url
, KUrl());
585 void DolphinView::changeSelection(const KFileItemList
& selection
)
588 if (selection
.isEmpty()) {
591 const KUrl
& baseUrl
= url();
593 QItemSelection newSelection
;
594 foreach(const KFileItem
& item
, selection
) {
595 url
= item
.url().upUrl();
596 if (baseUrl
.equals(url
, KUrl::CompareWithoutTrailingSlash
)) {
597 QModelIndex index
= m_viewAccessor
.proxyModel()->mapFromSource(m_viewAccessor
.dirModel()->indexForItem(item
));
598 newSelection
.select(index
, index
);
601 m_viewAccessor
.itemView()->selectionModel()->select(newSelection
,
602 QItemSelectionModel::ClearAndSelect
603 | QItemSelectionModel::Current
);
606 void DolphinView::renameSelectedItems()
608 KFileItemList items
= selectedItems();
609 const int itemCount
= items
.count();
615 // More than one item has been selected for renaming. Open
616 // a rename dialog and rename all items afterwards.
617 QPointer
<RenameDialog
> dialog
= new RenameDialog(this, items
);
618 if (dialog
->exec() == QDialog::Rejected
) {
623 const QString newName
= dialog
->newName();
624 if (newName
.isEmpty()) {
625 emit
errorMessage(dialog
->errorString());
631 // the selection would be invalid after renaming the items, so just clear
635 // TODO: check how this can be integrated into KIO::FileUndoManager/KonqOperations
636 // as one operation instead of n rename operations like it is done now...
637 Q_ASSERT(newName
.contains('#'));
639 // currently the items are sorted by the selection order, resort
640 // them by the file name
641 qSort(items
.begin(), items
.end(), lessThan
);
643 // iterate through all selected items and rename them...
645 foreach (const KFileItem
& item
, items
) {
646 const KUrl
& oldUrl
= item
.url();
648 number
.setNum(index
++);
650 QString name
= newName
;
651 name
.replace('#', number
);
653 if (oldUrl
.fileName() != name
) {
654 KUrl newUrl
= oldUrl
;
655 newUrl
.setFileName(name
);
656 KonqOperations::rename(this, oldUrl
, newUrl
);
659 } else if (DolphinSettings::instance().generalSettings()->renameInline()) {
660 Q_ASSERT(itemCount
== 1);
661 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForItem(items
.first());
662 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
663 m_viewAccessor
.itemView()->edit(proxyIndex
);
665 Q_ASSERT(itemCount
== 1);
667 QPointer
<RenameDialog
> dialog
= new RenameDialog(this, items
);
668 if (dialog
->exec() == QDialog::Rejected
) {
673 const QString newName
= dialog
->newName();
674 if (newName
.isEmpty()) {
675 emit
errorMessage(dialog
->errorString());
681 const KUrl
& oldUrl
= items
.first().url();
682 KUrl newUrl
= oldUrl
;
683 newUrl
.setFileName(newName
);
684 KonqOperations::rename(this, oldUrl
, newUrl
);
687 // assure that the current index remains visible when KDirLister
688 // will notify the view about changed items
689 m_assureVisibleCurrentIndex
= true;
692 void DolphinView::trashSelectedItems()
694 const KUrl::List list
= simplifiedSelectedUrls();
695 KonqOperations::del(this, KonqOperations::TRASH
, list
);
698 void DolphinView::deleteSelectedItems()
700 const KUrl::List list
= simplifiedSelectedUrls();
701 const bool del
= KonqOperations::askDeleteConfirmation(list
,
703 KonqOperations::DEFAULT_CONFIRMATION
,
707 KIO::Job
* job
= KIO::del(list
);
708 connect(job
, SIGNAL(result(KJob
*)),
709 this, SLOT(slotDeleteFileFinished(KJob
*)));
713 void DolphinView::cutSelectedItems()
715 QMimeData
* mimeData
= selectionMimeData();
716 KonqMimeData::addIsCutSelection(mimeData
, true);
717 QApplication::clipboard()->setMimeData(mimeData
);
720 void DolphinView::copySelectedItems()
722 QMimeData
* mimeData
= selectionMimeData();
723 QApplication::clipboard()->setMimeData(mimeData
);
726 void DolphinView::paste()
731 void DolphinView::pasteIntoFolder()
733 const KFileItemList items
= selectedItems();
734 if ((items
.count() == 1) && items
.first().isDir()) {
735 pasteToUrl(items
.first().url());
739 void DolphinView::setShowPreview(bool show
)
741 if (m_showPreview
== show
) {
745 const KUrl viewPropsUrl
= rootUrl();
746 ViewProperties
props(viewPropsUrl
);
747 props
.setShowPreview(show
);
749 m_showPreview
= show
;
750 const int oldZoomLevel
= m_controller
->zoomLevel();
751 emit
showPreviewChanged();
753 // Enabling or disabling the preview might change the icon size of the view.
754 // As the view does not emit a signal when the icon size has been changed,
755 // the used zoom level of the controller must be adjusted manually:
756 updateZoomLevel(oldZoomLevel
);
758 loadDirectory(viewPropsUrl
);
761 void DolphinView::setShowHiddenFiles(bool show
)
763 if (m_viewAccessor
.dirLister()->showingDotFiles() == show
) {
767 const KUrl viewPropsUrl
= rootUrl();
768 ViewProperties
props(viewPropsUrl
);
769 props
.setShowHiddenFiles(show
);
771 m_viewAccessor
.dirLister()->setShowingDotFiles(show
);
772 emit
showHiddenFilesChanged();
774 loadDirectory(viewPropsUrl
);
777 void DolphinView::setCategorizedSorting(bool categorized
)
779 if (categorized
== categorizedSorting()) {
783 // setCategorizedSorting(true) may only get invoked
784 // if the view supports categorized sorting
785 Q_ASSERT(!categorized
|| supportsCategorizedSorting());
787 ViewProperties
props(rootUrl());
788 props
.setCategorizedSorting(categorized
);
791 m_storedCategorizedSorting
= categorized
;
792 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
794 emit
categorizedSortingChanged();
797 void DolphinView::toggleSortOrder()
799 const Qt::SortOrder order
= (sortOrder() == Qt::AscendingOrder
) ?
800 Qt::DescendingOrder
:
805 void DolphinView::toggleSortFoldersFirst()
807 setSortFoldersFirst(!sortFoldersFirst());
810 void DolphinView::toggleAdditionalInfo(QAction
* action
)
812 const KFileItemDelegate::Information info
=
813 static_cast<KFileItemDelegate::Information
>(action
->data().toInt());
815 KFileItemDelegate::InformationList list
= additionalInfo();
817 const bool show
= action
->isChecked();
819 const int index
= list
.indexOf(info
);
820 const bool containsInfo
= (index
>= 0);
821 if (show
&& !containsInfo
) {
823 setAdditionalInfo(list
);
824 } else if (!show
&& containsInfo
) {
825 list
.removeAt(index
);
826 setAdditionalInfo(list
);
827 Q_ASSERT(list
.indexOf(info
) < 0);
831 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
833 QWidget::mouseReleaseEvent(event
);
837 void DolphinView::wheelEvent(QWheelEvent
* event
)
839 if (event
->modifiers() & Qt::ControlModifier
) {
840 const int delta
= event
->delta();
841 const int level
= zoomLevel();
843 setZoomLevel(level
+ 1);
844 } else if (delta
< 0) {
845 setZoomLevel(level
- 1);
851 bool DolphinView::eventFilter(QObject
* watched
, QEvent
* event
)
853 switch (event
->type()) {
854 case QEvent::FocusIn
:
855 if (watched
== m_viewAccessor
.itemView()) {
856 m_controller
->requestActivation();
860 case QEvent::MouseButtonPress
:
861 if ((watched
== m_viewAccessor
.itemView()->viewport()) && (m_expandedDragSource
!= 0)) {
862 // Listening to a mousebutton press event to delete expanded views is a
863 // workaround, as it seems impossible for the FolderExpander to know when
864 // a dragging outside a view has been finished. However it works quite well:
865 // A mousebutton press event indicates that a drag operation must be
867 m_expandedDragSource
->deleteLater();
868 m_expandedDragSource
= 0;
872 case QEvent::DragEnter
:
873 if (watched
== m_viewAccessor
.itemView()->viewport()) {
878 case QEvent::KeyPress
:
879 if (watched
== m_viewAccessor
.itemView()) {
880 // clear the selection when Escape has been pressed
881 QKeyEvent
* keyEvent
= static_cast<QKeyEvent
*>(event
);
882 if (keyEvent
->key() == Qt::Key_Escape
) {
892 return QWidget::eventFilter(watched
, event
);
895 void DolphinView::activate()
900 void DolphinView::triggerItem(const KFileItem
& item
)
902 const Qt::KeyboardModifiers modifier
= QApplication::keyboardModifiers();
903 if ((modifier
& Qt::ShiftModifier
) || (modifier
& Qt::ControlModifier
)) {
904 // items are selected by the user, hence don't trigger the
905 // item specified by 'index'
909 // TODO: the m_isContextMenuOpen check is a workaround for Qt-issue 207192
910 if (item
.isNull() || m_isContextMenuOpen
) {
914 emit
itemTriggered(item
); // caught by DolphinViewContainer or DolphinPart
917 void DolphinView::emitDelayedSelectionChangedSignal()
919 // Invoke emitSelectionChangedSignal() with a delay of 300 ms. This assures
920 // that fast selection changes don't result in expensive operations to
921 // collect all file items for the signal (see DolphinView::selectedItems()).
922 m_selectionChangedTimer
->start();
925 void DolphinView::emitSelectionChangedSignal()
927 emit
selectionChanged(DolphinView::selectedItems());
930 void DolphinView::openContextMenu(const QPoint
& pos
,
931 const QList
<QAction
*>& customActions
)
934 const QModelIndex index
= m_viewAccessor
.itemView()->indexAt(pos
);
935 if (index
.isValid() && (index
.column() == DolphinModel::Name
)) {
936 const QModelIndex dolphinModelIndex
= m_viewAccessor
.proxyModel()->mapToSource(index
);
937 item
= m_viewAccessor
.dirModel()->itemForIndex(dolphinModelIndex
);
940 m_isContextMenuOpen
= true; // TODO: workaround for Qt-issue 207192
941 emit
requestContextMenu(item
, url(), customActions
);
942 m_isContextMenuOpen
= false;
945 void DolphinView::dropUrls(const KFileItem
& destItem
,
946 const KUrl
& destPath
,
949 addNewFileNames(event
->mimeData());
950 DragAndDropHelper::instance().dropUrls(destItem
, destPath
, event
, this);
953 void DolphinView::updateSorting(DolphinView::Sorting sorting
)
955 ViewProperties
props(rootUrl());
956 props
.setSorting(sorting
);
958 m_viewAccessor
.proxyModel()->setSorting(sorting
);
960 emit
sortingChanged(sorting
);
963 void DolphinView::updateSortOrder(Qt::SortOrder order
)
965 ViewProperties
props(rootUrl());
966 props
.setSortOrder(order
);
968 m_viewAccessor
.proxyModel()->setSortOrder(order
);
970 emit
sortOrderChanged(order
);
973 void DolphinView::updateSortFoldersFirst(bool foldersFirst
)
975 ViewProperties
props(rootUrl());
976 props
.setSortFoldersFirst(foldersFirst
);
978 m_viewAccessor
.proxyModel()->setSortFoldersFirst(foldersFirst
);
980 emit
sortFoldersFirstChanged(foldersFirst
);
983 void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList
& info
)
985 ViewProperties
props(rootUrl());
986 props
.setAdditionalInfo(info
);
989 m_fileItemDelegate
->setShowInformation(info
);
991 emit
additionalInfoChanged();
994 void DolphinView::updateAdditionalInfoActions(KActionCollection
* collection
)
996 const bool enable
= (m_mode
== DolphinView::DetailsView
) ||
997 (m_mode
== DolphinView::IconsView
);
999 QAction
* showSizeInfo
= collection
->action("show_size_info");
1000 QAction
* showDateInfo
= collection
->action("show_date_info");
1001 QAction
* showPermissionsInfo
= collection
->action("show_permissions_info");
1002 QAction
* showOwnerInfo
= collection
->action("show_owner_info");
1003 QAction
* showGroupInfo
= collection
->action("show_group_info");
1004 QAction
* showMimeInfo
= collection
->action("show_mime_info");
1006 showSizeInfo
->setChecked(false);
1007 showDateInfo
->setChecked(false);
1008 showPermissionsInfo
->setChecked(false);
1009 showOwnerInfo
->setChecked(false);
1010 showGroupInfo
->setChecked(false);
1011 showMimeInfo
->setChecked(false);
1013 showSizeInfo
->setEnabled(enable
);
1014 showDateInfo
->setEnabled(enable
);
1015 showPermissionsInfo
->setEnabled(enable
);
1016 showOwnerInfo
->setEnabled(enable
);
1017 showGroupInfo
->setEnabled(enable
);
1018 showMimeInfo
->setEnabled(enable
);
1020 foreach (KFileItemDelegate::Information info
, m_fileItemDelegate
->showInformation()) {
1022 case KFileItemDelegate::Size
:
1023 showSizeInfo
->setChecked(true);
1025 case KFileItemDelegate::ModificationTime
:
1026 showDateInfo
->setChecked(true);
1028 case KFileItemDelegate::Permissions
:
1029 showPermissionsInfo
->setChecked(true);
1031 case KFileItemDelegate::Owner
:
1032 showOwnerInfo
->setChecked(true);
1034 case KFileItemDelegate::OwnerAndGroup
:
1035 showGroupInfo
->setChecked(true);
1037 case KFileItemDelegate::FriendlyMimeType
:
1038 showMimeInfo
->setChecked(true);
1046 QPair
<bool, QString
> DolphinView::pasteInfo() const
1048 return KonqOperations::pasteInfo(url());
1051 void DolphinView::setTabsForFilesEnabled(bool tabsForFiles
)
1053 m_tabsForFiles
= tabsForFiles
;
1056 bool DolphinView::isTabsForFilesEnabled() const
1058 return m_tabsForFiles
;
1061 void DolphinView::activateItem(const KUrl
& url
)
1063 m_activeItemUrl
= url
;
1066 bool DolphinView::itemsExpandable() const
1068 return m_viewAccessor
.itemsExpandable();
1071 void DolphinView::deleteWhenNotDragSource(QAbstractItemView
*view
)
1076 if (DragAndDropHelper::instance().isDragSource(view
)) {
1077 // We must store for later deletion.
1078 if (m_expandedDragSource
!= 0) {
1079 // The old stored view is obviously not the drag source anymore.
1080 m_expandedDragSource
->deleteLater();
1081 m_expandedDragSource
= 0;
1084 m_expandedDragSource
= view
;
1087 view
->deleteLater();
1091 void DolphinView::observeCreatedItem(const KUrl
& url
)
1093 m_createdItemUrl
= url
;
1094 connect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
1095 this, SLOT(selectAndScrollToCreatedItem()));
1098 void DolphinView::selectAndScrollToCreatedItem()
1100 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_createdItemUrl
);
1101 if (dirIndex
.isValid()) {
1102 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
1103 m_viewAccessor
.itemView()->setCurrentIndex(proxyIndex
);
1106 disconnect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
1107 this, SLOT(selectAndScrollToCreatedItem()));
1108 m_createdItemUrl
= KUrl();
1111 void DolphinView::restoreSelection()
1113 disconnect(m_viewAccessor
.dirLister(), SIGNAL(completed()), this, SLOT(restoreSelection()));
1114 changeSelection(m_selectedItems
);
1117 void DolphinView::emitContentsMoved()
1119 // only emit the contents moved signal if no directory loading is ongoing
1120 // (this would reset the contents position always to (0, 0))
1121 if (!m_loadingDirectory
) {
1122 const QPoint
pos(contentsPosition());
1123 emit
contentsMoved(pos
.x(), pos
.y());
1127 void DolphinView::showHoverInformation(const KFileItem
& item
)
1129 emit
requestItemInfo(item
);
1132 void DolphinView::clearHoverInformation()
1134 emit
requestItemInfo(KFileItem());
1137 void DolphinView::slotDeleteFileFinished(KJob
* job
)
1139 if (job
->error() == 0) {
1140 emit
operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
1141 } else if (job
->error() != KIO::ERR_USER_CANCELED
) {
1142 emit
errorMessage(job
->errorString());
1146 void DolphinView::slotRequestUrlChange(const KUrl
& url
)
1148 emit
requestUrlChange(url
);
1149 m_controller
->setUrl(url
);
1152 void DolphinView::slotDirListerCompleted()
1154 if (!m_activeItemUrl
.isEmpty()) {
1155 // assure that the current item remains visible
1156 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_activeItemUrl
);
1157 if (dirIndex
.isValid()) {
1158 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
1159 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1160 const bool clearSelection
= !hasSelection();
1161 view
->setCurrentIndex(proxyIndex
);
1162 if (clearSelection
) {
1163 view
->clearSelection();
1165 m_activeItemUrl
.clear();
1169 if (!m_newFileNames
.isEmpty()) {
1170 // select all newly added items created by a paste operation or
1171 // a drag & drop operation
1172 const int rowCount
= m_viewAccessor
.proxyModel()->rowCount();
1173 QItemSelection selection
;
1174 for (int row
= 0; row
< rowCount
; ++row
) {
1175 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->index(row
, 0);
1176 const QModelIndex dirIndex
= m_viewAccessor
.proxyModel()->mapToSource(proxyIndex
);
1177 const KUrl url
= m_viewAccessor
.dirModel()->itemForIndex(dirIndex
).url();
1178 if (m_newFileNames
.contains(url
.fileName())) {
1179 selection
.merge(QItemSelection(proxyIndex
, proxyIndex
), QItemSelectionModel::Select
);
1182 m_viewAccessor
.itemView()->selectionModel()->select(selection
, QItemSelectionModel::Select
);
1184 m_newFileNames
.clear();
1188 void DolphinView::slotRefreshItems()
1190 if (m_assureVisibleCurrentIndex
) {
1191 m_assureVisibleCurrentIndex
= false;
1192 m_viewAccessor
.itemView()->scrollTo(m_viewAccessor
.itemView()->currentIndex());
1196 void DolphinView::loadDirectory(const KUrl
& url
, bool reload
)
1198 if (!url
.isValid()) {
1199 const QString
location(url
.pathOrUrl());
1200 if (location
.isEmpty()) {
1201 emit
errorMessage(i18nc("@info:status", "The location is empty."));
1203 emit
errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location
));
1208 m_loadingDirectory
= true;
1211 m_selectedItems
= selectedItems();
1212 connect(m_viewAccessor
.dirLister(), SIGNAL(completed()), this, SLOT(restoreSelection()));
1215 m_viewAccessor
.dirLister()->stop();
1216 m_viewAccessor
.dirLister()->openUrl(url
, reload
? KDirLister::Reload
: KDirLister::NoFlags
);
1219 void DolphinView::applyViewProperties()
1221 if (m_ignoreViewProperties
) {
1225 const ViewProperties
props(rootUrl());
1227 const Mode mode
= props
.viewMode();
1228 if (m_mode
!= mode
) {
1229 const int oldZoomLevel
= m_controller
->zoomLevel();
1235 updateZoomLevel(oldZoomLevel
);
1237 if (m_viewAccessor
.itemView() == 0) {
1240 Q_ASSERT(m_viewAccessor
.itemView() != 0);
1241 Q_ASSERT(m_fileItemDelegate
!= 0);
1243 const bool showHiddenFiles
= props
.showHiddenFiles();
1244 if (showHiddenFiles
!= m_viewAccessor
.dirLister()->showingDotFiles()) {
1245 m_viewAccessor
.dirLister()->setShowingDotFiles(showHiddenFiles
);
1246 emit
showHiddenFilesChanged();
1249 m_storedCategorizedSorting
= props
.categorizedSorting();
1250 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
1251 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
1252 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
1253 emit
categorizedSortingChanged();
1256 const DolphinView::Sorting sorting
= props
.sorting();
1257 if (sorting
!= m_viewAccessor
.proxyModel()->sorting()) {
1258 m_viewAccessor
.proxyModel()->setSorting(sorting
);
1259 emit
sortingChanged(sorting
);
1262 const Qt::SortOrder sortOrder
= props
.sortOrder();
1263 if (sortOrder
!= m_viewAccessor
.proxyModel()->sortOrder()) {
1264 m_viewAccessor
.proxyModel()->setSortOrder(sortOrder
);
1265 emit
sortOrderChanged(sortOrder
);
1268 const bool sortFoldersFirst
= props
.sortFoldersFirst();
1269 if (sortFoldersFirst
!= m_viewAccessor
.proxyModel()->sortFoldersFirst()) {
1270 m_viewAccessor
.proxyModel()->setSortFoldersFirst(sortFoldersFirst
);
1271 emit
sortFoldersFirstChanged(sortFoldersFirst
);
1274 KFileItemDelegate::InformationList info
= props
.additionalInfo();
1275 if (info
!= m_fileItemDelegate
->showInformation()) {
1276 m_fileItemDelegate
->setShowInformation(info
);
1277 emit
additionalInfoChanged();
1280 const bool showPreview
= props
.showPreview();
1281 if (showPreview
!= m_showPreview
) {
1282 m_showPreview
= showPreview
;
1283 const int oldZoomLevel
= m_controller
->zoomLevel();
1284 emit
showPreviewChanged();
1286 // Enabling or disabling the preview might change the icon size of the view.
1287 // As the view does not emit a signal when the icon size has been changed,
1288 // the used zoom level of the controller must be adjusted manually:
1289 updateZoomLevel(oldZoomLevel
);
1292 if (DolphinSettings::instance().generalSettings()->globalViewProps()) {
1293 // During the lifetime of a DolphinView instance the global view properties
1294 // should not be changed. This allows e. g. to split a view and use different
1295 // view properties for each view.
1296 m_ignoreViewProperties
= true;
1300 void DolphinView::createView()
1303 Q_ASSERT(m_viewAccessor
.itemView() == 0);
1304 m_viewAccessor
.createView(this, m_controller
, m_mode
);
1306 m_topLayout
->insertWidget(1, m_viewAccessor
.layoutTarget());
1309 void DolphinView::deleteView()
1311 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1313 // It's important to set the keyboard focus to the parent
1314 // before deleting the view: Otherwise when having a split
1315 // view the other view will get the focus and will request
1316 // an activation (see DolphinView::eventFilter()).
1320 m_topLayout
->removeWidget(view
);
1324 m_controller
->disconnect(view
);
1327 // TODO: move this code into ViewAccessor::deleteView()
1328 deleteWhenNotDragSource(view
);
1331 m_viewAccessor
.deleteView();
1332 m_fileItemDelegate
= 0;
1336 void DolphinView::initializeView()
1338 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1339 Q_ASSERT(view
!= 0);
1340 view
->installEventFilter(this);
1341 view
->viewport()->installEventFilter(this);
1342 setFocusProxy(view
);
1344 //if (m_mode != ColumnView) {
1345 // Give the view the ability to auto-expand its directories on hovering
1346 // (the column view takes care about this itself). If the details view
1347 // uses expandable folders, the auto-expanding should be used always.
1348 FolderExpander
* folderExpander
= new FolderExpander(view
, m_viewAccessor
.proxyModel());
1349 folderExpander
->setEnabled(m_viewAccessor
.hasExpandableFolders());
1350 connect(folderExpander
, SIGNAL(enterDir(const QModelIndex
&)),
1351 m_controller
, SLOT(triggerItem(const QModelIndex
&)));
1353 // TODO: enable again later
1356 // Listen out for requests to delete the current column.
1357 connect(m_viewAccessor.columnsContainer(), SIGNAL(requestColumnDeletion(QAbstractItemView*)),
1358 this, SLOT(deleteWhenNotDragSource(QAbstractItemView*)));
1361 m_controller
->setItemView(view
);
1363 m_fileItemDelegate
= new DolphinFileItemDelegate(view
);
1364 m_fileItemDelegate
->setShowToolTipWhenElided(false);
1365 m_fileItemDelegate
->setMinimizedNameColumn(m_mode
== DetailsView
);
1366 view
->setItemDelegate(m_fileItemDelegate
);
1368 // TODO: reactivate selection model
1369 /*view->setModel(m_viewAccessor.proxyModel());
1370 if (m_selectionModel != 0) {
1371 view->setSelectionModel(m_selectionModel);
1373 m_selectionModel = view->selectionModel();
1376 m_selectionChangedTimer
= new QTimer(this);
1377 m_selectionChangedTimer
->setSingleShot(true);
1378 m_selectionChangedTimer
->setInterval(300);
1379 connect(m_selectionChangedTimer
, SIGNAL(timeout()),
1380 this, SLOT(emitSelectionChangedSignal()));
1382 // reparent the selection model, as it should not be deleted
1383 // when deleting the model
1384 //m_selectionModel->setParent(this);
1386 view
->setSelectionMode(QAbstractItemView::ExtendedSelection
);
1388 m_versionControlObserver
= new VersionControlObserver(view
);
1389 connect(m_versionControlObserver
, SIGNAL(infoMessage(const QString
&)),
1390 this, SIGNAL(infoMessage(const QString
&)));
1391 connect(m_versionControlObserver
, SIGNAL(errorMessage(const QString
&)),
1392 this, SIGNAL(errorMessage(const QString
&)));
1393 connect(m_versionControlObserver
, SIGNAL(operationCompletedMessage(const QString
&)),
1394 this, SIGNAL(operationCompletedMessage(const QString
&)));
1396 connect(view
->selectionModel(), SIGNAL(selectionChanged(const QItemSelection
&, const QItemSelection
&)),
1397 this, SLOT(emitDelayedSelectionChangedSignal()));
1398 connect(view
->verticalScrollBar(), SIGNAL(valueChanged(int)),
1399 this, SLOT(emitContentsMoved()));
1400 connect(view
->horizontalScrollBar(), SIGNAL(valueChanged(int)),
1401 this, SLOT(emitContentsMoved()));
1404 void DolphinView::pasteToUrl(const KUrl
& url
)
1406 addNewFileNames(QApplication::clipboard()->mimeData());
1407 KonqOperations::doPaste(this, url
);
1410 void DolphinView::updateZoomLevel(int oldZoomLevel
)
1412 const int newZoomLevel
= ZoomLevelInfo::zoomLevelForIconSize(m_viewAccessor
.itemView()->iconSize());
1413 if (oldZoomLevel
!= newZoomLevel
) {
1414 m_controller
->setZoomLevel(newZoomLevel
);
1415 emit
zoomLevelChanged(newZoomLevel
);
1419 KUrl::List
DolphinView::simplifiedSelectedUrls() const
1421 KUrl::List list
= selectedUrls();
1422 if (itemsExpandable() ) {
1423 list
= KDirModel::simplifiedUrlList(list
);
1428 QMimeData
* DolphinView::selectionMimeData() const
1430 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
1431 Q_ASSERT((view
!= 0) && (view
->selectionModel() != 0));
1432 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
1433 return m_viewAccessor
.dirModel()->mimeData(selection
.indexes());
1436 void DolphinView::addNewFileNames(const QMimeData
* mimeData
)
1438 const KUrl::List urls
= KUrl::List::fromMimeData(mimeData
);
1439 foreach (const KUrl
& url
, urls
) {
1440 m_newFileNames
.insert(url
.fileName());
1444 DolphinView::ViewAccessor::ViewAccessor(DolphinSortFilterProxyModel
* proxyModel
) :
1447 m_columnsContainer(0),
1448 m_proxyModel(proxyModel
)
1452 void DolphinView::ViewAccessor::createView(QWidget
* parent
,
1453 DolphinController
* controller
,
1456 Q_ASSERT(itemView() == 0);
1460 m_iconsView
= new DolphinIconsView(parent
, controller
, m_proxyModel
);
1464 m_detailsView
= new DolphinDetailsView(parent
, controller
, m_proxyModel
);
1468 m_columnsContainer
= new DolphinColumnViewContainer(parent
, controller
);
1476 void DolphinView::ViewAccessor::deleteView()
1478 // TODO: Move the deleteWhenNotDragSource() code into the view
1479 // accessor, so that creating and deleting is fully done by
1480 // the view accessor.
1484 m_columnsContainer
->deleteLater();
1485 m_columnsContainer
= 0;
1489 bool DolphinView::ViewAccessor::prepareUrlChange(const KUrl
& url
)
1491 if (m_columnsContainer
!= 0) {
1492 return m_columnsContainer
->showColumn(url
);
1497 QAbstractItemView
* DolphinView::ViewAccessor::itemView() const
1499 if (m_iconsView
!= 0) {
1503 if (m_detailsView
!= 0) {
1504 return m_detailsView
;
1507 if (m_columnsContainer
!= 0) {
1508 return m_columnsContainer
->activeColumn();
1514 QWidget
* DolphinView::ViewAccessor::layoutTarget() const
1516 if (m_columnsContainer
!= 0) {
1517 return m_columnsContainer
;
1522 KUrl
DolphinView::ViewAccessor::rootUrl() const
1524 return (m_columnsContainer
!= 0) ? m_columnsContainer
->rootUrl() : KUrl();
1527 bool DolphinView::ViewAccessor::supportsCategorizedSorting() const
1529 return m_iconsView
!= 0;
1532 bool DolphinView::ViewAccessor::hasExpandableFolders() const
1534 const DolphinSettings
& settings
= DolphinSettings::instance();
1535 return settings
.generalSettings()->autoExpandFolders() ||
1536 ((m_detailsView
!= 0) && settings
.detailsModeSettings()->expandableFolders());
1539 bool DolphinView::ViewAccessor::itemsExpandable() const
1541 return (m_detailsView
!= 0) && m_detailsView
->itemsExpandable();
1544 bool DolphinView::ViewAccessor::reloadOnAdditionalInfoChange() const
1546 // the details view requires no reloading of the directory, as it maps
1547 // the file item delegate info to its columns internally
1548 return m_detailsView
!= 0;
1552 DolphinModel
* DolphinView::ViewAccessor::dirModel() const
1554 return static_cast<DolphinModel
*>(proxyModel()->sourceModel());
1557 DolphinSortFilterProxyModel
* DolphinView::ViewAccessor::proxyModel() const
1559 if (m_columnsContainer
!= 0) {
1560 return static_cast<DolphinSortFilterProxyModel
*>(m_columnsContainer
->activeColumn()->model());
1562 return m_proxyModel
;
1565 KDirLister
* DolphinView::ViewAccessor::dirLister() const
1567 return dirModel()->dirLister();
1570 #include "dolphinview.moc"