mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
Fix dolphinpart context menu so that the delete/rename/send to trash options are disabled when the directory containing the selected files/dirs is not writable.
CCBUGS: 161594 Issues remaining: Send to trash should be disabled on remote files (and replaced with delete) and edit menu of konqueror still has the actions like cut/delete/rename always enabled. svn path=/trunk/KDE/kdebase/apps/; revision=815517
This commit is contained in:
parent
32298bba66
commit
df7c2385ec
1 changed files with 19 additions and 9 deletions
|
@ -297,34 +297,44 @@ void DolphinPart::slotOpenContextMenu(const KFileItem& _item, const KUrl&)
|
|||
KParts::BrowserExtension::PopupFlags popupFlags = KParts::BrowserExtension::DefaultPopupItems
|
||||
| KParts::BrowserExtension::ShowProperties
|
||||
| KParts::BrowserExtension::ShowUrlOperations;
|
||||
// TODO KonqKfmIconView had if ( !rootItem->isWritable() )
|
||||
// popupFlags |= KParts::BrowserExtension::NoDeletion;
|
||||
|
||||
KFileItem item(_item);
|
||||
|
||||
if (item.isNull()) { // viewport context menu
|
||||
popupFlags |= KParts::BrowserExtension::ShowNavigationItems | KParts::BrowserExtension::ShowUp;
|
||||
// TODO get m_dirLister->rootItem if possible. or via kdirmodel?
|
||||
// and use this as fallback:
|
||||
item = KFileItem( S_IFDIR, (mode_t)-1, url() );
|
||||
item = m_dirLister->rootItem();
|
||||
if (item.isNull())
|
||||
item = KFileItem( S_IFDIR, (mode_t)-1, url() );
|
||||
}
|
||||
|
||||
KParts::BrowserExtension::ActionGroupMap actionGroups;
|
||||
QList<QAction *> editActions;
|
||||
|
||||
if (!_item.isNull()) { // only for context menu on one or more items
|
||||
// TODO if ( sMoving )
|
||||
editActions.append(actionCollection()->action("rename"));
|
||||
bool sDeleting = true;
|
||||
bool sMoving = true;
|
||||
|
||||
// If the parent directory of the selected item is writable, moving
|
||||
// and deleting are possible.
|
||||
KFileItem parentDir = m_dirLister->rootItem();
|
||||
if (!parentDir.isWritable()) {
|
||||
popupFlags |= KParts::BrowserExtension::NoDeletion;
|
||||
sDeleting = false;
|
||||
sMoving = false;
|
||||
}
|
||||
|
||||
if ( sMoving )
|
||||
editActions.append(actionCollection()->action("rename"));
|
||||
|
||||
bool addTrash = false;
|
||||
bool addDel = false;
|
||||
|
||||
bool isIntoTrash = _item.url().protocol() == "trash";
|
||||
|
||||
if ( /*TODO sMoving &&*/ !isIntoTrash )
|
||||
if ( sMoving && !isIntoTrash )
|
||||
addTrash = true;
|
||||
|
||||
/* TODO if ( sDeleting ) */ {
|
||||
if ( sDeleting ) {
|
||||
if ( !item.isLocalFile() )
|
||||
addDel = true;
|
||||
else if (QApplication::keyboardModifiers() & Qt::ShiftModifier) {
|
||||
|
|
Loading…
Reference in a new issue