#include <kdirlister.h>
#include <kiconeffect.h>
#include <kfileitem.h>
+#include <kfileitemlistproperties.h>
#include <klocale.h>
#include <kio/deletejob.h>
#include <kio/netaccess.h>
m_tabsForFiles(false),
m_isContextMenuOpen(false),
m_assureVisibleCurrentIndex(false),
+ m_expanderActive(false),
+ m_isFolderWritable(true),
m_mode(DolphinView::IconsView),
m_topLayout(0),
m_dolphinViewController(0),
connect(m_dolphinViewController, SIGNAL(viewportEntered()),
this, SLOT(clearHoverInformation()));
connect(m_dolphinViewController, SIGNAL(urlChangeRequested(KUrl)),
- m_viewModeController, SLOT(setUrl(KUrl)));
+ this, SLOT(slotUrlChangeRequested(KUrl)));
// When a new item has been created by the "Create New..." menu, the item should
// get selected and it must be assured that the item will get visible. As the
m_active = active;
QColor color = KColorScheme(QPalette::Active, KColorScheme::View).background().color();
- if (active) {
- emitSelectionChangedSignal();
- } else {
+ if (!active) {
color.setAlpha(150);
}
if (active) {
m_viewAccessor.itemView()->setFocus();
emit activated();
+ emitSelectionChangedSignal();
+ emit writeStateChanged(m_isFolderWritable);
}
m_viewModeController->indicateActivationChange(active);
m_createdItemUrl = KUrl();
}
+void DolphinView::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl)
+{
+ if (oldUrl.equals(url(), KUrl::CompareWithoutTrailingSlash)) {
+ emit redirection(oldUrl, newUrl);
+ m_viewModeController->redirectToUrl(newUrl); // #186947
+ }
+}
+
+void DolphinView::restoreContentsPosition()
+{
+ if (!m_restoredContentsPosition.isNull()) {
+ const int x = m_restoredContentsPosition.x();
+ const int y = m_restoredContentsPosition.y();
+ m_restoredContentsPosition = QPoint();
+
+ QAbstractItemView* view = m_viewAccessor.itemView();
+ Q_ASSERT(view != 0);
+ view->horizontalScrollBar()->setValue(x);
+ view->verticalScrollBar()->setValue(y);
+ }
+}
+
+void DolphinView::slotUrlChangeRequested(const KUrl& url)
+{
+ m_viewModeController->setUrl(url);
+ updateWritableState();
+}
+
void DolphinView::showHoverInformation(const KFileItem& item)
{
emit requestItemInfo(item);
}
}
+void DolphinView::slotDirListerStarted(const KUrl& url)
+{
+ // Disable the writestate temporary until it can be determined in a fast way
+ // in DolphinView::slotDirListerCompleted()
+ if (m_isFolderWritable) {
+ m_isFolderWritable = false;
+ emit writeStateChanged(m_isFolderWritable);
+ }
+
+ emit startedPathLoading(url);
+}
+
void DolphinView::slotDirListerCompleted()
{
if (!m_expanderActive) {
m_newFileNames.clear();
}
+
+ updateWritableState();
}
void DolphinView::slotLoadingCompleted()
connect(dirLister, SIGNAL(redirection(KUrl,KUrl)),
this, SLOT(slotRedirection(KUrl,KUrl)));
connect(dirLister, SIGNAL(started(KUrl)),
- this, SIGNAL(startedPathLoading(KUrl)));
+ this, SLOT(slotDirListerStarted(KUrl)));
connect(dirLister, SIGNAL(completed()),
this, SLOT(slotDirListerCompleted()));
connect(dirLister, SIGNAL(refreshItems(const QList<QPair<KFileItem,KFileItem>>&)),
disconnect(dirLister, SIGNAL(redirection(KUrl,KUrl)),
this, SLOT(slotRedirection(KUrl,KUrl)));
disconnect(dirLister, SIGNAL(started(KUrl)),
- this, SIGNAL(startedPathLoading(KUrl)));
+ this, SLOT(slotDirListerStarted(KUrl)));
disconnect(dirLister, SIGNAL(completed()),
this, SLOT(slotDirListerCompleted()));
disconnect(dirLister, SIGNAL(refreshItems(const QList<QPair<KFileItem,KFileItem>>&)),
this, SLOT(slotSelectionChanged(QItemSelection, QItemSelection)));
}
+void DolphinView::updateWritableState()
+{
+ const bool wasFolderWritable = m_isFolderWritable;
+ m_isFolderWritable = true;
+
+ const KFileItem item = m_viewAccessor.dirLister()->rootItem();
+ if (!item.isNull()) {
+ KFileItemListProperties capabilities(KFileItemList() << item);
+ m_isFolderWritable = capabilities.supportsWriting();
+ }
+ if (m_isFolderWritable != wasFolderWritable) {
+ emit writeStateChanged(m_isFolderWritable);
+ }
+}
+
DolphinView::ViewAccessor::ViewAccessor(DolphinSortFilterProxyModel* proxyModel) :
m_rootUrl(),
m_iconsView(0),
return dirModel()->dirLister();
}
-void DolphinView::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl)
-{
- if (oldUrl.equals(url(), KUrl::CompareWithoutTrailingSlash)) {
- emit redirection(oldUrl, newUrl);
- m_viewModeController->redirectToUrl(newUrl); // #186947
- }
-}
-
-void DolphinView::restoreContentsPosition()
-{
- if (!m_restoredContentsPosition.isNull()) {
- const int x = m_restoredContentsPosition.x();
- const int y = m_restoredContentsPosition.y();
- m_restoredContentsPosition = QPoint();
-
- QAbstractItemView* view = m_viewAccessor.itemView();
- Q_ASSERT(view != 0);
- view->horizontalScrollBar()->setValue(x);
- view->verticalScrollBar()->setValue(y);
- }
-}
-
#include "dolphinview.moc"