1 /***************************************************************************
2 * Copyright (C) 2006-2009 by Peter Penz <peter.penz19@gmail.com> *
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 <config-nepomuk.h>
25 #include <QAbstractItemView>
26 #include <QApplication>
30 #include <QGraphicsSceneDragDropEvent>
32 #include <QItemSelection>
36 #include <KActionCollection>
37 #include <KColorScheme>
39 #include <KIconEffect>
41 #include <KFileItemListProperties>
43 #include <kitemviews/kfileitemmodel.h>
44 #include <kitemviews/kfileitemlistview.h>
45 #include <kitemviews/kitemlistcontainer.h>
46 #include <kitemviews/kitemlistheader.h>
47 #include <kitemviews/kitemlistselectionmanager.h>
48 #include <kitemviews/kitemlistview.h>
49 #include <kitemviews/kitemlistcontroller.h>
50 #include <KIO/DeleteJob>
51 #include <KIO/JobUiDelegate>
52 #include <KIO/NetAccess>
53 #include <KIO/PreviewJob>
56 #include <KMessageBox>
57 #include <konq_fileitemcapabilities.h>
58 #include <konq_operations.h>
59 #include <konqmimedata.h>
60 #include <KToggleAction>
63 #include "dolphinnewfilemenuobserver.h"
64 #include "dolphin_detailsmodesettings.h"
65 #include "dolphin_generalsettings.h"
66 #include "dolphinitemlistview.h"
67 #include "draganddrophelper.h"
68 #include "renamedialog.h"
69 #include "versioncontrol/versioncontrolobserver.h"
70 #include "viewmodecontroller.h"
71 #include "viewproperties.h"
72 #include "views/tooltips/tooltipmanager.h"
73 #include "zoomlevelinfo.h"
76 #include <Nepomuk/ResourceManager>
80 const int MaxModeEnum
= DolphinView::CompactView
;
83 DolphinView::DolphinView(const KUrl
& url
, QWidget
* parent
) :
86 m_tabsForFiles(false),
87 m_assureVisibleCurrentIndex(false),
88 m_isFolderWritable(true),
91 m_viewPropertiesContext(),
92 m_mode(DolphinView::IconsView
),
99 m_selectionChangedTimer(0),
101 m_scrollToCurrentItem(false),
102 m_restoredContentsPosition(),
104 m_versionControlObserver(0)
106 m_topLayout
= new QVBoxLayout(this);
107 m_topLayout
->setSpacing(0);
108 m_topLayout
->setMargin(0);
110 // When a new item has been created by the "Create New..." menu, the item should
111 // get selected and it must be assured that the item will get visible. As the
112 // creation is done asynchronously, several signals must be checked:
113 connect(&DolphinNewFileMenuObserver::instance(), SIGNAL(itemCreated(KUrl
)),
114 this, SLOT(observeCreatedItem(KUrl
)));
116 m_selectionChangedTimer
= new QTimer(this);
117 m_selectionChangedTimer
->setSingleShot(true);
118 m_selectionChangedTimer
->setInterval(300);
119 connect(m_selectionChangedTimer
, SIGNAL(timeout()),
120 this, SLOT(emitSelectionChangedSignal()));
122 m_model
= new KFileItemModel(this);
123 m_view
= new DolphinItemListView();
124 m_view
->setEnabledSelectionToggles(GeneralSettings::showSelectionToggle());
125 m_view
->setEnlargeSmallPreviews(GeneralSettings::enlargeSmallPreviews());
126 m_view
->setVisibleRoles(QList
<QByteArray
>() << "text");
129 KItemListController
* controller
= new KItemListController(m_model
, m_view
, this);
130 const int delay
= GeneralSettings::autoExpandFolders() ? 750 : -1;
131 controller
->setAutoActivationDelay(delay
);
133 m_container
= new KItemListContainer(controller
, this);
134 m_container
->installEventFilter(this);
135 setFocusProxy(m_container
);
136 connect(m_container
->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(hideToolTip()));
137 connect(m_container
->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(hideToolTip()));
139 controller
->setSelectionBehavior(KItemListController::MultiSelection
);
140 connect(controller
, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int)));
141 connect(controller
, SIGNAL(itemsActivated(QSet
<int>)), this, SLOT(slotItemsActivated(QSet
<int>)));
142 connect(controller
, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int)));
143 connect(controller
, SIGNAL(itemContextMenuRequested(int,QPointF
)), this, SLOT(slotItemContextMenuRequested(int,QPointF
)));
144 connect(controller
, SIGNAL(viewContextMenuRequested(QPointF
)), this, SLOT(slotViewContextMenuRequested(QPointF
)));
145 connect(controller
, SIGNAL(headerContextMenuRequested(QPointF
)), this, SLOT(slotHeaderContextMenuRequested(QPointF
)));
146 connect(controller
, SIGNAL(mouseButtonPressed(int,Qt::MouseButtons
)), this, SLOT(slotMouseButtonPressed(int,Qt::MouseButtons
)));
147 connect(controller
, SIGNAL(itemHovered(int)), this, SLOT(slotItemHovered(int)));
148 connect(controller
, SIGNAL(itemUnhovered(int)), this, SLOT(slotItemUnhovered(int)));
149 connect(controller
, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent
*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent
*)));
150 connect(controller
, SIGNAL(modelChanged(KItemModelBase
*,KItemModelBase
*)), this, SLOT(slotModelChanged(KItemModelBase
*,KItemModelBase
*)));
152 connect(m_model
, SIGNAL(directoryLoadingStarted()), this, SLOT(slotDirectoryLoadingStarted()));
153 connect(m_model
, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
154 connect(m_model
, SIGNAL(directoryLoadingProgress(int)), this, SIGNAL(directoryLoadingProgress(int)));
155 connect(m_model
, SIGNAL(directorySortingProgress(int)), this, SIGNAL(directorySortingProgress(int)));
156 connect(m_model
, SIGNAL(itemsChanged(KItemRangeList
,QSet
<QByteArray
>)),
157 this, SLOT(slotItemsChanged()));
158 connect(m_model
, SIGNAL(itemsRemoved(KItemRangeList
)), this, SIGNAL(itemCountChanged()));
159 connect(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), this, SIGNAL(itemCountChanged()));
160 connect(m_model
, SIGNAL(infoMessage(QString
)), this, SIGNAL(infoMessage(QString
)));
161 connect(m_model
, SIGNAL(errorMessage(QString
)), this, SIGNAL(errorMessage(QString
)));
162 connect(m_model
, SIGNAL(directoryRedirection(KUrl
,KUrl
)), this, SLOT(slotDirectoryRedirection(KUrl
,KUrl
)));
163 connect(m_model
, SIGNAL(urlIsFileError(KUrl
)), this, SIGNAL(urlIsFileError(KUrl
)));
165 m_view
->installEventFilter(this);
166 connect(m_view
, SIGNAL(sortOrderChanged(Qt::SortOrder
,Qt::SortOrder
)),
167 this, SLOT(slotSortOrderChangedByHeader(Qt::SortOrder
,Qt::SortOrder
)));
168 connect(m_view
, SIGNAL(sortRoleChanged(QByteArray
,QByteArray
)),
169 this, SLOT(slotSortRoleChangedByHeader(QByteArray
,QByteArray
)));
170 connect(m_view
, SIGNAL(visibleRolesChanged(QList
<QByteArray
>,QList
<QByteArray
>)),
171 this, SLOT(slotVisibleRolesChangedByHeader(QList
<QByteArray
>,QList
<QByteArray
>)));
172 connect(m_view
, SIGNAL(roleEditingFinished(int,QByteArray
,QVariant
)),
173 this, SLOT(slotRoleEditingFinished(int,QByteArray
,QVariant
)));
174 connect(m_view
->header(), SIGNAL(columnWidthChanged(QByteArray
,qreal
,qreal
)),
175 this, SLOT(slotHeaderColumnWidthChanged(QByteArray
,qreal
,qreal
)));
177 KItemListSelectionManager
* selectionManager
= controller
->selectionManager();
178 connect(selectionManager
, SIGNAL(selectionChanged(QSet
<int>,QSet
<int>)),
179 this, SLOT(slotSelectionChanged(QSet
<int>,QSet
<int>)));
181 m_toolTipManager
= new ToolTipManager(this);
183 m_versionControlObserver
= new VersionControlObserver(this);
184 m_versionControlObserver
->setModel(m_model
);
185 connect(m_versionControlObserver
, SIGNAL(infoMessage(QString
)), this, SIGNAL(infoMessage(QString
)));
186 connect(m_versionControlObserver
, SIGNAL(errorMessage(QString
)), this, SIGNAL(errorMessage(QString
)));
187 connect(m_versionControlObserver
, SIGNAL(operationCompletedMessage(QString
)), this, SIGNAL(operationCompletedMessage(QString
)));
189 applyViewProperties();
190 m_topLayout
->addWidget(m_container
);
195 DolphinView::~DolphinView()
199 KUrl
DolphinView::url() const
204 void DolphinView::setActive(bool active
)
206 if (active
== m_active
) {
212 QColor color
= KColorScheme(QPalette::Active
, KColorScheme::View
).background().color();
217 QWidget
* viewport
= m_container
->viewport();
220 palette
.setColor(viewport
->backgroundRole(), color
);
221 viewport
->setPalette(palette
);
227 m_container
->setFocus();
229 emit
writeStateChanged(m_isFolderWritable
);
233 bool DolphinView::isActive() const
238 void DolphinView::setMode(Mode mode
)
240 if (mode
!= m_mode
) {
241 ViewProperties
props(viewPropertiesUrl());
242 props
.setViewMode(mode
);
245 applyViewProperties();
249 DolphinView::Mode
DolphinView::mode() const
254 void DolphinView::setPreviewsShown(bool show
)
256 if (previewsShown() == show
) {
260 ViewProperties
props(viewPropertiesUrl());
261 props
.setPreviewsShown(show
);
263 const int oldZoomLevel
= m_view
->zoomLevel();
264 m_view
->setPreviewsShown(show
);
265 emit
previewsShownChanged(show
);
267 const int newZoomLevel
= m_view
->zoomLevel();
268 if (newZoomLevel
!= oldZoomLevel
) {
269 emit
zoomLevelChanged(newZoomLevel
, oldZoomLevel
);
273 bool DolphinView::previewsShown() const
275 return m_view
->previewsShown();
278 void DolphinView::setHiddenFilesShown(bool show
)
280 if (m_model
->showHiddenFiles() == show
) {
284 const KFileItemList itemList
= selectedItems();
285 m_selectedUrls
.clear();
286 m_selectedUrls
= itemList
.urlList();
288 ViewProperties
props(viewPropertiesUrl());
289 props
.setHiddenFilesShown(show
);
291 m_model
->setShowHiddenFiles(show
);
292 emit
hiddenFilesShownChanged(show
);
295 bool DolphinView::hiddenFilesShown() const
297 return m_model
->showHiddenFiles();
300 void DolphinView::setGroupedSorting(bool grouped
)
302 if (grouped
== groupedSorting()) {
306 ViewProperties
props(viewPropertiesUrl());
307 props
.setGroupedSorting(grouped
);
310 m_container
->controller()->model()->setGroupedSorting(grouped
);
312 emit
groupedSortingChanged(grouped
);
315 bool DolphinView::groupedSorting() const
317 return m_model
->groupedSorting();
320 KFileItemList
DolphinView::items() const
323 const int itemCount
= m_model
->count();
324 list
.reserve(itemCount
);
326 for (int i
= 0; i
< itemCount
; ++i
) {
327 list
.append(m_model
->fileItem(i
));
333 int DolphinView::itemsCount() const
335 return m_model
->count();
338 KFileItemList
DolphinView::selectedItems() const
340 const KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
341 const QSet
<int> selectedIndexes
= selectionManager
->selectedItems();
343 KFileItemList selectedItems
;
344 QSetIterator
<int> it(selectedIndexes
);
345 while (it
.hasNext()) {
346 const int index
= it
.next();
347 selectedItems
.append(m_model
->fileItem(index
));
349 return selectedItems
;
352 int DolphinView::selectedItemsCount() const
354 const KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
355 return selectionManager
->selectedItems().count();
358 void DolphinView::markUrlsAsSelected(const QList
<KUrl
>& urls
)
360 m_selectedUrls
= urls
;
363 void DolphinView::markUrlAsCurrent(const KUrl
& url
)
365 m_currentItemUrl
= url
;
366 m_scrollToCurrentItem
= true;
369 void DolphinView::selectItems(const QRegExp
& pattern
, bool enabled
)
371 const KItemListSelectionManager::SelectionMode mode
= enabled
372 ? KItemListSelectionManager::Select
373 : KItemListSelectionManager::Deselect
;
374 KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
376 for (int index
= 0; index
< m_model
->count(); index
++) {
377 const KFileItem item
= m_model
->fileItem(index
);
378 if (pattern
.exactMatch(item
.text())) {
379 // An alternative approach would be to store the matching items in a QSet<int> and
380 // select them in one go after the loop, but we'd need a new function
381 // KItemListSelectionManager::setSelected(QSet<int>, SelectionMode mode)
383 selectionManager
->setSelected(index
, 1, mode
);
388 void DolphinView::setZoomLevel(int level
)
390 const int oldZoomLevel
= zoomLevel();
391 m_view
->setZoomLevel(level
);
392 if (zoomLevel() != oldZoomLevel
) {
394 emit
zoomLevelChanged(zoomLevel(), oldZoomLevel
);
398 int DolphinView::zoomLevel() const
400 return m_view
->zoomLevel();
403 void DolphinView::setSortRole(const QByteArray
& role
)
405 if (role
!= sortRole()) {
406 updateSortRole(role
);
410 QByteArray
DolphinView::sortRole() const
412 const KItemModelBase
* model
= m_container
->controller()->model();
413 return model
->sortRole();
416 void DolphinView::setSortOrder(Qt::SortOrder order
)
418 if (sortOrder() != order
) {
419 updateSortOrder(order
);
423 Qt::SortOrder
DolphinView::sortOrder() const
425 return m_model
->sortOrder();
428 void DolphinView::setSortFoldersFirst(bool foldersFirst
)
430 if (sortFoldersFirst() != foldersFirst
) {
431 updateSortFoldersFirst(foldersFirst
);
435 bool DolphinView::sortFoldersFirst() const
437 return m_model
->sortDirectoriesFirst();
440 void DolphinView::setVisibleRoles(const QList
<QByteArray
>& roles
)
442 const QList
<QByteArray
> previousRoles
= roles
;
444 ViewProperties
props(viewPropertiesUrl());
445 props
.setVisibleRoles(roles
);
447 m_visibleRoles
= roles
;
448 m_view
->setVisibleRoles(roles
);
450 emit
visibleRolesChanged(m_visibleRoles
, previousRoles
);
453 QList
<QByteArray
> DolphinView::visibleRoles() const
455 return m_visibleRoles
;
458 void DolphinView::reload()
460 QByteArray viewState
;
461 QDataStream
saveStream(&viewState
, QIODevice::WriteOnly
);
462 saveState(saveStream
);
464 const KFileItemList itemList
= selectedItems();
465 m_selectedUrls
.clear();
466 m_selectedUrls
= itemList
.urlList();
469 loadDirectory(url(), true);
471 QDataStream
restoreStream(viewState
);
472 restoreState(restoreStream
);
475 void DolphinView::stopLoading()
477 m_model
->cancelDirectoryLoading();
480 void DolphinView::readSettings()
482 const int oldZoomLevel
= m_view
->zoomLevel();
484 GeneralSettings::self()->readConfig();
485 m_view
->readSettings();
486 applyViewProperties();
488 const int delay
= GeneralSettings::autoExpandFolders() ? 750 : -1;
489 m_container
->controller()->setAutoActivationDelay(delay
);
491 const int newZoomLevel
= m_view
->zoomLevel();
492 if (newZoomLevel
!= oldZoomLevel
) {
493 emit
zoomLevelChanged(newZoomLevel
, oldZoomLevel
);
497 void DolphinView::writeSettings()
499 GeneralSettings::self()->writeConfig();
500 m_view
->writeSettings();
503 void DolphinView::setNameFilter(const QString
& nameFilter
)
505 m_model
->setNameFilter(nameFilter
);
508 QString
DolphinView::nameFilter() const
510 return m_model
->nameFilter();
513 void DolphinView::setMimeTypeFilters(const QStringList
& filters
)
515 return m_model
->setMimeTypeFilters(filters
);
518 QStringList
DolphinView::mimeTypeFilters() const
520 return m_model
->mimeTypeFilters();
523 QString
DolphinView::statusBarText() const
531 KIO::filesize_t totalFileSize
= 0;
533 if (m_container
->controller()->selectionManager()->hasSelection()) {
534 // Give a summary of the status of the selected files
535 const KFileItemList list
= selectedItems();
536 foreach (const KFileItem
& item
, list
) {
541 totalFileSize
+= item
.size();
545 if (folderCount
+ fileCount
== 1) {
546 // If only one item is selected, show the filename
547 filesText
= i18nc("@info:status", "<filename>%1</filename> selected", list
.first().text());
549 // At least 2 items are selected
550 foldersText
= i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount
);
551 filesText
= i18ncp("@info:status", "1 File selected", "%1 Files selected", fileCount
);
554 calculateItemCount(fileCount
, folderCount
, totalFileSize
);
555 foldersText
= i18ncp("@info:status", "1 Folder", "%1 Folders", folderCount
);
556 filesText
= i18ncp("@info:status", "1 File", "%1 Files", fileCount
);
559 if (fileCount
> 0 && folderCount
> 0) {
560 summary
= i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
561 foldersText
, filesText
,
562 KGlobal::locale()->formatByteSize(totalFileSize
));
563 } else if (fileCount
> 0) {
564 summary
= i18nc("@info:status files (size)", "%1 (%2)",
566 KGlobal::locale()->formatByteSize(totalFileSize
));
567 } else if (folderCount
> 0) {
568 summary
= foldersText
;
570 summary
= i18nc("@info:status", "0 Folders, 0 Files");
576 QList
<QAction
*> DolphinView::versionControlActions(const KFileItemList
& items
) const
578 QList
<QAction
*> actions
;
580 if (items
.isEmpty()) {
581 const KFileItem item
= m_model
->rootItem();
582 if (!item
.isNull()) {
583 actions
= m_versionControlObserver
->actions(KFileItemList() << item
);
586 actions
= m_versionControlObserver
->actions(items
);
592 void DolphinView::setUrl(const KUrl
& url
)
598 emit
urlAboutToBeChanged(url
);
603 // It is important to clear the items from the model before
604 // applying the view properties, otherwise expensive operations
605 // might be done on the existing items although they get cleared
606 // anyhow afterwards by loadDirectory().
608 applyViewProperties();
611 emit
urlChanged(url
);
614 void DolphinView::selectAll()
616 KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
617 selectionManager
->setSelected(0, m_model
->count());
620 void DolphinView::invertSelection()
622 KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
623 selectionManager
->setSelected(0, m_model
->count(), KItemListSelectionManager::Toggle
);
626 void DolphinView::clearSelection()
628 m_container
->controller()->selectionManager()->clearSelection();
631 void DolphinView::renameSelectedItems()
633 const KFileItemList items
= selectedItems();
634 if (items
.isEmpty()) {
638 if (items
.count() == 1 && GeneralSettings::renameInline()) {
639 const int index
= m_model
->index(items
.first());
640 m_view
->editRole(index
, "text");
642 RenameDialog
* dialog
= new RenameDialog(this, items
);
643 dialog
->setAttribute(Qt::WA_DeleteOnClose
);
646 dialog
->activateWindow();
649 // Assure that the current index remains visible when KFileItemModel
650 // will notify the view about changed items (which might result in
651 // a changed sorting).
652 m_assureVisibleCurrentIndex
= true;
655 void DolphinView::trashSelectedItems()
657 const KUrl::List list
= simplifiedSelectedUrls();
658 KonqOperations::del(this, KonqOperations::TRASH
, list
);
661 void DolphinView::deleteSelectedItems()
663 const KUrl::List list
= simplifiedSelectedUrls();
664 const bool del
= KonqOperations::askDeleteConfirmation(list
,
666 KonqOperations::DEFAULT_CONFIRMATION
,
670 KIO::Job
* job
= KIO::del(list
);
672 job
->ui()->setWindow(this);
674 connect(job
, SIGNAL(result(KJob
*)),
675 this, SLOT(slotDeleteFileFinished(KJob
*)));
679 void DolphinView::cutSelectedItems()
681 QMimeData
* mimeData
= selectionMimeData();
682 KonqMimeData::addIsCutSelection(mimeData
, true);
683 QApplication::clipboard()->setMimeData(mimeData
);
686 void DolphinView::copySelectedItems()
688 QMimeData
* mimeData
= selectionMimeData();
689 QApplication::clipboard()->setMimeData(mimeData
);
692 void DolphinView::paste()
697 void DolphinView::pasteIntoFolder()
699 const KFileItemList items
= selectedItems();
700 if ((items
.count() == 1) && items
.first().isDir()) {
701 pasteToUrl(items
.first().url());
705 bool DolphinView::eventFilter(QObject
* watched
, QEvent
* event
)
707 switch (event
->type()) {
708 case QEvent::FocusIn
:
709 if (watched
== m_container
) {
714 case QEvent::GraphicsSceneDragEnter
:
715 if (watched
== m_view
) {
720 case QEvent::GraphicsSceneDragLeave
:
721 if (watched
== m_view
) {
726 case QEvent::GraphicsSceneDrop
:
727 if (watched
== m_view
) {
734 return QWidget::eventFilter(watched
, event
);
737 void DolphinView::wheelEvent(QWheelEvent
* event
)
739 if (event
->modifiers().testFlag(Qt::ControlModifier
)) {
740 const int numDegrees
= event
->delta() / 8;
741 const int numSteps
= numDegrees
/ 15;
743 setZoomLevel(zoomLevel() + numSteps
);
750 void DolphinView::hideEvent(QHideEvent
* event
)
753 QWidget::hideEvent(event
);
756 bool DolphinView::event(QEvent
* event
)
759 * Dolphin leaves file preview tooltips open even when is not visible.
761 * Hide tool-tip when Dolphin loses focus.
763 if (event
->type() == QEvent::WindowDeactivate
) {
767 return QWidget::event(event
);
770 void DolphinView::activate()
775 void DolphinView::slotItemActivated(int index
)
777 const KFileItem item
= m_model
->fileItem(index
);
778 if (!item
.isNull()) {
779 emit
itemActivated(item
);
783 void DolphinView::slotItemsActivated(const QSet
<int>& indexes
)
785 Q_ASSERT(indexes
.count() >= 2);
789 QSetIterator
<int> it(indexes
);
790 while (it
.hasNext()) {
791 const int index
= it
.next();
792 items
.append(m_model
->fileItem(index
));
795 if (items
.count() > 5) {
796 QString question
= QString("Are you sure you want to open %1 items?").arg(items
.count());
797 const int answer
= KMessageBox::warningYesNo(this, question
);
798 if (answer
!= KMessageBox::Yes
) {
803 foreach (const KFileItem
& item
, items
) {
805 emit
tabRequested(item
.url());
807 emit
itemActivated(item
);
812 void DolphinView::slotItemMiddleClicked(int index
)
814 const KFileItem item
= m_model
->fileItem(index
);
815 if (item
.isDir() || isTabsForFilesEnabled()) {
816 emit
tabRequested(item
.url());
820 void DolphinView::slotItemContextMenuRequested(int index
, const QPointF
& pos
)
822 const KFileItem item
= m_model
->fileItem(index
);
823 emit
requestContextMenu(pos
.toPoint(), item
, url(), QList
<QAction
*>());
826 void DolphinView::slotViewContextMenuRequested(const QPointF
& pos
)
828 emit
requestContextMenu(pos
.toPoint(), KFileItem(), url(), QList
<QAction
*>());
831 void DolphinView::slotHeaderContextMenuRequested(const QPointF
& pos
)
833 ViewProperties
props(viewPropertiesUrl());
835 QPointer
<KMenu
> menu
= new KMenu(QApplication::activeWindow());
837 KItemListView
* view
= m_container
->controller()->view();
838 const QSet
<QByteArray
> visibleRolesSet
= view
->visibleRoles().toSet();
840 bool nepomukRunning
= false;
841 bool indexingEnabled
= false;
843 nepomukRunning
= (Nepomuk::ResourceManager::instance()->initialized());
844 if (nepomukRunning
) {
845 KConfig
config("nepomukserverrc");
846 indexingEnabled
= config
.group("Service-nepomukfileindexer").readEntry("autostart", false);
851 QMenu
* groupMenu
= 0;
853 // Add all roles to the menu that can be shown or hidden by the user
854 const QList
<KFileItemModel::RoleInfo
> rolesInfo
= KFileItemModel::rolesInformation();
855 foreach (const KFileItemModel::RoleInfo
& info
, rolesInfo
) {
856 if (info
.role
== "text") {
857 // It should not be possible to hide the "text" role
861 const QString text
= m_model
->roleDescription(info
.role
);
863 if (info
.group
.isEmpty()) {
864 action
= menu
->addAction(text
);
866 if (!groupMenu
|| info
.group
!= groupName
) {
867 groupName
= info
.group
;
868 groupMenu
= menu
->addMenu(groupName
);
871 action
= groupMenu
->addAction(text
);
874 action
->setCheckable(true);
875 action
->setChecked(visibleRolesSet
.contains(info
.role
));
876 action
->setData(info
.role
);
878 const bool enable
= (!info
.requiresNepomuk
&& !info
.requiresIndexer
) ||
879 (info
.requiresNepomuk
&& nepomukRunning
) ||
880 (info
.requiresIndexer
&& indexingEnabled
);
881 action
->setEnabled(enable
);
884 menu
->addSeparator();
886 QActionGroup
* widthsGroup
= new QActionGroup(menu
);
887 const bool autoColumnWidths
= props
.headerColumnWidths().isEmpty();
889 QAction
* autoAdjustWidthsAction
= menu
->addAction(i18nc("@action:inmenu", "Automatic Column Widths"));
890 autoAdjustWidthsAction
->setCheckable(true);
891 autoAdjustWidthsAction
->setChecked(autoColumnWidths
);
892 autoAdjustWidthsAction
->setActionGroup(widthsGroup
);
894 QAction
* customWidthsAction
= menu
->addAction(i18nc("@action:inmenu", "Custom Column Widths"));
895 customWidthsAction
->setCheckable(true);
896 customWidthsAction
->setChecked(!autoColumnWidths
);
897 customWidthsAction
->setActionGroup(widthsGroup
);
899 QAction
* action
= menu
->exec(pos
.toPoint());
900 if (menu
&& action
) {
901 KItemListHeader
* header
= view
->header();
903 if (action
== autoAdjustWidthsAction
) {
904 // Clear the column-widths from the viewproperties and turn on
905 // the automatic resizing of the columns
906 props
.setHeaderColumnWidths(QList
<int>());
907 header
->setAutomaticColumnResizing(true);
908 } else if (action
== customWidthsAction
) {
909 // Apply the current column-widths as custom column-widths and turn
910 // off the automatic resizing of the columns
911 QList
<int> columnWidths
;
912 foreach (const QByteArray
& role
, view
->visibleRoles()) {
913 columnWidths
.append(header
->columnWidth(role
));
915 props
.setHeaderColumnWidths(columnWidths
);
916 header
->setAutomaticColumnResizing(false);
918 // Show or hide the selected role
919 const QByteArray selectedRole
= action
->data().toByteArray();
921 QList
<QByteArray
> visibleRoles
= view
->visibleRoles();
922 if (action
->isChecked()) {
923 visibleRoles
.append(selectedRole
);
925 visibleRoles
.removeOne(selectedRole
);
928 view
->setVisibleRoles(visibleRoles
);
929 props
.setVisibleRoles(visibleRoles
);
931 QList
<int> columnWidths
;
932 if (!header
->automaticColumnResizing()) {
933 foreach (const QByteArray
& role
, view
->visibleRoles()) {
934 columnWidths
.append(header
->columnWidth(role
));
937 props
.setHeaderColumnWidths(columnWidths
);
944 void DolphinView::slotHeaderColumnWidthChanged(const QByteArray
& role
, qreal current
, qreal previous
)
948 const QList
<QByteArray
> visibleRoles
= m_view
->visibleRoles();
950 ViewProperties
props(viewPropertiesUrl());
951 QList
<int> columnWidths
= props
.headerColumnWidths();
952 if (columnWidths
.count() != visibleRoles
.count()) {
953 columnWidths
.clear();
954 columnWidths
.reserve(visibleRoles
.count());
955 const KItemListHeader
* header
= m_view
->header();
956 foreach (const QByteArray
& role
, visibleRoles
) {
957 const int width
= header
->columnWidth(role
);
958 columnWidths
.append(width
);
962 const int roleIndex
= visibleRoles
.indexOf(role
);
963 Q_ASSERT(roleIndex
>= 0 && roleIndex
< columnWidths
.count());
964 columnWidths
[roleIndex
] = current
;
966 props
.setHeaderColumnWidths(columnWidths
);
969 void DolphinView::slotItemHovered(int index
)
971 const KFileItem item
= m_model
->fileItem(index
);
973 if (GeneralSettings::showToolTips() && !m_dragging
) {
974 QRectF itemRect
= m_container
->controller()->view()->itemContextRect(index
);
975 const QPoint pos
= m_container
->mapToGlobal(itemRect
.topLeft().toPoint());
976 itemRect
.moveTo(pos
);
978 m_toolTipManager
->showToolTip(item
, itemRect
);
981 emit
requestItemInfo(item
);
984 void DolphinView::slotItemUnhovered(int index
)
988 emit
requestItemInfo(KFileItem());
991 void DolphinView::slotItemDropEvent(int index
, QGraphicsSceneDragDropEvent
* event
)
994 KFileItem destItem
= m_model
->fileItem(index
);
995 if (destItem
.isNull() || (!destItem
.isDir() && !destItem
.isDesktopFile())) {
996 // Use the URL of the view as drop target if the item is no directory
998 destItem
= m_model
->rootItem();
1001 // The item represents a directory or desktop-file
1002 destUrl
= destItem
.url();
1005 QDropEvent
dropEvent(event
->pos().toPoint(),
1006 event
->possibleActions(),
1009 event
->modifiers());
1011 const QString error
= DragAndDropHelper::dropUrls(destItem
, destUrl
, &dropEvent
);
1012 if (!error
.isEmpty()) {
1013 emit
errorMessage(error
);
1016 if (destUrl
== url()) {
1017 // Mark the dropped urls as selected.
1018 markPastedUrlsAsSelected(event
->mimeData());
1022 void DolphinView::slotModelChanged(KItemModelBase
* current
, KItemModelBase
* previous
)
1024 if (previous
!= 0) {
1025 disconnect(previous
, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
1026 m_versionControlObserver
->setModel(0);
1030 Q_ASSERT(qobject_cast
<KFileItemModel
*>(current
));
1031 connect(current
, SIGNAL(loadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
1033 KFileItemModel
* fileItemModel
= static_cast<KFileItemModel
*>(current
);
1034 m_versionControlObserver
->setModel(fileItemModel
);
1038 void DolphinView::slotMouseButtonPressed(int itemIndex
, Qt::MouseButtons buttons
)
1042 if (itemIndex
< 0) {
1043 // Trigger the history navigation only when clicking on the viewport:
1044 // Above an item the XButtons provide a simple way to select items in
1045 // the singleClick mode.
1046 if (buttons
& Qt::XButton1
) {
1047 emit
goBackRequested();
1048 } else if (buttons
& Qt::XButton2
) {
1049 emit
goForwardRequested();
1054 void DolphinView::slotSelectionChanged(const QSet
<int>& current
, const QSet
<int>& previous
)
1056 const int currentCount
= current
.count();
1057 const int previousCount
= previous
.count();
1058 const bool selectionStateChanged
= (currentCount
== 0 && previousCount
> 0) ||
1059 (currentCount
> 0 && previousCount
== 0);
1061 // If nothing has been selected before and something got selected (or if something
1062 // was selected before and now nothing is selected) the selectionChangedSignal must
1063 // be emitted asynchronously as fast as possible to update the edit-actions.
1064 m_selectionChangedTimer
->setInterval(selectionStateChanged
? 0 : 300);
1065 m_selectionChangedTimer
->start();
1068 void DolphinView::emitSelectionChangedSignal()
1070 m_selectionChangedTimer
->stop();
1071 emit
selectionChanged(selectedItems());
1074 void DolphinView::updateSortRole(const QByteArray
& role
)
1076 ViewProperties
props(viewPropertiesUrl());
1077 props
.setSortRole(role
);
1079 KItemModelBase
* model
= m_container
->controller()->model();
1080 model
->setSortRole(role
);
1082 emit
sortRoleChanged(role
);
1085 void DolphinView::updateSortOrder(Qt::SortOrder order
)
1087 ViewProperties
props(viewPropertiesUrl());
1088 props
.setSortOrder(order
);
1090 m_model
->setSortOrder(order
);
1092 emit
sortOrderChanged(order
);
1095 void DolphinView::updateSortFoldersFirst(bool foldersFirst
)
1097 ViewProperties
props(viewPropertiesUrl());
1098 props
.setSortFoldersFirst(foldersFirst
);
1100 m_model
->setSortDirectoriesFirst(foldersFirst
);
1102 emit
sortFoldersFirstChanged(foldersFirst
);
1105 QPair
<bool, QString
> DolphinView::pasteInfo() const
1107 return KonqOperations::pasteInfo(url());
1110 void DolphinView::setTabsForFilesEnabled(bool tabsForFiles
)
1112 m_tabsForFiles
= tabsForFiles
;
1115 bool DolphinView::isTabsForFilesEnabled() const
1117 return m_tabsForFiles
;
1120 bool DolphinView::itemsExpandable() const
1122 return m_mode
== DetailsView
;
1125 void DolphinView::restoreState(QDataStream
& stream
)
1127 // Restore the current item that had the keyboard focus
1128 stream
>> m_currentItemUrl
;
1130 // Restore the view position
1131 stream
>> m_restoredContentsPosition
;
1133 // Restore expanded folders (only relevant for the details view - will be ignored by the view in other view modes)
1136 m_model
->restoreExpandedDirectories(urls
);
1139 void DolphinView::saveState(QDataStream
& stream
)
1141 // Save the current item that has the keyboard focus
1142 const int currentIndex
= m_container
->controller()->selectionManager()->currentItem();
1143 if (currentIndex
!= -1) {
1144 KFileItem item
= m_model
->fileItem(currentIndex
);
1145 Q_ASSERT(!item
.isNull()); // If the current index is valid a item must exist
1146 KUrl currentItemUrl
= item
.url();
1147 stream
<< currentItemUrl
;
1152 // Save view position
1153 const qreal x
= m_container
->horizontalScrollBar()->value();
1154 const qreal y
= m_container
->verticalScrollBar()->value();
1155 stream
<< QPoint(x
, y
);
1157 // Save expanded folders (only relevant for the details view - the set will be empty in other view modes)
1158 stream
<< m_model
->expandedDirectories();
1161 KFileItem
DolphinView::rootItem() const
1163 return m_model
->rootItem();
1166 void DolphinView::setViewPropertiesContext(const QString
& context
)
1168 m_viewPropertiesContext
= context
;
1171 QString
DolphinView::viewPropertiesContext() const
1173 return m_viewPropertiesContext
;
1176 void DolphinView::observeCreatedItem(const KUrl
& url
)
1178 markUrlAsCurrent(url
);
1179 markUrlsAsSelected(QList
<KUrl
>() << url
);
1182 void DolphinView::slotDirectoryRedirection(const KUrl
& oldUrl
, const KUrl
& newUrl
)
1184 if (oldUrl
.equals(url(), KUrl::CompareWithoutTrailingSlash
)) {
1185 emit
redirection(oldUrl
, newUrl
);
1186 m_url
= newUrl
; // #186947
1190 void DolphinView::updateViewState()
1192 if (m_currentItemUrl
!= KUrl()) {
1193 KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
1194 const int currentIndex
= m_model
->index(m_currentItemUrl
);
1195 if (currentIndex
!= -1) {
1196 selectionManager
->setCurrentItem(currentIndex
);
1198 // scroll to current item and reset the state
1199 if (m_scrollToCurrentItem
) {
1200 m_view
->scrollToItem(currentIndex
);
1201 m_scrollToCurrentItem
= false;
1204 selectionManager
->setCurrentItem(0);
1206 m_currentItemUrl
= KUrl();
1209 if (!m_restoredContentsPosition
.isNull()) {
1210 const int x
= m_restoredContentsPosition
.x();
1211 const int y
= m_restoredContentsPosition
.y();
1212 m_restoredContentsPosition
= QPoint();
1214 m_container
->horizontalScrollBar()->setValue(x
);
1215 m_container
->verticalScrollBar()->setValue(y
);
1218 if (!m_selectedUrls
.isEmpty()) {
1221 KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
1222 QSet
<int> selectedItems
= selectionManager
->selectedItems();
1224 foreach (const KUrl
& url
, m_selectedUrls
) {
1225 const int index
= m_model
->index(url
);
1227 selectedItems
.insert(index
);
1231 selectionManager
->setSelectedItems(selectedItems
);
1232 m_selectedUrls
.clear();
1236 void DolphinView::hideToolTip()
1238 if (GeneralSettings::showToolTips()) {
1239 m_toolTipManager
->hideToolTip();
1243 void DolphinView::calculateItemCount(int& fileCount
,
1245 KIO::filesize_t
& totalFileSize
) const
1247 const int itemCount
= m_model
->count();
1248 for (int i
= 0; i
< itemCount
; ++i
) {
1249 const KFileItem item
= m_model
->fileItem(i
);
1254 totalFileSize
+= item
.size();
1259 void DolphinView::showHoverInformation(const KFileItem
& item
)
1261 emit
requestItemInfo(item
);
1264 void DolphinView::clearHoverInformation()
1266 emit
requestItemInfo(KFileItem());
1269 void DolphinView::slotDeleteFileFinished(KJob
* job
)
1271 if (job
->error() == 0) {
1272 emit
operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
1273 } else if (job
->error() != KIO::ERR_USER_CANCELED
) {
1274 emit
errorMessage(job
->errorString());
1278 void DolphinView::slotDirectoryLoadingStarted()
1280 // Disable the writestate temporary until it can be determined in a fast way
1281 // in DolphinView::slotLoadingCompleted()
1282 if (m_isFolderWritable
) {
1283 m_isFolderWritable
= false;
1284 emit
writeStateChanged(m_isFolderWritable
);
1287 emit
directoryLoadingStarted();
1290 void DolphinView::slotDirectoryLoadingCompleted()
1292 // Update the view-state. This has to be done asynchronously
1293 // because the view might not be in its final state yet.
1294 QTimer::singleShot(0, this, SLOT(updateViewState()));
1296 emit
directoryLoadingCompleted();
1298 updateWritableState();
1301 void DolphinView::slotItemsChanged()
1303 m_assureVisibleCurrentIndex
= false;
1306 void DolphinView::slotSortOrderChangedByHeader(Qt::SortOrder current
, Qt::SortOrder previous
)
1309 Q_ASSERT(m_model
->sortOrder() == current
);
1311 ViewProperties
props(viewPropertiesUrl());
1312 props
.setSortOrder(current
);
1314 emit
sortOrderChanged(current
);
1317 void DolphinView::slotSortRoleChangedByHeader(const QByteArray
& current
, const QByteArray
& previous
)
1320 Q_ASSERT(m_model
->sortRole() == current
);
1322 ViewProperties
props(viewPropertiesUrl());
1323 props
.setSortRole(current
);
1325 emit
sortRoleChanged(current
);
1328 void DolphinView::slotVisibleRolesChangedByHeader(const QList
<QByteArray
>& current
,
1329 const QList
<QByteArray
>& previous
)
1332 Q_ASSERT(m_container
->controller()->view()->visibleRoles() == current
);
1334 const QList
<QByteArray
> previousVisibleRoles
= m_visibleRoles
;
1336 m_visibleRoles
= current
;
1338 ViewProperties
props(viewPropertiesUrl());
1339 props
.setVisibleRoles(m_visibleRoles
);
1341 emit
visibleRolesChanged(m_visibleRoles
, previousVisibleRoles
);
1344 void DolphinView::slotRoleEditingFinished(int index
, const QByteArray
& role
, const QVariant
& value
)
1346 if (index
< 0 || index
>= m_model
->count()) {
1350 if (role
== "text") {
1351 const KFileItem oldItem
= m_model
->fileItem(index
);
1352 const QString newName
= value
.toString();
1353 if (!newName
.isEmpty() && newName
!= oldItem
.text() && newName
!= QLatin1String(".") && newName
!= QLatin1String("..")) {
1354 const KUrl oldUrl
= oldItem
.url();
1356 QHash
<QByteArray
, QVariant
> data
;
1357 data
.insert(role
, value
);
1358 m_model
->setData(index
, data
);
1360 KonqOperations::rename(this, oldUrl
, newName
);
1365 void DolphinView::loadDirectory(const KUrl
& url
, bool reload
)
1367 if (!url
.isValid()) {
1368 const QString
location(url
.pathOrUrl());
1369 if (location
.isEmpty()) {
1370 emit
errorMessage(i18nc("@info:status", "The location is empty."));
1372 emit
errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location
));
1378 m_model
->refreshDirectory(url
);
1380 m_model
->loadDirectory(url
);
1384 void DolphinView::applyViewProperties()
1386 m_view
->beginTransaction();
1388 const ViewProperties
props(viewPropertiesUrl());
1390 const Mode mode
= props
.viewMode();
1391 if (m_mode
!= mode
) {
1392 const Mode previousMode
= m_mode
;
1395 // Changing the mode might result in changing
1396 // the zoom level. Remember the old zoom level so
1397 // that zoomLevelChanged() can get emitted.
1398 const int oldZoomLevel
= m_view
->zoomLevel();
1401 emit
modeChanged(m_mode
, previousMode
);
1403 if (m_view
->zoomLevel() != oldZoomLevel
) {
1404 emit
zoomLevelChanged(m_view
->zoomLevel(), oldZoomLevel
);
1408 const bool hiddenFilesShown
= props
.hiddenFilesShown();
1409 if (hiddenFilesShown
!= m_model
->showHiddenFiles()) {
1410 m_model
->setShowHiddenFiles(hiddenFilesShown
);
1411 emit
hiddenFilesShownChanged(hiddenFilesShown
);
1414 const bool groupedSorting
= props
.groupedSorting();
1415 if (groupedSorting
!= m_model
->groupedSorting()) {
1416 m_model
->setGroupedSorting(groupedSorting
);
1417 emit
groupedSortingChanged(groupedSorting
);
1420 const QByteArray sortRole
= props
.sortRole();
1421 if (sortRole
!= m_model
->sortRole()) {
1422 m_model
->setSortRole(sortRole
);
1423 emit
sortRoleChanged(sortRole
);
1426 const Qt::SortOrder sortOrder
= props
.sortOrder();
1427 if (sortOrder
!= m_model
->sortOrder()) {
1428 m_model
->setSortOrder(sortOrder
);
1429 emit
sortOrderChanged(sortOrder
);
1432 const bool sortFoldersFirst
= props
.sortFoldersFirst();
1433 if (sortFoldersFirst
!= m_model
->sortDirectoriesFirst()) {
1434 m_model
->setSortDirectoriesFirst(sortFoldersFirst
);
1435 emit
sortFoldersFirstChanged(sortFoldersFirst
);
1438 const QList
<QByteArray
> visibleRoles
= props
.visibleRoles();
1439 if (visibleRoles
!= m_visibleRoles
) {
1440 const QList
<QByteArray
> previousVisibleRoles
= m_visibleRoles
;
1441 m_visibleRoles
= visibleRoles
;
1442 m_view
->setVisibleRoles(visibleRoles
);
1443 emit
visibleRolesChanged(m_visibleRoles
, previousVisibleRoles
);
1446 const bool previewsShown
= props
.previewsShown();
1447 if (previewsShown
!= m_view
->previewsShown()) {
1448 const int oldZoomLevel
= zoomLevel();
1450 m_view
->setPreviewsShown(previewsShown
);
1451 emit
previewsShownChanged(previewsShown
);
1453 // Changing the preview-state might result in a changed zoom-level
1454 if (oldZoomLevel
!= zoomLevel()) {
1455 emit
zoomLevelChanged(zoomLevel(), oldZoomLevel
);
1459 KItemListView
* itemListView
= m_container
->controller()->view();
1460 if (itemListView
->isHeaderVisible()) {
1461 KItemListHeader
* header
= itemListView
->header();
1462 const QList
<int> headerColumnWidths
= props
.headerColumnWidths();
1463 const int rolesCount
= m_visibleRoles
.count();
1464 if (headerColumnWidths
.count() == rolesCount
) {
1465 header
->setAutomaticColumnResizing(false);
1467 QHash
<QByteArray
, qreal
> columnWidths
;
1468 for (int i
= 0; i
< rolesCount
; ++i
) {
1469 columnWidths
.insert(m_visibleRoles
[i
], headerColumnWidths
[i
]);
1471 header
->setColumnWidths(columnWidths
);
1473 header
->setAutomaticColumnResizing(true);
1477 m_view
->endTransaction();
1480 void DolphinView::applyModeToView()
1483 case IconsView
: m_view
->setItemLayout(KFileItemListView::IconsLayout
); break;
1484 case CompactView
: m_view
->setItemLayout(KFileItemListView::CompactLayout
); break;
1485 case DetailsView
: m_view
->setItemLayout(KFileItemListView::DetailsLayout
); break;
1486 default: Q_ASSERT(false); break;
1490 void DolphinView::pasteToUrl(const KUrl
& url
)
1492 markPastedUrlsAsSelected(QApplication::clipboard()->mimeData());
1493 KonqOperations::doPaste(this, url
);
1496 KUrl::List
DolphinView::simplifiedSelectedUrls() const
1500 const KFileItemList items
= selectedItems();
1501 foreach (const KFileItem
& item
, items
) {
1502 urls
.append(item
.url());
1505 if (itemsExpandable()) {
1506 // TODO: Check if we still need KDirModel for this in KDE 5.0
1507 urls
= KDirModel::simplifiedUrlList(urls
);
1513 QMimeData
* DolphinView::selectionMimeData() const
1515 const KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
1516 const QSet
<int> selectedIndexes
= selectionManager
->selectedItems();
1518 return m_model
->createMimeData(selectedIndexes
);
1521 void DolphinView::markPastedUrlsAsSelected(const QMimeData
* mimeData
)
1523 const KUrl::List sourceUrls
= KUrl::List::fromMimeData(mimeData
);
1524 KUrl::List destUrls
;
1525 foreach (const KUrl
& source
, sourceUrls
) {
1526 KUrl
destination(url().url() + '/' + source
.fileName());
1527 destUrls
<< destination
;
1529 markUrlsAsSelected(destUrls
);
1532 void DolphinView::updateWritableState()
1534 const bool wasFolderWritable
= m_isFolderWritable
;
1535 m_isFolderWritable
= true;
1537 const KFileItem item
= m_model
->rootItem();
1538 if (!item
.isNull()) {
1539 KFileItemListProperties
capabilities(KFileItemList() << item
);
1540 m_isFolderWritable
= capabilities
.supportsWriting();
1542 if (m_isFolderWritable
!= wasFolderWritable
) {
1543 emit
writeStateChanged(m_isFolderWritable
);
1547 KUrl
DolphinView::viewPropertiesUrl() const
1549 if (m_viewPropertiesContext
.isEmpty()) {
1554 url
.setProtocol(m_url
.protocol());
1555 url
.setPath(m_viewPropertiesContext
);
1559 #include "dolphinview.moc"