diff options
Diffstat (limited to 'src/dolphinpart.cpp')
| -rw-r--r-- | src/dolphinpart.cpp | 53 |
1 files changed, 37 insertions, 16 deletions
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 <kactioncollection.h> -#include <ktoggleaction.h> -#include <QActionGroup> #include "dolphinsortfilterproxymodel.h" #include "dolphinview.h" #include "dolphinmodel.h" +#include <kactioncollection.h> #include <kdirlister.h> #include <kmessagebox.h> -#include <kparts/browserextension.h> #include <kparts/genericfactory.h> +#include <ktoggleaction.h> + +#include <QActionGroup> #include <QApplication> +#include <QClipboard> typedef KParts::GenericFactory<DolphinPart> 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<bool, QString> 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" |
