From: asl Date: Thu, 18 Mar 2010 10:26:35 +0000 (+0000) Subject: implementation of copy/paste mechanism allowing the active module to use own copy... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=773cdd179a0bf7b59fe1e79496b498e51fb2922e;p=modules%2Fgui.git implementation of copy/paste mechanism allowing the active module to use own copy/paste implementation --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 13075b408..e66cf34c3 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -27,11 +27,14 @@ // E.A. : On windows with python 2.6, there is a conflict // E.A. : between pymath.h and Standard_math.h which define // E.A. : some same symbols : acosh, asinh, ... -#include -#include + #include + #ifndef DISABLE_PYCONSOLE + #include + #endif #endif #ifndef DISABLE_PYCONSOLE + #include "LightApp_PyInterp.h" // WARNING! This include must be the first! #include #endif @@ -1015,6 +1018,12 @@ void LightApp_Application::onHelpContextModule( const QString& theComponentName, */ void LightApp_Application::onSelectionChanged() { + LightApp_Module* m = dynamic_cast( activeModule() ); + bool canCopy = m ? m->canCopy() : false; + bool canPaste = m ? m->canPaste() : false; + + action( EditCopyId )->setEnabled(canCopy); + action( EditPasteId )->setEnabled(canPaste); } /*! @@ -3250,3 +3259,23 @@ void LightApp_Application::clearKnownViewManagers() removeViewManager(aMgr); } } + +/*! + Copy of current selection + */ +void LightApp_Application::onCopy() +{ + LightApp_Module* m = dynamic_cast( activeModule() ); + if( m ) + m->copy(); +} + +/*! + Paste of current data in clipboard + */ +void LightApp_Application::onPaste() +{ + LightApp_Module* m = dynamic_cast( activeModule() ); + if( m ) + m->paste(); +} diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index 27d0852af..8a6911a2d 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -167,6 +167,9 @@ public slots: virtual void onOpenDoc(); virtual void onHelpAbout(); virtual bool onOpenDoc( const QString& ); + virtual void onCopy(); + virtual void onPaste(); + virtual void onSelectionChanged(); protected: virtual void createActions(); @@ -181,7 +184,6 @@ protected: virtual void setActiveStudy( SUIT_Study* ); virtual void updateCommandsStatus(); - virtual void onSelectionChanged(); virtual void beforeCloseDoc( SUIT_Study* ); virtual void afterCloseDoc(); diff --git a/src/LightApp/LightApp_Module.cxx b/src/LightApp/LightApp_Module.cxx index 228234513..46d4b48da 100644 --- a/src/LightApp/LightApp_Module.cxx +++ b/src/LightApp/LightApp_Module.cxx @@ -649,3 +649,37 @@ bool LightApp_Module::reusableOperation( const int id ) { return true; } + +/*! + virtual method + \return true if module can copy the current selection +*/ +bool LightApp_Module::canCopy() const +{ + return false; +} + +/*! + virtual method + \return true if module can paste previously copied data +*/ +bool LightApp_Module::canPaste() const +{ + return false; +} + +/*! + virtual method + \brief Copies the current selection into clipboard +*/ +void LightApp_Module::copy() +{ +} + +/*! + virtual method + \brief Pastes the current data in the clipboard +*/ +void LightApp_Module::paste() +{ +} diff --git a/src/LightApp/LightApp_Module.h b/src/LightApp/LightApp_Module.h index c608497e5..971586ad2 100644 --- a/src/LightApp/LightApp_Module.h +++ b/src/LightApp/LightApp_Module.h @@ -92,6 +92,11 @@ public: virtual LightApp_Displayer* displayer(); virtual LightApp_Selection* createSelection() const; + virtual bool canCopy() const; + virtual bool canPaste() const; + virtual void copy(); + virtual void paste(); + public slots: virtual bool activateModule( SUIT_Study* ); virtual bool deactivateModule( SUIT_Study* );