1 /***************************************************************************
2 * Copyright (C) 2006-2009 by Peter Penz <peter.penz@gmx.at> *
3 * Copyright (C) 2006 by Gregor Kališnik <gregor@podnapisi.net> *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
21 #include "dolphinview.h"
23 #include <QAbstractItemView>
24 #include <QApplication>
27 #include <QItemSelection>
32 #include <kactioncollection.h>
33 #include <kcolorscheme.h>
34 #include <kdirlister.h>
35 #include <kiconeffect.h>
36 #include <kfileitem.h>
38 #include <kio/deletejob.h>
39 #include <kio/netaccess.h>
40 #include <kio/previewjob.h>
43 #include <kmessagebox.h>
44 #include <kmimetyperesolver.h>
45 #include <konq_fileitemcapabilities.h>
46 #include <konq_operations.h>
47 #include <konqmimedata.h>
48 #include <kstringhandler.h>
49 #include <ktoggleaction.h>
52 #include "dolphinmodel.h"
53 #include "dolphincolumnviewcontainer.h"
54 #include "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 "renamedialog.h"
64 #include "settings/dolphinsettings.h"
65 #include "viewproperties.h"
66 #include "zoomlevelinfo.h"
67 #include "dolphindetailsviewexpander.h"
70 * Helper function for sorting items with qSort() in
71 * DolphinView::renameSelectedItems().
73 bool lessThan(const KFileItem
& item1
, const KFileItem
& item2
)
75 return KStringHandler::naturalCompare(item1
.name(), item2
.name()) < 0;
78 DolphinView::DolphinView(QWidget
* parent
,
80 DolphinSortFilterProxyModel
* proxyModel
) :
84 m_loadingDirectory(false),
85 m_storedCategorizedSorting(false),
86 m_tabsForFiles(false),
87 m_isContextMenuOpen(false),
88 m_ignoreViewProperties(false),
89 m_assureVisibleCurrentIndex(false),
90 m_mode(DolphinView::IconsView
),
93 m_viewAccessor(proxyModel
),
95 m_selectionChangedTimer(0),
98 m_restoredContentsPosition(),
103 m_topLayout
= new QVBoxLayout(this);
104 m_topLayout
->setSpacing(0);
105 m_topLayout
->setMargin(0);
107 m_controller
= new DolphinController(this);
108 m_controller
->setUrl(url
);
110 connect(m_controller
, SIGNAL(urlChanged(const KUrl
&)),
111 this, SIGNAL(urlChanged(const KUrl
&)));
112 connect(m_controller
, SIGNAL(requestUrlChange(const KUrl
&)),
113 this, SLOT(slotRequestUrlChange(const KUrl
&)));
115 connect(m_controller
, SIGNAL(requestContextMenu(const QPoint
&, const QList
<QAction
*>&)),
116 this, SLOT(openContextMenu(const QPoint
&, const QList
<QAction
*>&)));
117 connect(m_controller
, SIGNAL(urlsDropped(const KFileItem
&, const KUrl
&, QDropEvent
*)),
118 this, SLOT(dropUrls(const KFileItem
&, const KUrl
&, QDropEvent
*)));
119 connect(m_controller
, SIGNAL(sortingChanged(DolphinView::Sorting
)),
120 this, SLOT(updateSorting(DolphinView::Sorting
)));
121 connect(m_controller
, SIGNAL(sortOrderChanged(Qt::SortOrder
)),
122 this, SLOT(updateSortOrder(Qt::SortOrder
)));
123 connect(m_controller
, SIGNAL(sortFoldersFirstChanged(bool)),
124 this, SLOT(updateSortFoldersFirst(bool)));
125 connect(m_controller
, SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList
&)),
126 this, SLOT(updateAdditionalInfo(const KFileItemDelegate::InformationList
&)));
127 connect(m_controller
, SIGNAL(itemTriggered(const KFileItem
&)),
128 this, SLOT(triggerItem(const KFileItem
&)));
129 connect(m_controller
, SIGNAL(tabRequested(const KUrl
&)),
130 this, SIGNAL(tabRequested(const KUrl
&)));
131 connect(m_controller
, SIGNAL(activated()),
132 this, SLOT(activate()));
133 connect(m_controller
, SIGNAL(itemEntered(const KFileItem
&)),
134 this, SLOT(showHoverInformation(const KFileItem
&)));
135 connect(m_controller
, SIGNAL(viewportEntered()),
136 this, SLOT(clearHoverInformation()));
138 KDirLister
* dirLister
= m_viewAccessor
.dirLister();
139 connect(dirLister
, SIGNAL(redirection(KUrl
,KUrl
)),
140 this, SLOT(slotRedirection(KUrl
,KUrl
)));
141 connect(dirLister
, SIGNAL(completed()),
142 this, SLOT(slotDirListerCompleted()));
143 connect(dirLister
, SIGNAL(refreshItems(const QList
<QPair
<KFileItem
,KFileItem
>>&)),
144 this, SLOT(slotRefreshItems()));
146 // When a new item has been created by the "Create New..." menu, the item should
147 // get selected and it must be assured that the item will get visible. As the
148 // creation is done asynchronously, several signals must be checked:
149 connect(&DolphinNewMenuObserver::instance(), SIGNAL(itemCreated(const KUrl
&)),
150 this, SLOT(observeCreatedItem(const KUrl
&)));
152 m_selectionChangedTimer
= new QTimer(this);
153 m_selectionChangedTimer
->setSingleShot(true);
154 m_selectionChangedTimer
->setInterval(300);
155 connect(m_selectionChangedTimer
, SIGNAL(timeout()),
156 this, SLOT(emitSelectionChangedSignal()));
158 applyViewProperties();
159 m_topLayout
->addWidget(m_viewAccessor
.itemView());
162 DolphinView::~DolphinView()
166 const KUrl
& DolphinView::url() const
168 return m_controller
->url();
171 KUrl
DolphinView::rootUrl() const
173 const KUrl viewUrl
= url();
174 const KUrl root
= m_viewAccessor
.rootUrl();
175 if (root
.isEmpty() || !root
.isParentOf(viewUrl
)) {
181 void DolphinView::setActive(bool active
)
183 if (active
== m_active
) {
189 QColor color
= KColorScheme(QPalette::Active
, KColorScheme::View
).background().color();
191 emitSelectionChangedSignal();
196 QWidget
* viewport
= m_viewAccessor
.itemView()->viewport();
198 palette
.setColor(viewport
->backgroundRole(), color
);
199 viewport
->setPalette(palette
);
204 m_viewAccessor
.itemView()->setFocus();
208 m_controller
->indicateActivationChange(active
);
211 bool DolphinView::isActive() const
216 void DolphinView::setMode(Mode mode
)
218 if (mode
== m_mode
) {
219 return; // the wished mode is already set
222 const int oldZoomLevel
= m_controller
->zoomLevel();
227 const KUrl viewPropsUrl
= rootUrl();
228 ViewProperties
props(viewPropsUrl
);
229 props
.setViewMode(m_mode
);
232 // the file item delegate has been recreated, apply the current
233 // additional information manually
234 const KFileItemDelegate::InformationList infoList
= props
.additionalInfo();
235 m_viewAccessor
.itemDelegate()->setShowInformation(infoList
);
236 emit
additionalInfoChanged();
238 // Not all view modes support categorized sorting. Adjust the sorting model
239 // if changing the view mode results in a change of the categorized sorting
241 m_storedCategorizedSorting
= props
.categorizedSorting();
242 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
243 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
244 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
245 emit
categorizedSortingChanged();
250 updateZoomLevel(oldZoomLevel
);
252 loadDirectory(viewPropsUrl
);
256 DolphinView::Mode
DolphinView::mode() const
261 bool DolphinView::showPreview() const
263 return m_showPreview
;
266 bool DolphinView::showHiddenFiles() const
268 return m_viewAccessor
.dirLister()->showingDotFiles();
271 bool DolphinView::categorizedSorting() const
273 // If all view modes would support categorized sorting, returning
274 // m_viewAccessor.proxyModel()->isCategorizedModel() would be the way to go. As
275 // currently only the icons view supports caterized sorting, we remember
276 // the stored view properties state in m_storedCategorizedSorting and
277 // return this state. The application takes care to disable the corresponding
278 // checkbox by checking DolphinView::supportsCategorizedSorting() to indicate
279 // that this setting is not applied to the current view mode.
280 return m_storedCategorizedSorting
;
283 bool DolphinView::supportsCategorizedSorting() const
285 return m_viewAccessor
.supportsCategorizedSorting();
288 bool DolphinView::hasSelection() const
290 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
291 return view
&& view
->selectionModel()->hasSelection();
294 KFileItemList
DolphinView::selectedItems() const
296 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
298 // Our view has a selection, we will map them back to the DolphinModel
299 // and then fill the KFileItemList.
300 Q_ASSERT((view
!= 0) && (view
->selectionModel() != 0));
302 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
303 KFileItemList itemList
;
305 const QModelIndexList indexList
= selection
.indexes();
306 foreach (const QModelIndex
&index
, indexList
) {
307 KFileItem item
= m_viewAccessor
.dirModel()->itemForIndex(index
);
308 if (!item
.isNull()) {
309 itemList
.append(item
);
316 KUrl::List
DolphinView::selectedUrls() const
319 const KFileItemList list
= selectedItems();
320 foreach (const KFileItem
&item
, list
) {
321 urls
.append(item
.url());
326 int DolphinView::selectedItemsCount() const
328 return m_viewAccessor
.itemView()->selectionModel()->selectedIndexes().count();
331 QItemSelectionModel
* DolphinView::selectionModel() const
333 return m_viewAccessor
.itemView()->selectionModel();
336 void DolphinView::setContentsPosition(int x
, int y
)
338 QAbstractItemView
* view
= m_viewAccessor
.itemView();
340 view
->horizontalScrollBar()->setValue(x
);
341 view
->verticalScrollBar()->setValue(y
);
343 m_loadingDirectory
= false;
346 void DolphinView::setRestoredContentsPosition(const QPoint
& pos
)
348 // TODO: This function is called by DolphinViewContainer.
349 // If it makes use of DolphinView::restoreState(...) to restore the
350 // view state in KDE 4.5, this function can be removed.
351 m_restoredContentsPosition
= pos
;
354 QPoint
DolphinView::contentsPosition() const
356 // TODO: If DolphinViewContainer uses DolphinView::saveState(...) to save the
357 // view state in KDE 4.5, this code can be moved to DolphinView::saveState.
358 QAbstractItemView
* view
= m_viewAccessor
.itemView();
360 const int x
= view
->horizontalScrollBar()->value();
361 const int y
= view
->verticalScrollBar()->value();
365 void DolphinView::setZoomLevel(int level
)
367 if (level
< ZoomLevelInfo::minimumLevel()) {
368 level
= ZoomLevelInfo::minimumLevel();
369 } else if (level
> ZoomLevelInfo::maximumLevel()) {
370 level
= ZoomLevelInfo::maximumLevel();
373 if (level
!= zoomLevel()) {
374 m_controller
->setZoomLevel(level
);
375 emit
zoomLevelChanged(level
);
379 int DolphinView::zoomLevel() const
381 return m_controller
->zoomLevel();
384 void DolphinView::setSorting(Sorting sorting
)
386 if (sorting
!= this->sorting()) {
387 updateSorting(sorting
);
391 DolphinView::Sorting
DolphinView::sorting() const
393 return m_viewAccessor
.proxyModel()->sorting();
396 void DolphinView::setSortOrder(Qt::SortOrder order
)
398 if (sortOrder() != order
) {
399 updateSortOrder(order
);
403 Qt::SortOrder
DolphinView::sortOrder() const
405 return m_viewAccessor
.proxyModel()->sortOrder();
408 void DolphinView::setSortFoldersFirst(bool foldersFirst
)
410 if (sortFoldersFirst() != foldersFirst
) {
411 updateSortFoldersFirst(foldersFirst
);
415 bool DolphinView::sortFoldersFirst() const
417 return m_viewAccessor
.proxyModel()->sortFoldersFirst();
420 void DolphinView::setAdditionalInfo(KFileItemDelegate::InformationList info
)
422 const KUrl viewPropsUrl
= rootUrl();
423 ViewProperties
props(viewPropsUrl
);
424 props
.setAdditionalInfo(info
);
425 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
427 emit
additionalInfoChanged();
429 if (m_viewAccessor
.reloadOnAdditionalInfoChange()) {
430 loadDirectory(viewPropsUrl
);
434 KFileItemDelegate::InformationList
DolphinView::additionalInfo() const
436 return m_viewAccessor
.itemDelegate()->showInformation();
439 void DolphinView::reload()
441 QByteArray viewState
;
442 QDataStream
saveStream(&viewState
, QIODevice::WriteOnly
);
443 saveState(saveStream
);
444 m_selectedItems
= selectedItems();
447 loadDirectory(url(), true);
449 QDataStream
restoreStream(viewState
);
450 restoreState(restoreStream
);
453 void DolphinView::refresh()
455 m_ignoreViewProperties
= false;
457 const bool oldActivationState
= m_active
;
458 const int oldZoomLevel
= m_controller
->zoomLevel();
462 applyViewProperties();
465 setActive(oldActivationState
);
466 updateZoomLevel(oldZoomLevel
);
469 void DolphinView::updateView(const KUrl
& url
, const KUrl
& rootUrl
)
471 Q_UNUSED(rootUrl
); // TODO: remove after columnview-cleanup has been finished
473 if (m_controller
->url() == url
) {
477 m_controller
->setUrl(url
); // emits urlChanged, which we forward
478 m_viewAccessor
.prepareUrlChange(url
);
479 applyViewProperties();
482 // When changing the URL there is no need to keep the version
483 // data of the previous URL.
484 m_viewAccessor
.dirModel()->clearVersionData();
486 emit
startedPathLoading(url
);
489 void DolphinView::setNameFilter(const QString
& nameFilter
)
491 m_controller
->setNameFilter(nameFilter
);
494 void DolphinView::calculateItemCount(int& fileCount
,
496 KIO::filesize_t
& totalFileSize
) const
498 foreach (const KFileItem
& item
, m_viewAccessor
.dirLister()->items()) {
503 totalFileSize
+= item
.size();
508 QString
DolphinView::statusBarText() const
513 KIO::filesize_t totalFileSize
= 0;
515 if (hasSelection()) {
516 // give a summary of the status of the selected files
517 const KFileItemList list
= selectedItems();
518 if (list
.isEmpty()) {
519 // when an item is triggered, it is temporary selected but selectedItems()
520 // will return an empty list
524 KFileItemList::const_iterator it
= list
.begin();
525 const KFileItemList::const_iterator end
= list
.end();
527 const KFileItem
& item
= *it
;
532 totalFileSize
+= item
.size();
537 if (folderCount
+ fileCount
== 1) {
538 // if only one item is selected, show the filename
539 const QString name
= list
.first().name();
540 text
= (folderCount
== 1) ? i18nc("@info:status", "<filename>%1</filename> selected", name
) :
541 i18nc("@info:status", "<filename>%1</filename> selected (%2)",
542 name
, KIO::convertSize(totalFileSize
));
544 // at least 2 items are selected
545 const QString foldersText
= i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount
);
546 const QString filesText
= i18ncp("@info:status", "1 File selected", "%1 Files selected", fileCount
);
547 if ((folderCount
> 0) && (fileCount
> 0)) {
548 text
= i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
549 foldersText
, filesText
, KIO::convertSize(totalFileSize
));
550 } else if (fileCount
> 0) {
551 text
= i18nc("@info:status files (size)", "%1 (%2)", filesText
, KIO::convertSize(totalFileSize
));
553 Q_ASSERT(folderCount
> 0);
558 calculateItemCount(fileCount
, folderCount
, totalFileSize
);
559 text
= KIO::itemsSummaryString(fileCount
+ folderCount
,
560 fileCount
, folderCount
,
561 totalFileSize
, true);
567 QList
<QAction
*> DolphinView::versionControlActions(const KFileItemList
& items
) const
569 return m_controller
->versionControlActions(items
);
572 void DolphinView::setUrl(const KUrl
& url
)
574 m_newFileNames
.clear();
575 updateView(url
, KUrl());
578 void DolphinView::selectAll()
580 m_viewAccessor
.itemView()->selectAll();
583 void DolphinView::invertSelection()
585 QItemSelectionModel
* selectionModel
= m_viewAccessor
.itemView()->selectionModel();
586 const QAbstractItemModel
* itemModel
= selectionModel
->model();
588 const QModelIndex topLeft
= itemModel
->index(0, 0);
589 const QModelIndex bottomRight
= itemModel
->index(itemModel
->rowCount() - 1,
590 itemModel
->columnCount() - 1);
592 const QItemSelection
selection(topLeft
, bottomRight
);
593 selectionModel
->select(selection
, QItemSelectionModel::Toggle
);
596 void DolphinView::clearSelection()
598 m_viewAccessor
.itemView()->clearSelection();
601 void DolphinView::changeSelection(const KFileItemList
& selection
)
604 if (selection
.isEmpty()) {
607 const KUrl
& baseUrl
= url();
609 QItemSelection newSelection
;
610 foreach(const KFileItem
& item
, selection
) {
611 url
= item
.url().upUrl();
612 if (baseUrl
.equals(url
, KUrl::CompareWithoutTrailingSlash
)) {
613 QModelIndex index
= m_viewAccessor
.proxyModel()->mapFromSource(m_viewAccessor
.dirModel()->indexForItem(item
));
614 newSelection
.select(index
, index
);
617 m_viewAccessor
.itemView()->selectionModel()->select(newSelection
,
618 QItemSelectionModel::ClearAndSelect
619 | QItemSelectionModel::Current
);
622 void DolphinView::renameSelectedItems()
624 KFileItemList items
= selectedItems();
625 const int itemCount
= items
.count();
631 // More than one item has been selected for renaming. Open
632 // a rename dialog and rename all items afterwards.
633 QPointer
<RenameDialog
> dialog
= new RenameDialog(this, items
);
634 if (dialog
->exec() == QDialog::Rejected
) {
639 const QString newName
= dialog
->newName();
640 if (newName
.isEmpty()) {
641 emit
errorMessage(dialog
->errorString());
647 // the selection would be invalid after renaming the items, so just clear
651 // TODO: check how this can be integrated into KIO::FileUndoManager/KonqOperations
652 // as one operation instead of n rename operations like it is done now...
653 Q_ASSERT(newName
.contains('#'));
655 // currently the items are sorted by the selection order, resort
656 // them by the file name
657 qSort(items
.begin(), items
.end(), lessThan
);
659 // iterate through all selected items and rename them...
661 foreach (const KFileItem
& item
, items
) {
662 const KUrl
& oldUrl
= item
.url();
664 number
.setNum(index
++);
666 QString name
= newName
;
667 name
.replace('#', number
);
669 if (oldUrl
.fileName() != name
) {
670 KUrl newUrl
= oldUrl
;
671 newUrl
.setFileName(name
);
672 KonqOperations::rename(this, oldUrl
, newUrl
);
675 } else if (DolphinSettings::instance().generalSettings()->renameInline()) {
676 Q_ASSERT(itemCount
== 1);
677 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForItem(items
.first());
678 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
679 m_viewAccessor
.itemView()->edit(proxyIndex
);
681 Q_ASSERT(itemCount
== 1);
683 QPointer
<RenameDialog
> dialog
= new RenameDialog(this, items
);
684 if (dialog
->exec() == QDialog::Rejected
) {
689 const QString newName
= dialog
->newName();
690 if (newName
.isEmpty()) {
691 emit
errorMessage(dialog
->errorString());
697 const KUrl
& oldUrl
= items
.first().url();
698 KUrl newUrl
= oldUrl
;
699 newUrl
.setFileName(newName
);
700 KonqOperations::rename(this, oldUrl
, newUrl
);
703 // assure that the current index remains visible when KDirLister
704 // will notify the view about changed items
705 m_assureVisibleCurrentIndex
= true;
708 void DolphinView::trashSelectedItems()
710 const KUrl::List list
= simplifiedSelectedUrls();
711 KonqOperations::del(this, KonqOperations::TRASH
, list
);
714 void DolphinView::deleteSelectedItems()
716 const KUrl::List list
= simplifiedSelectedUrls();
717 const bool del
= KonqOperations::askDeleteConfirmation(list
,
719 KonqOperations::DEFAULT_CONFIRMATION
,
723 KIO::Job
* job
= KIO::del(list
);
724 connect(job
, SIGNAL(result(KJob
*)),
725 this, SLOT(slotDeleteFileFinished(KJob
*)));
729 void DolphinView::cutSelectedItems()
731 QMimeData
* mimeData
= selectionMimeData();
732 KonqMimeData::addIsCutSelection(mimeData
, true);
733 QApplication::clipboard()->setMimeData(mimeData
);
736 void DolphinView::copySelectedItems()
738 QMimeData
* mimeData
= selectionMimeData();
739 QApplication::clipboard()->setMimeData(mimeData
);
742 void DolphinView::paste()
747 void DolphinView::pasteIntoFolder()
749 const KFileItemList items
= selectedItems();
750 if ((items
.count() == 1) && items
.first().isDir()) {
751 pasteToUrl(items
.first().url());
755 void DolphinView::setShowPreview(bool show
)
757 if (m_showPreview
== show
) {
761 const KUrl viewPropsUrl
= rootUrl();
762 ViewProperties
props(viewPropsUrl
);
763 props
.setShowPreview(show
);
765 m_showPreview
= show
;
766 const int oldZoomLevel
= m_controller
->zoomLevel();
767 emit
showPreviewChanged();
769 // Enabling or disabling the preview might change the icon size of the view.
770 // As the view does not emit a signal when the icon size has been changed,
771 // the used zoom level of the controller must be adjusted manually:
772 updateZoomLevel(oldZoomLevel
);
775 void DolphinView::setShowHiddenFiles(bool show
)
777 if (m_viewAccessor
.dirLister()->showingDotFiles() == show
) {
781 const KUrl viewPropsUrl
= rootUrl();
782 ViewProperties
props(viewPropsUrl
);
783 props
.setShowHiddenFiles(show
);
785 m_viewAccessor
.dirLister()->setShowingDotFiles(show
);
786 emit
showHiddenFilesChanged();
789 void DolphinView::setCategorizedSorting(bool categorized
)
791 if (categorized
== categorizedSorting()) {
795 // setCategorizedSorting(true) may only get invoked
796 // if the view supports categorized sorting
797 Q_ASSERT(!categorized
|| supportsCategorizedSorting());
799 ViewProperties
props(rootUrl());
800 props
.setCategorizedSorting(categorized
);
803 m_storedCategorizedSorting
= categorized
;
804 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
806 emit
categorizedSortingChanged();
809 void DolphinView::toggleSortOrder()
811 const Qt::SortOrder order
= (sortOrder() == Qt::AscendingOrder
) ?
812 Qt::DescendingOrder
:
817 void DolphinView::toggleSortFoldersFirst()
819 setSortFoldersFirst(!sortFoldersFirst());
822 void DolphinView::toggleAdditionalInfo(QAction
* action
)
824 const KFileItemDelegate::Information info
=
825 static_cast<KFileItemDelegate::Information
>(action
->data().toInt());
827 KFileItemDelegate::InformationList list
= additionalInfo();
829 const bool show
= action
->isChecked();
831 const int index
= list
.indexOf(info
);
832 const bool containsInfo
= (index
>= 0);
833 if (show
&& !containsInfo
) {
835 setAdditionalInfo(list
);
836 } else if (!show
&& containsInfo
) {
837 list
.removeAt(index
);
838 setAdditionalInfo(list
);
839 Q_ASSERT(list
.indexOf(info
) < 0);
843 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
845 QWidget::mouseReleaseEvent(event
);
849 bool DolphinView::eventFilter(QObject
* watched
, QEvent
* event
)
851 switch (event
->type()) {
852 case QEvent::FocusIn
:
853 if (watched
== m_viewAccessor
.itemView()) {
854 m_controller
->requestActivation();
858 case QEvent::DragEnter
:
859 if (watched
== m_viewAccessor
.itemView()->viewport()) {
864 case QEvent::KeyPress
:
865 if (watched
== m_viewAccessor
.itemView()) {
866 // clear the selection when Escape has been pressed
867 QKeyEvent
* keyEvent
= static_cast<QKeyEvent
*>(event
);
868 if (keyEvent
->key() == Qt::Key_Escape
) {
875 if (watched
== m_viewAccessor
.itemView()->viewport()) {
876 // Ctrl+wheel events should cause icon zooming, but not if the left mouse button is pressed
877 // (the user is probably trying to scroll during a selection in that case)
878 QWheelEvent
* wheelEvent
= static_cast<QWheelEvent
*>(event
);
879 if (wheelEvent
->modifiers() & Qt::ControlModifier
&& !(wheelEvent
->buttons() & Qt::LeftButton
)) {
880 const int delta
= wheelEvent
->delta();
881 const int level
= zoomLevel();
883 setZoomLevel(level
+ 1);
884 } else if (delta
< 0) {
885 setZoomLevel(level
- 1);
896 return QWidget::eventFilter(watched
, event
);
899 void DolphinView::activate()
904 void DolphinView::triggerItem(const KFileItem
& item
)
906 const Qt::KeyboardModifiers modifier
= QApplication::keyboardModifiers();
907 if ((modifier
& Qt::ShiftModifier
) || (modifier
& Qt::ControlModifier
)) {
908 // items are selected by the user, hence don't trigger the
909 // item specified by 'index'
913 // TODO: the m_isContextMenuOpen check is a workaround for Qt-issue 207192
914 if (item
.isNull() || m_isContextMenuOpen
) {
918 emit
itemTriggered(item
); // caught by DolphinViewContainer or DolphinPart
921 void DolphinView::emitDelayedSelectionChangedSignal()
923 // Invoke emitSelectionChangedSignal() with a delay of 300 ms. This assures
924 // that fast selection changes don't result in expensive operations to
925 // collect all file items for the signal (see DolphinView::selectedItems()).
926 m_selectionChangedTimer
->start();
929 void DolphinView::emitSelectionChangedSignal()
931 emit
selectionChanged(DolphinView::selectedItems());
934 void DolphinView::openContextMenu(const QPoint
& pos
,
935 const QList
<QAction
*>& customActions
)
938 const QModelIndex index
= m_viewAccessor
.itemView()->indexAt(pos
);
939 if (index
.isValid() && (index
.column() == DolphinModel::Name
)) {
940 const QModelIndex dolphinModelIndex
= m_viewAccessor
.proxyModel()->mapToSource(index
);
941 item
= m_viewAccessor
.dirModel()->itemForIndex(dolphinModelIndex
);
944 m_isContextMenuOpen
= true; // TODO: workaround for Qt-issue 207192
945 emit
requestContextMenu(item
, url(), customActions
);
946 m_isContextMenuOpen
= false;
949 void DolphinView::dropUrls(const KFileItem
& destItem
,
950 const KUrl
& destPath
,
953 addNewFileNames(event
->mimeData());
954 DragAndDropHelper::instance().dropUrls(destItem
, destPath
, event
, this);
957 void DolphinView::updateSorting(DolphinView::Sorting sorting
)
959 ViewProperties
props(rootUrl());
960 props
.setSorting(sorting
);
962 m_viewAccessor
.proxyModel()->setSorting(sorting
);
964 emit
sortingChanged(sorting
);
967 void DolphinView::updateSortOrder(Qt::SortOrder order
)
969 ViewProperties
props(rootUrl());
970 props
.setSortOrder(order
);
972 m_viewAccessor
.proxyModel()->setSortOrder(order
);
974 emit
sortOrderChanged(order
);
977 void DolphinView::updateSortFoldersFirst(bool foldersFirst
)
979 ViewProperties
props(rootUrl());
980 props
.setSortFoldersFirst(foldersFirst
);
982 m_viewAccessor
.proxyModel()->setSortFoldersFirst(foldersFirst
);
984 emit
sortFoldersFirstChanged(foldersFirst
);
987 void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList
& info
)
989 ViewProperties
props(rootUrl());
990 props
.setAdditionalInfo(info
);
993 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
995 emit
additionalInfoChanged();
998 void DolphinView::updateAdditionalInfoActions(KActionCollection
* collection
)
1000 const bool enable
= (m_mode
== DolphinView::DetailsView
) ||
1001 (m_mode
== DolphinView::IconsView
);
1003 QAction
* showSizeInfo
= collection
->action("show_size_info");
1004 QAction
* showDateInfo
= collection
->action("show_date_info");
1005 QAction
* showPermissionsInfo
= collection
->action("show_permissions_info");
1006 QAction
* showOwnerInfo
= collection
->action("show_owner_info");
1007 QAction
* showGroupInfo
= collection
->action("show_group_info");
1008 QAction
* showMimeInfo
= collection
->action("show_mime_info");
1010 showSizeInfo
->setChecked(false);
1011 showDateInfo
->setChecked(false);
1012 showPermissionsInfo
->setChecked(false);
1013 showOwnerInfo
->setChecked(false);
1014 showGroupInfo
->setChecked(false);
1015 showMimeInfo
->setChecked(false);
1017 showSizeInfo
->setEnabled(enable
);
1018 showDateInfo
->setEnabled(enable
);
1019 showPermissionsInfo
->setEnabled(enable
);
1020 showOwnerInfo
->setEnabled(enable
);
1021 showGroupInfo
->setEnabled(enable
);
1022 showMimeInfo
->setEnabled(enable
);
1024 foreach (KFileItemDelegate::Information info
, m_viewAccessor
.itemDelegate()->showInformation()) {
1026 case KFileItemDelegate::Size
:
1027 showSizeInfo
->setChecked(true);
1029 case KFileItemDelegate::ModificationTime
:
1030 showDateInfo
->setChecked(true);
1032 case KFileItemDelegate::Permissions
:
1033 showPermissionsInfo
->setChecked(true);
1035 case KFileItemDelegate::Owner
:
1036 showOwnerInfo
->setChecked(true);
1038 case KFileItemDelegate::OwnerAndGroup
:
1039 showGroupInfo
->setChecked(true);
1041 case KFileItemDelegate::FriendlyMimeType
:
1042 showMimeInfo
->setChecked(true);
1050 QPair
<bool, QString
> DolphinView::pasteInfo() const
1052 return KonqOperations::pasteInfo(url());
1055 void DolphinView::setTabsForFilesEnabled(bool tabsForFiles
)
1057 m_tabsForFiles
= tabsForFiles
;
1060 bool DolphinView::isTabsForFilesEnabled() const
1062 return m_tabsForFiles
;
1065 void DolphinView::activateItem(const KUrl
& url
)
1067 // TODO: If DolphinViewContainer uses DolphinView::restoreState(...) to restore the
1068 // view state in KDE 4.5, this function can be removed.
1069 m_activeItemUrl
= url
;
1072 bool DolphinView::itemsExpandable() const
1074 return m_viewAccessor
.itemsExpandable();
1077 void DolphinView::restoreState(QDataStream
&stream
)
1080 stream
>> m_activeItemUrl
;
1083 stream
>> m_restoredContentsPosition
;
1085 // expanded folders (only relevant for the details view - will be ignored by the view in other view modes)
1086 QSet
<KUrl
> urlsToExpand
;
1087 stream
>> urlsToExpand
;
1088 const DolphinDetailsViewExpander
* expander
= m_viewAccessor
.setExpandedUrls(urlsToExpand
);
1091 m_expanderActive
= true;
1092 connect (expander
, SIGNAL(completed()), this, SLOT(slotLoadingCompleted()));
1095 m_expanderActive
= false;
1099 void DolphinView::saveState(QDataStream
&stream
)
1102 KFileItem currentItem
;
1103 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
1106 const QModelIndex proxyIndex
= view
->currentIndex();
1107 const QModelIndex dirModelIndex
= m_viewAccessor
.proxyModel()->mapToSource(proxyIndex
);
1108 currentItem
= m_viewAccessor
.dirModel()->itemForIndex(dirModelIndex
);
1112 if (!currentItem
.isNull())
1113 currentUrl
= currentItem
.url();
1115 stream
<< currentUrl
;
1118 stream
<< contentsPosition();
1120 // expanded folders (only relevant for the details view - the set will be empty in other view modes)
1121 stream
<< m_viewAccessor
.expandedUrls();
1124 void DolphinView::observeCreatedItem(const KUrl
& url
)
1126 m_createdItemUrl
= url
;
1127 connect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
1128 this, SLOT(selectAndScrollToCreatedItem()));
1131 void DolphinView::selectAndScrollToCreatedItem()
1133 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_createdItemUrl
);
1134 if (dirIndex
.isValid()) {
1135 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
1136 m_viewAccessor
.itemView()->setCurrentIndex(proxyIndex
);
1139 disconnect(m_viewAccessor
.dirModel(), SIGNAL(rowsInserted(const QModelIndex
&, int, int)),
1140 this, SLOT(selectAndScrollToCreatedItem()));
1141 m_createdItemUrl
= KUrl();
1144 void DolphinView::emitContentsMoved()
1146 // TODO: If DolphinViewContainer uses DolphinView::saveState(...) to save the
1147 // view state in KDE 4.5, the contentsMoved signal might not be needed anymore,
1148 // depending on how the implementation is done.
1149 // In that case, the code in contentsPosition() can be moved to saveState().
1151 // only emit the contents moved signal if no directory loading is ongoing
1152 // (this would reset the contents position always to (0, 0))
1153 if (!m_loadingDirectory
) {
1154 const QPoint
pos(contentsPosition());
1155 emit
contentsMoved(pos
.x(), pos
.y());
1159 void DolphinView::showHoverInformation(const KFileItem
& item
)
1161 emit
requestItemInfo(item
);
1164 void DolphinView::clearHoverInformation()
1166 emit
requestItemInfo(KFileItem());
1169 void DolphinView::slotDeleteFileFinished(KJob
* job
)
1171 if (job
->error() == 0) {
1172 emit
operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
1173 } else if (job
->error() != KIO::ERR_USER_CANCELED
) {
1174 emit
errorMessage(job
->errorString());
1178 void DolphinView::slotRequestUrlChange(const KUrl
& url
)
1180 emit
requestUrlChange(url
);
1181 m_controller
->setUrl(url
);
1184 void DolphinView::slotDirListerCompleted()
1186 if (!m_expanderActive
) {
1187 slotLoadingCompleted();
1190 if (!m_newFileNames
.isEmpty()) {
1191 // select all newly added items created by a paste operation or
1192 // a drag & drop operation
1193 const int rowCount
= m_viewAccessor
.proxyModel()->rowCount();
1194 QItemSelection selection
;
1195 for (int row
= 0; row
< rowCount
; ++row
) {
1196 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->index(row
, 0);
1197 const QModelIndex dirIndex
= m_viewAccessor
.proxyModel()->mapToSource(proxyIndex
);
1198 const KUrl url
= m_viewAccessor
.dirModel()->itemForIndex(dirIndex
).url();
1199 if (m_newFileNames
.contains(url
.fileName())) {
1200 selection
.merge(QItemSelection(proxyIndex
, proxyIndex
), QItemSelectionModel::Select
);
1203 m_viewAccessor
.itemView()->selectionModel()->select(selection
, QItemSelectionModel::Select
);
1205 m_newFileNames
.clear();
1209 void DolphinView::slotLoadingCompleted()
1211 m_expanderActive
= false;
1212 m_loadingDirectory
= false;
1214 if (!m_activeItemUrl
.isEmpty()) {
1215 // assure that the current item remains visible
1216 const QModelIndex dirIndex
= m_viewAccessor
.dirModel()->indexForUrl(m_activeItemUrl
);
1217 if (dirIndex
.isValid()) {
1218 const QModelIndex proxyIndex
= m_viewAccessor
.proxyModel()->mapFromSource(dirIndex
);
1219 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1220 const bool clearSelection
= !hasSelection();
1221 view
->setCurrentIndex(proxyIndex
);
1222 if (clearSelection
) {
1223 view
->clearSelection();
1225 m_activeItemUrl
.clear();
1229 if (!m_selectedItems
.isEmpty()) {
1230 changeSelection(m_selectedItems
);
1231 m_selectedItems
.clear();
1234 // Restore the contents position. This has to be done using a Qt::QueuedConnection
1235 // because the view might not be in its final state yet.
1236 QMetaObject::invokeMethod(this, "restoreContentsPosition", Qt::QueuedConnection
);
1239 void DolphinView::slotRefreshItems()
1241 if (m_assureVisibleCurrentIndex
) {
1242 m_assureVisibleCurrentIndex
= false;
1243 m_viewAccessor
.itemView()->scrollTo(m_viewAccessor
.itemView()->currentIndex());
1247 void DolphinView::loadDirectory(const KUrl
& url
, bool reload
)
1249 if (!url
.isValid()) {
1250 const QString
location(url
.pathOrUrl());
1251 if (location
.isEmpty()) {
1252 emit
errorMessage(i18nc("@info:status", "The location is empty."));
1254 emit
errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location
));
1259 m_loadingDirectory
= true;
1260 m_expanderActive
= false;
1262 m_viewAccessor
.dirLister()->openUrl(url
, reload
? KDirLister::Reload
: KDirLister::NoFlags
);
1265 void DolphinView::applyViewProperties()
1267 if (m_ignoreViewProperties
) {
1271 const ViewProperties
props(rootUrl());
1273 const Mode mode
= props
.viewMode();
1274 if (m_mode
!= mode
) {
1275 const int oldZoomLevel
= m_controller
->zoomLevel();
1281 updateZoomLevel(oldZoomLevel
);
1283 if (m_viewAccessor
.itemView() == 0) {
1286 Q_ASSERT(m_viewAccessor
.itemView() != 0);
1287 Q_ASSERT(m_viewAccessor
.itemDelegate() != 0);
1289 const bool showHiddenFiles
= props
.showHiddenFiles();
1290 if (showHiddenFiles
!= m_viewAccessor
.dirLister()->showingDotFiles()) {
1291 m_viewAccessor
.dirLister()->setShowingDotFiles(showHiddenFiles
);
1292 emit
showHiddenFilesChanged();
1295 m_storedCategorizedSorting
= props
.categorizedSorting();
1296 const bool categorized
= m_storedCategorizedSorting
&& supportsCategorizedSorting();
1297 if (categorized
!= m_viewAccessor
.proxyModel()->isCategorizedModel()) {
1298 m_viewAccessor
.proxyModel()->setCategorizedModel(categorized
);
1299 emit
categorizedSortingChanged();
1302 const DolphinView::Sorting sorting
= props
.sorting();
1303 if (sorting
!= m_viewAccessor
.proxyModel()->sorting()) {
1304 m_viewAccessor
.proxyModel()->setSorting(sorting
);
1305 emit
sortingChanged(sorting
);
1308 const Qt::SortOrder sortOrder
= props
.sortOrder();
1309 if (sortOrder
!= m_viewAccessor
.proxyModel()->sortOrder()) {
1310 m_viewAccessor
.proxyModel()->setSortOrder(sortOrder
);
1311 emit
sortOrderChanged(sortOrder
);
1314 const bool sortFoldersFirst
= props
.sortFoldersFirst();
1315 if (sortFoldersFirst
!= m_viewAccessor
.proxyModel()->sortFoldersFirst()) {
1316 m_viewAccessor
.proxyModel()->setSortFoldersFirst(sortFoldersFirst
);
1317 emit
sortFoldersFirstChanged(sortFoldersFirst
);
1320 KFileItemDelegate::InformationList info
= props
.additionalInfo();
1321 if (info
!= m_viewAccessor
.itemDelegate()->showInformation()) {
1322 m_viewAccessor
.itemDelegate()->setShowInformation(info
);
1323 emit
additionalInfoChanged();
1326 const bool showPreview
= props
.showPreview();
1327 if (showPreview
!= m_showPreview
) {
1328 m_showPreview
= showPreview
;
1329 const int oldZoomLevel
= m_controller
->zoomLevel();
1330 emit
showPreviewChanged();
1332 // Enabling or disabling the preview might change the icon size of the view.
1333 // As the view does not emit a signal when the icon size has been changed,
1334 // the used zoom level of the controller must be adjusted manually:
1335 updateZoomLevel(oldZoomLevel
);
1338 if (DolphinSettings::instance().generalSettings()->globalViewProps()) {
1339 // During the lifetime of a DolphinView instance the global view properties
1340 // should not be changed. This allows e. g. to split a view and use different
1341 // view properties for each view.
1342 m_ignoreViewProperties
= true;
1346 void DolphinView::createView()
1350 Q_ASSERT(m_viewAccessor
.itemView() == 0);
1351 m_viewAccessor
.createView(this, m_controller
, m_mode
);
1353 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1354 Q_ASSERT(view
!= 0);
1355 view
->installEventFilter(this);
1356 view
->viewport()->installEventFilter(this);
1358 m_controller
->setItemView(view
);
1359 connect(m_controller
, SIGNAL(selectionChanged()),
1360 this, SLOT(emitDelayedSelectionChangedSignal()));
1362 // When changing the view mode, the selection is lost due to reinstantiating
1363 // a new item view with a custom selection model. Pass the ownership of the
1364 // selection model to DolphinView, so that it can be shared by all item views.
1365 if (m_selectionModel
!= 0) {
1366 view
->setSelectionModel(m_selectionModel
);
1368 m_selectionModel
= view
->selectionModel();
1370 m_selectionModel
->setParent(this);
1372 connect(view
->verticalScrollBar(), SIGNAL(valueChanged(int)),
1373 this, SLOT(emitContentsMoved()));
1374 connect(view
->horizontalScrollBar(), SIGNAL(valueChanged(int)),
1375 this, SLOT(emitContentsMoved()));
1377 setFocusProxy(m_viewAccessor
.layoutTarget());
1378 m_topLayout
->insertWidget(1, m_viewAccessor
.layoutTarget());
1381 void DolphinView::deleteView()
1383 QAbstractItemView
* view
= m_viewAccessor
.itemView();
1385 // It's important to set the keyboard focus to the parent
1386 // before deleting the view: Otherwise when having a split
1387 // view the other view will get the focus and will request
1388 // an activation (see DolphinView::eventFilter()).
1392 m_topLayout
->removeWidget(view
);
1395 // disconnect all signal/slots
1397 m_controller
->disconnect(view
);
1399 disconnect(view
->verticalScrollBar(), SIGNAL(valueChanged(int)),
1400 this, SLOT(emitContentsMoved()));
1401 disconnect(view
->horizontalScrollBar(), SIGNAL(valueChanged(int)),
1402 this, SLOT(emitContentsMoved()));
1404 m_viewAccessor
.deleteView();
1408 void DolphinView::pasteToUrl(const KUrl
& url
)
1410 addNewFileNames(QApplication::clipboard()->mimeData());
1411 KonqOperations::doPaste(this, url
);
1414 void DolphinView::updateZoomLevel(int oldZoomLevel
)
1416 const int newZoomLevel
= ZoomLevelInfo::zoomLevelForIconSize(m_viewAccessor
.itemView()->iconSize());
1417 if (oldZoomLevel
!= newZoomLevel
) {
1418 m_controller
->setZoomLevel(newZoomLevel
);
1419 emit
zoomLevelChanged(newZoomLevel
);
1423 KUrl::List
DolphinView::simplifiedSelectedUrls() const
1425 KUrl::List list
= selectedUrls();
1426 if (itemsExpandable() ) {
1427 list
= KDirModel::simplifiedUrlList(list
);
1432 QMimeData
* DolphinView::selectionMimeData() const
1434 const QAbstractItemView
* view
= m_viewAccessor
.itemView();
1435 Q_ASSERT((view
!= 0) && (view
->selectionModel() != 0));
1436 const QItemSelection selection
= m_viewAccessor
.proxyModel()->mapSelectionToSource(view
->selectionModel()->selection());
1437 return m_viewAccessor
.dirModel()->mimeData(selection
.indexes());
1440 void DolphinView::addNewFileNames(const QMimeData
* mimeData
)
1442 const KUrl::List urls
= KUrl::List::fromMimeData(mimeData
);
1443 foreach (const KUrl
& url
, urls
) {
1444 m_newFileNames
.insert(url
.fileName());
1448 DolphinView::ViewAccessor::ViewAccessor(DolphinSortFilterProxyModel
* proxyModel
) :
1451 m_columnsContainer(0),
1452 m_proxyModel(proxyModel
),
1457 DolphinView::ViewAccessor::~ViewAccessor()
1459 delete m_dragSource
;
1463 void DolphinView::ViewAccessor::createView(QWidget
* parent
,
1464 DolphinController
* controller
,
1467 Q_ASSERT(itemView() == 0);
1471 m_iconsView
= new DolphinIconsView(parent
, controller
, m_proxyModel
);
1475 m_detailsView
= new DolphinDetailsView(parent
, controller
, m_proxyModel
);
1479 m_columnsContainer
= new DolphinColumnViewContainer(parent
, controller
);
1487 void DolphinView::ViewAccessor::deleteView()
1489 QAbstractItemView
* view
= itemView();
1491 if (DragAndDropHelper::instance().isDragSource(view
)) {
1492 // The view is a drag source (the feature "Open folders
1493 // during drag operations" is used). Deleting the view
1494 // during an ongoing drag operation is not allowed, so
1495 // this will postponed.
1496 if (m_dragSource
!= 0) {
1497 // the old stored view is obviously not the drag source anymore
1498 m_dragSource
->deleteLater();
1502 m_dragSource
= view
;
1504 view
->deleteLater();
1511 if (m_columnsContainer
!= 0) {
1512 m_columnsContainer
->deleteLater();
1514 m_columnsContainer
= 0;
1518 void DolphinView::ViewAccessor::prepareUrlChange(const KUrl
& url
)
1520 if (m_columnsContainer
!= 0) {
1521 m_columnsContainer
->showColumn(url
);
1524 if(!m_detailsViewExpander
.isNull()) {
1525 // Stop expanding items in the current folder
1526 m_detailsViewExpander
->stop();
1530 QAbstractItemView
* DolphinView::ViewAccessor::itemView() const
1532 if (m_iconsView
!= 0) {
1536 if (m_detailsView
!= 0) {
1537 return m_detailsView
;
1540 if (m_columnsContainer
!= 0) {
1541 return m_columnsContainer
->activeColumn();
1547 KFileItemDelegate
* DolphinView::ViewAccessor::itemDelegate() const
1549 return static_cast<KFileItemDelegate
*>(itemView()->itemDelegate());
1552 QWidget
* DolphinView::ViewAccessor::layoutTarget() const
1554 if (m_columnsContainer
!= 0) {
1555 return m_columnsContainer
;
1560 KUrl
DolphinView::ViewAccessor::rootUrl() const
1562 return (m_columnsContainer
!= 0) ? m_columnsContainer
->rootUrl() : KUrl();
1565 bool DolphinView::ViewAccessor::supportsCategorizedSorting() const
1567 return m_iconsView
!= 0;
1570 bool DolphinView::ViewAccessor::itemsExpandable() const
1572 return (m_detailsView
!= 0) && m_detailsView
->itemsExpandable();
1576 QSet
<KUrl
> DolphinView::ViewAccessor::expandedUrls() const
1578 if(m_detailsView
!= 0) {
1579 return m_detailsView
->expandedUrls();
1582 return QSet
<KUrl
>();
1586 const DolphinDetailsViewExpander
* DolphinView::ViewAccessor::setExpandedUrls(const QSet
<KUrl
>& urlsToExpand
)
1588 if((m_detailsView
!= 0) && m_detailsView
->itemsExpandable() && !urlsToExpand
.isEmpty()) {
1589 m_detailsViewExpander
= new DolphinDetailsViewExpander(m_detailsView
, urlsToExpand
);
1590 return m_detailsViewExpander
;
1597 bool DolphinView::ViewAccessor::reloadOnAdditionalInfoChange() const
1599 // the details view requires no reloading of the directory, as it maps
1600 // the file item delegate info to its columns internally
1601 return m_detailsView
!= 0;
1604 DolphinModel
* DolphinView::ViewAccessor::dirModel() const
1606 return static_cast<DolphinModel
*>(proxyModel()->sourceModel());
1609 DolphinSortFilterProxyModel
* DolphinView::ViewAccessor::proxyModel() const
1611 if (m_columnsContainer
!= 0) {
1612 return static_cast<DolphinSortFilterProxyModel
*>(m_columnsContainer
->activeColumn()->model());
1614 return m_proxyModel
;
1617 KDirLister
* DolphinView::ViewAccessor::dirLister() const
1619 return dirModel()->dirLister();
1622 void DolphinView::slotRedirection(const KUrl
& oldUrl
, const KUrl
& newUrl
)
1624 emit
redirection(oldUrl
, newUrl
);
1625 m_controller
->redirectToUrl(newUrl
); // #186947
1628 void DolphinView::restoreContentsPosition()
1630 if (!m_restoredContentsPosition
.isNull()) {
1631 setContentsPosition(m_restoredContentsPosition
.x(), m_restoredContentsPosition
.y());
1632 m_restoredContentsPosition
= QPoint();
1636 #include "dolphinview.moc"