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
->setVisibleRoles(QList
<QByteArray
>() << "text");
128 KItemListController
* controller
= new KItemListController(m_model
, m_view
, this);
129 const int delay
= GeneralSettings::autoExpandFolders() ? 750 : -1;
130 controller
->setAutoActivationDelay(delay
);
132 // The EnlargeSmallPreviews setting can only be changed after the model
133 // has been set in the view by KItemListController.
134 m_view
->setEnlargeSmallPreviews(GeneralSettings::enlargeSmallPreviews());
136 m_container
= new KItemListContainer(controller
, this);
137 m_container
->installEventFilter(this);
138 setFocusProxy(m_container
);
139 connect(m_container
->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(hideToolTip()));
140 connect(m_container
->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(hideToolTip()));
142 controller
->setSelectionBehavior(KItemListController::MultiSelection
);
143 connect(controller
, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int)));
144 connect(controller
, SIGNAL(itemsActivated(QSet
<int>)), this, SLOT(slotItemsActivated(QSet
<int>)));
145 connect(controller
, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int)));
146 connect(controller
, SIGNAL(itemContextMenuRequested(int,QPointF
)), this, SLOT(slotItemContextMenuRequested(int,QPointF
)));
147 connect(controller
, SIGNAL(viewContextMenuRequested(QPointF
)), this, SLOT(slotViewContextMenuRequested(QPointF
)));
148 connect(controller
, SIGNAL(headerContextMenuRequested(QPointF
)), this, SLOT(slotHeaderContextMenuRequested(QPointF
)));
149 connect(controller
, SIGNAL(mouseButtonPressed(int,Qt::MouseButtons
)), this, SLOT(slotMouseButtonPressed(int,Qt::MouseButtons
)));
150 connect(controller
, SIGNAL(itemHovered(int)), this, SLOT(slotItemHovered(int)));
151 connect(controller
, SIGNAL(itemUnhovered(int)), this, SLOT(slotItemUnhovered(int)));
152 connect(controller
, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent
*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent
*)));
153 connect(controller
, SIGNAL(modelChanged(KItemModelBase
*,KItemModelBase
*)), this, SLOT(slotModelChanged(KItemModelBase
*,KItemModelBase
*)));
155 connect(m_model
, SIGNAL(directoryLoadingStarted()), this, SLOT(slotDirectoryLoadingStarted()));
156 connect(m_model
, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
157 connect(m_model
, SIGNAL(directoryLoadingProgress(int)), this, SIGNAL(directoryLoadingProgress(int)));
158 connect(m_model
, SIGNAL(directorySortingProgress(int)), this, SIGNAL(directorySortingProgress(int)));
159 connect(m_model
, SIGNAL(itemsChanged(KItemRangeList
,QSet
<QByteArray
>)),
160 this, SLOT(slotItemsChanged()));
161 connect(m_model
, SIGNAL(itemsRemoved(KItemRangeList
)), this, SIGNAL(itemCountChanged()));
162 connect(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), this, SIGNAL(itemCountChanged()));
163 connect(m_model
, SIGNAL(infoMessage(QString
)), this, SIGNAL(infoMessage(QString
)));
164 connect(m_model
, SIGNAL(errorMessage(QString
)), this, SIGNAL(errorMessage(QString
)));
165 connect(m_model
, SIGNAL(directoryRedirection(KUrl
,KUrl
)), this, SLOT(slotDirectoryRedirection(KUrl
,KUrl
)));
166 connect(m_model
, SIGNAL(urlIsFileError(KUrl
)), this, SIGNAL(urlIsFileError(KUrl
)));
168 m_view
->installEventFilter(this);
169 connect(m_view
, SIGNAL(sortOrderChanged(Qt::SortOrder
,Qt::SortOrder
)),
170 this, SLOT(slotSortOrderChangedByHeader(Qt::SortOrder
,Qt::SortOrder
)));
171 connect(m_view
, SIGNAL(sortRoleChanged(QByteArray
,QByteArray
)),
172 this, SLOT(slotSortRoleChangedByHeader(QByteArray
,QByteArray
)));
173 connect(m_view
, SIGNAL(visibleRolesChanged(QList
<QByteArray
>,QList
<QByteArray
>)),
174 this, SLOT(slotVisibleRolesChangedByHeader(QList
<QByteArray
>,QList
<QByteArray
>)));
175 connect(m_view
, SIGNAL(roleEditingFinished(int,QByteArray
,QVariant
)),
176 this, SLOT(slotRoleEditingFinished(int,QByteArray
,QVariant
)));
177 connect(m_view
->header(), SIGNAL(columnWidthChanged(QByteArray
,qreal
,qreal
)),
178 this, SLOT(slotHeaderColumnWidthChanged(QByteArray
,qreal
,qreal
)));
180 KItemListSelectionManager
* selectionManager
= controller
->selectionManager();
181 connect(selectionManager
, SIGNAL(selectionChanged(QSet
<int>,QSet
<int>)),
182 this, SLOT(slotSelectionChanged(QSet
<int>,QSet
<int>)));
184 m_toolTipManager
= new ToolTipManager(this);
186 m_versionControlObserver
= new VersionControlObserver(this);
187 m_versionControlObserver
->setModel(m_model
);
188 connect(m_versionControlObserver
, SIGNAL(infoMessage(QString
)), this, SIGNAL(infoMessage(QString
)));
189 connect(m_versionControlObserver
, SIGNAL(errorMessage(QString
)), this, SIGNAL(errorMessage(QString
)));
190 connect(m_versionControlObserver
, SIGNAL(operationCompletedMessage(QString
)), this, SIGNAL(operationCompletedMessage(QString
)));
192 applyViewProperties();
193 m_topLayout
->addWidget(m_container
);
198 DolphinView::~DolphinView()
202 KUrl
DolphinView::url() const
207 void DolphinView::setActive(bool active
)
209 if (active
== m_active
) {
215 QColor color
= KColorScheme(QPalette::Active
, KColorScheme::View
).background().color();
220 QWidget
* viewport
= m_container
->viewport();
223 palette
.setColor(viewport
->backgroundRole(), color
);
224 viewport
->setPalette(palette
);
230 m_container
->setFocus();
232 emit
writeStateChanged(m_isFolderWritable
);
236 bool DolphinView::isActive() const
241 void DolphinView::setMode(Mode mode
)
243 if (mode
!= m_mode
) {
244 ViewProperties
props(viewPropertiesUrl());
245 props
.setViewMode(mode
);
248 applyViewProperties();
252 DolphinView::Mode
DolphinView::mode() const
257 void DolphinView::setPreviewsShown(bool show
)
259 if (previewsShown() == show
) {
263 ViewProperties
props(viewPropertiesUrl());
264 props
.setPreviewsShown(show
);
266 const int oldZoomLevel
= m_view
->zoomLevel();
267 m_view
->setPreviewsShown(show
);
268 emit
previewsShownChanged(show
);
270 const int newZoomLevel
= m_view
->zoomLevel();
271 if (newZoomLevel
!= oldZoomLevel
) {
272 emit
zoomLevelChanged(newZoomLevel
, oldZoomLevel
);
276 bool DolphinView::previewsShown() const
278 return m_view
->previewsShown();
281 void DolphinView::setHiddenFilesShown(bool show
)
283 if (m_model
->showHiddenFiles() == show
) {
287 const KFileItemList itemList
= selectedItems();
288 m_selectedUrls
.clear();
289 m_selectedUrls
= itemList
.urlList();
291 ViewProperties
props(viewPropertiesUrl());
292 props
.setHiddenFilesShown(show
);
294 m_model
->setShowHiddenFiles(show
);
295 emit
hiddenFilesShownChanged(show
);
298 bool DolphinView::hiddenFilesShown() const
300 return m_model
->showHiddenFiles();
303 void DolphinView::setGroupedSorting(bool grouped
)
305 if (grouped
== groupedSorting()) {
309 ViewProperties
props(viewPropertiesUrl());
310 props
.setGroupedSorting(grouped
);
313 m_container
->controller()->model()->setGroupedSorting(grouped
);
315 emit
groupedSortingChanged(grouped
);
318 bool DolphinView::groupedSorting() const
320 return m_model
->groupedSorting();
323 KFileItemList
DolphinView::items() const
326 const int itemCount
= m_model
->count();
327 list
.reserve(itemCount
);
329 for (int i
= 0; i
< itemCount
; ++i
) {
330 list
.append(m_model
->fileItem(i
));
336 int DolphinView::itemsCount() const
338 return m_model
->count();
341 KFileItemList
DolphinView::selectedItems() const
343 const KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
344 const QSet
<int> selectedIndexes
= selectionManager
->selectedItems();
346 KFileItemList selectedItems
;
347 QSetIterator
<int> it(selectedIndexes
);
348 while (it
.hasNext()) {
349 const int index
= it
.next();
350 selectedItems
.append(m_model
->fileItem(index
));
352 return selectedItems
;
355 int DolphinView::selectedItemsCount() const
357 const KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
358 return selectionManager
->selectedItems().count();
361 void DolphinView::markUrlsAsSelected(const QList
<KUrl
>& urls
)
363 m_selectedUrls
= urls
;
366 void DolphinView::markUrlAsCurrent(const KUrl
& url
)
368 m_currentItemUrl
= url
;
369 m_scrollToCurrentItem
= true;
372 void DolphinView::selectItems(const QRegExp
& pattern
, bool enabled
)
374 const KItemListSelectionManager::SelectionMode mode
= enabled
375 ? KItemListSelectionManager::Select
376 : KItemListSelectionManager::Deselect
;
377 KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
379 for (int index
= 0; index
< m_model
->count(); index
++) {
380 const KFileItem item
= m_model
->fileItem(index
);
381 if (pattern
.exactMatch(item
.text())) {
382 // An alternative approach would be to store the matching items in a QSet<int> and
383 // select them in one go after the loop, but we'd need a new function
384 // KItemListSelectionManager::setSelected(QSet<int>, SelectionMode mode)
386 selectionManager
->setSelected(index
, 1, mode
);
391 void DolphinView::setZoomLevel(int level
)
393 const int oldZoomLevel
= zoomLevel();
394 m_view
->setZoomLevel(level
);
395 if (zoomLevel() != oldZoomLevel
) {
397 emit
zoomLevelChanged(zoomLevel(), oldZoomLevel
);
401 int DolphinView::zoomLevel() const
403 return m_view
->zoomLevel();
406 void DolphinView::setSortRole(const QByteArray
& role
)
408 if (role
!= sortRole()) {
409 updateSortRole(role
);
413 QByteArray
DolphinView::sortRole() const
415 const KItemModelBase
* model
= m_container
->controller()->model();
416 return model
->sortRole();
419 void DolphinView::setSortOrder(Qt::SortOrder order
)
421 if (sortOrder() != order
) {
422 updateSortOrder(order
);
426 Qt::SortOrder
DolphinView::sortOrder() const
428 return m_model
->sortOrder();
431 void DolphinView::setSortFoldersFirst(bool foldersFirst
)
433 if (sortFoldersFirst() != foldersFirst
) {
434 updateSortFoldersFirst(foldersFirst
);
438 bool DolphinView::sortFoldersFirst() const
440 return m_model
->sortDirectoriesFirst();
443 void DolphinView::setVisibleRoles(const QList
<QByteArray
>& roles
)
445 const QList
<QByteArray
> previousRoles
= roles
;
447 ViewProperties
props(viewPropertiesUrl());
448 props
.setVisibleRoles(roles
);
450 m_visibleRoles
= roles
;
451 m_view
->setVisibleRoles(roles
);
453 emit
visibleRolesChanged(m_visibleRoles
, previousRoles
);
456 QList
<QByteArray
> DolphinView::visibleRoles() const
458 return m_visibleRoles
;
461 void DolphinView::reload()
463 QByteArray viewState
;
464 QDataStream
saveStream(&viewState
, QIODevice::WriteOnly
);
465 saveState(saveStream
);
467 const KFileItemList itemList
= selectedItems();
468 m_selectedUrls
.clear();
469 m_selectedUrls
= itemList
.urlList();
472 loadDirectory(url(), true);
474 QDataStream
restoreStream(viewState
);
475 restoreState(restoreStream
);
478 void DolphinView::stopLoading()
480 m_model
->cancelDirectoryLoading();
483 void DolphinView::readSettings()
485 const int oldZoomLevel
= m_view
->zoomLevel();
487 GeneralSettings::self()->readConfig();
488 m_view
->readSettings();
489 applyViewProperties();
491 const int delay
= GeneralSettings::autoExpandFolders() ? 750 : -1;
492 m_container
->controller()->setAutoActivationDelay(delay
);
494 const int newZoomLevel
= m_view
->zoomLevel();
495 if (newZoomLevel
!= oldZoomLevel
) {
496 emit
zoomLevelChanged(newZoomLevel
, oldZoomLevel
);
500 void DolphinView::writeSettings()
502 GeneralSettings::self()->writeConfig();
503 m_view
->writeSettings();
506 void DolphinView::setNameFilter(const QString
& nameFilter
)
508 m_model
->setNameFilter(nameFilter
);
511 QString
DolphinView::nameFilter() const
513 return m_model
->nameFilter();
516 void DolphinView::setMimeTypeFilters(const QStringList
& filters
)
518 return m_model
->setMimeTypeFilters(filters
);
521 QStringList
DolphinView::mimeTypeFilters() const
523 return m_model
->mimeTypeFilters();
526 QString
DolphinView::statusBarText() const
534 KIO::filesize_t totalFileSize
= 0;
536 if (m_container
->controller()->selectionManager()->hasSelection()) {
537 // Give a summary of the status of the selected files
538 const KFileItemList list
= selectedItems();
539 foreach (const KFileItem
& item
, list
) {
544 totalFileSize
+= item
.size();
548 if (folderCount
+ fileCount
== 1) {
549 // If only one item is selected, show the filename
550 filesText
= i18nc("@info:status", "<filename>%1</filename> selected", list
.first().text());
552 // At least 2 items are selected
553 foldersText
= i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount
);
554 filesText
= i18ncp("@info:status", "1 File selected", "%1 Files selected", fileCount
);
557 calculateItemCount(fileCount
, folderCount
, totalFileSize
);
558 foldersText
= i18ncp("@info:status", "1 Folder", "%1 Folders", folderCount
);
559 filesText
= i18ncp("@info:status", "1 File", "%1 Files", fileCount
);
562 if (fileCount
> 0 && folderCount
> 0) {
563 summary
= i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
564 foldersText
, filesText
,
565 KGlobal::locale()->formatByteSize(totalFileSize
));
566 } else if (fileCount
> 0) {
567 summary
= i18nc("@info:status files (size)", "%1 (%2)",
569 KGlobal::locale()->formatByteSize(totalFileSize
));
570 } else if (folderCount
> 0) {
571 summary
= foldersText
;
573 summary
= i18nc("@info:status", "0 Folders, 0 Files");
579 QList
<QAction
*> DolphinView::versionControlActions(const KFileItemList
& items
) const
581 QList
<QAction
*> actions
;
583 if (items
.isEmpty()) {
584 const KFileItem item
= m_model
->rootItem();
585 if (!item
.isNull()) {
586 actions
= m_versionControlObserver
->actions(KFileItemList() << item
);
589 actions
= m_versionControlObserver
->actions(items
);
595 void DolphinView::setUrl(const KUrl
& url
)
601 emit
urlAboutToBeChanged(url
);
606 // It is important to clear the items from the model before
607 // applying the view properties, otherwise expensive operations
608 // might be done on the existing items although they get cleared
609 // anyhow afterwards by loadDirectory().
611 applyViewProperties();
614 emit
urlChanged(url
);
617 void DolphinView::selectAll()
619 KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
620 selectionManager
->setSelected(0, m_model
->count());
623 void DolphinView::invertSelection()
625 KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
626 selectionManager
->setSelected(0, m_model
->count(), KItemListSelectionManager::Toggle
);
629 void DolphinView::clearSelection()
631 m_container
->controller()->selectionManager()->clearSelection();
634 void DolphinView::renameSelectedItems()
636 const KFileItemList items
= selectedItems();
637 if (items
.isEmpty()) {
641 if (items
.count() == 1 && GeneralSettings::renameInline()) {
642 const int index
= m_model
->index(items
.first());
643 m_view
->editRole(index
, "text");
645 RenameDialog
* dialog
= new RenameDialog(this, items
);
646 dialog
->setAttribute(Qt::WA_DeleteOnClose
);
649 dialog
->activateWindow();
652 // Assure that the current index remains visible when KFileItemModel
653 // will notify the view about changed items (which might result in
654 // a changed sorting).
655 m_assureVisibleCurrentIndex
= true;
658 void DolphinView::trashSelectedItems()
660 const KUrl::List list
= simplifiedSelectedUrls();
661 KonqOperations::del(this, KonqOperations::TRASH
, list
);
664 void DolphinView::deleteSelectedItems()
666 const KUrl::List list
= simplifiedSelectedUrls();
667 const bool del
= KonqOperations::askDeleteConfirmation(list
,
669 KonqOperations::DEFAULT_CONFIRMATION
,
673 KIO::Job
* job
= KIO::del(list
);
675 job
->ui()->setWindow(this);
677 connect(job
, SIGNAL(result(KJob
*)),
678 this, SLOT(slotDeleteFileFinished(KJob
*)));
682 void DolphinView::cutSelectedItems()
684 QMimeData
* mimeData
= selectionMimeData();
685 KonqMimeData::addIsCutSelection(mimeData
, true);
686 QApplication::clipboard()->setMimeData(mimeData
);
689 void DolphinView::copySelectedItems()
691 QMimeData
* mimeData
= selectionMimeData();
692 QApplication::clipboard()->setMimeData(mimeData
);
695 void DolphinView::paste()
700 void DolphinView::pasteIntoFolder()
702 const KFileItemList items
= selectedItems();
703 if ((items
.count() == 1) && items
.first().isDir()) {
704 pasteToUrl(items
.first().url());
708 bool DolphinView::eventFilter(QObject
* watched
, QEvent
* event
)
710 switch (event
->type()) {
711 case QEvent::FocusIn
:
712 if (watched
== m_container
) {
717 case QEvent::GraphicsSceneDragEnter
:
718 if (watched
== m_view
) {
723 case QEvent::GraphicsSceneDragLeave
:
724 if (watched
== m_view
) {
729 case QEvent::GraphicsSceneDrop
:
730 if (watched
== m_view
) {
737 return QWidget::eventFilter(watched
, event
);
740 void DolphinView::wheelEvent(QWheelEvent
* event
)
742 if (event
->modifiers().testFlag(Qt::ControlModifier
)) {
743 const int numDegrees
= event
->delta() / 8;
744 const int numSteps
= numDegrees
/ 15;
746 setZoomLevel(zoomLevel() + numSteps
);
753 void DolphinView::hideEvent(QHideEvent
* event
)
756 QWidget::hideEvent(event
);
759 bool DolphinView::event(QEvent
* event
)
762 * Dolphin leaves file preview tooltips open even when is not visible.
764 * Hide tool-tip when Dolphin loses focus.
766 if (event
->type() == QEvent::WindowDeactivate
) {
770 return QWidget::event(event
);
773 void DolphinView::activate()
778 void DolphinView::slotItemActivated(int index
)
780 const KFileItem item
= m_model
->fileItem(index
);
781 if (!item
.isNull()) {
782 emit
itemActivated(item
);
786 void DolphinView::slotItemsActivated(const QSet
<int>& indexes
)
788 Q_ASSERT(indexes
.count() >= 2);
792 QSetIterator
<int> it(indexes
);
793 while (it
.hasNext()) {
794 const int index
= it
.next();
795 items
.append(m_model
->fileItem(index
));
798 if (items
.count() > 5) {
799 QString question
= QString("Are you sure you want to open %1 items?").arg(items
.count());
800 const int answer
= KMessageBox::warningYesNo(this, question
);
801 if (answer
!= KMessageBox::Yes
) {
806 foreach (const KFileItem
& item
, items
) {
808 emit
tabRequested(item
.url());
810 emit
itemActivated(item
);
815 void DolphinView::slotItemMiddleClicked(int index
)
817 const KFileItem item
= m_model
->fileItem(index
);
818 if (item
.isDir() || isTabsForFilesEnabled()) {
819 emit
tabRequested(item
.url());
823 void DolphinView::slotItemContextMenuRequested(int index
, const QPointF
& pos
)
825 const KFileItem item
= m_model
->fileItem(index
);
826 emit
requestContextMenu(pos
.toPoint(), item
, url(), QList
<QAction
*>());
829 void DolphinView::slotViewContextMenuRequested(const QPointF
& pos
)
831 emit
requestContextMenu(pos
.toPoint(), KFileItem(), url(), QList
<QAction
*>());
834 void DolphinView::slotHeaderContextMenuRequested(const QPointF
& pos
)
836 ViewProperties
props(viewPropertiesUrl());
838 QPointer
<KMenu
> menu
= new KMenu(QApplication::activeWindow());
840 KItemListView
* view
= m_container
->controller()->view();
841 const QSet
<QByteArray
> visibleRolesSet
= view
->visibleRoles().toSet();
843 bool nepomukRunning
= false;
844 bool indexingEnabled
= false;
846 nepomukRunning
= (Nepomuk::ResourceManager::instance()->initialized());
847 if (nepomukRunning
) {
848 KConfig
config("nepomukserverrc");
849 indexingEnabled
= config
.group("Service-nepomukfileindexer").readEntry("autostart", false);
854 QMenu
* groupMenu
= 0;
856 // Add all roles to the menu that can be shown or hidden by the user
857 const QList
<KFileItemModel::RoleInfo
> rolesInfo
= KFileItemModel::rolesInformation();
858 foreach (const KFileItemModel::RoleInfo
& info
, rolesInfo
) {
859 if (info
.role
== "text") {
860 // It should not be possible to hide the "text" role
864 const QString text
= m_model
->roleDescription(info
.role
);
866 if (info
.group
.isEmpty()) {
867 action
= menu
->addAction(text
);
869 if (!groupMenu
|| info
.group
!= groupName
) {
870 groupName
= info
.group
;
871 groupMenu
= menu
->addMenu(groupName
);
874 action
= groupMenu
->addAction(text
);
877 action
->setCheckable(true);
878 action
->setChecked(visibleRolesSet
.contains(info
.role
));
879 action
->setData(info
.role
);
881 const bool enable
= (!info
.requiresNepomuk
&& !info
.requiresIndexer
) ||
882 (info
.requiresNepomuk
&& nepomukRunning
) ||
883 (info
.requiresIndexer
&& indexingEnabled
);
884 action
->setEnabled(enable
);
887 menu
->addSeparator();
889 QActionGroup
* widthsGroup
= new QActionGroup(menu
);
890 const bool autoColumnWidths
= props
.headerColumnWidths().isEmpty();
892 QAction
* autoAdjustWidthsAction
= menu
->addAction(i18nc("@action:inmenu", "Automatic Column Widths"));
893 autoAdjustWidthsAction
->setCheckable(true);
894 autoAdjustWidthsAction
->setChecked(autoColumnWidths
);
895 autoAdjustWidthsAction
->setActionGroup(widthsGroup
);
897 QAction
* customWidthsAction
= menu
->addAction(i18nc("@action:inmenu", "Custom Column Widths"));
898 customWidthsAction
->setCheckable(true);
899 customWidthsAction
->setChecked(!autoColumnWidths
);
900 customWidthsAction
->setActionGroup(widthsGroup
);
902 QAction
* action
= menu
->exec(pos
.toPoint());
903 if (menu
&& action
) {
904 KItemListHeader
* header
= view
->header();
906 if (action
== autoAdjustWidthsAction
) {
907 // Clear the column-widths from the viewproperties and turn on
908 // the automatic resizing of the columns
909 props
.setHeaderColumnWidths(QList
<int>());
910 header
->setAutomaticColumnResizing(true);
911 } else if (action
== customWidthsAction
) {
912 // Apply the current column-widths as custom column-widths and turn
913 // off the automatic resizing of the columns
914 QList
<int> columnWidths
;
915 foreach (const QByteArray
& role
, view
->visibleRoles()) {
916 columnWidths
.append(header
->columnWidth(role
));
918 props
.setHeaderColumnWidths(columnWidths
);
919 header
->setAutomaticColumnResizing(false);
921 // Show or hide the selected role
922 const QByteArray selectedRole
= action
->data().toByteArray();
924 QList
<QByteArray
> visibleRoles
= view
->visibleRoles();
925 if (action
->isChecked()) {
926 visibleRoles
.append(selectedRole
);
928 visibleRoles
.removeOne(selectedRole
);
931 view
->setVisibleRoles(visibleRoles
);
932 props
.setVisibleRoles(visibleRoles
);
934 QList
<int> columnWidths
;
935 if (!header
->automaticColumnResizing()) {
936 foreach (const QByteArray
& role
, view
->visibleRoles()) {
937 columnWidths
.append(header
->columnWidth(role
));
940 props
.setHeaderColumnWidths(columnWidths
);
947 void DolphinView::slotHeaderColumnWidthChanged(const QByteArray
& role
, qreal current
, qreal previous
)
951 const QList
<QByteArray
> visibleRoles
= m_view
->visibleRoles();
953 ViewProperties
props(viewPropertiesUrl());
954 QList
<int> columnWidths
= props
.headerColumnWidths();
955 if (columnWidths
.count() != visibleRoles
.count()) {
956 columnWidths
.clear();
957 columnWidths
.reserve(visibleRoles
.count());
958 const KItemListHeader
* header
= m_view
->header();
959 foreach (const QByteArray
& role
, visibleRoles
) {
960 const int width
= header
->columnWidth(role
);
961 columnWidths
.append(width
);
965 const int roleIndex
= visibleRoles
.indexOf(role
);
966 Q_ASSERT(roleIndex
>= 0 && roleIndex
< columnWidths
.count());
967 columnWidths
[roleIndex
] = current
;
969 props
.setHeaderColumnWidths(columnWidths
);
972 void DolphinView::slotItemHovered(int index
)
974 const KFileItem item
= m_model
->fileItem(index
);
976 if (GeneralSettings::showToolTips() && !m_dragging
) {
977 QRectF itemRect
= m_container
->controller()->view()->itemContextRect(index
);
978 const QPoint pos
= m_container
->mapToGlobal(itemRect
.topLeft().toPoint());
979 itemRect
.moveTo(pos
);
981 m_toolTipManager
->showToolTip(item
, itemRect
);
984 emit
requestItemInfo(item
);
987 void DolphinView::slotItemUnhovered(int index
)
991 emit
requestItemInfo(KFileItem());
994 void DolphinView::slotItemDropEvent(int index
, QGraphicsSceneDragDropEvent
* event
)
997 KFileItem destItem
= m_model
->fileItem(index
);
998 if (destItem
.isNull() || (!destItem
.isDir() && !destItem
.isDesktopFile())) {
999 // Use the URL of the view as drop target if the item is no directory
1001 destItem
= m_model
->rootItem();
1004 // The item represents a directory or desktop-file
1005 destUrl
= destItem
.url();
1008 QDropEvent
dropEvent(event
->pos().toPoint(),
1009 event
->possibleActions(),
1012 event
->modifiers());
1014 const QString error
= DragAndDropHelper::dropUrls(destItem
, destUrl
, &dropEvent
);
1015 if (!error
.isEmpty()) {
1016 emit
errorMessage(error
);
1019 if (destUrl
== url()) {
1020 // Mark the dropped urls as selected.
1021 markPastedUrlsAsSelected(event
->mimeData());
1025 void DolphinView::slotModelChanged(KItemModelBase
* current
, KItemModelBase
* previous
)
1027 if (previous
!= 0) {
1028 disconnect(previous
, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
1029 m_versionControlObserver
->setModel(0);
1033 Q_ASSERT(qobject_cast
<KFileItemModel
*>(current
));
1034 connect(current
, SIGNAL(loadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
1036 KFileItemModel
* fileItemModel
= static_cast<KFileItemModel
*>(current
);
1037 m_versionControlObserver
->setModel(fileItemModel
);
1041 void DolphinView::slotMouseButtonPressed(int itemIndex
, Qt::MouseButtons buttons
)
1045 if (itemIndex
< 0) {
1046 // Trigger the history navigation only when clicking on the viewport:
1047 // Above an item the XButtons provide a simple way to select items in
1048 // the singleClick mode.
1049 if (buttons
& Qt::XButton1
) {
1050 emit
goBackRequested();
1051 } else if (buttons
& Qt::XButton2
) {
1052 emit
goForwardRequested();
1057 void DolphinView::slotSelectionChanged(const QSet
<int>& current
, const QSet
<int>& previous
)
1059 const int currentCount
= current
.count();
1060 const int previousCount
= previous
.count();
1061 const bool selectionStateChanged
= (currentCount
== 0 && previousCount
> 0) ||
1062 (currentCount
> 0 && previousCount
== 0);
1064 // If nothing has been selected before and something got selected (or if something
1065 // was selected before and now nothing is selected) the selectionChangedSignal must
1066 // be emitted asynchronously as fast as possible to update the edit-actions.
1067 m_selectionChangedTimer
->setInterval(selectionStateChanged
? 0 : 300);
1068 m_selectionChangedTimer
->start();
1071 void DolphinView::emitSelectionChangedSignal()
1073 m_selectionChangedTimer
->stop();
1074 emit
selectionChanged(selectedItems());
1077 void DolphinView::updateSortRole(const QByteArray
& role
)
1079 ViewProperties
props(viewPropertiesUrl());
1080 props
.setSortRole(role
);
1082 KItemModelBase
* model
= m_container
->controller()->model();
1083 model
->setSortRole(role
);
1085 emit
sortRoleChanged(role
);
1088 void DolphinView::updateSortOrder(Qt::SortOrder order
)
1090 ViewProperties
props(viewPropertiesUrl());
1091 props
.setSortOrder(order
);
1093 m_model
->setSortOrder(order
);
1095 emit
sortOrderChanged(order
);
1098 void DolphinView::updateSortFoldersFirst(bool foldersFirst
)
1100 ViewProperties
props(viewPropertiesUrl());
1101 props
.setSortFoldersFirst(foldersFirst
);
1103 m_model
->setSortDirectoriesFirst(foldersFirst
);
1105 emit
sortFoldersFirstChanged(foldersFirst
);
1108 QPair
<bool, QString
> DolphinView::pasteInfo() const
1110 return KonqOperations::pasteInfo(url());
1113 void DolphinView::setTabsForFilesEnabled(bool tabsForFiles
)
1115 m_tabsForFiles
= tabsForFiles
;
1118 bool DolphinView::isTabsForFilesEnabled() const
1120 return m_tabsForFiles
;
1123 bool DolphinView::itemsExpandable() const
1125 return m_mode
== DetailsView
;
1128 void DolphinView::restoreState(QDataStream
& stream
)
1130 // Restore the current item that had the keyboard focus
1131 stream
>> m_currentItemUrl
;
1133 // Restore the view position
1134 stream
>> m_restoredContentsPosition
;
1136 // Restore expanded folders (only relevant for the details view - will be ignored by the view in other view modes)
1139 m_model
->restoreExpandedDirectories(urls
);
1142 void DolphinView::saveState(QDataStream
& stream
)
1144 // Save the current item that has the keyboard focus
1145 const int currentIndex
= m_container
->controller()->selectionManager()->currentItem();
1146 if (currentIndex
!= -1) {
1147 KFileItem item
= m_model
->fileItem(currentIndex
);
1148 Q_ASSERT(!item
.isNull()); // If the current index is valid a item must exist
1149 KUrl currentItemUrl
= item
.url();
1150 stream
<< currentItemUrl
;
1155 // Save view position
1156 const qreal x
= m_container
->horizontalScrollBar()->value();
1157 const qreal y
= m_container
->verticalScrollBar()->value();
1158 stream
<< QPoint(x
, y
);
1160 // Save expanded folders (only relevant for the details view - the set will be empty in other view modes)
1161 stream
<< m_model
->expandedDirectories();
1164 KFileItem
DolphinView::rootItem() const
1166 return m_model
->rootItem();
1169 void DolphinView::setViewPropertiesContext(const QString
& context
)
1171 m_viewPropertiesContext
= context
;
1174 QString
DolphinView::viewPropertiesContext() const
1176 return m_viewPropertiesContext
;
1179 void DolphinView::observeCreatedItem(const KUrl
& url
)
1181 markUrlAsCurrent(url
);
1182 markUrlsAsSelected(QList
<KUrl
>() << url
);
1185 void DolphinView::slotDirectoryRedirection(const KUrl
& oldUrl
, const KUrl
& newUrl
)
1187 if (oldUrl
.equals(url(), KUrl::CompareWithoutTrailingSlash
)) {
1188 emit
redirection(oldUrl
, newUrl
);
1189 m_url
= newUrl
; // #186947
1193 void DolphinView::updateViewState()
1195 if (m_currentItemUrl
!= KUrl()) {
1196 KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
1197 const int currentIndex
= m_model
->index(m_currentItemUrl
);
1198 if (currentIndex
!= -1) {
1199 selectionManager
->setCurrentItem(currentIndex
);
1201 // scroll to current item and reset the state
1202 if (m_scrollToCurrentItem
) {
1203 m_view
->scrollToItem(currentIndex
);
1204 m_scrollToCurrentItem
= false;
1207 selectionManager
->setCurrentItem(0);
1209 m_currentItemUrl
= KUrl();
1212 if (!m_restoredContentsPosition
.isNull()) {
1213 const int x
= m_restoredContentsPosition
.x();
1214 const int y
= m_restoredContentsPosition
.y();
1215 m_restoredContentsPosition
= QPoint();
1217 m_container
->horizontalScrollBar()->setValue(x
);
1218 m_container
->verticalScrollBar()->setValue(y
);
1221 if (!m_selectedUrls
.isEmpty()) {
1224 KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
1225 QSet
<int> selectedItems
= selectionManager
->selectedItems();
1227 foreach (const KUrl
& url
, m_selectedUrls
) {
1228 const int index
= m_model
->index(url
);
1230 selectedItems
.insert(index
);
1234 selectionManager
->setSelectedItems(selectedItems
);
1235 m_selectedUrls
.clear();
1239 void DolphinView::hideToolTip()
1241 if (GeneralSettings::showToolTips()) {
1242 m_toolTipManager
->hideToolTip();
1246 void DolphinView::calculateItemCount(int& fileCount
,
1248 KIO::filesize_t
& totalFileSize
) const
1250 const int itemCount
= m_model
->count();
1251 for (int i
= 0; i
< itemCount
; ++i
) {
1252 const KFileItem item
= m_model
->fileItem(i
);
1257 totalFileSize
+= item
.size();
1262 void DolphinView::showHoverInformation(const KFileItem
& item
)
1264 emit
requestItemInfo(item
);
1267 void DolphinView::clearHoverInformation()
1269 emit
requestItemInfo(KFileItem());
1272 void DolphinView::slotDeleteFileFinished(KJob
* job
)
1274 if (job
->error() == 0) {
1275 emit
operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
1276 } else if (job
->error() != KIO::ERR_USER_CANCELED
) {
1277 emit
errorMessage(job
->errorString());
1281 void DolphinView::slotDirectoryLoadingStarted()
1283 // Disable the writestate temporary until it can be determined in a fast way
1284 // in DolphinView::slotLoadingCompleted()
1285 if (m_isFolderWritable
) {
1286 m_isFolderWritable
= false;
1287 emit
writeStateChanged(m_isFolderWritable
);
1290 emit
directoryLoadingStarted();
1293 void DolphinView::slotDirectoryLoadingCompleted()
1295 // Update the view-state. This has to be done asynchronously
1296 // because the view might not be in its final state yet.
1297 QTimer::singleShot(0, this, SLOT(updateViewState()));
1299 emit
directoryLoadingCompleted();
1301 updateWritableState();
1304 void DolphinView::slotItemsChanged()
1306 m_assureVisibleCurrentIndex
= false;
1309 void DolphinView::slotSortOrderChangedByHeader(Qt::SortOrder current
, Qt::SortOrder previous
)
1312 Q_ASSERT(m_model
->sortOrder() == current
);
1314 ViewProperties
props(viewPropertiesUrl());
1315 props
.setSortOrder(current
);
1317 emit
sortOrderChanged(current
);
1320 void DolphinView::slotSortRoleChangedByHeader(const QByteArray
& current
, const QByteArray
& previous
)
1323 Q_ASSERT(m_model
->sortRole() == current
);
1325 ViewProperties
props(viewPropertiesUrl());
1326 props
.setSortRole(current
);
1328 emit
sortRoleChanged(current
);
1331 void DolphinView::slotVisibleRolesChangedByHeader(const QList
<QByteArray
>& current
,
1332 const QList
<QByteArray
>& previous
)
1335 Q_ASSERT(m_container
->controller()->view()->visibleRoles() == current
);
1337 const QList
<QByteArray
> previousVisibleRoles
= m_visibleRoles
;
1339 m_visibleRoles
= current
;
1341 ViewProperties
props(viewPropertiesUrl());
1342 props
.setVisibleRoles(m_visibleRoles
);
1344 emit
visibleRolesChanged(m_visibleRoles
, previousVisibleRoles
);
1347 void DolphinView::slotRoleEditingFinished(int index
, const QByteArray
& role
, const QVariant
& value
)
1349 if (index
< 0 || index
>= m_model
->count()) {
1353 if (role
== "text") {
1354 const KFileItem oldItem
= m_model
->fileItem(index
);
1355 const QString newName
= value
.toString();
1356 if (!newName
.isEmpty() && newName
!= oldItem
.text() && newName
!= QLatin1String(".") && newName
!= QLatin1String("..")) {
1357 const KUrl oldUrl
= oldItem
.url();
1359 QHash
<QByteArray
, QVariant
> data
;
1360 data
.insert(role
, value
);
1361 m_model
->setData(index
, data
);
1363 KonqOperations::rename(this, oldUrl
, newName
);
1368 void DolphinView::loadDirectory(const KUrl
& url
, bool reload
)
1370 if (!url
.isValid()) {
1371 const QString
location(url
.pathOrUrl());
1372 if (location
.isEmpty()) {
1373 emit
errorMessage(i18nc("@info:status", "The location is empty."));
1375 emit
errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location
));
1381 m_model
->refreshDirectory(url
);
1383 m_model
->loadDirectory(url
);
1387 void DolphinView::applyViewProperties()
1389 m_view
->beginTransaction();
1391 const ViewProperties
props(viewPropertiesUrl());
1393 const Mode mode
= props
.viewMode();
1394 if (m_mode
!= mode
) {
1395 const Mode previousMode
= m_mode
;
1398 // Changing the mode might result in changing
1399 // the zoom level. Remember the old zoom level so
1400 // that zoomLevelChanged() can get emitted.
1401 const int oldZoomLevel
= m_view
->zoomLevel();
1404 emit
modeChanged(m_mode
, previousMode
);
1406 if (m_view
->zoomLevel() != oldZoomLevel
) {
1407 emit
zoomLevelChanged(m_view
->zoomLevel(), oldZoomLevel
);
1411 const bool hiddenFilesShown
= props
.hiddenFilesShown();
1412 if (hiddenFilesShown
!= m_model
->showHiddenFiles()) {
1413 m_model
->setShowHiddenFiles(hiddenFilesShown
);
1414 emit
hiddenFilesShownChanged(hiddenFilesShown
);
1417 const bool groupedSorting
= props
.groupedSorting();
1418 if (groupedSorting
!= m_model
->groupedSorting()) {
1419 m_model
->setGroupedSorting(groupedSorting
);
1420 emit
groupedSortingChanged(groupedSorting
);
1423 const QByteArray sortRole
= props
.sortRole();
1424 if (sortRole
!= m_model
->sortRole()) {
1425 m_model
->setSortRole(sortRole
);
1426 emit
sortRoleChanged(sortRole
);
1429 const Qt::SortOrder sortOrder
= props
.sortOrder();
1430 if (sortOrder
!= m_model
->sortOrder()) {
1431 m_model
->setSortOrder(sortOrder
);
1432 emit
sortOrderChanged(sortOrder
);
1435 const bool sortFoldersFirst
= props
.sortFoldersFirst();
1436 if (sortFoldersFirst
!= m_model
->sortDirectoriesFirst()) {
1437 m_model
->setSortDirectoriesFirst(sortFoldersFirst
);
1438 emit
sortFoldersFirstChanged(sortFoldersFirst
);
1441 const QList
<QByteArray
> visibleRoles
= props
.visibleRoles();
1442 if (visibleRoles
!= m_visibleRoles
) {
1443 const QList
<QByteArray
> previousVisibleRoles
= m_visibleRoles
;
1444 m_visibleRoles
= visibleRoles
;
1445 m_view
->setVisibleRoles(visibleRoles
);
1446 emit
visibleRolesChanged(m_visibleRoles
, previousVisibleRoles
);
1449 const bool previewsShown
= props
.previewsShown();
1450 if (previewsShown
!= m_view
->previewsShown()) {
1451 const int oldZoomLevel
= zoomLevel();
1453 m_view
->setPreviewsShown(previewsShown
);
1454 emit
previewsShownChanged(previewsShown
);
1456 // Changing the preview-state might result in a changed zoom-level
1457 if (oldZoomLevel
!= zoomLevel()) {
1458 emit
zoomLevelChanged(zoomLevel(), oldZoomLevel
);
1462 KItemListView
* itemListView
= m_container
->controller()->view();
1463 if (itemListView
->isHeaderVisible()) {
1464 KItemListHeader
* header
= itemListView
->header();
1465 const QList
<int> headerColumnWidths
= props
.headerColumnWidths();
1466 const int rolesCount
= m_visibleRoles
.count();
1467 if (headerColumnWidths
.count() == rolesCount
) {
1468 header
->setAutomaticColumnResizing(false);
1470 QHash
<QByteArray
, qreal
> columnWidths
;
1471 for (int i
= 0; i
< rolesCount
; ++i
) {
1472 columnWidths
.insert(m_visibleRoles
[i
], headerColumnWidths
[i
]);
1474 header
->setColumnWidths(columnWidths
);
1476 header
->setAutomaticColumnResizing(true);
1480 m_view
->endTransaction();
1483 void DolphinView::applyModeToView()
1486 case IconsView
: m_view
->setItemLayout(KFileItemListView::IconsLayout
); break;
1487 case CompactView
: m_view
->setItemLayout(KFileItemListView::CompactLayout
); break;
1488 case DetailsView
: m_view
->setItemLayout(KFileItemListView::DetailsLayout
); break;
1489 default: Q_ASSERT(false); break;
1493 void DolphinView::pasteToUrl(const KUrl
& url
)
1495 markPastedUrlsAsSelected(QApplication::clipboard()->mimeData());
1496 KonqOperations::doPaste(this, url
);
1499 KUrl::List
DolphinView::simplifiedSelectedUrls() const
1503 const KFileItemList items
= selectedItems();
1504 foreach (const KFileItem
& item
, items
) {
1505 urls
.append(item
.url());
1508 if (itemsExpandable()) {
1509 // TODO: Check if we still need KDirModel for this in KDE 5.0
1510 urls
= KDirModel::simplifiedUrlList(urls
);
1516 QMimeData
* DolphinView::selectionMimeData() const
1518 const KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
1519 const QSet
<int> selectedIndexes
= selectionManager
->selectedItems();
1521 return m_model
->createMimeData(selectedIndexes
);
1524 void DolphinView::markPastedUrlsAsSelected(const QMimeData
* mimeData
)
1526 const KUrl::List sourceUrls
= KUrl::List::fromMimeData(mimeData
);
1527 KUrl::List destUrls
;
1528 foreach (const KUrl
& source
, sourceUrls
) {
1529 KUrl
destination(url().url() + '/' + source
.fileName());
1530 destUrls
<< destination
;
1532 markUrlsAsSelected(destUrls
);
1535 void DolphinView::updateWritableState()
1537 const bool wasFolderWritable
= m_isFolderWritable
;
1538 m_isFolderWritable
= true;
1540 const KFileItem item
= m_model
->rootItem();
1541 if (!item
.isNull()) {
1542 KFileItemListProperties
capabilities(KFileItemList() << item
);
1543 m_isFolderWritable
= capabilities
.supportsWriting();
1545 if (m_isFolderWritable
!= wasFolderWritable
) {
1546 emit
writeStateChanged(m_isFolderWritable
);
1550 KUrl
DolphinView::viewPropertiesUrl() const
1552 if (m_viewPropertiesContext
.isEmpty()) {
1557 url
.setProtocol(m_url
.protocol());
1558 url
.setPath(m_viewPropertiesContext
);
1562 #include "dolphinview.moc"