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 <Nepomuk2/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(directoryLoadingCanceled()), this, SIGNAL(directoryLoadingCanceled()));
158 connect(m_model
, SIGNAL(directoryLoadingProgress(int)), this, SIGNAL(directoryLoadingProgress(int)));
159 connect(m_model
, SIGNAL(directorySortingProgress(int)), this, SIGNAL(directorySortingProgress(int)));
160 connect(m_model
, SIGNAL(itemsChanged(KItemRangeList
,QSet
<QByteArray
>)),
161 this, SLOT(slotItemsChanged()));
162 connect(m_model
, SIGNAL(itemsRemoved(KItemRangeList
)), this, SIGNAL(itemCountChanged()));
163 connect(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), this, SIGNAL(itemCountChanged()));
164 connect(m_model
, SIGNAL(infoMessage(QString
)), this, SIGNAL(infoMessage(QString
)));
165 connect(m_model
, SIGNAL(errorMessage(QString
)), this, SIGNAL(errorMessage(QString
)));
166 connect(m_model
, SIGNAL(directoryRedirection(KUrl
,KUrl
)), this, SLOT(slotDirectoryRedirection(KUrl
,KUrl
)));
167 connect(m_model
, SIGNAL(urlIsFileError(KUrl
)), this, SIGNAL(urlIsFileError(KUrl
)));
169 m_view
->installEventFilter(this);
170 connect(m_view
, SIGNAL(sortOrderChanged(Qt::SortOrder
,Qt::SortOrder
)),
171 this, SLOT(slotSortOrderChangedByHeader(Qt::SortOrder
,Qt::SortOrder
)));
172 connect(m_view
, SIGNAL(sortRoleChanged(QByteArray
,QByteArray
)),
173 this, SLOT(slotSortRoleChangedByHeader(QByteArray
,QByteArray
)));
174 connect(m_view
, SIGNAL(visibleRolesChanged(QList
<QByteArray
>,QList
<QByteArray
>)),
175 this, SLOT(slotVisibleRolesChangedByHeader(QList
<QByteArray
>,QList
<QByteArray
>)));
176 connect(m_view
, SIGNAL(roleEditingFinished(int,QByteArray
,QVariant
)),
177 this, SLOT(slotRoleEditingFinished(int,QByteArray
,QVariant
)));
178 connect(m_view
->header(), SIGNAL(columnWidthChanged(QByteArray
,qreal
,qreal
)),
179 this, SLOT(slotHeaderColumnWidthChanged(QByteArray
,qreal
,qreal
)));
181 KItemListSelectionManager
* selectionManager
= controller
->selectionManager();
182 connect(selectionManager
, SIGNAL(selectionChanged(QSet
<int>,QSet
<int>)),
183 this, SLOT(slotSelectionChanged(QSet
<int>,QSet
<int>)));
185 m_toolTipManager
= new ToolTipManager(this);
187 m_versionControlObserver
= new VersionControlObserver(this);
188 m_versionControlObserver
->setModel(m_model
);
189 connect(m_versionControlObserver
, SIGNAL(infoMessage(QString
)), this, SIGNAL(infoMessage(QString
)));
190 connect(m_versionControlObserver
, SIGNAL(errorMessage(QString
)), this, SIGNAL(errorMessage(QString
)));
191 connect(m_versionControlObserver
, SIGNAL(operationCompletedMessage(QString
)), this, SIGNAL(operationCompletedMessage(QString
)));
193 applyViewProperties();
194 m_topLayout
->addWidget(m_container
);
199 DolphinView::~DolphinView()
203 KUrl
DolphinView::url() const
208 void DolphinView::setActive(bool active
)
210 if (active
== m_active
) {
216 QColor color
= KColorScheme(QPalette::Active
, KColorScheme::View
).background().color();
221 QWidget
* viewport
= m_container
->viewport();
224 palette
.setColor(viewport
->backgroundRole(), color
);
225 viewport
->setPalette(palette
);
231 m_container
->setFocus();
233 emit
writeStateChanged(m_isFolderWritable
);
237 bool DolphinView::isActive() const
242 void DolphinView::setMode(Mode mode
)
244 if (mode
!= m_mode
) {
245 ViewProperties
props(viewPropertiesUrl());
246 props
.setViewMode(mode
);
249 applyViewProperties();
253 DolphinView::Mode
DolphinView::mode() const
258 void DolphinView::setPreviewsShown(bool show
)
260 if (previewsShown() == show
) {
264 ViewProperties
props(viewPropertiesUrl());
265 props
.setPreviewsShown(show
);
267 const int oldZoomLevel
= m_view
->zoomLevel();
268 m_view
->setPreviewsShown(show
);
269 emit
previewsShownChanged(show
);
271 const int newZoomLevel
= m_view
->zoomLevel();
272 if (newZoomLevel
!= oldZoomLevel
) {
273 emit
zoomLevelChanged(newZoomLevel
, oldZoomLevel
);
277 bool DolphinView::previewsShown() const
279 return m_view
->previewsShown();
282 void DolphinView::setHiddenFilesShown(bool show
)
284 if (m_model
->showHiddenFiles() == show
) {
288 const KFileItemList itemList
= selectedItems();
289 m_selectedUrls
.clear();
290 m_selectedUrls
= itemList
.urlList();
292 ViewProperties
props(viewPropertiesUrl());
293 props
.setHiddenFilesShown(show
);
295 m_model
->setShowHiddenFiles(show
);
296 emit
hiddenFilesShownChanged(show
);
299 bool DolphinView::hiddenFilesShown() const
301 return m_model
->showHiddenFiles();
304 void DolphinView::setGroupedSorting(bool grouped
)
306 if (grouped
== groupedSorting()) {
310 ViewProperties
props(viewPropertiesUrl());
311 props
.setGroupedSorting(grouped
);
314 m_container
->controller()->model()->setGroupedSorting(grouped
);
316 emit
groupedSortingChanged(grouped
);
319 bool DolphinView::groupedSorting() const
321 return m_model
->groupedSorting();
324 KFileItemList
DolphinView::items() const
327 const int itemCount
= m_model
->count();
328 list
.reserve(itemCount
);
330 for (int i
= 0; i
< itemCount
; ++i
) {
331 list
.append(m_model
->fileItem(i
));
337 int DolphinView::itemsCount() const
339 return m_model
->count();
342 KFileItemList
DolphinView::selectedItems() const
344 const KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
345 const QSet
<int> selectedIndexes
= selectionManager
->selectedItems();
347 KFileItemList selectedItems
;
348 QSetIterator
<int> it(selectedIndexes
);
349 while (it
.hasNext()) {
350 const int index
= it
.next();
351 selectedItems
.append(m_model
->fileItem(index
));
353 return selectedItems
;
356 int DolphinView::selectedItemsCount() const
358 const KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
359 return selectionManager
->selectedItems().count();
362 void DolphinView::markUrlsAsSelected(const QList
<KUrl
>& urls
)
364 m_selectedUrls
= urls
;
367 void DolphinView::markUrlAsCurrent(const KUrl
& url
)
369 m_currentItemUrl
= url
;
370 m_scrollToCurrentItem
= true;
373 void DolphinView::selectItems(const QRegExp
& pattern
, bool enabled
)
375 const KItemListSelectionManager::SelectionMode mode
= enabled
376 ? KItemListSelectionManager::Select
377 : KItemListSelectionManager::Deselect
;
378 KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
380 for (int index
= 0; index
< m_model
->count(); index
++) {
381 const KFileItem item
= m_model
->fileItem(index
);
382 if (pattern
.exactMatch(item
.text())) {
383 // An alternative approach would be to store the matching items in a QSet<int> and
384 // select them in one go after the loop, but we'd need a new function
385 // KItemListSelectionManager::setSelected(QSet<int>, SelectionMode mode)
387 selectionManager
->setSelected(index
, 1, mode
);
392 void DolphinView::setZoomLevel(int level
)
394 const int oldZoomLevel
= zoomLevel();
395 m_view
->setZoomLevel(level
);
396 if (zoomLevel() != oldZoomLevel
) {
398 emit
zoomLevelChanged(zoomLevel(), oldZoomLevel
);
402 int DolphinView::zoomLevel() const
404 return m_view
->zoomLevel();
407 void DolphinView::setSortRole(const QByteArray
& role
)
409 if (role
!= sortRole()) {
410 updateSortRole(role
);
414 QByteArray
DolphinView::sortRole() const
416 const KItemModelBase
* model
= m_container
->controller()->model();
417 return model
->sortRole();
420 void DolphinView::setSortOrder(Qt::SortOrder order
)
422 if (sortOrder() != order
) {
423 updateSortOrder(order
);
427 Qt::SortOrder
DolphinView::sortOrder() const
429 return m_model
->sortOrder();
432 void DolphinView::setSortFoldersFirst(bool foldersFirst
)
434 if (sortFoldersFirst() != foldersFirst
) {
435 updateSortFoldersFirst(foldersFirst
);
439 bool DolphinView::sortFoldersFirst() const
441 return m_model
->sortDirectoriesFirst();
444 void DolphinView::setVisibleRoles(const QList
<QByteArray
>& roles
)
446 const QList
<QByteArray
> previousRoles
= roles
;
448 ViewProperties
props(viewPropertiesUrl());
449 props
.setVisibleRoles(roles
);
451 m_visibleRoles
= roles
;
452 m_view
->setVisibleRoles(roles
);
454 emit
visibleRolesChanged(m_visibleRoles
, previousRoles
);
457 QList
<QByteArray
> DolphinView::visibleRoles() const
459 return m_visibleRoles
;
462 void DolphinView::reload()
464 QByteArray viewState
;
465 QDataStream
saveStream(&viewState
, QIODevice::WriteOnly
);
466 saveState(saveStream
);
468 const KFileItemList itemList
= selectedItems();
469 m_selectedUrls
.clear();
470 m_selectedUrls
= itemList
.urlList();
473 loadDirectory(url(), true);
475 QDataStream
restoreStream(viewState
);
476 restoreState(restoreStream
);
479 void DolphinView::stopLoading()
481 m_model
->cancelDirectoryLoading();
484 void DolphinView::readSettings()
486 const int oldZoomLevel
= m_view
->zoomLevel();
488 GeneralSettings::self()->readConfig();
489 m_view
->readSettings();
490 applyViewProperties();
492 const int delay
= GeneralSettings::autoExpandFolders() ? 750 : -1;
493 m_container
->controller()->setAutoActivationDelay(delay
);
495 const int newZoomLevel
= m_view
->zoomLevel();
496 if (newZoomLevel
!= oldZoomLevel
) {
497 emit
zoomLevelChanged(newZoomLevel
, oldZoomLevel
);
501 void DolphinView::writeSettings()
503 GeneralSettings::self()->writeConfig();
504 m_view
->writeSettings();
507 void DolphinView::setNameFilter(const QString
& nameFilter
)
509 m_model
->setNameFilter(nameFilter
);
512 QString
DolphinView::nameFilter() const
514 return m_model
->nameFilter();
517 void DolphinView::setMimeTypeFilters(const QStringList
& filters
)
519 return m_model
->setMimeTypeFilters(filters
);
522 QStringList
DolphinView::mimeTypeFilters() const
524 return m_model
->mimeTypeFilters();
527 QString
DolphinView::statusBarText() const
535 KIO::filesize_t totalFileSize
= 0;
537 if (m_container
->controller()->selectionManager()->hasSelection()) {
538 // Give a summary of the status of the selected files
539 const KFileItemList list
= selectedItems();
540 foreach (const KFileItem
& item
, list
) {
545 totalFileSize
+= item
.size();
549 if (folderCount
+ fileCount
== 1) {
550 // If only one item is selected, show the filename
551 filesText
= i18nc("@info:status", "<filename>%1</filename> selected", list
.first().text());
553 // At least 2 items are selected
554 foldersText
= i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount
);
555 filesText
= i18ncp("@info:status", "1 File selected", "%1 Files selected", fileCount
);
558 calculateItemCount(fileCount
, folderCount
, totalFileSize
);
559 foldersText
= i18ncp("@info:status", "1 Folder", "%1 Folders", folderCount
);
560 filesText
= i18ncp("@info:status", "1 File", "%1 Files", fileCount
);
563 if (fileCount
> 0 && folderCount
> 0) {
564 summary
= i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
565 foldersText
, filesText
,
566 KGlobal::locale()->formatByteSize(totalFileSize
));
567 } else if (fileCount
> 0) {
568 summary
= i18nc("@info:status files (size)", "%1 (%2)",
570 KGlobal::locale()->formatByteSize(totalFileSize
));
571 } else if (folderCount
> 0) {
572 summary
= foldersText
;
574 summary
= i18nc("@info:status", "0 Folders, 0 Files");
580 QList
<QAction
*> DolphinView::versionControlActions(const KFileItemList
& items
) const
582 QList
<QAction
*> actions
;
584 if (items
.isEmpty()) {
585 const KFileItem item
= m_model
->rootItem();
586 if (!item
.isNull()) {
587 actions
= m_versionControlObserver
->actions(KFileItemList() << item
);
590 actions
= m_versionControlObserver
->actions(items
);
596 void DolphinView::setUrl(const KUrl
& url
)
602 emit
urlAboutToBeChanged(url
);
607 // It is important to clear the items from the model before
608 // applying the view properties, otherwise expensive operations
609 // might be done on the existing items although they get cleared
610 // anyhow afterwards by loadDirectory().
612 applyViewProperties();
615 emit
urlChanged(url
);
618 void DolphinView::selectAll()
620 KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
621 selectionManager
->setSelected(0, m_model
->count());
624 void DolphinView::invertSelection()
626 KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
627 selectionManager
->setSelected(0, m_model
->count(), KItemListSelectionManager::Toggle
);
630 void DolphinView::clearSelection()
632 m_container
->controller()->selectionManager()->clearSelection();
635 void DolphinView::renameSelectedItems()
637 const KFileItemList items
= selectedItems();
638 if (items
.isEmpty()) {
642 if (items
.count() == 1 && GeneralSettings::renameInline()) {
643 const int index
= m_model
->index(items
.first());
644 m_view
->editRole(index
, "text");
646 RenameDialog
* dialog
= new RenameDialog(this, items
);
647 dialog
->setAttribute(Qt::WA_DeleteOnClose
);
650 dialog
->activateWindow();
653 // Assure that the current index remains visible when KFileItemModel
654 // will notify the view about changed items (which might result in
655 // a changed sorting).
656 m_assureVisibleCurrentIndex
= true;
659 void DolphinView::trashSelectedItems()
661 const KUrl::List list
= simplifiedSelectedUrls();
662 KonqOperations::del(this, KonqOperations::TRASH
, list
);
665 void DolphinView::deleteSelectedItems()
667 const KUrl::List list
= simplifiedSelectedUrls();
668 const bool del
= KonqOperations::askDeleteConfirmation(list
,
670 KonqOperations::DEFAULT_CONFIRMATION
,
674 KIO::Job
* job
= KIO::del(list
);
676 job
->ui()->setWindow(this);
678 connect(job
, SIGNAL(result(KJob
*)),
679 this, SLOT(slotDeleteFileFinished(KJob
*)));
683 void DolphinView::cutSelectedItems()
685 QMimeData
* mimeData
= selectionMimeData();
686 KonqMimeData::addIsCutSelection(mimeData
, true);
687 QApplication::clipboard()->setMimeData(mimeData
);
690 void DolphinView::copySelectedItems()
692 QMimeData
* mimeData
= selectionMimeData();
693 QApplication::clipboard()->setMimeData(mimeData
);
696 void DolphinView::paste()
701 void DolphinView::pasteIntoFolder()
703 const KFileItemList items
= selectedItems();
704 if ((items
.count() == 1) && items
.first().isDir()) {
705 pasteToUrl(items
.first().url());
709 bool DolphinView::eventFilter(QObject
* watched
, QEvent
* event
)
711 switch (event
->type()) {
712 case QEvent::FocusIn
:
713 if (watched
== m_container
) {
718 case QEvent::GraphicsSceneDragEnter
:
719 if (watched
== m_view
) {
724 case QEvent::GraphicsSceneDragLeave
:
725 if (watched
== m_view
) {
730 case QEvent::GraphicsSceneDrop
:
731 if (watched
== m_view
) {
738 return QWidget::eventFilter(watched
, event
);
741 void DolphinView::wheelEvent(QWheelEvent
* event
)
743 if (event
->modifiers().testFlag(Qt::ControlModifier
)) {
744 const int numDegrees
= event
->delta() / 8;
745 const int numSteps
= numDegrees
/ 15;
747 setZoomLevel(zoomLevel() + numSteps
);
754 void DolphinView::hideEvent(QHideEvent
* event
)
757 QWidget::hideEvent(event
);
760 bool DolphinView::event(QEvent
* event
)
763 * Dolphin leaves file preview tooltips open even when is not visible.
765 * Hide tool-tip when Dolphin loses focus.
767 if (event
->type() == QEvent::WindowDeactivate
) {
771 return QWidget::event(event
);
774 void DolphinView::activate()
779 void DolphinView::slotItemActivated(int index
)
781 const KFileItem item
= m_model
->fileItem(index
);
782 if (!item
.isNull()) {
783 emit
itemActivated(item
);
787 void DolphinView::slotItemsActivated(const QSet
<int>& indexes
)
789 Q_ASSERT(indexes
.count() >= 2);
793 QSetIterator
<int> it(indexes
);
794 while (it
.hasNext()) {
795 const int index
= it
.next();
796 items
.append(m_model
->fileItem(index
));
799 if (items
.count() > 5) {
800 QString question
= QString("Are you sure you want to open %1 items?").arg(items
.count());
801 const int answer
= KMessageBox::warningYesNo(this, question
);
802 if (answer
!= KMessageBox::Yes
) {
807 foreach (const KFileItem
& item
, items
) {
809 emit
tabRequested(item
.url());
811 emit
itemActivated(item
);
816 void DolphinView::slotItemMiddleClicked(int index
)
818 const KFileItem item
= m_model
->fileItem(index
);
819 if (item
.isDir() || isTabsForFilesEnabled()) {
820 emit
tabRequested(item
.url());
824 void DolphinView::slotItemContextMenuRequested(int index
, const QPointF
& pos
)
826 const KFileItem item
= m_model
->fileItem(index
);
827 emit
requestContextMenu(pos
.toPoint(), item
, url(), QList
<QAction
*>());
830 void DolphinView::slotViewContextMenuRequested(const QPointF
& pos
)
832 emit
requestContextMenu(pos
.toPoint(), KFileItem(), url(), QList
<QAction
*>());
835 void DolphinView::slotHeaderContextMenuRequested(const QPointF
& pos
)
837 ViewProperties
props(viewPropertiesUrl());
839 QPointer
<KMenu
> menu
= new KMenu(QApplication::activeWindow());
841 KItemListView
* view
= m_container
->controller()->view();
842 const QSet
<QByteArray
> visibleRolesSet
= view
->visibleRoles().toSet();
844 bool nepomukRunning
= false;
845 bool indexingEnabled
= false;
847 nepomukRunning
= (Nepomuk2::ResourceManager::instance()->initialized());
848 if (nepomukRunning
) {
849 KConfig
config("nepomukserverrc");
850 indexingEnabled
= config
.group("Service-nepomukfileindexer").readEntry("autostart", false);
855 QMenu
* groupMenu
= 0;
857 // Add all roles to the menu that can be shown or hidden by the user
858 const QList
<KFileItemModel::RoleInfo
> rolesInfo
= KFileItemModel::rolesInformation();
859 foreach (const KFileItemModel::RoleInfo
& info
, rolesInfo
) {
860 if (info
.role
== "text") {
861 // It should not be possible to hide the "text" role
865 const QString text
= m_model
->roleDescription(info
.role
);
867 if (info
.group
.isEmpty()) {
868 action
= menu
->addAction(text
);
870 if (!groupMenu
|| info
.group
!= groupName
) {
871 groupName
= info
.group
;
872 groupMenu
= menu
->addMenu(groupName
);
875 action
= groupMenu
->addAction(text
);
878 action
->setCheckable(true);
879 action
->setChecked(visibleRolesSet
.contains(info
.role
));
880 action
->setData(info
.role
);
882 const bool enable
= (!info
.requiresNepomuk
&& !info
.requiresIndexer
) ||
883 (info
.requiresNepomuk
&& nepomukRunning
) ||
884 (info
.requiresIndexer
&& indexingEnabled
);
885 action
->setEnabled(enable
);
888 menu
->addSeparator();
890 QActionGroup
* widthsGroup
= new QActionGroup(menu
);
891 const bool autoColumnWidths
= props
.headerColumnWidths().isEmpty();
893 QAction
* autoAdjustWidthsAction
= menu
->addAction(i18nc("@action:inmenu", "Automatic Column Widths"));
894 autoAdjustWidthsAction
->setCheckable(true);
895 autoAdjustWidthsAction
->setChecked(autoColumnWidths
);
896 autoAdjustWidthsAction
->setActionGroup(widthsGroup
);
898 QAction
* customWidthsAction
= menu
->addAction(i18nc("@action:inmenu", "Custom Column Widths"));
899 customWidthsAction
->setCheckable(true);
900 customWidthsAction
->setChecked(!autoColumnWidths
);
901 customWidthsAction
->setActionGroup(widthsGroup
);
903 QAction
* action
= menu
->exec(pos
.toPoint());
904 if (menu
&& action
) {
905 KItemListHeader
* header
= view
->header();
907 if (action
== autoAdjustWidthsAction
) {
908 // Clear the column-widths from the viewproperties and turn on
909 // the automatic resizing of the columns
910 props
.setHeaderColumnWidths(QList
<int>());
911 header
->setAutomaticColumnResizing(true);
912 } else if (action
== customWidthsAction
) {
913 // Apply the current column-widths as custom column-widths and turn
914 // off the automatic resizing of the columns
915 QList
<int> columnWidths
;
916 foreach (const QByteArray
& role
, view
->visibleRoles()) {
917 columnWidths
.append(header
->columnWidth(role
));
919 props
.setHeaderColumnWidths(columnWidths
);
920 header
->setAutomaticColumnResizing(false);
922 // Show or hide the selected role
923 const QByteArray selectedRole
= action
->data().toByteArray();
925 QList
<QByteArray
> visibleRoles
= view
->visibleRoles();
926 if (action
->isChecked()) {
927 visibleRoles
.append(selectedRole
);
929 visibleRoles
.removeOne(selectedRole
);
932 view
->setVisibleRoles(visibleRoles
);
933 props
.setVisibleRoles(visibleRoles
);
935 QList
<int> columnWidths
;
936 if (!header
->automaticColumnResizing()) {
937 foreach (const QByteArray
& role
, view
->visibleRoles()) {
938 columnWidths
.append(header
->columnWidth(role
));
941 props
.setHeaderColumnWidths(columnWidths
);
948 void DolphinView::slotHeaderColumnWidthChanged(const QByteArray
& role
, qreal current
, qreal previous
)
952 const QList
<QByteArray
> visibleRoles
= m_view
->visibleRoles();
954 ViewProperties
props(viewPropertiesUrl());
955 QList
<int> columnWidths
= props
.headerColumnWidths();
956 if (columnWidths
.count() != visibleRoles
.count()) {
957 columnWidths
.clear();
958 columnWidths
.reserve(visibleRoles
.count());
959 const KItemListHeader
* header
= m_view
->header();
960 foreach (const QByteArray
& role
, visibleRoles
) {
961 const int width
= header
->columnWidth(role
);
962 columnWidths
.append(width
);
966 const int roleIndex
= visibleRoles
.indexOf(role
);
967 Q_ASSERT(roleIndex
>= 0 && roleIndex
< columnWidths
.count());
968 columnWidths
[roleIndex
] = current
;
970 props
.setHeaderColumnWidths(columnWidths
);
973 void DolphinView::slotItemHovered(int index
)
975 const KFileItem item
= m_model
->fileItem(index
);
977 if (GeneralSettings::showToolTips() && !m_dragging
) {
978 QRectF itemRect
= m_container
->controller()->view()->itemContextRect(index
);
979 const QPoint pos
= m_container
->mapToGlobal(itemRect
.topLeft().toPoint());
980 itemRect
.moveTo(pos
);
982 m_toolTipManager
->showToolTip(item
, itemRect
);
985 emit
requestItemInfo(item
);
988 void DolphinView::slotItemUnhovered(int index
)
992 emit
requestItemInfo(KFileItem());
995 void DolphinView::slotItemDropEvent(int index
, QGraphicsSceneDragDropEvent
* event
)
998 KFileItem destItem
= m_model
->fileItem(index
);
999 if (destItem
.isNull() || (!destItem
.isDir() && !destItem
.isDesktopFile())) {
1000 // Use the URL of the view as drop target if the item is no directory
1002 destItem
= m_model
->rootItem();
1005 // The item represents a directory or desktop-file
1006 destUrl
= destItem
.url();
1009 QDropEvent
dropEvent(event
->pos().toPoint(),
1010 event
->possibleActions(),
1013 event
->modifiers());
1015 const QString error
= DragAndDropHelper::dropUrls(destItem
, destUrl
, &dropEvent
);
1016 if (!error
.isEmpty()) {
1017 emit
errorMessage(error
);
1020 if (destUrl
== url()) {
1021 // Mark the dropped urls as selected.
1022 markPastedUrlsAsSelected(event
->mimeData());
1026 void DolphinView::slotModelChanged(KItemModelBase
* current
, KItemModelBase
* previous
)
1028 if (previous
!= 0) {
1029 disconnect(previous
, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
1030 m_versionControlObserver
->setModel(0);
1034 Q_ASSERT(qobject_cast
<KFileItemModel
*>(current
));
1035 connect(current
, SIGNAL(loadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
1037 KFileItemModel
* fileItemModel
= static_cast<KFileItemModel
*>(current
);
1038 m_versionControlObserver
->setModel(fileItemModel
);
1042 void DolphinView::slotMouseButtonPressed(int itemIndex
, Qt::MouseButtons buttons
)
1046 if (itemIndex
< 0) {
1047 // Trigger the history navigation only when clicking on the viewport:
1048 // Above an item the XButtons provide a simple way to select items in
1049 // the singleClick mode.
1050 if (buttons
& Qt::XButton1
) {
1051 emit
goBackRequested();
1052 } else if (buttons
& Qt::XButton2
) {
1053 emit
goForwardRequested();
1058 void DolphinView::slotSelectionChanged(const QSet
<int>& current
, const QSet
<int>& previous
)
1060 const int currentCount
= current
.count();
1061 const int previousCount
= previous
.count();
1062 const bool selectionStateChanged
= (currentCount
== 0 && previousCount
> 0) ||
1063 (currentCount
> 0 && previousCount
== 0);
1065 // If nothing has been selected before and something got selected (or if something
1066 // was selected before and now nothing is selected) the selectionChangedSignal must
1067 // be emitted asynchronously as fast as possible to update the edit-actions.
1068 m_selectionChangedTimer
->setInterval(selectionStateChanged
? 0 : 300);
1069 m_selectionChangedTimer
->start();
1072 void DolphinView::emitSelectionChangedSignal()
1074 m_selectionChangedTimer
->stop();
1075 emit
selectionChanged(selectedItems());
1078 void DolphinView::updateSortRole(const QByteArray
& role
)
1080 ViewProperties
props(viewPropertiesUrl());
1081 props
.setSortRole(role
);
1083 KItemModelBase
* model
= m_container
->controller()->model();
1084 model
->setSortRole(role
);
1086 emit
sortRoleChanged(role
);
1089 void DolphinView::updateSortOrder(Qt::SortOrder order
)
1091 ViewProperties
props(viewPropertiesUrl());
1092 props
.setSortOrder(order
);
1094 m_model
->setSortOrder(order
);
1096 emit
sortOrderChanged(order
);
1099 void DolphinView::updateSortFoldersFirst(bool foldersFirst
)
1101 ViewProperties
props(viewPropertiesUrl());
1102 props
.setSortFoldersFirst(foldersFirst
);
1104 m_model
->setSortDirectoriesFirst(foldersFirst
);
1106 emit
sortFoldersFirstChanged(foldersFirst
);
1109 QPair
<bool, QString
> DolphinView::pasteInfo() const
1111 return KonqOperations::pasteInfo(url());
1114 void DolphinView::setTabsForFilesEnabled(bool tabsForFiles
)
1116 m_tabsForFiles
= tabsForFiles
;
1119 bool DolphinView::isTabsForFilesEnabled() const
1121 return m_tabsForFiles
;
1124 bool DolphinView::itemsExpandable() const
1126 return m_mode
== DetailsView
;
1129 void DolphinView::restoreState(QDataStream
& stream
)
1131 // Restore the current item that had the keyboard focus
1132 stream
>> m_currentItemUrl
;
1134 // Restore the view position
1135 stream
>> m_restoredContentsPosition
;
1137 // Restore expanded folders (only relevant for the details view - will be ignored by the view in other view modes)
1140 m_model
->restoreExpandedDirectories(urls
);
1143 void DolphinView::saveState(QDataStream
& stream
)
1145 // Save the current item that has the keyboard focus
1146 const int currentIndex
= m_container
->controller()->selectionManager()->currentItem();
1147 if (currentIndex
!= -1) {
1148 KFileItem item
= m_model
->fileItem(currentIndex
);
1149 Q_ASSERT(!item
.isNull()); // If the current index is valid a item must exist
1150 KUrl currentItemUrl
= item
.url();
1151 stream
<< currentItemUrl
;
1156 // Save view position
1157 const qreal x
= m_container
->horizontalScrollBar()->value();
1158 const qreal y
= m_container
->verticalScrollBar()->value();
1159 stream
<< QPoint(x
, y
);
1161 // Save expanded folders (only relevant for the details view - the set will be empty in other view modes)
1162 stream
<< m_model
->expandedDirectories();
1165 KFileItem
DolphinView::rootItem() const
1167 return m_model
->rootItem();
1170 void DolphinView::setViewPropertiesContext(const QString
& context
)
1172 m_viewPropertiesContext
= context
;
1175 QString
DolphinView::viewPropertiesContext() const
1177 return m_viewPropertiesContext
;
1180 void DolphinView::observeCreatedItem(const KUrl
& url
)
1182 markUrlAsCurrent(url
);
1183 markUrlsAsSelected(QList
<KUrl
>() << url
);
1186 void DolphinView::slotDirectoryRedirection(const KUrl
& oldUrl
, const KUrl
& newUrl
)
1188 if (oldUrl
.equals(url(), KUrl::CompareWithoutTrailingSlash
)) {
1189 emit
redirection(oldUrl
, newUrl
);
1190 m_url
= newUrl
; // #186947
1194 void DolphinView::updateViewState()
1196 if (m_currentItemUrl
!= KUrl()) {
1197 KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
1198 const int currentIndex
= m_model
->index(m_currentItemUrl
);
1199 if (currentIndex
!= -1) {
1200 selectionManager
->setCurrentItem(currentIndex
);
1202 // scroll to current item and reset the state
1203 if (m_scrollToCurrentItem
) {
1204 m_view
->scrollToItem(currentIndex
);
1205 m_scrollToCurrentItem
= false;
1208 selectionManager
->setCurrentItem(0);
1210 m_currentItemUrl
= KUrl();
1213 if (!m_restoredContentsPosition
.isNull()) {
1214 const int x
= m_restoredContentsPosition
.x();
1215 const int y
= m_restoredContentsPosition
.y();
1216 m_restoredContentsPosition
= QPoint();
1218 m_container
->horizontalScrollBar()->setValue(x
);
1219 m_container
->verticalScrollBar()->setValue(y
);
1222 if (!m_selectedUrls
.isEmpty()) {
1225 KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
1226 QSet
<int> selectedItems
= selectionManager
->selectedItems();
1228 foreach (const KUrl
& url
, m_selectedUrls
) {
1229 const int index
= m_model
->index(url
);
1231 selectedItems
.insert(index
);
1235 selectionManager
->setSelectedItems(selectedItems
);
1236 m_selectedUrls
.clear();
1240 void DolphinView::hideToolTip()
1242 if (GeneralSettings::showToolTips()) {
1243 m_toolTipManager
->hideToolTip();
1247 void DolphinView::calculateItemCount(int& fileCount
,
1249 KIO::filesize_t
& totalFileSize
) const
1251 const int itemCount
= m_model
->count();
1252 for (int i
= 0; i
< itemCount
; ++i
) {
1253 const KFileItem item
= m_model
->fileItem(i
);
1258 totalFileSize
+= item
.size();
1263 void DolphinView::showHoverInformation(const KFileItem
& item
)
1265 emit
requestItemInfo(item
);
1268 void DolphinView::clearHoverInformation()
1270 emit
requestItemInfo(KFileItem());
1273 void DolphinView::slotDeleteFileFinished(KJob
* job
)
1275 if (job
->error() == 0) {
1276 emit
operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
1277 } else if (job
->error() != KIO::ERR_USER_CANCELED
) {
1278 emit
errorMessage(job
->errorString());
1282 void DolphinView::slotDirectoryLoadingStarted()
1284 // Disable the writestate temporary until it can be determined in a fast way
1285 // in DolphinView::slotLoadingCompleted()
1286 if (m_isFolderWritable
) {
1287 m_isFolderWritable
= false;
1288 emit
writeStateChanged(m_isFolderWritable
);
1291 emit
directoryLoadingStarted();
1294 void DolphinView::slotDirectoryLoadingCompleted()
1296 // Update the view-state. This has to be done asynchronously
1297 // because the view might not be in its final state yet.
1298 QTimer::singleShot(0, this, SLOT(updateViewState()));
1300 emit
directoryLoadingCompleted();
1302 updateWritableState();
1305 void DolphinView::slotItemsChanged()
1307 m_assureVisibleCurrentIndex
= false;
1310 void DolphinView::slotSortOrderChangedByHeader(Qt::SortOrder current
, Qt::SortOrder previous
)
1313 Q_ASSERT(m_model
->sortOrder() == current
);
1315 ViewProperties
props(viewPropertiesUrl());
1316 props
.setSortOrder(current
);
1318 emit
sortOrderChanged(current
);
1321 void DolphinView::slotSortRoleChangedByHeader(const QByteArray
& current
, const QByteArray
& previous
)
1324 Q_ASSERT(m_model
->sortRole() == current
);
1326 ViewProperties
props(viewPropertiesUrl());
1327 props
.setSortRole(current
);
1329 emit
sortRoleChanged(current
);
1332 void DolphinView::slotVisibleRolesChangedByHeader(const QList
<QByteArray
>& current
,
1333 const QList
<QByteArray
>& previous
)
1336 Q_ASSERT(m_container
->controller()->view()->visibleRoles() == current
);
1338 const QList
<QByteArray
> previousVisibleRoles
= m_visibleRoles
;
1340 m_visibleRoles
= current
;
1342 ViewProperties
props(viewPropertiesUrl());
1343 props
.setVisibleRoles(m_visibleRoles
);
1345 emit
visibleRolesChanged(m_visibleRoles
, previousVisibleRoles
);
1348 void DolphinView::slotRoleEditingFinished(int index
, const QByteArray
& role
, const QVariant
& value
)
1350 if (index
< 0 || index
>= m_model
->count()) {
1354 if (role
== "text") {
1355 const KFileItem oldItem
= m_model
->fileItem(index
);
1356 const QString newName
= value
.toString();
1357 if (!newName
.isEmpty() && newName
!= oldItem
.text() && newName
!= QLatin1String(".") && newName
!= QLatin1String("..")) {
1358 const KUrl oldUrl
= oldItem
.url();
1360 QHash
<QByteArray
, QVariant
> data
;
1361 data
.insert(role
, value
);
1362 m_model
->setData(index
, data
);
1364 KonqOperations::rename(this, oldUrl
, newName
);
1369 void DolphinView::loadDirectory(const KUrl
& url
, bool reload
)
1371 if (!url
.isValid()) {
1372 const QString
location(url
.pathOrUrl());
1373 if (location
.isEmpty()) {
1374 emit
errorMessage(i18nc("@info:status", "The location is empty."));
1376 emit
errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location
));
1382 m_model
->refreshDirectory(url
);
1384 m_model
->loadDirectory(url
);
1388 void DolphinView::applyViewProperties()
1390 m_view
->beginTransaction();
1392 const ViewProperties
props(viewPropertiesUrl());
1394 const Mode mode
= props
.viewMode();
1395 if (m_mode
!= mode
) {
1396 const Mode previousMode
= m_mode
;
1399 // Changing the mode might result in changing
1400 // the zoom level. Remember the old zoom level so
1401 // that zoomLevelChanged() can get emitted.
1402 const int oldZoomLevel
= m_view
->zoomLevel();
1405 emit
modeChanged(m_mode
, previousMode
);
1407 if (m_view
->zoomLevel() != oldZoomLevel
) {
1408 emit
zoomLevelChanged(m_view
->zoomLevel(), oldZoomLevel
);
1412 const bool hiddenFilesShown
= props
.hiddenFilesShown();
1413 if (hiddenFilesShown
!= m_model
->showHiddenFiles()) {
1414 m_model
->setShowHiddenFiles(hiddenFilesShown
);
1415 emit
hiddenFilesShownChanged(hiddenFilesShown
);
1418 const bool groupedSorting
= props
.groupedSorting();
1419 if (groupedSorting
!= m_model
->groupedSorting()) {
1420 m_model
->setGroupedSorting(groupedSorting
);
1421 emit
groupedSortingChanged(groupedSorting
);
1424 const QByteArray sortRole
= props
.sortRole();
1425 if (sortRole
!= m_model
->sortRole()) {
1426 m_model
->setSortRole(sortRole
);
1427 emit
sortRoleChanged(sortRole
);
1430 const Qt::SortOrder sortOrder
= props
.sortOrder();
1431 if (sortOrder
!= m_model
->sortOrder()) {
1432 m_model
->setSortOrder(sortOrder
);
1433 emit
sortOrderChanged(sortOrder
);
1436 const bool sortFoldersFirst
= props
.sortFoldersFirst();
1437 if (sortFoldersFirst
!= m_model
->sortDirectoriesFirst()) {
1438 m_model
->setSortDirectoriesFirst(sortFoldersFirst
);
1439 emit
sortFoldersFirstChanged(sortFoldersFirst
);
1442 const QList
<QByteArray
> visibleRoles
= props
.visibleRoles();
1443 if (visibleRoles
!= m_visibleRoles
) {
1444 const QList
<QByteArray
> previousVisibleRoles
= m_visibleRoles
;
1445 m_visibleRoles
= visibleRoles
;
1446 m_view
->setVisibleRoles(visibleRoles
);
1447 emit
visibleRolesChanged(m_visibleRoles
, previousVisibleRoles
);
1450 const bool previewsShown
= props
.previewsShown();
1451 if (previewsShown
!= m_view
->previewsShown()) {
1452 const int oldZoomLevel
= zoomLevel();
1454 m_view
->setPreviewsShown(previewsShown
);
1455 emit
previewsShownChanged(previewsShown
);
1457 // Changing the preview-state might result in a changed zoom-level
1458 if (oldZoomLevel
!= zoomLevel()) {
1459 emit
zoomLevelChanged(zoomLevel(), oldZoomLevel
);
1463 KItemListView
* itemListView
= m_container
->controller()->view();
1464 if (itemListView
->isHeaderVisible()) {
1465 KItemListHeader
* header
= itemListView
->header();
1466 const QList
<int> headerColumnWidths
= props
.headerColumnWidths();
1467 const int rolesCount
= m_visibleRoles
.count();
1468 if (headerColumnWidths
.count() == rolesCount
) {
1469 header
->setAutomaticColumnResizing(false);
1471 QHash
<QByteArray
, qreal
> columnWidths
;
1472 for (int i
= 0; i
< rolesCount
; ++i
) {
1473 columnWidths
.insert(m_visibleRoles
[i
], headerColumnWidths
[i
]);
1475 header
->setColumnWidths(columnWidths
);
1477 header
->setAutomaticColumnResizing(true);
1481 m_view
->endTransaction();
1484 void DolphinView::applyModeToView()
1487 case IconsView
: m_view
->setItemLayout(KFileItemListView::IconsLayout
); break;
1488 case CompactView
: m_view
->setItemLayout(KFileItemListView::CompactLayout
); break;
1489 case DetailsView
: m_view
->setItemLayout(KFileItemListView::DetailsLayout
); break;
1490 default: Q_ASSERT(false); break;
1494 void DolphinView::pasteToUrl(const KUrl
& url
)
1496 markPastedUrlsAsSelected(QApplication::clipboard()->mimeData());
1497 KonqOperations::doPaste(this, url
);
1500 KUrl::List
DolphinView::simplifiedSelectedUrls() const
1504 const KFileItemList items
= selectedItems();
1505 foreach (const KFileItem
& item
, items
) {
1506 urls
.append(item
.url());
1509 if (itemsExpandable()) {
1510 // TODO: Check if we still need KDirModel for this in KDE 5.0
1511 urls
= KDirModel::simplifiedUrlList(urls
);
1517 QMimeData
* DolphinView::selectionMimeData() const
1519 const KItemListSelectionManager
* selectionManager
= m_container
->controller()->selectionManager();
1520 const QSet
<int> selectedIndexes
= selectionManager
->selectedItems();
1522 return m_model
->createMimeData(selectedIndexes
);
1525 void DolphinView::markPastedUrlsAsSelected(const QMimeData
* mimeData
)
1527 const KUrl::List sourceUrls
= KUrl::List::fromMimeData(mimeData
);
1528 KUrl::List destUrls
;
1529 foreach (const KUrl
& source
, sourceUrls
) {
1530 KUrl
destination(url().url() + '/' + source
.fileName());
1531 destUrls
<< destination
;
1533 markUrlsAsSelected(destUrls
);
1536 void DolphinView::updateWritableState()
1538 const bool wasFolderWritable
= m_isFolderWritable
;
1539 m_isFolderWritable
= true;
1541 const KFileItem item
= m_model
->rootItem();
1542 if (!item
.isNull()) {
1543 KFileItemListProperties
capabilities(KFileItemList() << item
);
1544 m_isFolderWritable
= capabilities
.supportsWriting();
1546 if (m_isFolderWritable
!= wasFolderWritable
) {
1547 emit
writeStateChanged(m_isFolderWritable
);
1551 KUrl
DolphinView::viewPropertiesUrl() const
1553 if (m_viewPropertiesContext
.isEmpty()) {
1558 url
.setProtocol(m_url
.protocol());
1559 url
.setPath(m_viewPropertiesContext
);
1563 #include "dolphinview.moc"