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 <kfilepreviewgenerator.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 "tooltips/tooltipmanager.h"
66 #include "settings/dolphinsettings.h"
67 #include "versioncontrolobserver.h"
68 #include "viewproperties.h"
69 #include "zoomlevelinfo.h"
72 * Helper function for sorting items with qSort() in
73 * DolphinView::renameSelectedItems().
75 bool lessThan(const KFileItem
& item1
, const KFileItem
& item2
)
77 return KStringHandler::naturalCompare(item1
.name(), item2
.name()) < 0;
80 DolphinView::DolphinView(QWidget
* parent
,
82 DolphinSortFilterProxyModel
* proxyModel
) :
86 m_loadingDirectory(false),
87 m_storedCategorizedSorting(false),
88 m_tabsForFiles(false),
89 m_isContextMenuOpen(false),
90 m_ignoreViewProperties(false),
91 m_assureVisibleCurrentIndex(false),
92 m_mode(DolphinView::IconsView
),
95 m_fileItemDelegate(0),
96 m_viewAccessor(proxyModel
),
98 m_selectionChangedTimer(0),
99 m_previewGenerator(0),
101 m_versionControlObserver(0),
107 m_expandedDragSource(0)
109 m_topLayout
= new QVBoxLayout(this);
110 m_topLayout
->setSpacing(0);
111 m_topLayout
->setMargin(0);
113 m_controller
= new DolphinController(this);
114 m_controller
->setUrl(url
);
116 connect(m_controller
, SIGNAL(urlChanged(const KUrl
&)),
117 this, SIGNAL(urlChanged(const KUrl
&)));
118 connect(m_controller
, SIGNAL(requestUrlChange(const KUrl
&)),
119 this, SLOT(slotRequestUrlChange(const KUrl
&)));
121 connect(m_controller
, SIGNAL(requestContextMenu(const QPoint
&, const QList
<QAction
*>&)),
122 this, SLOT(openContextMenu(const QPoint
&, const QList
<QAction
*>&)));
123 connect(m_controller
, SIGNAL(urlsDropped(const KFileItem
&, const KUrl
&, QDropEvent
*)),
124 this, SLOT(dropUrls(const KFileItem
&, const KUrl
&, QDropEvent
*)));
125 connect(m_controller
, SIGNAL(sortingChanged(DolphinView::Sorting
)),
126 this, SLOT(updateSorting(DolphinView::Sorting
)));
127 connect(m_controller
, SIGNAL(sortOrderChanged(Qt::SortOrder
)),
128 this, SLOT(updateSortOrder(Qt::SortOrder
)));
129 connect(m_controller
, SIGNAL(sortFoldersFirstChanged(bool)),
130 this, SLOT(updateSortFoldersFirst(bool)));
131 connect(m_controller
, SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList
&)),
132 this, SLOT(updateAdditionalInfo(const KFileItemDelegate::InformationList
&)));
133 connect(m_controller
, SIGNAL(itemTriggered(const KFileItem
&)),
134 this, SLOT(triggerItem(const KFileItem
&)));
135 connect(m_controller
, SIGNAL(tabRequested(const KUrl
&)),
136 this, SIGNAL(tabRequested(const KUrl
&)));
137 connect(m_controller
, SIGNAL(activated()),
138 this, SLOT(activate()));
139 connect(m_controller
, SIGNAL(itemEntered(const KFileItem
&)),
140 this, SLOT(showHoverInformation(const KFileItem
&)));
141 connect(m_controller
, SIGNAL(viewportEntered()),
142 this, SLOT(clearHoverInformation()));
144 KDirLister
* dirLister
= m_viewAccessor
.dirLister();
145 connect(dirLister
, SIGNAL(redirection(KUrl
, KUrl
)),
146 this, SIGNAL(redirection(KUrl
, KUrl
)));
147 connect(dirLister
, SIGNAL(completed()),
148 this, SLOT(slotDirListerCompleted()));
149 connect(dirLister
, SIGNAL(refreshItems(const QList
<QPair
<KFileItem
,KFileItem
>>&)),
150 this, SLOT(slotRefreshItems()));
152 // When a new item has been created by the "Create New..." menu, the item should
153 // get selected and it must be assured that the item will get visible. As the
154 // creation is done asynchronously, several signals must be checked:
155 connect(&DolphinNewMenuObserver::instance(), SIGNAL(itemCreated(const KUrl
&)),
156 this, SLOT(observeCreatedItem(const KUrl
&)));
158 applyViewProperties();
159 m_topLayout
->addWidget(m_viewAccessor
.itemView());
162 DolphinView::~DolphinView()
164 delete m_expandedDragSource
;
165 m_expandedDragSource
= 0;
168 const KUrl
& DolphinView::url() const
170 return m_controller
->url();
173 KUrl
DolphinView::rootUrl() const
175 const KUrl viewUrl
= url();
176 const KUrl root
= m_viewAccessor
.rootUrl();
177 if (root
.isEmpty() || !root
.isParentOf(viewUrl
)) {
183 void DolphinView::setActive(bool active
)
185 if (active
== m_active
) {
191 QColor color
= KColorScheme(QPalette::Active
, KColorScheme::View
).background().color();
193 emitSelectionChangedSignal();
198 QWidget
* viewport
= m_viewAccessor
.itemView()->viewport();
200 palette
.setColor(viewport
->backgroundRole(), color
);
201 viewport
->setPalette(palette
);
206 m_viewAccessor
.itemView()->setFocus();
210 m_controller
->indicateActivationChange(active
);
213 bool DolphinView::isActive() const
218 void DolphinView::setMode(Mode mode
)
220 if (mode
== m_mode
) {
221 return; // the wished mode is already set
224 const int oldZoomLevel
= m_controller
->zoomLevel();
229 const KUrl viewPropsUrl
= rootUrl();
230 ViewProperties
props(viewPropsUrl
);
231 props
.setViewMode(m_mode
);
234 // the file item delegate has been recreated, apply the current
235 // additional information manually
236 const KFileItemDelegate::InformationList infoList
= props
.additionalInfo();
237 m_fileItemDelegate
->setShowInformation(infoList
);
238 emit
additionalInfoChanged();
240 // Not all view modes support categorized sorting. Adjust the sorting model
241 // if changing the view mode results in a change of the categorized sorting
243 m_storedCategorizedSorting
= props
.categorizedSorting();
244 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
245 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
246 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
247 emit
categorizedSortingChanged();
252 updateZoomLevel(oldZoomLevel
);
254 loadDirectory(viewPropsUrl
);
258 DolphinView::Mode
DolphinView::mode() const
263 bool DolphinView::showPreview() const
265 return m_showPreview
;
268 bool DolphinView::showHiddenFiles() const
270 return m_viewAccessor
.dirLister()->showingDotFiles();
273 bool DolphinView::categorizedSorting() const
275 // If all view modes would support categorized sorting, returning
276 // m_viewAccessor.proxyModel()->isCategorizedModel() would be the way to go. As
277 // currently only the icons view supports caterized sorting, we remember
278 // the stored view properties state in m_storedCategorizedSorting and
279 // return this state. The application takes care to disable the corresponding
280 // checkbox by checking DolphinView::supportsCategorizedSorting() to indicate
281 // that this setting is not applied to the current view mode.
282 return m_storedCategorizedSorting
;
285 bool DolphinView::supportsCategorizedSorting() const
287 return m_viewAccessor
.supportsCategorizedSorting();
290 void DolphinView::selectAll()
292 QAbstractItemView
* view
= m_viewAccessor
.itemView();
293 // TODO: there seems to be a bug in QAbstractItemView::selectAll(); if
294 // the Ctrl-key is pressed (e. g. for Ctrl+A), selectAll() inverts the
295 // selection instead of selecting all items. This is bypassed for KDE 4.0
296 // by invoking clearSelection() first.
297 view
->clearSelection();
301 void DolphinView::invertSelection()
303 QItemSelectionModel
* selectionModel
= m_viewAccessor
.itemView()->selectionModel();
304 const QAbstractItemModel
* itemModel
= selectionModel
->model();
306 const QModelIndex topLeft
= itemModel
->index(0, 0);
307 const QModelIndex bottomRight
= itemModel
->index(itemModel
->rowCount() - 1,
308 itemModel
->columnCount() - 1);
310 const QItemSelection
selection(topLeft
, bottomRight
);
311 selectionModel
->select(selection
, QItemSelectionModel::Toggle
);
314 bool DolphinView::hasSelection() const
316 return m_viewAccessor
.itemView()->selectionModel()->hasSelection();
319 void DolphinView::clearSelection()
321 QItemSelectionModel
* selModel
= m_viewAccessor
.itemView()->selectionModel();
322 const QModelIndex currentIndex
= selModel
->currentIndex();
323 selModel
->setCurrentIndex(currentIndex
, QItemSelectionModel::Current
|
324 QItemSelectionModel::Clear
);
325 m_selectedItems
.clear();
328 KFileItemList
DolphinView::selectedItems() const
330 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
332 // Our view has a selection, we will map them back to the DolphinModel
333 // and then fill the KFileItemList.
334 Q_ASSERT((view
!= 0) && (view
->selectionModel() != 0));
336 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
337 KFileItemList itemList
;
339 const QModelIndexList indexList
= selection
.indexes();
340 foreach (const QModelIndex
&index
, indexList
) {
341 KFileItem item
= m_viewAccessor
.dirModel()->itemForIndex(index
);
342 if (!item
.isNull()) {
343 itemList
.append(item
);
350 KUrl::List
DolphinView::selectedUrls() const
353 const KFileItemList list
= selectedItems();
354 foreach (const KFileItem
&item
, list
) {
355 urls
.append(item
.url());
360 int DolphinView::selectedItemsCount() const
362 return m_viewAccessor
.itemView()->selectionModel()->selectedIndexes().count();
365 void DolphinView::setContentsPosition(int x
, int y
)
367 QAbstractItemView
* view
= m_viewAccessor
.itemView();
368 view
->horizontalScrollBar()->setValue(x
);
369 view
->verticalScrollBar()->setValue(y
);
371 m_loadingDirectory
= false;
374 QPoint
DolphinView::contentsPosition() const
376 const int x
= m_viewAccessor
.itemView()->horizontalScrollBar()->value();
377 const int y
= m_viewAccessor
.itemView()->verticalScrollBar()->value();
381 void DolphinView::setZoomLevel(int level
)
383 if (level
< ZoomLevelInfo::minimumLevel()) {
384 level
= ZoomLevelInfo::minimumLevel();
385 } else if (level
> ZoomLevelInfo::maximumLevel()) {
386 level
= ZoomLevelInfo::maximumLevel();
389 if (level
!= zoomLevel()) {
390 m_controller
->setZoomLevel(level
);
391 m_previewGenerator
->updateIcons();
392 emit
zoomLevelChanged(level
);
396 int DolphinView::zoomLevel() const
398 return m_controller
->zoomLevel();
401 void DolphinView::setSorting(Sorting sorting
)
403 if (sorting
!= this->sorting()) {
404 updateSorting(sorting
);
408 DolphinView::Sorting
DolphinView::sorting() const
410 return m_viewAccessor
.proxyModel()->sorting();
413 void DolphinView::setSortOrder(Qt::SortOrder order
)
415 if (sortOrder() != order
) {
416 updateSortOrder(order
);
420 Qt::SortOrder
DolphinView::sortOrder() const
422 return m_viewAccessor
.proxyModel()->sortOrder();
425 void DolphinView::setSortFoldersFirst(bool foldersFirst
)
427 if (sortFoldersFirst() != foldersFirst
) {
428 updateSortFoldersFirst(foldersFirst
);
432 bool DolphinView::sortFoldersFirst() const
434 return m_viewAccessor
.proxyModel()->sortFoldersFirst();
437 void DolphinView::setAdditionalInfo(KFileItemDelegate::InformationList info
)
439 const KUrl viewPropsUrl
= rootUrl();
440 ViewProperties
props(viewPropsUrl
);
441 props
.setAdditionalInfo(info
);
442 m_fileItemDelegate
->setShowInformation(info
);
444 emit
additionalInfoChanged();
446 if (m_viewAccessor
.reloadOnAdditionalInfoChange()) {
447 loadDirectory(viewPropsUrl
);
451 KFileItemDelegate::InformationList
DolphinView::additionalInfo() const
453 return m_fileItemDelegate
->showInformation();
456 void DolphinView::reload()
459 loadDirectory(url(), true);
462 void DolphinView::refresh()
464 m_ignoreViewProperties
= false;
466 const bool oldActivationState
= m_active
;
467 const int oldZoomLevel
= m_controller
->zoomLevel();
471 applyViewProperties();
474 setActive(oldActivationState
);
475 updateZoomLevel(oldZoomLevel
);
478 void DolphinView::updateView(const KUrl
& url
, const KUrl
& rootUrl
)
480 Q_UNUSED(rootUrl
); // TODO: remove after columnview-cleanup has been finished
482 if (m_controller
->url() == url
) {
486 m_previewGenerator
->cancelPreviews();
487 m_controller
->setUrl(url
); // emits urlChanged, which we forward
488 if (m_viewAccessor
.prepareUrlChange(url
)) {
491 applyViewProperties();
494 // When changing the URL there is no need to keep the version
495 // data of the previous URL.
496 m_viewAccessor
.dirModel()->clearVersionData();
498 emit
startedPathLoading(url
);
501 void DolphinView::setNameFilter(const QString
& nameFilter
)
503 m_viewAccessor
.setNameFilter(nameFilter
);
506 void DolphinView::calculateItemCount(int& fileCount
,
508 KIO::filesize_t
& totalFileSize
) const
510 foreach (const KFileItem
& item
, m_viewAccessor
.dirLister()->items()) {
515 totalFileSize
+= item
.size();
520 QString
DolphinView::statusBarText() const
525 KIO::filesize_t totalFileSize
= 0;
527 if (hasSelection()) {
528 // give a summary of the status of the selected files
529 const KFileItemList list
= selectedItems();
530 if (list
.isEmpty()) {
531 // when an item is triggered, it is temporary selected but selectedItems()
532 // will return an empty list
536 KFileItemList::const_iterator it
= list
.begin();
537 const KFileItemList::const_iterator end
= list
.end();
539 const KFileItem
& item
= *it
;
544 totalFileSize
+= item
.size();
549 if (folderCount
+ fileCount
== 1) {
550 // if only one item is selected, show the filename
551 const QString name
= list
.first().name();
552 text
= (folderCount
== 1) ? i18nc("@info:status", "<filename>%1</filename> selected", name
) :
553 i18nc("@info:status", "<filename>%1</filename> selected (%2)",
554 name
, KIO::convertSize(totalFileSize
));
556 // at least 2 items are selected
557 const QString foldersText
= i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount
);
558 const QString filesText
= i18ncp("@info:status", "1 File selected", "%1 Files selected", fileCount
);
559 if ((folderCount
> 0) && (fileCount
> 0)) {
560 text
= i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
561 foldersText
, filesText
, KIO::convertSize(totalFileSize
));
562 } else if (fileCount
> 0) {
563 text
= i18nc("@info:status files (size)", "%1 (%2)", filesText
, KIO::convertSize(totalFileSize
));
565 Q_ASSERT(folderCount
> 0);
570 calculateItemCount(fileCount
, folderCount
, totalFileSize
);
571 text
= KIO::itemsSummaryString(fileCount
+ folderCount
,
572 fileCount
, folderCount
,
573 totalFileSize
, true);
579 QList
<QAction
*> DolphinView::versionControlActions(const KFileItemList
& items
) const
581 return items
.isEmpty()
582 ? m_versionControlObserver
->contextMenuActions(url().path(KUrl::AddTrailingSlash
))
583 : m_versionControlObserver
->contextMenuActions(items
);
586 void DolphinView::setUrl(const KUrl
& url
)
588 m_newFileNames
.clear();
589 updateView(url
, KUrl());
592 void DolphinView::changeSelection(const KFileItemList
& selection
)
595 if (selection
.isEmpty()) {
598 const KUrl
& baseUrl
= url();
600 QItemSelection newSelection
;
601 foreach(const KFileItem
& item
, selection
) {
602 url
= item
.url().upUrl();
603 if (baseUrl
.equals(url
, KUrl::CompareWithoutTrailingSlash
)) {
604 QModelIndex index
= m_viewAccessor
.proxyModel()->mapFromSource(m_viewAccessor
.dirModel()->indexForItem(item
));
605 newSelection
.select(index
, index
);
608 m_viewAccessor
.itemView()->selectionModel()->select(newSelection
,
609 QItemSelectionModel::ClearAndSelect
610 | QItemSelectionModel::Current
);
613 void DolphinView::renameSelectedItems()
615 KFileItemList items
= selectedItems();
616 const int itemCount
= items
.count();
622 // More than one item has been selected for renaming. Open
623 // a rename dialog and rename all items afterwards.
624 QPointer
<RenameDialog
> dialog
= new RenameDialog(this, items
);
625 if (dialog
->exec() == QDialog::Rejected
) {
630 const QString newName
= dialog
->newName();
631 if (newName
.isEmpty()) {
632 emit
errorMessage(dialog
->errorString());
638 // the selection would be invalid after renaming the items, so just clear
642 // TODO: check how this can be integrated into KIO::FileUndoManager/KonqOperations
643 // as one operation instead of n rename operations like it is done now...
644 Q_ASSERT(newName
.contains('#'));
646 // currently the items are sorted by the selection order, resort
647 // them by the file name
648 qSort(items
.begin(), items
.end(), lessThan
);
650 // iterate through all selected items and rename them...
652 foreach (const KFileItem
& item
, items
) {
653 const KUrl
& oldUrl
= item
.url();
655 number
.setNum(index
++);
657 QString name
= newName
;
658 name
.replace('#', number
);
660 if (oldUrl
.fileName() != name
) {
661 KUrl newUrl
= oldUrl
;
662 newUrl
.setFileName(name
);
663 KonqOperations::rename(this, oldUrl
, newUrl
);
666 } else if (DolphinSettings::instance().generalSettings()->renameInline()) {
667 Q_ASSERT(itemCount
== 1);
668 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForItem(items
.first());
669 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
670 m_viewAccessor
.itemView()->edit(proxyIndex
);
672 Q_ASSERT(itemCount
== 1);
674 QPointer
<RenameDialog
> dialog
= new RenameDialog(this, items
);
675 if (dialog
->exec() == QDialog::Rejected
) {
680 const QString newName
= dialog
->newName();
681 if (newName
.isEmpty()) {
682 emit
errorMessage(dialog
->errorString());
688 const KUrl
& oldUrl
= items
.first().url();
689 KUrl newUrl
= oldUrl
;
690 newUrl
.setFileName(newName
);
691 KonqOperations::rename(this, oldUrl
, newUrl
);
694 // assure that the current index remains visible when KDirLister
695 // will notify the view about changed items
696 m_assureVisibleCurrentIndex
= true;
699 void DolphinView::trashSelectedItems()
701 const KUrl::List list
= simplifiedSelectedUrls();
702 KonqOperations::del(this, KonqOperations::TRASH
, list
);
705 void DolphinView::deleteSelectedItems()
707 const KUrl::List list
= simplifiedSelectedUrls();
708 const bool del
= KonqOperations::askDeleteConfirmation(list
,
710 KonqOperations::DEFAULT_CONFIRMATION
,
714 KIO::Job
* job
= KIO::del(list
);
715 connect(job
, SIGNAL(result(KJob
*)),
716 this, SLOT(slotDeleteFileFinished(KJob
*)));
720 void DolphinView::cutSelectedItems()
722 QMimeData
* mimeData
= selectionMimeData();
723 KonqMimeData::addIsCutSelection(mimeData
, true);
724 QApplication::clipboard()->setMimeData(mimeData
);
727 void DolphinView::copySelectedItems()
729 QMimeData
* mimeData
= selectionMimeData();
730 QApplication::clipboard()->setMimeData(mimeData
);
733 void DolphinView::paste()
738 void DolphinView::pasteIntoFolder()
740 const KFileItemList items
= selectedItems();
741 if ((items
.count() == 1) && items
.first().isDir()) {
742 pasteToUrl(items
.first().url());
746 void DolphinView::setShowPreview(bool show
)
748 if (m_showPreview
== show
) {
752 const KUrl viewPropsUrl
= rootUrl();
753 ViewProperties
props(viewPropsUrl
);
754 props
.setShowPreview(show
);
756 m_showPreview
= show
;
757 m_previewGenerator
->setPreviewShown(show
);
759 const int oldZoomLevel
= m_controller
->zoomLevel();
760 emit
showPreviewChanged();
762 // Enabling or disabling the preview might change the icon size of the view.
763 // As the view does not emit a signal when the icon size has been changed,
764 // the used zoom level of the controller must be adjusted manually:
765 updateZoomLevel(oldZoomLevel
);
767 loadDirectory(viewPropsUrl
);
770 void DolphinView::setShowHiddenFiles(bool show
)
772 if (m_viewAccessor
.dirLister()->showingDotFiles() == show
) {
776 const KUrl viewPropsUrl
= rootUrl();
777 ViewProperties
props(viewPropsUrl
);
778 props
.setShowHiddenFiles(show
);
780 m_viewAccessor
.dirLister()->setShowingDotFiles(show
);
781 emit
showHiddenFilesChanged();
783 loadDirectory(viewPropsUrl
);
786 void DolphinView::setCategorizedSorting(bool categorized
)
788 if (categorized
== categorizedSorting()) {
792 // setCategorizedSorting(true) may only get invoked
793 // if the view supports categorized sorting
794 Q_ASSERT(!categorized
|| supportsCategorizedSorting());
796 ViewProperties
props(rootUrl());
797 props
.setCategorizedSorting(categorized
);
800 m_storedCategorizedSorting
= categorized
;
801 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
803 emit
categorizedSortingChanged();
806 void DolphinView::toggleSortOrder()
808 const Qt::SortOrder order
= (sortOrder() == Qt::AscendingOrder
) ?
809 Qt::DescendingOrder
:
814 void DolphinView::toggleSortFoldersFirst()
816 setSortFoldersFirst(!sortFoldersFirst());
819 void DolphinView::toggleAdditionalInfo(QAction
* action
)
821 const KFileItemDelegate::Information info
=
822 static_cast<KFileItemDelegate::Information
>(action
->data().toInt());
824 KFileItemDelegate::InformationList list
= additionalInfo();
826 const bool show
= action
->isChecked();
828 const int index
= list
.indexOf(info
);
829 const bool containsInfo
= (index
>= 0);
830 if (show
&& !containsInfo
) {
832 setAdditionalInfo(list
);
833 } else if (!show
&& containsInfo
) {
834 list
.removeAt(index
);
835 setAdditionalInfo(list
);
836 Q_ASSERT(list
.indexOf(info
) < 0);
840 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
842 QWidget::mouseReleaseEvent(event
);
846 void DolphinView::wheelEvent(QWheelEvent
* event
)
848 if (event
->modifiers() & Qt::ControlModifier
) {
849 const int delta
= event
->delta();
850 const int level
= zoomLevel();
852 setZoomLevel(level
+ 1);
853 } else if (delta
< 0) {
854 setZoomLevel(level
- 1);
860 bool DolphinView::eventFilter(QObject
* watched
, QEvent
* event
)
862 switch (event
->type()) {
863 case QEvent::FocusIn
:
864 if (watched
== m_viewAccessor
.itemView()) {
865 m_controller
->requestActivation();
869 case QEvent::MouseButtonPress
:
870 if ((watched
== m_viewAccessor
.itemView()->viewport()) && (m_expandedDragSource
!= 0)) {
871 // Listening to a mousebutton press event to delete expanded views is a
872 // workaround, as it seems impossible for the FolderExpander to know when
873 // a dragging outside a view has been finished. However it works quite well:
874 // A mousebutton press event indicates that a drag operation must be
876 m_expandedDragSource
->deleteLater();
877 m_expandedDragSource
= 0;
881 case QEvent::DragEnter
:
882 if (watched
== m_viewAccessor
.itemView()->viewport()) {
887 case QEvent::KeyPress
:
888 if (watched
== m_viewAccessor
.itemView()) {
889 if (m_toolTipManager
!= 0) {
890 m_toolTipManager
->hideTip();
893 // clear the selection when Escape has been pressed
894 QKeyEvent
* keyEvent
= static_cast<QKeyEvent
*>(event
);
895 if (keyEvent
->key() == Qt::Key_Escape
) {
905 return QWidget::eventFilter(watched
, event
);
908 void DolphinView::activate()
913 void DolphinView::triggerItem(const KFileItem
& item
)
915 const Qt::KeyboardModifiers modifier
= QApplication::keyboardModifiers();
916 if ((modifier
& Qt::ShiftModifier
) || (modifier
& Qt::ControlModifier
)) {
917 // items are selected by the user, hence don't trigger the
918 // item specified by 'index'
922 // TODO: the m_isContextMenuOpen check is a workaround for Qt-issue 207192
923 if (item
.isNull() || m_isContextMenuOpen
) {
927 if (m_toolTipManager
!= 0) {
928 m_toolTipManager
->hideTip();
930 emit
itemTriggered(item
); // caught by DolphinViewContainer or DolphinPart
933 void DolphinView::emitDelayedSelectionChangedSignal()
935 // Invoke emitSelectionChangedSignal() with a delay of 300 ms. This assures
936 // that fast selection changes don't result in expensive operations to
937 // collect all file items for the signal (see DolphinView::selectedItems()).
938 m_selectionChangedTimer
->start();
941 void DolphinView::emitSelectionChangedSignal()
943 emit
selectionChanged(DolphinView::selectedItems());
946 void DolphinView::openContextMenu(const QPoint
& pos
,
947 const QList
<QAction
*>& customActions
)
950 const QModelIndex index
= m_viewAccessor
.itemView()->indexAt(pos
);
951 if (index
.isValid() && (index
.column() == DolphinModel::Name
)) {
952 const QModelIndex dolphinModelIndex
= m_viewAccessor
.proxyModel()->mapToSource(index
);
953 item
= m_viewAccessor
.dirModel()->itemForIndex(dolphinModelIndex
);
956 if (m_toolTipManager
!= 0) {
957 m_toolTipManager
->hideTip();
960 m_isContextMenuOpen
= true; // TODO: workaround for Qt-issue 207192
961 emit
requestContextMenu(item
, url(), customActions
);
962 m_isContextMenuOpen
= false;
965 void DolphinView::dropUrls(const KFileItem
& destItem
,
966 const KUrl
& destPath
,
969 addNewFileNames(event
->mimeData());
970 DragAndDropHelper::instance().dropUrls(destItem
, destPath
, event
, this);
973 void DolphinView::updateSorting(DolphinView::Sorting sorting
)
975 ViewProperties
props(rootUrl());
976 props
.setSorting(sorting
);
978 m_viewAccessor
.proxyModel()->setSorting(sorting
);
980 emit
sortingChanged(sorting
);
983 void DolphinView::updateSortOrder(Qt::SortOrder order
)
985 ViewProperties
props(rootUrl());
986 props
.setSortOrder(order
);
988 m_viewAccessor
.proxyModel()->setSortOrder(order
);
990 emit
sortOrderChanged(order
);
993 void DolphinView::updateSortFoldersFirst(bool foldersFirst
)
995 ViewProperties
props(rootUrl());
996 props
.setSortFoldersFirst(foldersFirst
);
998 m_viewAccessor
.proxyModel()->setSortFoldersFirst(foldersFirst
);
1000 emit
sortFoldersFirstChanged(foldersFirst
);
1003 void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList
& info
)
1005 ViewProperties
props(rootUrl());
1006 props
.setAdditionalInfo(info
);
1009 m_fileItemDelegate
->setShowInformation(info
);
1011 emit
additionalInfoChanged();
1014 void DolphinView::updateAdditionalInfoActions(KActionCollection
* collection
)
1016 const bool enable
= (m_mode
== DolphinView::DetailsView
) ||
1017 (m_mode
== DolphinView::IconsView
);
1019 QAction
* showSizeInfo
= collection
->action("show_size_info");
1020 QAction
* showDateInfo
= collection
->action("show_date_info");
1021 QAction
* showPermissionsInfo
= collection
->action("show_permissions_info");
1022 QAction
* showOwnerInfo
= collection
->action("show_owner_info");
1023 QAction
* showGroupInfo
= collection
->action("show_group_info");
1024 QAction
* showMimeInfo
= collection
->action("show_mime_info");
1026 showSizeInfo
->setChecked(false);
1027 showDateInfo
->setChecked(false);
1028 showPermissionsInfo
->setChecked(false);
1029 showOwnerInfo
->setChecked(false);
1030 showGroupInfo
->setChecked(false);
1031 showMimeInfo
->setChecked(false);
1033 showSizeInfo
->setEnabled(enable
);
1034 showDateInfo
->setEnabled(enable
);
1035 showPermissionsInfo
->setEnabled(enable
);
1036 showOwnerInfo
->setEnabled(enable
);
1037 showGroupInfo
->setEnabled(enable
);
1038 showMimeInfo
->setEnabled(enable
);
1040 foreach (KFileItemDelegate::Information info
, m_fileItemDelegate
->showInformation()) {
1042 case KFileItemDelegate::Size
:
1043 showSizeInfo
->setChecked(true);
1045 case KFileItemDelegate::ModificationTime
:
1046 showDateInfo
->setChecked(true);
1048 case KFileItemDelegate::Permissions
:
1049 showPermissionsInfo
->setChecked(true);
1051 case KFileItemDelegate::Owner
:
1052 showOwnerInfo
->setChecked(true);
1054 case KFileItemDelegate::OwnerAndGroup
:
1055 showGroupInfo
->setChecked(true);
1057 case KFileItemDelegate::FriendlyMimeType
:
1058 showMimeInfo
->setChecked(true);
1066 QPair
<bool, QString
> DolphinView::pasteInfo() const
1068 return KonqOperations::pasteInfo(url());
1071 void DolphinView::setTabsForFilesEnabled(bool tabsForFiles
)
1073 m_tabsForFiles
= tabsForFiles
;
1076 bool DolphinView::isTabsForFilesEnabled() const
1078 return m_tabsForFiles
;
1081 void DolphinView::activateItem(const KUrl
& url
)
1083 m_activeItemUrl
= url
;
1086 bool DolphinView::itemsExpandable() const
1088 return m_viewAccessor
.itemsExpandable();
1091 void DolphinView::deleteWhenNotDragSource(QAbstractItemView
*view
)
1096 if (DragAndDropHelper::instance().isDragSource(view
)) {
1097 // We must store for later deletion.
1098 if (m_expandedDragSource
!= 0) {
1099 // The old stored view is obviously not the drag source anymore.
1100 m_expandedDragSource
->deleteLater();
1101 m_expandedDragSource
= 0;
1104 m_expandedDragSource
= view
;
1107 view
->deleteLater();
1111 void DolphinView::observeCreatedItem(const KUrl
& url
)
1113 m_createdItemUrl
= url
;
1114 connect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
1115 this, SLOT(selectAndScrollToCreatedItem()));
1118 void DolphinView::selectAndScrollToCreatedItem()
1120 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_createdItemUrl
);
1121 if (dirIndex
.isValid()) {
1122 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
1123 m_viewAccessor
.itemView()->setCurrentIndex(proxyIndex
);
1126 disconnect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
1127 this, SLOT(selectAndScrollToCreatedItem()));
1128 m_createdItemUrl
= KUrl();
1131 void DolphinView::restoreSelection()
1133 disconnect(m_viewAccessor
.dirLister(), SIGNAL(completed()), this, SLOT(restoreSelection()));
1134 changeSelection(m_selectedItems
);
1137 void DolphinView::emitContentsMoved()
1139 // only emit the contents moved signal if no directory loading is ongoing
1140 // (this would reset the contents position always to (0, 0))
1141 if (!m_loadingDirectory
) {
1142 const QPoint
pos(contentsPosition());
1143 emit
contentsMoved(pos
.x(), pos
.y());
1147 void DolphinView::showHoverInformation(const KFileItem
& item
)
1149 emit
requestItemInfo(item
);
1152 void DolphinView::clearHoverInformation()
1154 emit
requestItemInfo(KFileItem());
1157 void DolphinView::slotDeleteFileFinished(KJob
* job
)
1159 if (job
->error() == 0) {
1160 emit
operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
1161 } else if (job
->error() != KIO::ERR_USER_CANCELED
) {
1162 emit
errorMessage(job
->errorString());
1166 void DolphinView::slotRequestUrlChange(const KUrl
& url
)
1168 emit
requestUrlChange(url
);
1169 m_controller
->setUrl(url
);
1172 void DolphinView::slotDirListerCompleted()
1174 if (!m_activeItemUrl
.isEmpty()) {
1175 // assure that the current item remains visible
1176 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_activeItemUrl
);
1177 if (dirIndex
.isValid()) {
1178 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
1179 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1180 const bool clearSelection
= !hasSelection();
1181 view
->setCurrentIndex(proxyIndex
);
1182 if (clearSelection
) {
1183 view
->clearSelection();
1185 m_activeItemUrl
.clear();
1189 if (!m_newFileNames
.isEmpty()) {
1190 // select all newly added items created by a paste operation or
1191 // a drag & drop operation
1192 const int rowCount
= m_viewAccessor
.proxyModel()->rowCount();
1193 QItemSelection selection
;
1194 for (int row
= 0; row
< rowCount
; ++row
) {
1195 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->index(row
, 0);
1196 const QModelIndex dirIndex
= m_viewAccessor
.proxyModel()->mapToSource(proxyIndex
);
1197 const KUrl url
= m_viewAccessor
.dirModel()->itemForIndex(dirIndex
).url();
1198 if (m_newFileNames
.contains(url
.fileName())) {
1199 selection
.merge(QItemSelection(proxyIndex
, proxyIndex
), QItemSelectionModel::Select
);
1202 m_viewAccessor
.itemView()->selectionModel()->select(selection
, QItemSelectionModel::Select
);
1204 m_newFileNames
.clear();
1208 void DolphinView::slotRefreshItems()
1210 if (m_assureVisibleCurrentIndex
) {
1211 m_assureVisibleCurrentIndex
= false;
1212 m_viewAccessor
.itemView()->scrollTo(m_viewAccessor
.itemView()->currentIndex());
1216 void DolphinView::loadDirectory(const KUrl
& url
, bool reload
)
1218 if (!url
.isValid()) {
1219 const QString
location(url
.pathOrUrl());
1220 if (location
.isEmpty()) {
1221 emit
errorMessage(i18nc("@info:status", "The location is empty."));
1223 emit
errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location
));
1228 m_loadingDirectory
= true;
1231 m_selectedItems
= selectedItems();
1232 connect(m_viewAccessor
.dirLister(), SIGNAL(completed()), this, SLOT(restoreSelection()));
1235 m_viewAccessor
.dirLister()->stop();
1236 m_viewAccessor
.dirLister()->openUrl(url
, reload
? KDirLister::Reload
: KDirLister::NoFlags
);
1239 void DolphinView::applyViewProperties()
1241 if (m_ignoreViewProperties
) {
1245 const ViewProperties
props(rootUrl());
1247 const Mode mode
= props
.viewMode();
1248 if (m_mode
!= mode
) {
1249 const int oldZoomLevel
= m_controller
->zoomLevel();
1255 updateZoomLevel(oldZoomLevel
);
1257 if (m_viewAccessor
.itemView() == 0) {
1260 Q_ASSERT(m_viewAccessor
.itemView() != 0);
1261 Q_ASSERT(m_fileItemDelegate
!= 0);
1263 const bool showHiddenFiles
= props
.showHiddenFiles();
1264 if (showHiddenFiles
!= m_viewAccessor
.dirLister()->showingDotFiles()) {
1265 m_viewAccessor
.dirLister()->setShowingDotFiles(showHiddenFiles
);
1266 emit
showHiddenFilesChanged();
1269 m_storedCategorizedSorting
= props
.categorizedSorting();
1270 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
1271 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
1272 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
1273 emit
categorizedSortingChanged();
1276 const DolphinView::Sorting sorting
= props
.sorting();
1277 if (sorting
!= m_viewAccessor
.proxyModel()->sorting()) {
1278 m_viewAccessor
.proxyModel()->setSorting(sorting
);
1279 emit
sortingChanged(sorting
);
1282 const Qt::SortOrder sortOrder
= props
.sortOrder();
1283 if (sortOrder
!= m_viewAccessor
.proxyModel()->sortOrder()) {
1284 m_viewAccessor
.proxyModel()->setSortOrder(sortOrder
);
1285 emit
sortOrderChanged(sortOrder
);
1288 const bool sortFoldersFirst
= props
.sortFoldersFirst();
1289 if (sortFoldersFirst
!= m_viewAccessor
.proxyModel()->sortFoldersFirst()) {
1290 m_viewAccessor
.proxyModel()->setSortFoldersFirst(sortFoldersFirst
);
1291 emit
sortFoldersFirstChanged(sortFoldersFirst
);
1294 KFileItemDelegate::InformationList info
= props
.additionalInfo();
1295 if (info
!= m_fileItemDelegate
->showInformation()) {
1296 m_fileItemDelegate
->setShowInformation(info
);
1297 emit
additionalInfoChanged();
1300 const bool showPreview
= props
.showPreview();
1301 if (showPreview
!= m_showPreview
) {
1302 m_showPreview
= showPreview
;
1303 m_previewGenerator
->setPreviewShown(showPreview
);
1305 const int oldZoomLevel
= m_controller
->zoomLevel();
1306 emit
showPreviewChanged();
1308 // Enabling or disabling the preview might change the icon size of the view.
1309 // As the view does not emit a signal when the icon size has been changed,
1310 // the used zoom level of the controller must be adjusted manually:
1311 updateZoomLevel(oldZoomLevel
);
1314 if (DolphinSettings::instance().generalSettings()->globalViewProps()) {
1315 // During the lifetime of a DolphinView instance the global view properties
1316 // should not be changed. This allows e. g. to split a view and use different
1317 // view properties for each view.
1318 m_ignoreViewProperties
= true;
1322 void DolphinView::createView()
1325 Q_ASSERT(m_viewAccessor
.itemView() == 0);
1326 m_viewAccessor
.createView(this, m_controller
, m_mode
);
1328 m_topLayout
->insertWidget(1, m_viewAccessor
.layoutTarget());
1331 void DolphinView::deleteView()
1333 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1335 // It's important to set the keyboard focus to the parent
1336 // before deleting the view: Otherwise when having a split
1337 // view the other view will get the focus and will request
1338 // an activation (see DolphinView::eventFilter()).
1342 m_topLayout
->removeWidget(view
);
1345 // m_previewGenerator's parent is not always destroyed, and we
1346 // don't want two active at once - manually delete.
1347 delete m_previewGenerator
;
1348 m_previewGenerator
= 0;
1351 m_controller
->disconnect(view
);
1354 // TODO: move this code into ViewAccessor::deleteView()
1355 deleteWhenNotDragSource(view
);
1358 m_viewAccessor
.deleteView();
1359 m_fileItemDelegate
= 0;
1360 m_toolTipManager
= 0;
1364 void DolphinView::initializeView()
1366 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1367 Q_ASSERT(view
!= 0);
1368 view
->installEventFilter(this);
1369 view
->viewport()->installEventFilter(this);
1370 setFocusProxy(view
);
1372 //if (m_mode != ColumnView) {
1373 // Give the view the ability to auto-expand its directories on hovering
1374 // (the column view takes care about this itself). If the details view
1375 // uses expandable folders, the auto-expanding should be used always.
1376 FolderExpander
* folderExpander
= new FolderExpander(view
, m_viewAccessor
.proxyModel());
1377 folderExpander
->setEnabled(m_viewAccessor
.hasExpandableFolders());
1378 connect(folderExpander
, SIGNAL(enterDir(const QModelIndex
&)),
1379 m_controller
, SLOT(triggerItem(const QModelIndex
&)));
1381 // TODO: enable again later
1384 // Listen out for requests to delete the current column.
1385 connect(m_viewAccessor.columnsContainer(), SIGNAL(requestColumnDeletion(QAbstractItemView*)),
1386 this, SLOT(deleteWhenNotDragSource(QAbstractItemView*)));
1389 m_controller
->setItemView(view
);
1391 m_fileItemDelegate
= new DolphinFileItemDelegate(view
);
1392 m_fileItemDelegate
->setShowToolTipWhenElided(false);
1393 m_fileItemDelegate
->setMinimizedNameColumn(m_mode
== DetailsView
);
1394 view
->setItemDelegate(m_fileItemDelegate
);
1396 view
->setModel(m_viewAccessor
.proxyModel());
1397 if (m_selectionModel
!= 0) {
1398 view
->setSelectionModel(m_selectionModel
);
1400 m_selectionModel
= view
->selectionModel();
1403 m_selectionChangedTimer
= new QTimer(this);
1404 m_selectionChangedTimer
->setSingleShot(true);
1405 m_selectionChangedTimer
->setInterval(300);
1406 connect(m_selectionChangedTimer
, SIGNAL(timeout()),
1407 this, SLOT(emitSelectionChangedSignal()));
1409 // reparent the selection model, as it should not be deleted
1410 // when deleting the model
1411 m_selectionModel
->setParent(this);
1413 view
->setSelectionMode(QAbstractItemView::ExtendedSelection
);
1415 m_previewGenerator
= new KFilePreviewGenerator(view
);
1416 m_previewGenerator
->setPreviewShown(m_showPreview
);
1418 m_versionControlObserver
= new VersionControlObserver(view
);
1419 connect(m_versionControlObserver
, SIGNAL(infoMessage(const QString
&)),
1420 this, SIGNAL(infoMessage(const QString
&)));
1421 connect(m_versionControlObserver
, SIGNAL(errorMessage(const QString
&)),
1422 this, SIGNAL(errorMessage(const QString
&)));
1423 connect(m_versionControlObserver
, SIGNAL(operationCompletedMessage(const QString
&)),
1424 this, SIGNAL(operationCompletedMessage(const QString
&)));
1426 if (DolphinSettings::instance().generalSettings()->showToolTips()) {
1427 m_toolTipManager
= new ToolTipManager(view
, m_viewAccessor
.proxyModel());
1428 connect(m_controller
, SIGNAL(hideToolTip()),
1429 m_toolTipManager
, SLOT(hideTip()));
1432 connect(view
->selectionModel(), SIGNAL(selectionChanged(const QItemSelection
&, const QItemSelection
&)),
1433 this, SLOT(emitDelayedSelectionChangedSignal()));
1434 connect(view
->verticalScrollBar(), SIGNAL(valueChanged(int)),
1435 this, SLOT(emitContentsMoved()));
1436 connect(view
->horizontalScrollBar(), SIGNAL(valueChanged(int)),
1437 this, SLOT(emitContentsMoved()));
1440 void DolphinView::pasteToUrl(const KUrl
& url
)
1442 addNewFileNames(QApplication::clipboard()->mimeData());
1443 KonqOperations::doPaste(this, url
);
1446 void DolphinView::updateZoomLevel(int oldZoomLevel
)
1448 const int newZoomLevel
= ZoomLevelInfo::zoomLevelForIconSize(m_viewAccessor
.itemView()->iconSize());
1449 if (oldZoomLevel
!= newZoomLevel
) {
1450 m_controller
->setZoomLevel(newZoomLevel
);
1451 emit
zoomLevelChanged(newZoomLevel
);
1455 KUrl::List
DolphinView::simplifiedSelectedUrls() const
1457 KUrl::List list
= selectedUrls();
1458 if (itemsExpandable() ) {
1459 list
= KDirModel::simplifiedUrlList(list
);
1464 QMimeData
* DolphinView::selectionMimeData() const
1466 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
1467 Q_ASSERT((view
!= 0) && (view
->selectionModel() != 0));
1468 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
1469 return m_viewAccessor
.dirModel()->mimeData(selection
.indexes());
1472 void DolphinView::addNewFileNames(const QMimeData
* mimeData
)
1474 const KUrl::List urls
= KUrl::List::fromMimeData(mimeData
);
1475 foreach (const KUrl
& url
, urls
) {
1476 m_newFileNames
.insert(url
.fileName());
1480 DolphinView::ViewAccessor::ViewAccessor(DolphinSortFilterProxyModel
* proxyModel
) :
1483 m_columnsContainer(0),
1484 m_proxyModel(proxyModel
)
1488 void DolphinView::ViewAccessor::createView(QWidget
* parent
,
1489 DolphinController
* controller
,
1492 Q_ASSERT(itemView() == 0);
1496 m_iconsView
= new DolphinIconsView(parent
, controller
);
1500 m_detailsView
= new DolphinDetailsView(parent
, controller
);
1504 m_columnsContainer
= new DolphinColumnViewContainer(parent
, controller
);
1512 void DolphinView::ViewAccessor::deleteView()
1514 // TODO: Move the deleteWhenNotDragSource() code into the view
1515 // accessor, so that creating and deleting is fully done by
1516 // the view accessor.
1520 m_columnsContainer
->deleteLater();
1521 m_columnsContainer
= 0;
1525 bool DolphinView::ViewAccessor::prepareUrlChange(const KUrl
& url
)
1527 if (m_columnsContainer
!= 0) {
1528 return m_columnsContainer
->showColumn(url
);
1533 QAbstractItemView
* DolphinView::ViewAccessor::itemView() const
1535 if (m_iconsView
!= 0) {
1539 if (m_detailsView
!= 0) {
1540 return m_detailsView
;
1543 if (m_columnsContainer
!= 0) {
1544 return m_columnsContainer
->activeColumn();
1550 QWidget
* DolphinView::ViewAccessor::layoutTarget() const
1552 if (m_columnsContainer
!= 0) {
1553 return m_columnsContainer
;
1558 void DolphinView::ViewAccessor::setNameFilter(const QString
& nameFilter
)
1560 if (m_columnsContainer
== 0) {
1561 m_columnsContainer
->setNameFilter(nameFilter
);
1563 proxyModel()->setFilterRegExp(nameFilter
);
1567 KUrl
DolphinView::ViewAccessor::rootUrl() const
1569 return (m_columnsContainer
!= 0) ? m_columnsContainer
->rootUrl() : KUrl();
1572 bool DolphinView::ViewAccessor::supportsCategorizedSorting() const
1574 return m_iconsView
!= 0;
1577 bool DolphinView::ViewAccessor::hasExpandableFolders() const
1579 const DolphinSettings
& settings
= DolphinSettings::instance();
1580 return settings
.generalSettings()->autoExpandFolders() ||
1581 ((m_detailsView
!= 0) && settings
.detailsModeSettings()->expandableFolders());
1584 bool DolphinView::ViewAccessor::itemsExpandable() const
1586 return (m_detailsView
!= 0) && m_detailsView
->itemsExpandable();
1589 bool DolphinView::ViewAccessor::reloadOnAdditionalInfoChange() const
1591 // the details view requires no reloading of the directory, as it maps
1592 // the file item delegate info to its columns internally
1593 return m_detailsView
!= 0;
1597 DolphinModel
* DolphinView::ViewAccessor::dirModel() const
1599 return static_cast<DolphinModel
*>(proxyModel()->sourceModel());
1602 DolphinSortFilterProxyModel
* DolphinView::ViewAccessor::proxyModel() const
1604 if (m_columnsContainer
!= 0) {
1605 return static_cast<DolphinSortFilterProxyModel
*>(m_columnsContainer
->activeColumn()->model());
1607 return m_proxyModel
;
1610 KDirLister
* DolphinView::ViewAccessor::dirLister() const
1612 return dirModel()->dirLister();
1615 #include "dolphinview.moc"