#include "dolphinsettingsdialog.h"
#include "dolphinstatusbar.h"
#include "dolphinviewcontainer.h"
+#include "fileitemcapabilities.h"
#include "infosidebarpage.h"
#include "metadatawidget.h"
#include "mainwindowadaptor.h"
void DolphinMainWindow::updatePasteAction()
{
QAction* pasteAction = actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
- if (pasteAction == 0) {
- return;
- }
-
QPair<bool, QString> pasteInfo = m_activeViewContainer->view()->pasteInfo();
pasteAction->setEnabled(pasteInfo.first);
pasteAction->setText(pasteInfo.second);
QAction* selectedAction = menu.exec(pos);
if (selectedAction == newTabAction) {
const ViewTab& tab = m_viewTab[index];
- const KUrl url = tab.primaryView->isActive() ? tab.primaryView->url() :
- tab.secondaryView->url();
+ Q_ASSERT(tab.primaryView != 0);
+ const KUrl url = (tab.secondaryView != 0) && tab.secondaryView->isActive() ?
+ tab.secondaryView->url() : tab.primaryView->url();
openNewTab(url);
m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
} else if (selectedAction == closeOtherTabsAction) {
} else {
stateChanged("has_selection");
- QAction* renameAction = actionCollection()->action("rename");
- if (renameAction != 0) {
- renameAction->setEnabled(true);
- }
-
- bool enableMoveToTrash = true;
-
- KFileItemList::const_iterator it = list.begin();
- const KFileItemList::const_iterator end = list.end();
- while (it != end) {
- const KUrl& url = (*it).url();
- // only enable the 'Move to Trash' action for local files
- if (!url.isLocalFile()) {
- enableMoveToTrash = false;
- }
- ++it;
- }
-
- QAction* moveToTrashAction = actionCollection()->action("move_to_trash");
- moveToTrashAction->setEnabled(enableMoveToTrash);
+ FileItemCapabilities capabilities(list);
+ actionCollection()->action("rename")->setEnabled(capabilities.supportsMoving());
+ const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving();
+ actionCollection()->action("move_to_trash")->setEnabled(enableMoveToTrash);
+ actionCollection()->action("delete")->setEnabled(capabilities.supportsDeleting());
}
updatePasteAction();
}