1 /***************************************************************************
2 * Copyright (C) 2006-2009 by Peter Penz <peter.penz@gmx.at> *
3 * Copyright (C) 2006 by Gregor Kališnik <gregor@podnapisi.net> *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
21 #include "dolphinview.h"
23 #include <QAbstractItemView>
24 #include <QApplication>
27 #include <QItemSelection>
32 #include <kactioncollection.h>
33 #include <kcolorscheme.h>
34 #include <kdirlister.h>
35 #include <kiconeffect.h>
36 #include <kfileitem.h>
37 #include <kfileitemlistproperties.h>
39 #include <kio/deletejob.h>
40 #include <kio/netaccess.h>
41 #include <kio/previewjob.h>
44 #include <kmessagebox.h>
45 #include <konq_fileitemcapabilities.h>
46 #include <konq_operations.h>
47 #include <konqmimedata.h>
48 #include <ktoggleaction.h>
51 #include "additionalinfoaccessor.h"
52 #include "dolphinmodel.h"
53 #include "dolphincolumnviewcontainer.h"
54 #include "dolphinviewcontroller.h"
55 #include "dolphindetailsview.h"
56 #include "dolphinfileitemdelegate.h"
57 #include "dolphinnewfilemenuobserver.h"
58 #include "dolphinsortfilterproxymodel.h"
59 #include "dolphin_detailsmodesettings.h"
60 #include "dolphiniconsview.h"
61 #include "dolphin_generalsettings.h"
62 #include "draganddrophelper.h"
63 #include "renamedialog.h"
64 #include "settings/dolphinsettings.h"
65 #include "viewmodecontroller.h"
66 #include "viewproperties.h"
67 #include "zoomlevelinfo.h"
68 #include "dolphindetailsviewexpander.h"
70 DolphinView::DolphinView(QWidget
* parent
,
72 DolphinSortFilterProxyModel
* proxyModel
) :
76 m_storedCategorizedSorting(false),
77 m_tabsForFiles(false),
78 m_isContextMenuOpen(false),
79 m_assureVisibleCurrentIndex(false),
80 m_expanderActive(false),
81 m_isFolderWritable(true),
82 m_mode(DolphinView::IconsView
),
84 m_dolphinViewController(0),
85 m_viewModeController(0),
86 m_viewAccessor(proxyModel
),
87 m_selectionChangedTimer(0),
89 m_restoredContentsPosition(),
94 m_topLayout
= new QVBoxLayout(this);
95 m_topLayout
->setSpacing(0);
96 m_topLayout
->setMargin(0);
98 m_dolphinViewController
= new DolphinViewController(this);
100 m_viewModeController
= new ViewModeController(this);
101 m_viewModeController
->setUrl(url
);
103 connect(m_viewModeController
, SIGNAL(urlChanged(const KUrl
&)),
104 this, SIGNAL(urlChanged(const KUrl
&)));
106 connect(m_dolphinViewController
, SIGNAL(requestContextMenu(const QPoint
&, const QList
<QAction
*>&)),
107 this, SLOT(openContextMenu(const QPoint
&, const QList
<QAction
*>&)));
108 connect(m_dolphinViewController
, SIGNAL(urlsDropped(const KFileItem
&, const KUrl
&, QDropEvent
*)),
109 this, SLOT(dropUrls(const KFileItem
&, const KUrl
&, QDropEvent
*)));
110 connect(m_dolphinViewController
, SIGNAL(sortingChanged(DolphinView::Sorting
)),
111 this, SLOT(updateSorting(DolphinView::Sorting
)));
112 connect(m_dolphinViewController
, SIGNAL(sortOrderChanged(Qt::SortOrder
)),
113 this, SLOT(updateSortOrder(Qt::SortOrder
)));
114 connect(m_dolphinViewController
, SIGNAL(sortFoldersFirstChanged(bool)),
115 this, SLOT(updateSortFoldersFirst(bool)));
116 connect(m_dolphinViewController
, SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList
&)),
117 this, SLOT(updateAdditionalInfo(const KFileItemDelegate::InformationList
&)));
118 connect(m_dolphinViewController
, SIGNAL(itemTriggered(const KFileItem
&)),
119 this, SLOT(triggerItem(const KFileItem
&)));
120 connect(m_dolphinViewController
, SIGNAL(tabRequested(const KUrl
&)),
121 this, SIGNAL(tabRequested(const KUrl
&)));
122 connect(m_dolphinViewController
, SIGNAL(activated()),
123 this, SLOT(activate()));
124 connect(m_dolphinViewController
, SIGNAL(itemEntered(const KFileItem
&)),
125 this, SLOT(showHoverInformation(const KFileItem
&)));
126 connect(m_dolphinViewController
, SIGNAL(viewportEntered()),
127 this, SLOT(clearHoverInformation()));
128 connect(m_dolphinViewController
, SIGNAL(urlChangeRequested(KUrl
)),
129 this, SLOT(slotUrlChangeRequested(KUrl
)));
131 // When a new item has been created by the "Create New..." menu, the item should
132 // get selected and it must be assured that the item will get visible. As the
133 // creation is done asynchronously, several signals must be checked:
134 connect(&DolphinNewFileMenuObserver::instance(), SIGNAL(itemCreated(const KUrl
&)),
135 this, SLOT(observeCreatedItem(const KUrl
&)));
137 m_selectionChangedTimer
= new QTimer(this);
138 m_selectionChangedTimer
->setSingleShot(true);
139 m_selectionChangedTimer
->setInterval(300);
140 connect(m_selectionChangedTimer
, SIGNAL(timeout()),
141 this, SLOT(emitSelectionChangedSignal()));
143 applyViewProperties();
144 m_topLayout
->addWidget(m_viewAccessor
.layoutTarget());
147 DolphinView::~DolphinView()
151 KUrl
DolphinView::url() const
153 return m_viewModeController
->url();
156 KUrl
DolphinView::rootUrl() const
158 const KUrl viewUrl
= url();
159 const KUrl root
= m_viewAccessor
.rootUrl();
160 if (root
.isEmpty() || !root
.isParentOf(viewUrl
)) {
166 void DolphinView::setActive(bool active
)
168 if (active
== m_active
) {
174 QColor color
= KColorScheme(QPalette::Active
, KColorScheme::View
).background().color();
179 QWidget
* viewport
= m_viewAccessor
.itemView()->viewport();
181 palette
.setColor(viewport
->backgroundRole(), color
);
182 viewport
->setPalette(palette
);
187 m_viewAccessor
.itemView()->setFocus();
189 emitSelectionChangedSignal();
190 emit
writeStateChanged(m_isFolderWritable
);
193 m_viewModeController
->indicateActivationChange(active
);
196 bool DolphinView::isActive() const
201 void DolphinView::setMode(Mode mode
)
203 if (mode
== m_mode
) {
204 return; // the wished mode is already set
207 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
210 // remember the currently selected items, so that they will
211 // be restored after reloading the directory
212 m_selectedItems
= selectedItems();
214 const bool hasFocus
= m_viewAccessor
.itemView()->hasFocus();
217 const KUrl viewPropsUrl
= rootUrl();
218 ViewProperties
props(viewPropsUrl
);
219 props
.setViewMode(m_mode
);
223 m_viewAccessor
.itemView()->setFocus();
226 // the file item delegate has been recreated, apply the current
227 // additional information manually
228 const KFileItemDelegate::InformationList infoList
= props
.additionalInfo();
229 m_viewAccessor
.itemDelegate()->setShowInformation(infoList
);
230 emit
additionalInfoChanged();
232 // Not all view modes support categorized sorting. Adjust the sorting model
233 // if changing the view mode results in a change of the categorized sorting
235 m_storedCategorizedSorting
= props
.categorizedSorting();
236 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
237 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
238 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
239 emit
categorizedSortingChanged();
244 updateZoomLevel(oldZoomLevel
);
245 loadDirectory(viewPropsUrl
);
248 DolphinView::Mode
DolphinView::mode() const
253 bool DolphinView::showPreview() const
255 return m_showPreview
;
258 bool DolphinView::showHiddenFiles() const
260 return m_viewAccessor
.dirLister()->showingDotFiles();
263 bool DolphinView::categorizedSorting() const
265 // If all view modes would support categorized sorting, returning
266 // m_viewAccessor.proxyModel()->isCategorizedModel() would be the way to go. As
267 // currently only the icons view supports caterized sorting, we remember
268 // the stored view properties state in m_storedCategorizedSorting and
269 // return this state. The application takes care to disable the corresponding
270 // checkbox by checking DolphinView::supportsCategorizedSorting() to indicate
271 // that this setting is not applied to the current view mode.
272 return m_storedCategorizedSorting
;
275 bool DolphinView::supportsCategorizedSorting() const
277 return m_viewAccessor
.supportsCategorizedSorting();
280 KFileItemList
DolphinView::items() const
282 return m_viewAccessor
.dirLister()->items();
285 KFileItemList
DolphinView::selectedItems() const
287 KFileItemList itemList
;
288 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
293 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
295 const QModelIndexList indexList
= selection
.indexes();
296 foreach (const QModelIndex
&index
, indexList
) {
297 KFileItem item
= m_viewAccessor
.dirModel()->itemForIndex(index
);
298 if (!item
.isNull()) {
299 itemList
.append(item
);
306 int DolphinView::selectedItemsCount() const
308 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
313 return view
->selectionModel()->selectedIndexes().count();
316 void DolphinView::markUrlsAsSelected(const QList
<KUrl
>& urls
)
318 foreach (const KUrl
& url
, urls
) {
319 KFileItem
item(KFileItem::Unknown
, KFileItem::Unknown
, url
);
320 m_selectedItems
.append(item
);
324 void DolphinView::setItemSelectionEnabled(const QRegExp
& pattern
, bool enabled
)
326 const QItemSelection matchingIndexes
= childrenMatchingPattern(QModelIndex(), pattern
);
327 const QItemSelectionModel::SelectionFlags command
= enabled
328 ? QItemSelectionModel::Select
329 : QItemSelectionModel::Deselect
;
330 m_viewAccessor
.itemView()->selectionModel()->select(matchingIndexes
, command
);
333 void DolphinView::setZoomLevel(int level
)
335 if (level
< ZoomLevelInfo::minimumLevel()) {
336 level
= ZoomLevelInfo::minimumLevel();
337 } else if (level
> ZoomLevelInfo::maximumLevel()) {
338 level
= ZoomLevelInfo::maximumLevel();
341 if (level
!= zoomLevel()) {
342 m_viewModeController
->setZoomLevel(level
);
343 emit
zoomLevelChanged(level
);
347 int DolphinView::zoomLevel() const
349 return m_viewModeController
->zoomLevel();
352 void DolphinView::setSorting(Sorting sorting
)
354 if (sorting
!= this->sorting()) {
355 updateSorting(sorting
);
359 DolphinView::Sorting
DolphinView::sorting() const
361 return m_viewAccessor
.proxyModel()->sorting();
364 void DolphinView::setSortOrder(Qt::SortOrder order
)
366 if (sortOrder() != order
) {
367 updateSortOrder(order
);
371 Qt::SortOrder
DolphinView::sortOrder() const
373 return m_viewAccessor
.proxyModel()->sortOrder();
376 void DolphinView::setSortFoldersFirst(bool foldersFirst
)
378 if (sortFoldersFirst() != foldersFirst
) {
379 updateSortFoldersFirst(foldersFirst
);
383 bool DolphinView::sortFoldersFirst() const
385 return m_viewAccessor
.proxyModel()->sortFoldersFirst();
388 void DolphinView::setAdditionalInfo(KFileItemDelegate::InformationList info
)
390 const KUrl viewPropsUrl
= rootUrl();
391 ViewProperties
props(viewPropsUrl
);
392 props
.setAdditionalInfo(info
);
393 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
395 emit
additionalInfoChanged();
397 if (m_viewAccessor
.reloadOnAdditionalInfoChange()) {
398 loadDirectory(viewPropsUrl
);
402 KFileItemDelegate::InformationList
DolphinView::additionalInfo() const
404 return m_viewAccessor
.itemDelegate()->showInformation();
407 void DolphinView::reload()
409 QByteArray viewState
;
410 QDataStream
saveStream(&viewState
, QIODevice::WriteOnly
);
411 saveState(saveStream
);
412 m_selectedItems
= selectedItems();
415 loadDirectory(url(), true);
417 QDataStream
restoreStream(viewState
);
418 restoreState(restoreStream
);
421 void DolphinView::stopLoading()
423 m_viewAccessor
.dirLister()->stop();
426 void DolphinView::refresh()
428 const bool oldActivationState
= m_active
;
429 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
433 applyViewProperties();
436 setActive(oldActivationState
);
437 updateZoomLevel(oldZoomLevel
);
440 void DolphinView::setNameFilter(const QString
& nameFilter
)
442 m_viewModeController
->setNameFilter(nameFilter
);
445 void DolphinView::calculateItemCount(int& fileCount
,
447 KIO::filesize_t
& totalFileSize
) const
449 foreach (const KFileItem
& item
, m_viewAccessor
.dirLister()->items()) {
454 totalFileSize
+= item
.size();
459 QString
DolphinView::statusBarText() const
464 KIO::filesize_t totalFileSize
= 0;
466 if (hasSelection()) {
467 // give a summary of the status of the selected files
468 const KFileItemList list
= selectedItems();
469 if (list
.isEmpty()) {
470 // when an item is triggered, it is temporary selected but selectedItems()
471 // will return an empty list
475 KFileItemList::const_iterator it
= list
.begin();
476 const KFileItemList::const_iterator end
= list
.end();
478 const KFileItem
& item
= *it
;
483 totalFileSize
+= item
.size();
488 if (folderCount
+ fileCount
== 1) {
489 // if only one item is selected, show the filename
490 const QString name
= list
.first().text();
491 text
= (folderCount
== 1) ? i18nc("@info:status", "<filename>%1</filename> selected", name
) :
492 i18nc("@info:status", "<filename>%1</filename> selected (%2)",
493 name
, KIO::convertSize(totalFileSize
));
495 // at least 2 items are selected
496 const QString foldersText
= i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount
);
497 const QString filesText
= i18ncp("@info:status", "1 File selected", "%1 Files selected", fileCount
);
498 if ((folderCount
> 0) && (fileCount
> 0)) {
499 text
= i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
500 foldersText
, filesText
, KIO::convertSize(totalFileSize
));
501 } else if (fileCount
> 0) {
502 text
= i18nc("@info:status files (size)", "%1 (%2)", filesText
, KIO::convertSize(totalFileSize
));
504 Q_ASSERT(folderCount
> 0);
509 calculateItemCount(fileCount
, folderCount
, totalFileSize
);
510 text
= KIO::itemsSummaryString(fileCount
+ folderCount
,
511 fileCount
, folderCount
,
512 totalFileSize
, true);
518 QList
<QAction
*> DolphinView::versionControlActions(const KFileItemList
& items
) const
520 return m_dolphinViewController
->versionControlActions(items
);
523 void DolphinView::setUrl(const KUrl
& url
)
525 if (m_viewModeController
->url() == url
) {
529 const bool hadSelection
= hasSelection();
531 // The selection model and directory lister might change in the case of the column view:
532 disconnectViewAccessor();
534 m_newFileNames
.clear();
536 m_viewModeController
->setUrl(url
); // emits urlChanged, which we forward
537 m_viewAccessor
.prepareUrlChange(url
);
538 applyViewProperties();
540 // When changing the URL there is no need to keep the version
541 // data of the previous URL.
542 m_viewAccessor
.dirModel()->clearVersionData();
544 // Reconnect to the (probably) new selection model and directory lister
545 connectViewAccessor();
548 if (hadSelection
|| hasSelection()) {
549 emitSelectionChangedSignal();
553 void DolphinView::selectAll()
555 m_viewAccessor
.itemView()->selectAll();
558 void DolphinView::invertSelection()
560 QItemSelectionModel
* selectionModel
= m_viewAccessor
.itemView()->selectionModel();
561 const QAbstractItemModel
* itemModel
= selectionModel
->model();
563 const QModelIndex topLeft
= itemModel
->index(0, 0);
564 const QModelIndex bottomRight
= itemModel
->index(itemModel
->rowCount() - 1,
565 itemModel
->columnCount() - 1);
567 const QItemSelection
selection(topLeft
, bottomRight
);
568 selectionModel
->select(selection
, QItemSelectionModel::Toggle
);
571 void DolphinView::clearSelection()
573 m_viewAccessor
.itemView()->clearSelection();
576 void DolphinView::renameSelectedItems()
578 KFileItemList items
= selectedItems();
579 const int itemCount
= items
.count();
584 if ((itemCount
== 1) && DolphinSettings::instance().generalSettings()->renameInline()) {
585 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForItem(items
.first());
586 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
587 m_viewAccessor
.itemView()->edit(proxyIndex
);
589 RenameDialog
* dialog
= new RenameDialog(this, items
);
590 dialog
->setAttribute(Qt::WA_DeleteOnClose
);
593 dialog
->activateWindow();
597 void DolphinView::trashSelectedItems()
599 const KUrl::List list
= simplifiedSelectedUrls();
600 KonqOperations::del(this, KonqOperations::TRASH
, list
);
603 void DolphinView::deleteSelectedItems()
605 const KUrl::List list
= simplifiedSelectedUrls();
606 const bool del
= KonqOperations::askDeleteConfirmation(list
,
608 KonqOperations::DEFAULT_CONFIRMATION
,
612 KIO::Job
* job
= KIO::del(list
);
613 connect(job
, SIGNAL(result(KJob
*)),
614 this, SLOT(slotDeleteFileFinished(KJob
*)));
618 void DolphinView::cutSelectedItems()
620 QMimeData
* mimeData
= selectionMimeData();
621 KonqMimeData::addIsCutSelection(mimeData
, true);
622 QApplication::clipboard()->setMimeData(mimeData
);
625 void DolphinView::copySelectedItems()
627 QMimeData
* mimeData
= selectionMimeData();
628 QApplication::clipboard()->setMimeData(mimeData
);
631 void DolphinView::paste()
636 void DolphinView::pasteIntoFolder()
638 const KFileItemList items
= selectedItems();
639 if ((items
.count() == 1) && items
.first().isDir()) {
640 pasteToUrl(items
.first().url());
644 void DolphinView::setShowPreview(bool show
)
646 if (m_showPreview
== show
) {
650 const KUrl viewPropsUrl
= rootUrl();
651 ViewProperties
props(viewPropsUrl
);
652 props
.setShowPreview(show
);
654 m_showPreview
= show
;
655 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
656 emit
showPreviewChanged();
658 // Enabling or disabling the preview might change the icon size of the view.
659 // As the view does not emit a signal when the icon size has been changed,
660 // the used zoom level of the controller must be adjusted manually:
661 updateZoomLevel(oldZoomLevel
);
664 void DolphinView::setShowHiddenFiles(bool show
)
666 if (m_viewAccessor
.dirLister()->showingDotFiles() == show
) {
670 const KUrl viewPropsUrl
= rootUrl();
671 ViewProperties
props(viewPropsUrl
);
672 props
.setShowHiddenFiles(show
);
674 m_viewAccessor
.dirLister()->setShowingDotFiles(show
);
675 emit
showHiddenFilesChanged();
678 void DolphinView::setCategorizedSorting(bool categorized
)
680 if (categorized
== categorizedSorting()) {
684 // setCategorizedSorting(true) may only get invoked
685 // if the view supports categorized sorting
686 Q_ASSERT(!categorized
|| supportsCategorizedSorting());
688 ViewProperties
props(rootUrl());
689 props
.setCategorizedSorting(categorized
);
692 m_storedCategorizedSorting
= categorized
;
693 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
695 emit
categorizedSortingChanged();
698 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
700 QWidget::mouseReleaseEvent(event
);
704 bool DolphinView::eventFilter(QObject
* watched
, QEvent
* event
)
706 switch (event
->type()) {
707 case QEvent::FocusIn
:
708 if (watched
== m_viewAccessor
.itemView()) {
709 m_dolphinViewController
->requestActivation();
713 case QEvent::DragEnter
:
714 if (watched
== m_viewAccessor
.itemView()->viewport()) {
719 case QEvent::KeyPress
:
720 if (watched
== m_viewAccessor
.itemView()) {
721 // clear the selection when Escape has been pressed
722 QKeyEvent
* keyEvent
= static_cast<QKeyEvent
*>(event
);
723 if (keyEvent
->key() == Qt::Key_Escape
) {
730 if (watched
== m_viewAccessor
.itemView()->viewport()) {
731 // Ctrl+wheel events should cause icon zooming, but not if the left mouse button is pressed
732 // (the user is probably trying to scroll during a selection in that case)
733 QWheelEvent
* wheelEvent
= static_cast<QWheelEvent
*>(event
);
734 if (wheelEvent
->modifiers() & Qt::ControlModifier
&& !(wheelEvent
->buttons() & Qt::LeftButton
)) {
735 const int delta
= wheelEvent
->delta();
736 const int level
= zoomLevel();
738 setZoomLevel(level
+ 1);
739 } else if (delta
< 0) {
740 setZoomLevel(level
- 1);
751 return QWidget::eventFilter(watched
, event
);
754 void DolphinView::activate()
759 void DolphinView::triggerItem(const KFileItem
& item
)
761 const Qt::KeyboardModifiers modifier
= QApplication::keyboardModifiers();
762 if ((modifier
& Qt::ShiftModifier
) || (modifier
& Qt::ControlModifier
)) {
763 // items are selected by the user, hence don't trigger the
764 // item specified by 'index'
768 // TODO: the m_isContextMenuOpen check is a workaround for Qt-issue 207192
769 if (item
.isNull() || m_isContextMenuOpen
) {
773 emit
itemTriggered(item
); // caught by DolphinViewContainer or DolphinPart
776 void DolphinView::slotSelectionChanged(const QItemSelection
& selected
, const QItemSelection
& deselected
)
778 const int count
= selectedItemsCount();
779 const bool selectionStateChanged
= ((count
> 0) && (selected
.count() == count
)) ||
780 ((count
== 0) && !deselected
.isEmpty());
782 // If nothing has been selected before and something got selected (or if something
783 // was selected before and now nothing is selected) the selectionChangedSignal must
784 // be emitted asynchronously as fast as possible to update the edit-actions.
785 m_selectionChangedTimer
->setInterval(selectionStateChanged
? 0 : 300);
786 m_selectionChangedTimer
->start();
789 void DolphinView::emitSelectionChangedSignal()
791 m_selectionChangedTimer
->stop();
792 emit
selectionChanged(selectedItems());
795 void DolphinView::openContextMenu(const QPoint
& pos
,
796 const QList
<QAction
*>& customActions
)
799 const QModelIndex index
= m_viewAccessor
.itemView()->indexAt(pos
);
800 if (index
.isValid() && (index
.column() == DolphinModel::Name
)) {
801 const QModelIndex dolphinModelIndex
= m_viewAccessor
.proxyModel()->mapToSource(index
);
802 item
= m_viewAccessor
.dirModel()->itemForIndex(dolphinModelIndex
);
805 m_isContextMenuOpen
= true; // TODO: workaround for Qt-issue 207192
806 emit
requestContextMenu(item
, url(), customActions
);
807 m_isContextMenuOpen
= false;
810 void DolphinView::dropUrls(const KFileItem
& destItem
,
811 const KUrl
& destPath
,
814 addNewFileNames(event
->mimeData());
815 DragAndDropHelper::instance().dropUrls(destItem
, destPath
, event
, this);
818 void DolphinView::updateSorting(DolphinView::Sorting sorting
)
820 ViewProperties
props(rootUrl());
821 props
.setSorting(sorting
);
823 m_viewAccessor
.proxyModel()->setSorting(sorting
);
825 emit
sortingChanged(sorting
);
828 void DolphinView::updateSortOrder(Qt::SortOrder order
)
830 ViewProperties
props(rootUrl());
831 props
.setSortOrder(order
);
833 m_viewAccessor
.proxyModel()->setSortOrder(order
);
835 emit
sortOrderChanged(order
);
838 void DolphinView::updateSortFoldersFirst(bool foldersFirst
)
840 ViewProperties
props(rootUrl());
841 props
.setSortFoldersFirst(foldersFirst
);
843 m_viewAccessor
.proxyModel()->setSortFoldersFirst(foldersFirst
);
845 emit
sortFoldersFirstChanged(foldersFirst
);
848 void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList
& info
)
850 ViewProperties
props(rootUrl());
851 props
.setAdditionalInfo(info
);
854 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
856 emit
additionalInfoChanged();
859 void DolphinView::updateAdditionalInfoActions(KActionCollection
* collection
)
861 const AdditionalInfoAccessor
& infoAccessor
= AdditionalInfoAccessor::instance();
863 const KFileItemDelegate::InformationList checkedInfo
= m_viewAccessor
.itemDelegate()->showInformation();
864 const KFileItemDelegate::InformationList infoKeys
= infoAccessor
.keys();
866 const bool enable
= (m_mode
== DolphinView::DetailsView
) ||
867 (m_mode
== DolphinView::IconsView
);
869 foreach (const KFileItemDelegate::Information
& info
, infoKeys
) {
870 const QString name
= infoAccessor
.actionCollectionName(info
, AdditionalInfoAccessor::AdditionalInfoType
);
871 QAction
* action
= collection
->action(name
);
872 Q_ASSERT(action
!= 0);
873 action
->setEnabled(enable
);
874 action
->setChecked(checkedInfo
.contains(info
));
878 QPair
<bool, QString
> DolphinView::pasteInfo() const
880 return KonqOperations::pasteInfo(url());
883 void DolphinView::setTabsForFilesEnabled(bool tabsForFiles
)
885 m_tabsForFiles
= tabsForFiles
;
888 bool DolphinView::isTabsForFilesEnabled() const
890 return m_tabsForFiles
;
893 bool DolphinView::itemsExpandable() const
895 return m_viewAccessor
.itemsExpandable();
898 void DolphinView::restoreState(QDataStream
& stream
)
900 // Restore the URL of the current item that had the keyboard focus
901 stream
>> m_activeItemUrl
;
903 // Restore the root URL
906 m_viewAccessor
.setRootUrl(rootUrl
);
908 // Restore the view position
909 stream
>> m_restoredContentsPosition
;
911 // Restore expanded folders (only relevant for the details view - will be ignored by the view in other view modes)
912 QSet
<KUrl
> urlsToExpand
;
913 stream
>> urlsToExpand
;
914 const DolphinDetailsViewExpander
* expander
= m_viewAccessor
.setExpandedUrls(urlsToExpand
);
916 m_expanderActive
= true;
917 connect (expander
, SIGNAL(completed()), this, SLOT(slotLoadingCompleted()));
920 m_expanderActive
= false;
924 void DolphinView::saveState(QDataStream
& stream
)
926 // Save the URL of the current item that has the keyboard focus
927 KFileItem currentItem
;
928 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
931 const QModelIndex proxyIndex
= view
->currentIndex();
932 const QModelIndex dirModelIndex
= m_viewAccessor
.proxyModel()->mapToSource(proxyIndex
);
933 currentItem
= m_viewAccessor
.dirModel()->itemForIndex(dirModelIndex
);
937 if (!currentItem
.isNull()) {
938 currentItemUrl
= currentItem
.url();
941 stream
<< currentItemUrl
;
944 stream
<< m_viewAccessor
.rootUrl();
946 // Save view position
947 const int x
= view
->horizontalScrollBar()->value();
948 const int y
= view
->verticalScrollBar()->value();
949 stream
<< QPoint(x
, y
);
951 // Save expanded folders (only relevant for the details view - the set will be empty in other view modes)
952 stream
<< m_viewAccessor
.expandedUrls();
955 bool DolphinView::hasSelection() const
957 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
958 return (view
!= 0) && view
->selectionModel()->hasSelection();
961 void DolphinView::observeCreatedItem(const KUrl
& url
)
963 m_createdItemUrl
= url
;
964 connect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
965 this, SLOT(selectAndScrollToCreatedItem()));
968 void DolphinView::selectAndScrollToCreatedItem()
970 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_createdItemUrl
);
971 if (dirIndex
.isValid()) {
972 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
973 m_viewAccessor
.itemView()->setCurrentIndex(proxyIndex
);
976 disconnect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
977 this, SLOT(selectAndScrollToCreatedItem()));
978 m_createdItemUrl
= KUrl();
981 void DolphinView::slotRedirection(const KUrl
& oldUrl
, const KUrl
& newUrl
)
983 if (oldUrl
.equals(url(), KUrl::CompareWithoutTrailingSlash
)) {
984 emit
redirection(oldUrl
, newUrl
);
985 m_viewModeController
->redirectToUrl(newUrl
); // #186947
989 void DolphinView::restoreContentsPosition()
991 if (!m_restoredContentsPosition
.isNull()) {
992 const int x
= m_restoredContentsPosition
.x();
993 const int y
= m_restoredContentsPosition
.y();
994 m_restoredContentsPosition
= QPoint();
996 QAbstractItemView
* view
= m_viewAccessor
.itemView();
998 view
->horizontalScrollBar()->setValue(x
);
999 view
->verticalScrollBar()->setValue(y
);
1003 void DolphinView::slotUrlChangeRequested(const KUrl
& url
)
1005 m_viewModeController
->setUrl(url
);
1006 updateWritableState();
1009 void DolphinView::showHoverInformation(const KFileItem
& item
)
1011 emit
requestItemInfo(item
);
1014 void DolphinView::clearHoverInformation()
1016 emit
requestItemInfo(KFileItem());
1019 void DolphinView::slotDeleteFileFinished(KJob
* job
)
1021 if (job
->error() == 0) {
1022 emit
operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
1023 } else if (job
->error() != KIO::ERR_USER_CANCELED
) {
1024 emit
errorMessage(job
->errorString());
1028 void DolphinView::slotDirListerStarted(const KUrl
& url
)
1030 // Disable the writestate temporary until it can be determined in a fast way
1031 // in DolphinView::slotDirListerCompleted()
1032 if (m_isFolderWritable
) {
1033 m_isFolderWritable
= false;
1034 emit
writeStateChanged(m_isFolderWritable
);
1037 emit
startedPathLoading(url
);
1040 void DolphinView::slotDirListerCompleted()
1042 if (!m_expanderActive
) {
1043 slotLoadingCompleted();
1046 if (!m_newFileNames
.isEmpty()) {
1047 // select all newly added items created by a paste operation or
1048 // a drag & drop operation, and clear the previous selection
1049 m_viewAccessor
.itemView()->clearSelection();
1050 const int rowCount
= m_viewAccessor
.proxyModel()->rowCount();
1051 QItemSelection selection
;
1052 for (int row
= 0; row
< rowCount
; ++row
) {
1053 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->index(row
, 0);
1054 const QModelIndex dirIndex
= m_viewAccessor
.proxyModel()->mapToSource(proxyIndex
);
1055 const KUrl url
= m_viewAccessor
.dirModel()->itemForIndex(dirIndex
).url();
1056 if (m_newFileNames
.contains(url
.fileName())) {
1057 selection
.merge(QItemSelection(proxyIndex
, proxyIndex
), QItemSelectionModel::Select
);
1060 m_viewAccessor
.itemView()->selectionModel()->select(selection
, QItemSelectionModel::Select
);
1062 m_newFileNames
.clear();
1065 updateWritableState();
1068 void DolphinView::slotLoadingCompleted()
1070 m_expanderActive
= false;
1072 if (!m_activeItemUrl
.isEmpty()) {
1073 // assure that the current item remains visible
1074 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_activeItemUrl
);
1075 if (dirIndex
.isValid()) {
1076 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
1077 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1078 const bool clearSelection
= !hasSelection();
1079 view
->setCurrentIndex(proxyIndex
);
1080 if (clearSelection
) {
1081 view
->clearSelection();
1083 m_activeItemUrl
.clear();
1087 if (!m_selectedItems
.isEmpty()) {
1088 const KUrl
& baseUrl
= url();
1090 QItemSelection newSelection
;
1091 foreach(const KFileItem
& item
, m_selectedItems
) {
1092 url
= item
.url().upUrl();
1093 if (baseUrl
.equals(url
, KUrl::CompareWithoutTrailingSlash
)) {
1094 QModelIndex index
= m_viewAccessor
.proxyModel()->mapFromSource(m_viewAccessor
.dirModel()->indexForItem(item
));
1095 newSelection
.select(index
, index
);
1098 m_viewAccessor
.itemView()->selectionModel()->select(newSelection
,
1099 QItemSelectionModel::ClearAndSelect
1100 | QItemSelectionModel::Current
);
1101 m_selectedItems
.clear();
1104 // Restore the contents position. This has to be done using a Qt::QueuedConnection
1105 // because the view might not be in its final state yet.
1106 QMetaObject::invokeMethod(this, "restoreContentsPosition", Qt::QueuedConnection
);
1108 emit
finishedPathLoading(url());
1111 void DolphinView::slotRefreshItems()
1113 if (m_assureVisibleCurrentIndex
) {
1114 m_assureVisibleCurrentIndex
= false;
1115 m_viewAccessor
.itemView()->scrollTo(m_viewAccessor
.itemView()->currentIndex());
1119 void DolphinView::loadDirectory(const KUrl
& url
, bool reload
)
1121 if (!url
.isValid()) {
1122 const QString
location(url
.pathOrUrl());
1123 if (location
.isEmpty()) {
1124 emit
errorMessage(i18nc("@info:status", "The location is empty."));
1126 emit
errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location
));
1131 KDirLister
* dirLister
= m_viewAccessor
.dirLister();
1132 dirLister
->openUrl(url
, reload
? KDirLister::Reload
: KDirLister::NoFlags
);
1135 void DolphinView::applyViewProperties()
1137 const ViewProperties
props(rootUrl());
1139 const Mode mode
= props
.viewMode();
1140 if (m_mode
!= mode
) {
1141 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
1147 updateZoomLevel(oldZoomLevel
);
1149 if (m_viewAccessor
.itemView() == 0) {
1153 Q_ASSERT(m_viewAccessor
.itemView() != 0);
1154 Q_ASSERT(m_viewAccessor
.itemDelegate() != 0);
1156 const bool showHiddenFiles
= props
.showHiddenFiles();
1157 if (showHiddenFiles
!= m_viewAccessor
.dirLister()->showingDotFiles()) {
1158 m_viewAccessor
.dirLister()->setShowingDotFiles(showHiddenFiles
);
1159 emit
showHiddenFilesChanged();
1162 m_storedCategorizedSorting
= props
.categorizedSorting();
1163 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
1164 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
1165 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
1166 emit
categorizedSortingChanged();
1169 const DolphinView::Sorting sorting
= props
.sorting();
1170 if (sorting
!= m_viewAccessor
.proxyModel()->sorting()) {
1171 m_viewAccessor
.proxyModel()->setSorting(sorting
);
1172 emit
sortingChanged(sorting
);
1175 const Qt::SortOrder sortOrder
= props
.sortOrder();
1176 if (sortOrder
!= m_viewAccessor
.proxyModel()->sortOrder()) {
1177 m_viewAccessor
.proxyModel()->setSortOrder(sortOrder
);
1178 emit
sortOrderChanged(sortOrder
);
1181 const bool sortFoldersFirst
= props
.sortFoldersFirst();
1182 if (sortFoldersFirst
!= m_viewAccessor
.proxyModel()->sortFoldersFirst()) {
1183 m_viewAccessor
.proxyModel()->setSortFoldersFirst(sortFoldersFirst
);
1184 emit
sortFoldersFirstChanged(sortFoldersFirst
);
1187 KFileItemDelegate::InformationList info
= props
.additionalInfo();
1188 if (info
!= m_viewAccessor
.itemDelegate()->showInformation()) {
1189 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
1190 emit
additionalInfoChanged();
1193 const bool showPreview
= props
.showPreview();
1194 if (showPreview
!= m_showPreview
) {
1195 m_showPreview
= showPreview
;
1196 const int oldZoomLevel
= m_viewModeController
->zoomLevel();
1197 emit
showPreviewChanged();
1199 // Enabling or disabling the preview might change the icon size of the view.
1200 // As the view does not emit a signal when the icon size has been changed,
1201 // the used zoom level of the controller must be adjusted manually:
1202 updateZoomLevel(oldZoomLevel
);
1206 void DolphinView::createView()
1210 Q_ASSERT(m_viewAccessor
.itemView() == 0);
1211 Q_ASSERT(m_dolphinViewController
->itemView() == 0);
1212 m_viewAccessor
.createView(this, m_dolphinViewController
, m_viewModeController
, m_mode
);
1214 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1215 Q_ASSERT(view
!= 0);
1216 view
->installEventFilter(this);
1217 view
->viewport()->installEventFilter(this);
1219 m_dolphinViewController
->setItemView(view
);
1221 const int zoomLevel
= ZoomLevelInfo::zoomLevelForIconSize(view
->iconSize());
1222 m_viewModeController
->setZoomLevel(zoomLevel
);
1224 connectViewAccessor();
1226 setFocusProxy(m_viewAccessor
.layoutTarget());
1227 m_topLayout
->insertWidget(1, m_viewAccessor
.layoutTarget());
1230 void DolphinView::deleteView()
1232 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1233 Q_ASSERT((m_dolphinViewController
->itemView() == 0) || (m_dolphinViewController
->itemView() == view
));
1234 m_dolphinViewController
->setItemView(0);
1237 disconnectViewAccessor();
1240 // It's important to set the keyboard focus to the parent
1241 // before deleting the view: Otherwise when having a split
1242 // view the other view will get the focus and will request
1243 // an activation (see DolphinView::eventFilter()).
1248 m_viewModeController
->disconnect(view
);
1250 m_viewAccessor
.deleteView();
1254 void DolphinView::pasteToUrl(const KUrl
& url
)
1256 addNewFileNames(QApplication::clipboard()->mimeData());
1257 KonqOperations::doPaste(this, url
);
1260 void DolphinView::updateZoomLevel(int oldZoomLevel
)
1262 const int newZoomLevel
= ZoomLevelInfo::zoomLevelForIconSize(m_viewAccessor
.itemView()->iconSize());
1263 if (oldZoomLevel
!= newZoomLevel
) {
1264 m_viewModeController
->setZoomLevel(newZoomLevel
);
1265 emit
zoomLevelChanged(newZoomLevel
);
1269 KUrl::List
DolphinView::simplifiedSelectedUrls() const
1273 const KFileItemList items
= selectedItems();
1274 foreach (const KFileItem
&item
, items
) {
1275 urls
.append(item
.url());
1279 if (itemsExpandable()) {
1280 urls
= KDirModel::simplifiedUrlList(urls
);
1286 QMimeData
* DolphinView::selectionMimeData() const
1288 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
1289 Q_ASSERT((view
!= 0) && (view
->selectionModel() != 0));
1290 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
1291 return m_viewAccessor
.dirModel()->mimeData(selection
.indexes());
1294 void DolphinView::addNewFileNames(const QMimeData
* mimeData
)
1296 const KUrl::List urls
= KUrl::List::fromMimeData(mimeData
);
1297 foreach (const KUrl
& url
, urls
) {
1298 m_newFileNames
.insert(url
.fileName());
1302 QItemSelection
DolphinView::childrenMatchingPattern(const QModelIndex
& parent
, const QRegExp
& pattern
) const
1304 QItemSelection matchingIndexes
;
1305 const DolphinSortFilterProxyModel
* proxyModel
= m_viewAccessor
.proxyModel();
1306 const DolphinModel
* dolphinModel
= m_viewAccessor
.dirModel();
1308 const int rowCount
= proxyModel
->rowCount(parent
);
1310 for (int row
= 0; row
< rowCount
; ++row
) {
1311 QModelIndex index
= proxyModel
->index(row
, 0, parent
);
1312 QModelIndex sourceIndex
= proxyModel
->mapToSource(index
);
1314 if (sourceIndex
.isValid() && pattern
.exactMatch(dolphinModel
->data(sourceIndex
).toString())) {
1315 matchingIndexes
+= QItemSelectionRange(index
);
1318 if (proxyModel
->hasChildren(index
)) {
1319 matchingIndexes
+= childrenMatchingPattern(index
, pattern
);
1323 return matchingIndexes
;
1326 void DolphinView::connectViewAccessor()
1328 KDirLister
* dirLister
= m_viewAccessor
.dirLister();
1329 connect(dirLister
, SIGNAL(redirection(KUrl
,KUrl
)),
1330 this, SLOT(slotRedirection(KUrl
,KUrl
)));
1331 connect(dirLister
, SIGNAL(started(KUrl
)),
1332 this, SLOT(slotDirListerStarted(KUrl
)));
1333 connect(dirLister
, SIGNAL(completed()),
1334 this, SLOT(slotDirListerCompleted()));
1335 connect(dirLister
, SIGNAL(refreshItems(const QList
<QPair
<KFileItem
,KFileItem
>>&)),
1336 this, SLOT(slotRefreshItems()));
1338 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1339 connect(view
->selectionModel(), SIGNAL(selectionChanged(QItemSelection
, QItemSelection
)),
1340 this, SLOT(slotSelectionChanged(QItemSelection
, QItemSelection
)));
1343 void DolphinView::disconnectViewAccessor()
1345 KDirLister
* dirLister
= m_viewAccessor
.dirLister();
1346 disconnect(dirLister
, SIGNAL(redirection(KUrl
,KUrl
)),
1347 this, SLOT(slotRedirection(KUrl
,KUrl
)));
1348 disconnect(dirLister
, SIGNAL(started(KUrl
)),
1349 this, SLOT(slotDirListerStarted(KUrl
)));
1350 disconnect(dirLister
, SIGNAL(completed()),
1351 this, SLOT(slotDirListerCompleted()));
1352 disconnect(dirLister
, SIGNAL(refreshItems(const QList
<QPair
<KFileItem
,KFileItem
>>&)),
1353 this, SLOT(slotRefreshItems()));
1355 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1356 disconnect(view
->selectionModel(), SIGNAL(selectionChanged(QItemSelection
, QItemSelection
)),
1357 this, SLOT(slotSelectionChanged(QItemSelection
, QItemSelection
)));
1360 void DolphinView::updateWritableState()
1362 const bool wasFolderWritable
= m_isFolderWritable
;
1363 m_isFolderWritable
= true;
1365 const KFileItem item
= m_viewAccessor
.dirLister()->rootItem();
1366 if (!item
.isNull()) {
1367 KFileItemListProperties
capabilities(KFileItemList() << item
);
1368 m_isFolderWritable
= capabilities
.supportsWriting();
1370 if (m_isFolderWritable
!= wasFolderWritable
) {
1371 emit
writeStateChanged(m_isFolderWritable
);
1375 DolphinView::ViewAccessor::ViewAccessor(DolphinSortFilterProxyModel
* proxyModel
) :
1379 m_columnsContainer(0),
1380 m_proxyModel(proxyModel
),
1385 DolphinView::ViewAccessor::~ViewAccessor()
1387 delete m_dragSource
;
1391 void DolphinView::ViewAccessor::createView(QWidget
* parent
,
1392 DolphinViewController
* dolphinViewController
,
1393 const ViewModeController
* viewModeController
,
1396 Q_ASSERT(itemView() == 0);
1400 m_iconsView
= new DolphinIconsView(parent
,
1401 dolphinViewController
,
1407 m_detailsView
= new DolphinDetailsView(parent
,
1408 dolphinViewController
,
1414 m_columnsContainer
= new DolphinColumnViewContainer(parent
,
1415 dolphinViewController
,
1416 viewModeController
);
1417 if (!m_rootUrl
.isEmpty() && m_rootUrl
.isParentOf(viewModeController
->url())) {
1418 // The column-view must show several columns starting with m_rootUrl as
1419 // first column and viewModeController->url() as last column.
1420 m_columnsContainer
->showColumn(m_rootUrl
);
1421 m_columnsContainer
->showColumn(viewModeController
->url());
1430 void DolphinView::ViewAccessor::deleteView()
1432 if (m_columnsContainer
!= 0) {
1433 m_columnsContainer
->close();
1434 m_columnsContainer
->disconnect();
1435 m_columnsContainer
->deleteLater();
1436 m_columnsContainer
= 0;
1438 QAbstractItemView
* view
= itemView();
1443 if (DragAndDropHelper::instance().isDragSource(view
)) {
1444 // The view is a drag source (the feature "Open folders
1445 // during drag operations" is used). Deleting the view
1446 // during an ongoing drag operation is not allowed, so
1447 // this will postponed.
1448 if (m_dragSource
!= 0) {
1449 // the old stored view is obviously not the drag source anymore
1450 m_dragSource
->deleteLater();
1454 m_dragSource
= view
;
1456 view
->deleteLater();
1466 void DolphinView::ViewAccessor::prepareUrlChange(const KUrl
& url
)
1468 if (m_columnsContainer
!= 0) {
1469 m_columnsContainer
->showColumn(url
);
1473 QAbstractItemView
* DolphinView::ViewAccessor::itemView() const
1475 if (m_iconsView
!= 0) {
1479 if (m_detailsView
!= 0) {
1480 return m_detailsView
;
1483 if (m_columnsContainer
!= 0) {
1484 return m_columnsContainer
->activeColumn();
1490 KFileItemDelegate
* DolphinView::ViewAccessor::itemDelegate() const
1492 return static_cast<KFileItemDelegate
*>(itemView()->itemDelegate());
1495 QWidget
* DolphinView::ViewAccessor::layoutTarget() const
1497 if (m_columnsContainer
!= 0) {
1498 return m_columnsContainer
;
1503 void DolphinView::ViewAccessor::setRootUrl(const KUrl
& rootUrl
)
1505 m_rootUrl
= rootUrl
;
1508 KUrl
DolphinView::ViewAccessor::rootUrl() const
1510 return (m_columnsContainer
!= 0) ? m_columnsContainer
->rootUrl() : m_rootUrl
;
1513 bool DolphinView::ViewAccessor::supportsCategorizedSorting() const
1515 return m_iconsView
!= 0;
1518 bool DolphinView::ViewAccessor::itemsExpandable() const
1520 return (m_detailsView
!= 0) && m_detailsView
->itemsExpandable();
1523 QSet
<KUrl
> DolphinView::ViewAccessor::expandedUrls() const
1525 if (m_detailsView
!= 0) {
1526 return m_detailsView
->expandedUrls();
1529 return QSet
<KUrl
>();
1532 const DolphinDetailsViewExpander
* DolphinView::ViewAccessor::setExpandedUrls(const QSet
<KUrl
>& urlsToExpand
)
1534 if ((m_detailsView
!= 0) && m_detailsView
->itemsExpandable() && !urlsToExpand
.isEmpty()) {
1535 // Check if another expander is already active and stop it if necessary.
1536 if(!m_detailsViewExpander
.isNull()) {
1537 m_detailsViewExpander
->stop();
1540 m_detailsViewExpander
= new DolphinDetailsViewExpander(m_detailsView
, urlsToExpand
);
1541 return m_detailsViewExpander
;
1548 bool DolphinView::ViewAccessor::reloadOnAdditionalInfoChange() const
1550 // the details view requires no reloading of the directory, as it maps
1551 // the file item delegate info to its columns internally
1552 return m_detailsView
!= 0;
1555 DolphinModel
* DolphinView::ViewAccessor::dirModel() const
1557 return static_cast<DolphinModel
*>(proxyModel()->sourceModel());
1560 DolphinSortFilterProxyModel
* DolphinView::ViewAccessor::proxyModel() const
1562 if (m_columnsContainer
!= 0) {
1563 return static_cast<DolphinSortFilterProxyModel
*>(m_columnsContainer
->activeColumn()->model());
1565 return m_proxyModel
;
1568 KDirLister
* DolphinView::ViewAccessor::dirLister() const
1570 return dirModel()->dirLister();
1573 #include "dolphinview.moc"