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 <QAbstractItemView>
24 #include <QApplication>
27 #include <QItemSelection>
32 #include <kactioncollection.h>
33 #include <kcolorscheme.h>
34 #include <kdirlister.h>
35 #include <kiconeffect.h>
36 #include <kfileitem.h>
38 #include <kio/deletejob.h>
39 #include <kio/netaccess.h>
40 #include <kio/previewjob.h>
43 #include <kmessagebox.h>
44 #include <kmimetyperesolver.h>
45 #include <konq_fileitemcapabilities.h>
46 #include <konq_operations.h>
47 #include <konqmimedata.h>
48 #include <kstringhandler.h>
49 #include <ktoggleaction.h>
52 #include "dolphinmodel.h"
53 #include "dolphincolumnviewcontainer.h"
54 #include "dolphincontroller.h"
55 #include "dolphindetailsview.h"
56 #include "dolphinfileitemdelegate.h"
57 #include "dolphinnewmenuobserver.h"
58 #include "dolphinsortfilterproxymodel.h"
59 #include "dolphin_detailsmodesettings.h"
60 #include "dolphiniconsview.h"
61 #include "dolphin_generalsettings.h"
62 #include "draganddrophelper.h"
63 #include "folderexpander.h"
64 #include "renamedialog.h"
65 #include "settings/dolphinsettings.h"
66 #include "versioncontrolobserver.h"
67 #include "viewproperties.h"
68 #include "zoomlevelinfo.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_loadingDirectory(false),
86 m_storedCategorizedSorting(false),
87 m_tabsForFiles(false),
88 m_isContextMenuOpen(false),
89 m_ignoreViewProperties(false),
90 m_assureVisibleCurrentIndex(false),
91 m_mode(DolphinView::IconsView
),
94 m_viewAccessor(proxyModel
),
96 m_selectionChangedTimer(0),
97 m_versionControlObserver(0),
103 m_expandedDragSource(0)
105 m_topLayout
= new QVBoxLayout(this);
106 m_topLayout
->setSpacing(0);
107 m_topLayout
->setMargin(0);
109 m_controller
= new DolphinController(this);
110 m_controller
->setUrl(url
);
112 connect(m_controller
, SIGNAL(urlChanged(const KUrl
&)),
113 this, SIGNAL(urlChanged(const KUrl
&)));
114 connect(m_controller
, SIGNAL(requestUrlChange(const KUrl
&)),
115 this, SLOT(slotRequestUrlChange(const KUrl
&)));
117 connect(m_controller
, SIGNAL(requestContextMenu(const QPoint
&, const QList
<QAction
*>&)),
118 this, SLOT(openContextMenu(const QPoint
&, const QList
<QAction
*>&)));
119 connect(m_controller
, SIGNAL(urlsDropped(const KFileItem
&, const KUrl
&, QDropEvent
*)),
120 this, SLOT(dropUrls(const KFileItem
&, const KUrl
&, QDropEvent
*)));
121 connect(m_controller
, SIGNAL(sortingChanged(DolphinView::Sorting
)),
122 this, SLOT(updateSorting(DolphinView::Sorting
)));
123 connect(m_controller
, SIGNAL(sortOrderChanged(Qt::SortOrder
)),
124 this, SLOT(updateSortOrder(Qt::SortOrder
)));
125 connect(m_controller
, SIGNAL(sortFoldersFirstChanged(bool)),
126 this, SLOT(updateSortFoldersFirst(bool)));
127 connect(m_controller
, SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList
&)),
128 this, SLOT(updateAdditionalInfo(const KFileItemDelegate::InformationList
&)));
129 connect(m_controller
, SIGNAL(itemTriggered(const KFileItem
&)),
130 this, SLOT(triggerItem(const KFileItem
&)));
131 connect(m_controller
, SIGNAL(tabRequested(const KUrl
&)),
132 this, SIGNAL(tabRequested(const KUrl
&)));
133 connect(m_controller
, SIGNAL(activated()),
134 this, SLOT(activate()));
135 connect(m_controller
, SIGNAL(itemEntered(const KFileItem
&)),
136 this, SLOT(showHoverInformation(const KFileItem
&)));
137 connect(m_controller
, SIGNAL(viewportEntered()),
138 this, SLOT(clearHoverInformation()));
140 KDirLister
* dirLister
= m_viewAccessor
.dirLister();
141 connect(dirLister
, SIGNAL(redirection(KUrl
, KUrl
)),
142 this, SIGNAL(redirection(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(&DolphinNewMenuObserver::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
.itemView());
164 DolphinView::~DolphinView()
166 delete m_expandedDragSource
;
167 m_expandedDragSource
= 0;
170 const KUrl
& DolphinView::url() const
172 return m_controller
->url();
175 KUrl
DolphinView::rootUrl() const
177 const KUrl viewUrl
= url();
178 const KUrl root
= m_viewAccessor
.rootUrl();
179 if (root
.isEmpty() || !root
.isParentOf(viewUrl
)) {
185 void DolphinView::setActive(bool active
)
187 if (active
== m_active
) {
193 QColor color
= KColorScheme(QPalette::Active
, KColorScheme::View
).background().color();
195 emitSelectionChangedSignal();
200 QWidget
* viewport
= m_viewAccessor
.itemView()->viewport();
202 palette
.setColor(viewport
->backgroundRole(), color
);
203 viewport
->setPalette(palette
);
208 m_viewAccessor
.itemView()->setFocus();
212 m_controller
->indicateActivationChange(active
);
215 bool DolphinView::isActive() const
220 void DolphinView::setMode(Mode mode
)
222 if (mode
== m_mode
) {
223 return; // the wished mode is already set
226 const int oldZoomLevel
= m_controller
->zoomLevel();
231 const KUrl viewPropsUrl
= rootUrl();
232 ViewProperties
props(viewPropsUrl
);
233 props
.setViewMode(m_mode
);
236 // the file item delegate has been recreated, apply the current
237 // additional information manually
238 const KFileItemDelegate::InformationList infoList
= props
.additionalInfo();
239 m_viewAccessor
.itemDelegate()->setShowInformation(infoList
);
240 emit
additionalInfoChanged();
242 // Not all view modes support categorized sorting. Adjust the sorting model
243 // if changing the view mode results in a change of the categorized sorting
245 m_storedCategorizedSorting
= props
.categorizedSorting();
246 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
247 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
248 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
249 emit
categorizedSortingChanged();
254 updateZoomLevel(oldZoomLevel
);
256 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 void DolphinView::selectAll()
294 QAbstractItemView
* view
= m_viewAccessor
.itemView();
295 // TODO: there seems to be a bug in QAbstractItemView::selectAll(); if
296 // the Ctrl-key is pressed (e. g. for Ctrl+A), selectAll() inverts the
297 // selection instead of selecting all items. This is bypassed for KDE 4.0
298 // by invoking clearSelection() first.
299 view
->clearSelection();
303 void DolphinView::invertSelection()
305 QItemSelectionModel
* selectionModel
= m_viewAccessor
.itemView()->selectionModel();
306 const QAbstractItemModel
* itemModel
= selectionModel
->model();
308 const QModelIndex topLeft
= itemModel
->index(0, 0);
309 const QModelIndex bottomRight
= itemModel
->index(itemModel
->rowCount() - 1,
310 itemModel
->columnCount() - 1);
312 const QItemSelection
selection(topLeft
, bottomRight
);
313 selectionModel
->select(selection
, QItemSelectionModel::Toggle
);
316 bool DolphinView::hasSelection() const
318 return m_viewAccessor
.itemView()->selectionModel()->hasSelection();
321 void DolphinView::clearSelection()
323 QItemSelectionModel
* selModel
= m_viewAccessor
.itemView()->selectionModel();
324 const QModelIndex currentIndex
= selModel
->currentIndex();
325 selModel
->setCurrentIndex(currentIndex
, QItemSelectionModel::Current
|
326 QItemSelectionModel::Clear
);
327 m_selectedItems
.clear();
330 KFileItemList
DolphinView::selectedItems() const
332 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
334 // Our view has a selection, we will map them back to the DolphinModel
335 // and then fill the KFileItemList.
336 Q_ASSERT((view
!= 0) && (view
->selectionModel() != 0));
338 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
339 KFileItemList itemList
;
341 const QModelIndexList indexList
= selection
.indexes();
342 foreach (const QModelIndex
&index
, indexList
) {
343 KFileItem item
= m_viewAccessor
.dirModel()->itemForIndex(index
);
344 if (!item
.isNull()) {
345 itemList
.append(item
);
352 KUrl::List
DolphinView::selectedUrls() const
355 const KFileItemList list
= selectedItems();
356 foreach (const KFileItem
&item
, list
) {
357 urls
.append(item
.url());
362 int DolphinView::selectedItemsCount() const
364 return m_viewAccessor
.itemView()->selectionModel()->selectedIndexes().count();
367 void DolphinView::setContentsPosition(int x
, int y
)
369 QAbstractItemView
* view
= m_viewAccessor
.itemView();
370 view
->horizontalScrollBar()->setValue(x
);
371 view
->verticalScrollBar()->setValue(y
);
373 m_loadingDirectory
= false;
376 QPoint
DolphinView::contentsPosition() const
378 const int x
= m_viewAccessor
.itemView()->horizontalScrollBar()->value();
379 const int y
= m_viewAccessor
.itemView()->verticalScrollBar()->value();
383 void DolphinView::setZoomLevel(int level
)
385 if (level
< ZoomLevelInfo::minimumLevel()) {
386 level
= ZoomLevelInfo::minimumLevel();
387 } else if (level
> ZoomLevelInfo::maximumLevel()) {
388 level
= ZoomLevelInfo::maximumLevel();
391 if (level
!= zoomLevel()) {
392 m_controller
->setZoomLevel(level
);
393 emit
zoomLevelChanged(level
);
397 int DolphinView::zoomLevel() const
399 return m_controller
->zoomLevel();
402 void DolphinView::setSorting(Sorting sorting
)
404 if (sorting
!= this->sorting()) {
405 updateSorting(sorting
);
409 DolphinView::Sorting
DolphinView::sorting() const
411 return m_viewAccessor
.proxyModel()->sorting();
414 void DolphinView::setSortOrder(Qt::SortOrder order
)
416 if (sortOrder() != order
) {
417 updateSortOrder(order
);
421 Qt::SortOrder
DolphinView::sortOrder() const
423 return m_viewAccessor
.proxyModel()->sortOrder();
426 void DolphinView::setSortFoldersFirst(bool foldersFirst
)
428 if (sortFoldersFirst() != foldersFirst
) {
429 updateSortFoldersFirst(foldersFirst
);
433 bool DolphinView::sortFoldersFirst() const
435 return m_viewAccessor
.proxyModel()->sortFoldersFirst();
438 void DolphinView::setAdditionalInfo(KFileItemDelegate::InformationList info
)
440 const KUrl viewPropsUrl
= rootUrl();
441 ViewProperties
props(viewPropsUrl
);
442 props
.setAdditionalInfo(info
);
443 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
445 emit
additionalInfoChanged();
447 if (m_viewAccessor
.reloadOnAdditionalInfoChange()) {
448 loadDirectory(viewPropsUrl
);
452 KFileItemDelegate::InformationList
DolphinView::additionalInfo() const
454 return m_viewAccessor
.itemDelegate()->showInformation();
457 void DolphinView::reload()
460 loadDirectory(url(), true);
463 void DolphinView::refresh()
465 m_ignoreViewProperties
= false;
467 const bool oldActivationState
= m_active
;
468 const int oldZoomLevel
= m_controller
->zoomLevel();
472 applyViewProperties();
475 setActive(oldActivationState
);
476 updateZoomLevel(oldZoomLevel
);
479 void DolphinView::updateView(const KUrl
& url
, const KUrl
& rootUrl
)
481 Q_UNUSED(rootUrl
); // TODO: remove after columnview-cleanup has been finished
483 if (m_controller
->url() == url
) {
487 m_controller
->setUrl(url
); // emits urlChanged, which we forward
488 m_viewAccessor
.prepareUrlChange(url
);
489 applyViewProperties();
492 // When changing the URL there is no need to keep the version
493 // data of the previous URL.
494 m_viewAccessor
.dirModel()->clearVersionData();
496 emit
startedPathLoading(url
);
499 void DolphinView::setNameFilter(const QString
& nameFilter
)
501 m_controller
->setNameFilter(nameFilter
);
504 void DolphinView::calculateItemCount(int& fileCount
,
506 KIO::filesize_t
& totalFileSize
) const
508 foreach (const KFileItem
& item
, m_viewAccessor
.dirLister()->items()) {
513 totalFileSize
+= item
.size();
518 QString
DolphinView::statusBarText() const
523 KIO::filesize_t totalFileSize
= 0;
525 if (hasSelection()) {
526 // give a summary of the status of the selected files
527 const KFileItemList list
= selectedItems();
528 if (list
.isEmpty()) {
529 // when an item is triggered, it is temporary selected but selectedItems()
530 // will return an empty list
534 KFileItemList::const_iterator it
= list
.begin();
535 const KFileItemList::const_iterator end
= list
.end();
537 const KFileItem
& item
= *it
;
542 totalFileSize
+= item
.size();
547 if (folderCount
+ fileCount
== 1) {
548 // if only one item is selected, show the filename
549 const QString name
= list
.first().name();
550 text
= (folderCount
== 1) ? i18nc("@info:status", "<filename>%1</filename> selected", name
) :
551 i18nc("@info:status", "<filename>%1</filename> selected (%2)",
552 name
, KIO::convertSize(totalFileSize
));
554 // at least 2 items are selected
555 const QString foldersText
= i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount
);
556 const QString filesText
= i18ncp("@info:status", "1 File selected", "%1 Files selected", fileCount
);
557 if ((folderCount
> 0) && (fileCount
> 0)) {
558 text
= i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
559 foldersText
, filesText
, KIO::convertSize(totalFileSize
));
560 } else if (fileCount
> 0) {
561 text
= i18nc("@info:status files (size)", "%1 (%2)", filesText
, KIO::convertSize(totalFileSize
));
563 Q_ASSERT(folderCount
> 0);
568 calculateItemCount(fileCount
, folderCount
, totalFileSize
);
569 text
= KIO::itemsSummaryString(fileCount
+ folderCount
,
570 fileCount
, folderCount
,
571 totalFileSize
, true);
577 QList
<QAction
*> DolphinView::versionControlActions(const KFileItemList
& items
) const
579 return items
.isEmpty()
580 ? m_versionControlObserver
->contextMenuActions(url().path(KUrl::AddTrailingSlash
))
581 : m_versionControlObserver
->contextMenuActions(items
);
584 void DolphinView::setUrl(const KUrl
& url
)
586 m_newFileNames
.clear();
587 updateView(url
, KUrl());
590 void DolphinView::changeSelection(const KFileItemList
& selection
)
593 if (selection
.isEmpty()) {
596 const KUrl
& baseUrl
= url();
598 QItemSelection newSelection
;
599 foreach(const KFileItem
& item
, selection
) {
600 url
= item
.url().upUrl();
601 if (baseUrl
.equals(url
, KUrl::CompareWithoutTrailingSlash
)) {
602 QModelIndex index
= m_viewAccessor
.proxyModel()->mapFromSource(m_viewAccessor
.dirModel()->indexForItem(item
));
603 newSelection
.select(index
, index
);
606 m_viewAccessor
.itemView()->selectionModel()->select(newSelection
,
607 QItemSelectionModel::ClearAndSelect
608 | QItemSelectionModel::Current
);
611 void DolphinView::renameSelectedItems()
613 KFileItemList items
= selectedItems();
614 const int itemCount
= items
.count();
620 // More than one item has been selected for renaming. Open
621 // a rename dialog and rename all items afterwards.
622 QPointer
<RenameDialog
> dialog
= new RenameDialog(this, items
);
623 if (dialog
->exec() == QDialog::Rejected
) {
628 const QString newName
= dialog
->newName();
629 if (newName
.isEmpty()) {
630 emit
errorMessage(dialog
->errorString());
636 // the selection would be invalid after renaming the items, so just clear
640 // TODO: check how this can be integrated into KIO::FileUndoManager/KonqOperations
641 // as one operation instead of n rename operations like it is done now...
642 Q_ASSERT(newName
.contains('#'));
644 // currently the items are sorted by the selection order, resort
645 // them by the file name
646 qSort(items
.begin(), items
.end(), lessThan
);
648 // iterate through all selected items and rename them...
650 foreach (const KFileItem
& item
, items
) {
651 const KUrl
& oldUrl
= item
.url();
653 number
.setNum(index
++);
655 QString name
= newName
;
656 name
.replace('#', number
);
658 if (oldUrl
.fileName() != name
) {
659 KUrl newUrl
= oldUrl
;
660 newUrl
.setFileName(name
);
661 KonqOperations::rename(this, oldUrl
, newUrl
);
664 } else if (DolphinSettings::instance().generalSettings()->renameInline()) {
665 Q_ASSERT(itemCount
== 1);
666 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForItem(items
.first());
667 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
668 m_viewAccessor
.itemView()->edit(proxyIndex
);
670 Q_ASSERT(itemCount
== 1);
672 QPointer
<RenameDialog
> dialog
= new RenameDialog(this, items
);
673 if (dialog
->exec() == QDialog::Rejected
) {
678 const QString newName
= dialog
->newName();
679 if (newName
.isEmpty()) {
680 emit
errorMessage(dialog
->errorString());
686 const KUrl
& oldUrl
= items
.first().url();
687 KUrl newUrl
= oldUrl
;
688 newUrl
.setFileName(newName
);
689 KonqOperations::rename(this, oldUrl
, newUrl
);
692 // assure that the current index remains visible when KDirLister
693 // will notify the view about changed items
694 m_assureVisibleCurrentIndex
= true;
697 void DolphinView::trashSelectedItems()
699 const KUrl::List list
= simplifiedSelectedUrls();
700 KonqOperations::del(this, KonqOperations::TRASH
, list
);
703 void DolphinView::deleteSelectedItems()
705 const KUrl::List list
= simplifiedSelectedUrls();
706 const bool del
= KonqOperations::askDeleteConfirmation(list
,
708 KonqOperations::DEFAULT_CONFIRMATION
,
712 KIO::Job
* job
= KIO::del(list
);
713 connect(job
, SIGNAL(result(KJob
*)),
714 this, SLOT(slotDeleteFileFinished(KJob
*)));
718 void DolphinView::cutSelectedItems()
720 QMimeData
* mimeData
= selectionMimeData();
721 KonqMimeData::addIsCutSelection(mimeData
, true);
722 QApplication::clipboard()->setMimeData(mimeData
);
725 void DolphinView::copySelectedItems()
727 QMimeData
* mimeData
= selectionMimeData();
728 QApplication::clipboard()->setMimeData(mimeData
);
731 void DolphinView::paste()
736 void DolphinView::pasteIntoFolder()
738 const KFileItemList items
= selectedItems();
739 if ((items
.count() == 1) && items
.first().isDir()) {
740 pasteToUrl(items
.first().url());
744 void DolphinView::setShowPreview(bool show
)
746 if (m_showPreview
== show
) {
750 const KUrl viewPropsUrl
= rootUrl();
751 ViewProperties
props(viewPropsUrl
);
752 props
.setShowPreview(show
);
754 m_showPreview
= show
;
755 const int oldZoomLevel
= m_controller
->zoomLevel();
756 emit
showPreviewChanged();
758 // Enabling or disabling the preview might change the icon size of the view.
759 // As the view does not emit a signal when the icon size has been changed,
760 // the used zoom level of the controller must be adjusted manually:
761 updateZoomLevel(oldZoomLevel
);
764 void DolphinView::setShowHiddenFiles(bool show
)
766 if (m_viewAccessor
.dirLister()->showingDotFiles() == show
) {
770 const KUrl viewPropsUrl
= rootUrl();
771 ViewProperties
props(viewPropsUrl
);
772 props
.setShowHiddenFiles(show
);
774 m_viewAccessor
.dirLister()->setShowingDotFiles(show
);
775 emit
showHiddenFilesChanged();
778 void DolphinView::setCategorizedSorting(bool categorized
)
780 if (categorized
== categorizedSorting()) {
784 // setCategorizedSorting(true) may only get invoked
785 // if the view supports categorized sorting
786 Q_ASSERT(!categorized
|| supportsCategorizedSorting());
788 ViewProperties
props(rootUrl());
789 props
.setCategorizedSorting(categorized
);
792 m_storedCategorizedSorting
= categorized
;
793 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
795 emit
categorizedSortingChanged();
798 void DolphinView::toggleSortOrder()
800 const Qt::SortOrder order
= (sortOrder() == Qt::AscendingOrder
) ?
801 Qt::DescendingOrder
:
806 void DolphinView::toggleSortFoldersFirst()
808 setSortFoldersFirst(!sortFoldersFirst());
811 void DolphinView::toggleAdditionalInfo(QAction
* action
)
813 const KFileItemDelegate::Information info
=
814 static_cast<KFileItemDelegate::Information
>(action
->data().toInt());
816 KFileItemDelegate::InformationList list
= additionalInfo();
818 const bool show
= action
->isChecked();
820 const int index
= list
.indexOf(info
);
821 const bool containsInfo
= (index
>= 0);
822 if (show
&& !containsInfo
) {
824 setAdditionalInfo(list
);
825 } else if (!show
&& containsInfo
) {
826 list
.removeAt(index
);
827 setAdditionalInfo(list
);
828 Q_ASSERT(list
.indexOf(info
) < 0);
832 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
834 QWidget::mouseReleaseEvent(event
);
838 void DolphinView::wheelEvent(QWheelEvent
* event
)
840 if (event
->modifiers() & Qt::ControlModifier
) {
841 const int delta
= event
->delta();
842 const int level
= zoomLevel();
844 setZoomLevel(level
+ 1);
845 } else if (delta
< 0) {
846 setZoomLevel(level
- 1);
852 bool DolphinView::eventFilter(QObject
* watched
, QEvent
* event
)
854 switch (event
->type()) {
855 case QEvent::FocusIn
:
856 if (watched
== m_viewAccessor
.itemView()) {
857 m_controller
->requestActivation();
861 case QEvent::MouseButtonPress
:
862 if ((watched
== m_viewAccessor
.itemView()->viewport()) && (m_expandedDragSource
!= 0)) {
863 // Listening to a mousebutton press event to delete expanded views is a
864 // workaround, as it seems impossible for the FolderExpander to know when
865 // a dragging outside a view has been finished. However it works quite well:
866 // A mousebutton press event indicates that a drag operation must be
868 m_expandedDragSource
->deleteLater();
869 m_expandedDragSource
= 0;
873 case QEvent::DragEnter
:
874 if (watched
== m_viewAccessor
.itemView()->viewport()) {
879 case QEvent::KeyPress
:
880 if (watched
== m_viewAccessor
.itemView()) {
881 // clear the selection when Escape has been pressed
882 QKeyEvent
* keyEvent
= static_cast<QKeyEvent
*>(event
);
883 if (keyEvent
->key() == Qt::Key_Escape
) {
893 return QWidget::eventFilter(watched
, event
);
896 void DolphinView::activate()
901 void DolphinView::triggerItem(const KFileItem
& item
)
903 const Qt::KeyboardModifiers modifier
= QApplication::keyboardModifiers();
904 if ((modifier
& Qt::ShiftModifier
) || (modifier
& Qt::ControlModifier
)) {
905 // items are selected by the user, hence don't trigger the
906 // item specified by 'index'
910 // TODO: the m_isContextMenuOpen check is a workaround for Qt-issue 207192
911 if (item
.isNull() || m_isContextMenuOpen
) {
915 emit
itemTriggered(item
); // caught by DolphinViewContainer or DolphinPart
918 void DolphinView::emitDelayedSelectionChangedSignal()
920 // Invoke emitSelectionChangedSignal() with a delay of 300 ms. This assures
921 // that fast selection changes don't result in expensive operations to
922 // collect all file items for the signal (see DolphinView::selectedItems()).
923 m_selectionChangedTimer
->start();
926 void DolphinView::emitSelectionChangedSignal()
928 emit
selectionChanged(DolphinView::selectedItems());
931 void DolphinView::openContextMenu(const QPoint
& pos
,
932 const QList
<QAction
*>& customActions
)
935 const QModelIndex index
= m_viewAccessor
.itemView()->indexAt(pos
);
936 if (index
.isValid() && (index
.column() == DolphinModel::Name
)) {
937 const QModelIndex dolphinModelIndex
= m_viewAccessor
.proxyModel()->mapToSource(index
);
938 item
= m_viewAccessor
.dirModel()->itemForIndex(dolphinModelIndex
);
941 m_isContextMenuOpen
= true; // TODO: workaround for Qt-issue 207192
942 emit
requestContextMenu(item
, url(), customActions
);
943 m_isContextMenuOpen
= false;
946 void DolphinView::dropUrls(const KFileItem
& destItem
,
947 const KUrl
& destPath
,
950 addNewFileNames(event
->mimeData());
951 DragAndDropHelper::instance().dropUrls(destItem
, destPath
, event
, this);
954 void DolphinView::updateSorting(DolphinView::Sorting sorting
)
956 ViewProperties
props(rootUrl());
957 props
.setSorting(sorting
);
959 m_viewAccessor
.proxyModel()->setSorting(sorting
);
961 emit
sortingChanged(sorting
);
964 void DolphinView::updateSortOrder(Qt::SortOrder order
)
966 ViewProperties
props(rootUrl());
967 props
.setSortOrder(order
);
969 m_viewAccessor
.proxyModel()->setSortOrder(order
);
971 emit
sortOrderChanged(order
);
974 void DolphinView::updateSortFoldersFirst(bool foldersFirst
)
976 ViewProperties
props(rootUrl());
977 props
.setSortFoldersFirst(foldersFirst
);
979 m_viewAccessor
.proxyModel()->setSortFoldersFirst(foldersFirst
);
981 emit
sortFoldersFirstChanged(foldersFirst
);
984 void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList
& info
)
986 ViewProperties
props(rootUrl());
987 props
.setAdditionalInfo(info
);
990 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
992 emit
additionalInfoChanged();
995 void DolphinView::updateAdditionalInfoActions(KActionCollection
* collection
)
997 const bool enable
= (m_mode
== DolphinView::DetailsView
) ||
998 (m_mode
== DolphinView::IconsView
);
1000 QAction
* showSizeInfo
= collection
->action("show_size_info");
1001 QAction
* showDateInfo
= collection
->action("show_date_info");
1002 QAction
* showPermissionsInfo
= collection
->action("show_permissions_info");
1003 QAction
* showOwnerInfo
= collection
->action("show_owner_info");
1004 QAction
* showGroupInfo
= collection
->action("show_group_info");
1005 QAction
* showMimeInfo
= collection
->action("show_mime_info");
1007 showSizeInfo
->setChecked(false);
1008 showDateInfo
->setChecked(false);
1009 showPermissionsInfo
->setChecked(false);
1010 showOwnerInfo
->setChecked(false);
1011 showGroupInfo
->setChecked(false);
1012 showMimeInfo
->setChecked(false);
1014 showSizeInfo
->setEnabled(enable
);
1015 showDateInfo
->setEnabled(enable
);
1016 showPermissionsInfo
->setEnabled(enable
);
1017 showOwnerInfo
->setEnabled(enable
);
1018 showGroupInfo
->setEnabled(enable
);
1019 showMimeInfo
->setEnabled(enable
);
1021 foreach (KFileItemDelegate::Information info
, m_viewAccessor
.itemDelegate()->showInformation()) {
1023 case KFileItemDelegate::Size
:
1024 showSizeInfo
->setChecked(true);
1026 case KFileItemDelegate::ModificationTime
:
1027 showDateInfo
->setChecked(true);
1029 case KFileItemDelegate::Permissions
:
1030 showPermissionsInfo
->setChecked(true);
1032 case KFileItemDelegate::Owner
:
1033 showOwnerInfo
->setChecked(true);
1035 case KFileItemDelegate::OwnerAndGroup
:
1036 showGroupInfo
->setChecked(true);
1038 case KFileItemDelegate::FriendlyMimeType
:
1039 showMimeInfo
->setChecked(true);
1047 QPair
<bool, QString
> DolphinView::pasteInfo() const
1049 return KonqOperations::pasteInfo(url());
1052 void DolphinView::setTabsForFilesEnabled(bool tabsForFiles
)
1054 m_tabsForFiles
= tabsForFiles
;
1057 bool DolphinView::isTabsForFilesEnabled() const
1059 return m_tabsForFiles
;
1062 void DolphinView::activateItem(const KUrl
& url
)
1064 m_activeItemUrl
= url
;
1067 bool DolphinView::itemsExpandable() const
1069 return m_viewAccessor
.itemsExpandable();
1072 void DolphinView::deleteWhenNotDragSource(QAbstractItemView
*view
)
1077 if (DragAndDropHelper::instance().isDragSource(view
)) {
1078 // We must store for later deletion.
1079 if (m_expandedDragSource
!= 0) {
1080 // The old stored view is obviously not the drag source anymore.
1081 m_expandedDragSource
->deleteLater();
1082 m_expandedDragSource
= 0;
1085 m_expandedDragSource
= view
;
1088 view
->deleteLater();
1092 void DolphinView::observeCreatedItem(const KUrl
& url
)
1094 m_createdItemUrl
= url
;
1095 connect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
1096 this, SLOT(selectAndScrollToCreatedItem()));
1099 void DolphinView::selectAndScrollToCreatedItem()
1101 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_createdItemUrl
);
1102 if (dirIndex
.isValid()) {
1103 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
1104 m_viewAccessor
.itemView()->setCurrentIndex(proxyIndex
);
1107 disconnect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
1108 this, SLOT(selectAndScrollToCreatedItem()));
1109 m_createdItemUrl
= KUrl();
1112 void DolphinView::restoreSelection()
1114 disconnect(m_viewAccessor
.dirLister(), SIGNAL(completed()), this, SLOT(restoreSelection()));
1115 changeSelection(m_selectedItems
);
1118 void DolphinView::emitContentsMoved()
1120 // only emit the contents moved signal if no directory loading is ongoing
1121 // (this would reset the contents position always to (0, 0))
1122 if (!m_loadingDirectory
) {
1123 const QPoint
pos(contentsPosition());
1124 emit
contentsMoved(pos
.x(), pos
.y());
1128 void DolphinView::showHoverInformation(const KFileItem
& item
)
1130 emit
requestItemInfo(item
);
1133 void DolphinView::clearHoverInformation()
1135 emit
requestItemInfo(KFileItem());
1138 void DolphinView::slotDeleteFileFinished(KJob
* job
)
1140 if (job
->error() == 0) {
1141 emit
operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
1142 } else if (job
->error() != KIO::ERR_USER_CANCELED
) {
1143 emit
errorMessage(job
->errorString());
1147 void DolphinView::slotRequestUrlChange(const KUrl
& url
)
1149 emit
requestUrlChange(url
);
1150 m_controller
->setUrl(url
);
1153 void DolphinView::slotDirListerCompleted()
1155 if (!m_activeItemUrl
.isEmpty()) {
1156 // assure that the current item remains visible
1157 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_activeItemUrl
);
1158 if (dirIndex
.isValid()) {
1159 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
1160 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1161 const bool clearSelection
= !hasSelection();
1162 view
->setCurrentIndex(proxyIndex
);
1163 if (clearSelection
) {
1164 view
->clearSelection();
1166 m_activeItemUrl
.clear();
1170 if (!m_newFileNames
.isEmpty()) {
1171 // select all newly added items created by a paste operation or
1172 // a drag & drop operation
1173 const int rowCount
= m_viewAccessor
.proxyModel()->rowCount();
1174 QItemSelection selection
;
1175 for (int row
= 0; row
< rowCount
; ++row
) {
1176 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->index(row
, 0);
1177 const QModelIndex dirIndex
= m_viewAccessor
.proxyModel()->mapToSource(proxyIndex
);
1178 const KUrl url
= m_viewAccessor
.dirModel()->itemForIndex(dirIndex
).url();
1179 if (m_newFileNames
.contains(url
.fileName())) {
1180 selection
.merge(QItemSelection(proxyIndex
, proxyIndex
), QItemSelectionModel::Select
);
1183 m_viewAccessor
.itemView()->selectionModel()->select(selection
, QItemSelectionModel::Select
);
1185 m_newFileNames
.clear();
1189 void DolphinView::slotRefreshItems()
1191 if (m_assureVisibleCurrentIndex
) {
1192 m_assureVisibleCurrentIndex
= false;
1193 m_viewAccessor
.itemView()->scrollTo(m_viewAccessor
.itemView()->currentIndex());
1197 void DolphinView::loadDirectory(const KUrl
& url
, bool reload
)
1199 if (!url
.isValid()) {
1200 const QString
location(url
.pathOrUrl());
1201 if (location
.isEmpty()) {
1202 emit
errorMessage(i18nc("@info:status", "The location is empty."));
1204 emit
errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location
));
1209 m_loadingDirectory
= true;
1212 m_selectedItems
= selectedItems();
1213 connect(m_viewAccessor
.dirLister(), SIGNAL(completed()), this, SLOT(restoreSelection()));
1216 m_viewAccessor
.dirLister()->stop();
1217 m_viewAccessor
.dirLister()->openUrl(url
, reload
? KDirLister::Reload
: KDirLister::NoFlags
);
1220 void DolphinView::applyViewProperties()
1222 if (m_ignoreViewProperties
) {
1226 const ViewProperties
props(rootUrl());
1228 const Mode mode
= props
.viewMode();
1229 if (m_mode
!= mode
) {
1230 const int oldZoomLevel
= m_controller
->zoomLevel();
1236 updateZoomLevel(oldZoomLevel
);
1238 if (m_viewAccessor
.itemView() == 0) {
1241 Q_ASSERT(m_viewAccessor
.itemView() != 0);
1242 Q_ASSERT(m_viewAccessor
.itemDelegate() != 0);
1244 const bool showHiddenFiles
= props
.showHiddenFiles();
1245 if (showHiddenFiles
!= m_viewAccessor
.dirLister()->showingDotFiles()) {
1246 m_viewAccessor
.dirLister()->setShowingDotFiles(showHiddenFiles
);
1247 emit
showHiddenFilesChanged();
1250 m_storedCategorizedSorting
= props
.categorizedSorting();
1251 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
1252 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
1253 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
1254 emit
categorizedSortingChanged();
1257 const DolphinView::Sorting sorting
= props
.sorting();
1258 if (sorting
!= m_viewAccessor
.proxyModel()->sorting()) {
1259 m_viewAccessor
.proxyModel()->setSorting(sorting
);
1260 emit
sortingChanged(sorting
);
1263 const Qt::SortOrder sortOrder
= props
.sortOrder();
1264 if (sortOrder
!= m_viewAccessor
.proxyModel()->sortOrder()) {
1265 m_viewAccessor
.proxyModel()->setSortOrder(sortOrder
);
1266 emit
sortOrderChanged(sortOrder
);
1269 const bool sortFoldersFirst
= props
.sortFoldersFirst();
1270 if (sortFoldersFirst
!= m_viewAccessor
.proxyModel()->sortFoldersFirst()) {
1271 m_viewAccessor
.proxyModel()->setSortFoldersFirst(sortFoldersFirst
);
1272 emit
sortFoldersFirstChanged(sortFoldersFirst
);
1275 KFileItemDelegate::InformationList info
= props
.additionalInfo();
1276 if (info
!= m_viewAccessor
.itemDelegate()->showInformation()) {
1277 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
1278 emit
additionalInfoChanged();
1281 const bool showPreview
= props
.showPreview();
1282 if (showPreview
!= m_showPreview
) {
1283 m_showPreview
= showPreview
;
1284 const int oldZoomLevel
= m_controller
->zoomLevel();
1285 emit
showPreviewChanged();
1287 // Enabling or disabling the preview might change the icon size of the view.
1288 // As the view does not emit a signal when the icon size has been changed,
1289 // the used zoom level of the controller must be adjusted manually:
1290 updateZoomLevel(oldZoomLevel
);
1293 if (DolphinSettings::instance().generalSettings()->globalViewProps()) {
1294 // During the lifetime of a DolphinView instance the global view properties
1295 // should not be changed. This allows e. g. to split a view and use different
1296 // view properties for each view.
1297 m_ignoreViewProperties
= true;
1301 void DolphinView::createView()
1304 Q_ASSERT(m_viewAccessor
.itemView() == 0);
1305 m_viewAccessor
.createView(this, m_controller
, m_mode
);
1307 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1308 Q_ASSERT(view
!= 0);
1309 view
->installEventFilter(this);
1310 view
->viewport()->installEventFilter(this);
1313 /* TODO: enable folder expanding again later
1315 if (m_mode != ColumnView) {
1316 // Give the view the ability to auto-expand its directories on hovering
1317 // (the column view takes care about this itself). If the details view
1318 // uses expandable folders, the auto-expanding should be used always.
1319 FolderExpander* folderExpander = new FolderExpander(view, m_viewAccessor.proxyModel());
1320 folderExpander->setEnabled(m_viewAccessor.hasExpandableFolders());
1321 connect(folderExpander, SIGNAL(enterDir(const QModelIndex&)),
1322 m_controller, SLOT(triggerItem(const QModelIndex&)));
1326 // Listen out for requests to delete the current column.
1327 connect(m_viewAccessor.columnsContainer(), SIGNAL(requestColumnDeletion(QAbstractItemView*)),
1328 this, SLOT(deleteWhenNotDragSource(QAbstractItemView*)));
1331 m_controller
->setItemView(view
);
1333 // When changing the view mode, the selection is lost due to reinstantiating
1334 // a new item view with a custom selection model. Pass the ownership of the
1335 // selection model to DolphinView, so that it can be shared by all item views.
1336 if (m_selectionModel
!= 0) {
1337 view
->setSelectionModel(m_selectionModel
);
1339 m_selectionModel
= view
->selectionModel();
1341 m_selectionModel
->setParent(this);
1343 m_versionControlObserver
= new VersionControlObserver(view
);
1344 connect(m_versionControlObserver
, SIGNAL(infoMessage(const QString
&)),
1345 this, SIGNAL(infoMessage(const QString
&)));
1346 connect(m_versionControlObserver
, SIGNAL(errorMessage(const QString
&)),
1347 this, SIGNAL(errorMessage(const QString
&)));
1348 connect(m_versionControlObserver
, SIGNAL(operationCompletedMessage(const QString
&)),
1349 this, SIGNAL(operationCompletedMessage(const QString
&)));
1351 connect(view
->selectionModel(), SIGNAL(selectionChanged(const QItemSelection
&, const QItemSelection
&)),
1352 this, SLOT(emitDelayedSelectionChangedSignal()));
1353 connect(view
->verticalScrollBar(), SIGNAL(valueChanged(int)),
1354 this, SLOT(emitContentsMoved()));
1355 connect(view
->horizontalScrollBar(), SIGNAL(valueChanged(int)),
1356 this, SLOT(emitContentsMoved()));
1358 setFocusProxy(m_viewAccessor
.layoutTarget());
1359 m_topLayout
->insertWidget(1, m_viewAccessor
.layoutTarget());
1362 void DolphinView::deleteView()
1364 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1366 // It's important to set the keyboard focus to the parent
1367 // before deleting the view: Otherwise when having a split
1368 // view the other view will get the focus and will request
1369 // an activation (see DolphinView::eventFilter()).
1373 m_topLayout
->removeWidget(view
);
1377 m_controller
->disconnect(view
);
1380 // TODO: move this code into ViewAccessor::deleteView()
1381 deleteWhenNotDragSource(view
);
1384 m_viewAccessor
.deleteView();
1388 void DolphinView::pasteToUrl(const KUrl
& url
)
1390 addNewFileNames(QApplication::clipboard()->mimeData());
1391 KonqOperations::doPaste(this, url
);
1394 void DolphinView::updateZoomLevel(int oldZoomLevel
)
1396 const int newZoomLevel
= ZoomLevelInfo::zoomLevelForIconSize(m_viewAccessor
.itemView()->iconSize());
1397 if (oldZoomLevel
!= newZoomLevel
) {
1398 m_controller
->setZoomLevel(newZoomLevel
);
1399 emit
zoomLevelChanged(newZoomLevel
);
1403 KUrl::List
DolphinView::simplifiedSelectedUrls() const
1405 KUrl::List list
= selectedUrls();
1406 if (itemsExpandable() ) {
1407 list
= KDirModel::simplifiedUrlList(list
);
1412 QMimeData
* DolphinView::selectionMimeData() const
1414 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
1415 Q_ASSERT((view
!= 0) && (view
->selectionModel() != 0));
1416 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
1417 return m_viewAccessor
.dirModel()->mimeData(selection
.indexes());
1420 void DolphinView::addNewFileNames(const QMimeData
* mimeData
)
1422 const KUrl::List urls
= KUrl::List::fromMimeData(mimeData
);
1423 foreach (const KUrl
& url
, urls
) {
1424 m_newFileNames
.insert(url
.fileName());
1428 DolphinView::ViewAccessor::ViewAccessor(DolphinSortFilterProxyModel
* proxyModel
) :
1431 m_columnsContainer(0),
1432 m_proxyModel(proxyModel
)
1436 void DolphinView::ViewAccessor::createView(QWidget
* parent
,
1437 DolphinController
* controller
,
1440 Q_ASSERT(itemView() == 0);
1444 m_iconsView
= new DolphinIconsView(parent
, controller
, m_proxyModel
);
1448 m_detailsView
= new DolphinDetailsView(parent
, controller
, m_proxyModel
);
1452 m_columnsContainer
= new DolphinColumnViewContainer(parent
, controller
);
1460 void DolphinView::ViewAccessor::deleteView()
1462 // TODO: Move the deleteWhenNotDragSource() code into the view
1463 // accessor, so that creating and deleting is fully done by
1464 // the view accessor.
1468 m_columnsContainer
->deleteLater();
1469 m_columnsContainer
= 0;
1473 void DolphinView::ViewAccessor::prepareUrlChange(const KUrl
& url
)
1475 if (m_columnsContainer
!= 0) {
1476 m_columnsContainer
->showColumn(url
);
1480 QAbstractItemView
* DolphinView::ViewAccessor::itemView() const
1482 if (m_iconsView
!= 0) {
1486 if (m_detailsView
!= 0) {
1487 return m_detailsView
;
1490 if (m_columnsContainer
!= 0) {
1491 return m_columnsContainer
->activeColumn();
1497 KFileItemDelegate
* DolphinView::ViewAccessor::itemDelegate() const
1499 return static_cast<KFileItemDelegate
*>(itemView()->itemDelegate());
1502 QWidget
* DolphinView::ViewAccessor::layoutTarget() const
1504 if (m_columnsContainer
!= 0) {
1505 return m_columnsContainer
;
1510 KUrl
DolphinView::ViewAccessor::rootUrl() const
1512 return (m_columnsContainer
!= 0) ? m_columnsContainer
->rootUrl() : KUrl();
1515 bool DolphinView::ViewAccessor::supportsCategorizedSorting() const
1517 return m_iconsView
!= 0;
1520 bool DolphinView::ViewAccessor::hasExpandableFolders() const
1522 const DolphinSettings
& settings
= DolphinSettings::instance();
1523 return settings
.generalSettings()->autoExpandFolders() ||
1524 ((m_detailsView
!= 0) && settings
.detailsModeSettings()->expandableFolders());
1527 bool DolphinView::ViewAccessor::itemsExpandable() const
1529 return (m_detailsView
!= 0) && m_detailsView
->itemsExpandable();
1532 bool DolphinView::ViewAccessor::reloadOnAdditionalInfoChange() const
1534 // the details view requires no reloading of the directory, as it maps
1535 // the file item delegate info to its columns internally
1536 return m_detailsView
!= 0;
1540 DolphinModel
* DolphinView::ViewAccessor::dirModel() const
1542 return static_cast<DolphinModel
*>(proxyModel()->sourceModel());
1545 DolphinSortFilterProxyModel
* DolphinView::ViewAccessor::proxyModel() const
1547 if (m_columnsContainer
!= 0) {
1548 return static_cast<DolphinSortFilterProxyModel
*>(m_columnsContainer
->activeColumn()->model());
1550 return m_proxyModel
;
1553 KDirLister
* DolphinView::ViewAccessor::dirLister() const
1555 return dirModel()->dirLister();
1558 #include "dolphinview.moc"