Always enable the "Create New..." menu if the URL is writable

This commit works around the problem that KDirLister may not provide a
"rootItem" for some kioslaves by setting up a KFileItem with the view
URL and using this to find out if the URL is writable.

BUG: 330001
CCBUG: 330015
REVIEW: 115405
FIXED-IN: 4.12.2
This commit is contained in:
Frank Reininghaus 2014-01-30 22:10:08 +01:00
parent df2179ec6b
commit 900a4ba3b9

View file

@ -1666,11 +1666,16 @@ void DolphinView::updateWritableState()
const bool wasFolderWritable = m_isFolderWritable;
m_isFolderWritable = false;
const KFileItem item = m_model->rootItem();
if (!item.isNull()) {
KFileItemListProperties capabilities(KFileItemList() << item);
m_isFolderWritable = capabilities.supportsWriting();
KFileItem item = m_model->rootItem();
if (item.isNull()) {
// Try to find out if the URL is writable even if the "root item" is
// null, see https://bugs.kde.org/show_bug.cgi?id=330001
item = KFileItem(KFileItem::Unknown, KFileItem::Unknown, url(), true);
}
KFileItemListProperties capabilities(KFileItemList() << item);
m_isFolderWritable = capabilities.supportsWriting();
if (m_isFolderWritable != wasFolderWritable) {
emit writeStateChanged(m_isFolderWritable);
}