#include "dolphinview.h"
#include "dolphinmodel.h"
+#include <konq_fileitemcapabilities.h>
#include <konq_operations.h>
#include <kaboutdata.h>
this, SLOT(slotRequestItemInfo(KFileItem)));
connect(m_view, SIGNAL(urlChanged(KUrl)),
this, SLOT(slotUrlChanged(KUrl)));
+ connect(m_view, SIGNAL(requestUrlChange(KUrl)),
+ this, SLOT(slotRequestUrlChange(KUrl)));
connect(m_view, SIGNAL(modeChanged()),
this, SIGNAL(viewModeChanged())); // relay signal
void DolphinPart::slotSelectionChanged(const KFileItemList& selection)
{
const bool hasSelection = !selection.isEmpty();
+
+ QAction* renameAction = actionCollection()->action("rename");
+ QAction* moveToTrashAction = actionCollection()->action("move_to_trash");
+ QAction* deleteAction = actionCollection()->action("delete");
+ QAction* editMimeTypeAction = actionCollection()->action("editMimeType");
+ QAction* propertiesAction = actionCollection()->action("properties");
+
if (!hasSelection) {
stateChanged("has_no_selection");
+
+ emit m_extension->enableAction("cut", false);
+ emit m_extension->enableAction("copy", false);
+ renameAction->setEnabled(false);
+ moveToTrashAction->setEnabled(false);
+ deleteAction->setEnabled(false);
+ editMimeTypeAction->setEnabled(false);
+ propertiesAction->setEnabled(false);
} else {
stateChanged("has_selection");
- }
- QStringList actions;
- actions << "rename" << "move_to_trash" << "delete" << "editMimeType" << "properties";
- foreach(const QString& actionName, actions) {
- QAction* action = actionCollection()->action(actionName);
- Q_ASSERT(action);
- if (action) {
- action->setEnabled(hasSelection);
- }
+ KonqFileItemCapabilities capabilities(selection);
+ const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving();
+
+ renameAction->setEnabled(capabilities.supportsMoving());
+ moveToTrashAction->setEnabled(enableMoveToTrash);
+ deleteAction->setEnabled(capabilities.supportsDeleting());
+ editMimeTypeAction->setEnabled(true);
+ propertiesAction->setEnabled(true);
+ emit m_extension->enableAction("cut", capabilities.supportsMoving());
+ emit m_extension->enableAction("copy", true);
}
-
- emit m_extension->enableAction("cut", hasSelection);
- emit m_extension->enableAction("copy", hasSelection);
}
void DolphinPart::updatePasteAction()
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 && item.isLocalFile() )
addTrash = true;
- /* TODO if ( sDeleting ) */ {
+ if ( sDeleting ) {
if ( !item.isLocalFile() )
addDel = true;
else if (QApplication::keyboardModifiers() & Qt::ShiftModifier) {
}
void DolphinPart::slotUrlChanged(const KUrl& url)
+{
+ QString prettyUrl = url.pathOrUrl();
+ emit m_extension->setLocationBarUrl(prettyUrl);
+}
+
+void DolphinPart::slotRequestUrlChange(const KUrl& url)
{
if (m_view->url() != url) {
// If the view URL is not equal to 'url', then an inner URL change has