X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/da8dc77c53c5cd604645768a1dacc6497cd58838..e8bc9f1072bfc43d7605315c8df69f37bfc71cc3:/src/dolphinpart.cpp diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index f278edddf..a0871ce06 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -18,29 +18,23 @@ */ #include "dolphinpart.h" -#include -#include -#include #include "dolphinsortfilterproxymodel.h" #include "dolphinview.h" #include "dolphinmodel.h" +#include #include #include -#include #include +#include + +#include #include +#include typedef KParts::GenericFactory DolphinPartFactory; K_EXPORT_COMPONENT_FACTORY(dolphinpart, DolphinPartFactory) -class DolphinPartBrowserExtension : public KParts::BrowserExtension -{ -public: - DolphinPartBrowserExtension( KParts::ReadOnlyPart* part ) - : KParts::BrowserExtension( part ) {} -}; - DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringList& args) : KParts::ReadOnlyPart(parent) { @@ -91,6 +85,10 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi connect(m_view, SIGNAL(modeChanged()), this, SLOT(updateViewActions())); + QClipboard* clipboard = QApplication::clipboard(); + connect(clipboard, SIGNAL(dataChanged()), + this, SLOT(updatePasteAction())); + createActions(); updateViewActions(); @@ -107,10 +105,6 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi // TODO MMB-click should do something like KonqDirPart::mmbClicked - // TODO updating the paste action - // if (paste) emit m_extension->setActionText( "paste", actionText ); - // emit m_extension->enableAction( "paste", paste ); - // TODO updating the trash and del actions too - or removing special handling of those from konq? } @@ -137,7 +131,8 @@ void DolphinPart::createActions() void DolphinPart::slotSelectionChanged(const KFileItemList& selection) { // Yes, DolphinMainWindow has very similar code :/ - if (selection.isEmpty()) { + const bool hasSelection = !selection.isEmpty(); + if (!hasSelection) { stateChanged("has_no_selection"); } else { stateChanged("has_selection"); @@ -148,6 +143,15 @@ void DolphinPart::slotSelectionChanged(const KFileItemList& selection) renameAction->setEnabled(true); } } + emit m_extension->enableAction("cut", hasSelection); + emit m_extension->enableAction("copy", hasSelection); +} + +void DolphinPart::updatePasteAction() +{ + QPair pasteInfo = m_view->pasteInfo(); + emit m_extension->enableAction( "paste", pasteInfo.first ); + emit m_extension->setActionText( "paste", pasteInfo.second ); } void DolphinPart::updateViewActions() @@ -274,4 +278,21 @@ void DolphinPart::slotUrlChanged(const KUrl& url) } } +//// + +void DolphinPartBrowserExtension::cut() +{ + m_part->view()->cutSelectedItems(); +} + +void DolphinPartBrowserExtension::copy() +{ + m_part->view()->copySelectedItems(); +} + +void DolphinPartBrowserExtension::paste() +{ + m_part->view()->paste(); +} + #include "dolphinpart.moc"