Salome HOME
refs #416: to store the open state of object browser items in the binary array
[modules/gui.git] / src / LightApp / LightApp_Module.cxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File:      LightApp_Module.cxx
24 // Created:   6/20/2005 16:30:56 AM
25 // Author:    OCC team
26
27 #include "LightApp_Module.h"
28
29 #include "CAM_Application.h"
30
31 #include "LightApp_Application.h"
32 #include "LightApp_DataModel.h"
33 #include "LightApp_DataObject.h"
34 #include "LightApp_Study.h"
35 #include "LightApp_Preferences.h"
36 #include "LightApp_Selection.h"
37 #include "LightApp_Operation.h"
38 #include "LightApp_SwitchOp.h"
39 #include "LightApp_UpdateFlags.h"
40 #include "LightApp_ShowHideOp.h"
41 #include "LightApp_SelectionMgr.h"
42
43 #include <SUIT_Study.h>
44 #include <SUIT_DataObject.h>
45 #include <SUIT_DataBrowser.h>
46 #include <SUIT_Operation.h>
47 #include <SUIT_ViewManager.h>
48 #include <SUIT_ResourceMgr.h>
49 #include <SUIT_ShortcutMgr.h>
50 #include <SUIT_Desktop.h>
51 #include <SUIT_TreeModel.h>
52
53 #ifndef DISABLE_SALOMEOBJECT
54 #include <SALOME_ListIO.hxx>
55 #include <SALOME_ListIteratorOfListIO.hxx>
56 #endif
57
58 #ifndef DISABLE_VTKVIEWER
59 #ifndef DISABLE_SALOMEOBJECT
60   #include <SVTK_ViewWindow.h>
61   #include <SVTK_ViewModel.h>
62 #else
63   #include <VTKViewer_ViewWindow.h>
64 #endif
65   #include <VTKViewer_ViewModel.h>
66 #endif
67 #ifndef DISABLE_OCCVIEWER
68   #include <OCCViewer_ViewWindow.h>
69   #include <OCCViewer_ViewPort3d.h>
70 #ifndef DISABLE_SALOMEOBJECT
71   #include <SOCC_ViewModel.h>
72 #else
73   #include <OCCViewer_ViewModel.h>
74 #endif
75 #endif
76 #ifndef DISABLE_GLVIEWER
77   #include <GLViewer_ViewFrame.h>
78   #include <GLViewer_ViewPort.h>
79 #endif
80 #ifndef DISABLE_PLOT2DVIEWER
81   #include <Plot2d_ViewWindow.h>
82   #include <Plot2d_ViewFrame.h>
83 #ifndef DISABLE_SALOMEOBJECT
84   #include <SPlot2d_ViewModel.h>
85 #else
86   #include <Plot2d_ViewModel.h>
87 #endif
88 #endif
89
90 #include <QtxPopupMgr.h>
91
92 #include <QVariant>
93 #include <QString>
94 #include <QStringList>
95 #include <QAction>
96
97 #include <iostream>
98
99 /*!Constructor.*/
100 LightApp_Module::LightApp_Module( const QString& name )
101 : CAM_Module( name ),
102   myPopupMgr( 0 ),
103   mySwitchOp( 0 ),
104   myDisplay( -1 ),
105   myErase( -1 ),
106   myDisplayOnly( -1 ),
107   myEraseAll( -1 )
108 {
109 }
110
111 /*!Destructor.*/
112 LightApp_Module::~LightApp_Module()
113 {
114   if ( mySwitchOp )
115     delete mySwitchOp;
116 }
117
118 /*!Initialize module.*/
119 void LightApp_Module::initialize( CAM_Application* app )
120 {
121   CAM_Module::initialize( app );
122
123   SUIT_ResourceMgr* resMgr = app ? app->resourceMgr() : 0;
124   if ( resMgr )
125     resMgr->raiseTranslators( name() );
126 }
127
128 /*!NOT IMPLEMENTED*/
129 void LightApp_Module::windows( QMap<int, int>& ) const
130 {
131 }
132
133 /*!NOT IMPLEMENTED*/
134 void LightApp_Module::viewManagers( QStringList& ) const
135 {
136 }
137
138 /*!Context menu popup.*/
139 void LightApp_Module::contextMenuPopup( const QString& client, QMenu* menu, QString& /*title*/ )
140 {
141   LightApp_Selection* sel = createSelection();
142   sel->init( client, getApp()->selectionMgr() );
143
144   popupMgr()->setSelection( sel );
145   popupMgr()->setMenu( menu );
146   popupMgr()->updateMenu();
147 }
148
149 /*!Update object browser.
150  * For updating model or whole object browser use update() method can be used.
151 */
152 void LightApp_Module::updateObjBrowser( bool theIsUpdateDataModel, 
153                                         SUIT_DataObject* theDataObject )
154 {
155   bool upd = getApp()->objectBrowser()->autoUpdate();
156   getApp()->objectBrowser()->setAutoUpdate( false );
157
158   if( theIsUpdateDataModel ){
159     if( CAM_DataModel* aDataModel = dataModel() ){
160       if ( LightApp_DataModel* aModel = dynamic_cast<LightApp_DataModel*>( aDataModel ) ) {
161         //SUIT_DataObject* aParent = NULL;
162         //if(theDataObject && theDataObject != aDataModel->root())
163         //  aParent = theDataObject->parent();
164
165         LightApp_DataObject* anObject = dynamic_cast<LightApp_DataObject*>(theDataObject);
166         LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(getApp()->activeStudy());
167         aModel->update( anObject, aStudy );
168       }
169     }
170   }
171
172   getApp()->objectBrowser()->setAutoUpdate( upd );
173   getApp()->objectBrowser()->updateTree( 0, false );
174 }
175
176 /*!NOT IMPLEMENTED*/
177 void LightApp_Module::selectionChanged()
178 {
179 }
180
181 /*! \brief If return false, selection will be cleared at module activation
182  */
183 bool LightApp_Module::isSelectionCompatible()
184 {
185   // return true if selected objects belong to this module
186   bool isCompatible = true;
187 #ifndef DISABLE_SALOMEOBJECT
188   SALOME_ListIO selected;
189   if ( LightApp_SelectionMgr *Sel = getApp()->selectionMgr() )
190     Sel->selectedObjects( selected );
191
192   LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( getApp()->activeStudy() );
193   LightApp_DataObject* aRoot = dynamic_cast<LightApp_DataObject*>( dataModel()->root() );
194   if ( aStudy && aRoot ) {
195     // my data type
196     QString moduleDataType = aRoot->componentDataType();
197     // check data type of selection
198     SALOME_ListIteratorOfListIO It( selected );
199     for ( ; isCompatible && It.More(); It.Next()) {
200       Handle(SALOME_InteractiveObject)& io = It.Value();
201       isCompatible = ( aStudy->componentDataType( io->getEntry() ) == moduleDataType );
202     }
203   }
204 #endif
205   return isCompatible;
206 }
207
208 /*!Activate module.*/
209 bool LightApp_Module::activateModule( SUIT_Study* study )
210 {
211   bool res = CAM_Module::activateModule( study );
212
213   if ( !isSelectionCompatible() )// PAL19290, PAL18352
214     getApp()->selectionMgr()->clearSelected();
215
216   if ( res && application() && application()->resourceMgr() )
217     application()->resourceMgr()->raiseTranslators( name() );
218
219   connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
220            this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
221   connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
222            this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
223
224   if ( mySwitchOp == 0 )
225     mySwitchOp = new LightApp_SwitchOp( this );
226
227   // Enable Display and Erase actions
228   if ( action(myDisplay) )
229     action(myDisplay)->setEnabled(true);
230   if ( action(myErase) )
231     action(myErase)->setEnabled(true);
232
233   application()->shortcutMgr()->setSectionEnabled( moduleName() );
234
235   /*  BUG 0020498 : The Entry column is always shown at module activation
236       The registration of column is moved into LightApp_Application
237
238   QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
239   LightApp_DataModel* m = dynamic_cast<LightApp_DataModel*>( dataModel() );
240   if( m )
241   {
242     SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
243     m->registerColumn( getApp()->objectBrowser(), EntryCol, LightApp_DataObject::EntryId );
244     treeModel->setAppropriate( EntryCol, Qtx::Toggled );
245   }*/
246   return res;
247 }
248
249 /*!Deactivate module.*/
250 bool LightApp_Module::deactivateModule( SUIT_Study* study )
251 {
252   delete mySwitchOp;
253   mySwitchOp = 0;
254
255   disconnect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
256               this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
257   disconnect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
258               this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
259
260   // abort all operations
261   MapOfOperation::const_iterator anIt;
262   for( anIt = myOperations.begin(); anIt != myOperations.end(); anIt++ ) {
263     anIt.value()->abort();
264   }
265
266   // Disable Display and Erase action
267   if ( action(myDisplay) )
268     action(myDisplay)->setEnabled(false);
269   if ( action(myErase) )
270     action(myErase)->setEnabled(false);
271
272   application()->shortcutMgr()->setSectionEnabled( moduleName(), false );
273   
274   /*  BUG 0020498 : The Entry column is always shown at module activation
275   QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
276   LightApp_DataModel* m = dynamic_cast<LightApp_DataModel*>( dataModel() );
277   if( m )
278   {
279     SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
280
281     treeModel->setAppropriate( EntryCol, Qtx::Shown );
282     m->unregisterColumn( getApp()->objectBrowser(), EntryCol );
283   }
284   */
285   return CAM_Module::deactivateModule( study );
286 }
287
288 /*!NOT IMPLEMENTED*/
289 void LightApp_Module::MenuItem()
290 {
291 }
292
293 /*!NOT IMPLEMENTED*/
294 void LightApp_Module::createPreferences()
295 {
296 }
297
298 /*!NOT IMPLEMENTED*/
299 void LightApp_Module::preferencesChanged( const QString&, const QString& )
300 {
301 }
302
303 /*!NOT IMPLEMENTED*/
304 void LightApp_Module::message( const QString& )
305 {
306 }
307
308 /*!Gets application.*/
309 LightApp_Application* LightApp_Module::getApp() const
310 {
311   return (LightApp_Application*)application();
312 }
313
314 /*!
315  * \brief Update something in accordance with update flags
316  * \param theFlags - update flags
317 *
318 * Update viewer or/and object browser etc. in accordance with update flags ( see
319 * LightApp_UpdateFlags enumeration ). Derived modules can redefine this method for their
320 * own purposes
321 */
322 void LightApp_Module::update( const int theFlags )
323 {
324   if ( theFlags & UF_Model )
325   {
326     if( CAM_DataModel* aDataModel = dataModel() )
327       if( LightApp_DataModel* aModel = dynamic_cast<LightApp_DataModel*>( aDataModel ) )
328         aModel->update( 0, dynamic_cast<LightApp_Study*>( getApp()->activeStudy() ) );
329   }
330
331   if ( theFlags & UF_ObjBrowser )
332     getApp()->objectBrowser()->updateTree( 0 );
333
334   if ( theFlags & UF_Controls )
335     updateControls();
336   if ( theFlags & UF_Viewer )
337   {
338     if ( SUIT_ViewManager* viewMgr = getApp()->activeViewManager() )
339       if ( SUIT_ViewWindow* viewWnd = viewMgr->getActiveView() )
340       {
341 #ifndef DISABLE_VTKVIEWER
342 #ifndef DISABLE_SALOMEOBJECT
343         if ( viewWnd->inherits( "SVTK_ViewWindow" ) )
344           ( (SVTK_ViewWindow*)viewWnd )->Repaint();
345 #else
346         if ( viewWnd->inherits( "VTKViewer_ViewWindow" ) )
347           ( (VTKViewer_ViewWindow*)viewWnd )->Repaint();
348 #endif
349 #endif
350 #ifndef DISABLE_OCCVIEWER
351         if ( viewWnd->inherits( "OCCViewer_ViewWindow" ) )
352           ( (OCCViewer_ViewWindow*)viewWnd )->getViewPort()->onUpdate();
353 #endif
354 #ifndef DISABLE_PLOT2DVIEWER
355         if ( viewWnd->inherits( "Plot2d_ViewWindow" ) )
356           ( (Plot2d_ViewWindow*)viewWnd )->getViewFrame()->Repaint();
357 #endif
358 #ifndef DISABLE_GLVIEWER
359         if ( viewWnd->inherits( "GLViewer_ViewFrame" ) )
360           ( (GLViewer_ViewFrame*)viewWnd )->getViewPort()->onUpdate();
361 #endif
362       }
363   }
364 }
365 /*!
366  * \brief Updates controls
367 *
368 * Updates (i.e. disable/enable) controls states (menus, tool bars etc.). This method is
369 * called from update( UF_Controls ). You may redefine it in concrete module.
370 */
371 void LightApp_Module::updateControls()
372 {
373 }
374
375 /*!Create new instance of data model and return it.*/
376 CAM_DataModel* LightApp_Module::createDataModel()
377 {
378   return new LightApp_DataModel( this );
379 }
380
381 /*!Create and return instance of LightApp_Selection.*/
382 LightApp_Selection* LightApp_Module::createSelection() const
383 {
384   return new LightApp_Selection();
385 }
386
387 /*!NOT IMPLEMENTED*/
388 void LightApp_Module::onModelOpened()
389 {
390 }
391
392 /*!NOT IMPLEMENTED*/
393 void LightApp_Module::onModelSaved()
394 {
395 }
396
397 /*!NOT IMPLEMENTED*/
398 void LightApp_Module::onModelClosed()
399 {
400 }
401
402 /*!Gets popup manager.(create if not exist)*/
403 QtxPopupMgr* LightApp_Module::popupMgr()
404 {
405   if ( !myPopupMgr )
406   {
407     myPopupMgr = new QtxPopupMgr( 0, this );
408
409     QPixmap p;
410     SUIT_Desktop* d = application()->desktop();
411     
412     QAction 
413       *disp = createAction( -1, tr( "TOP_SHOW" ), p, tr( "MEN_SHOW" ), tr( "STB_SHOW" ),
414                             0, d, false, this, SLOT( onShowHide() ), QString("General:Show object(s)") ),
415       *erase = createAction( -1, tr( "TOP_HIDE" ), p, tr( "MEN_HIDE" ), tr( "STB_HIDE" ),
416                              0, d, false, this, SLOT( onShowHide() ) , QString("General:Hide object(s)") ),
417       *dispOnly = createAction( -1, tr( "TOP_DISPLAY_ONLY" ), p, tr( "MEN_DISPLAY_ONLY" ), tr( "STB_DISPLAY_ONLY" ),
418                                 0, d, false, this, SLOT( onShowHide() ) ),
419       *eraseAll = createAction( -1, tr( "TOP_ERASE_ALL" ), p, tr( "MEN_ERASE_ALL" ), tr( "STB_ERASE_ALL" ),
420                                 0, d, false, this, SLOT( onShowHide() ) );
421     myDisplay     = actionId( disp );
422     myErase       = actionId( erase );
423     myDisplayOnly = actionId( dispOnly );
424     myEraseAll    = actionId( eraseAll );
425
426     myPopupMgr->insert( disp, -1, 0 ); 
427     myPopupMgr->insert( erase, -1, 0 );
428     myPopupMgr->insert( dispOnly, -1, 0 );
429     myPopupMgr->insert( eraseAll, -1, 0 );
430     myPopupMgr->insert( separator(), -1, 0 );
431
432     QString oneAndNotActive = "( count( $component ) = 1 ) and ( not( activeModule in $component ) )";
433     QString uniform = "true in $canBeDisplayed and %1 and ( activeModule = '%2' )";
434     uniform = uniform.arg( oneAndNotActive ).arg( name() );
435     myPopupMgr->setRule( disp, /*QString( "( not isVisible ) and " ) + */ uniform, QtxPopupMgr::VisibleRule );
436     myPopupMgr->setRule( erase, /*QString( "( isVisible ) and " ) + */ uniform, QtxPopupMgr::VisibleRule );
437     myPopupMgr->setRule( dispOnly, uniform, QtxPopupMgr::VisibleRule );
438
439     QStringList viewers;
440
441 #ifndef DISABLE_OCCVIEWER
442 #ifndef DISABLE_SALOMEOBJECT
443     viewers.append( SOCC_Viewer::Type() );
444 #else
445     viewers.append( OCCViewer_Viewer::Type() );
446 #endif
447 #endif
448 #ifndef DISABLE_VTKVIEWER
449 #ifndef DISABLE_SALOMEOBJECT
450     viewers.append( SVTK_Viewer::Type() );
451 #else
452     viewers.append( VTKViewer_Viewer::Type() );
453 #endif
454 #endif
455 #ifndef DISABLE_PLOT2DVIEWER
456 #ifndef DISABLE_SALOMEOBJECT
457     viewers.append( SPlot2d_Viewer::Type() );
458 #else
459     viewers.append( Plot2d_Viewer::Type() );
460 #endif
461 #endif
462
463     if( !viewers.isEmpty() )
464     {
465       QString strViewers = "{ ", temp = "'%1' ";
466       QStringList::const_iterator anIt = viewers.begin(), aLast = viewers.end();
467       for( ; anIt!=aLast; anIt++ )
468         strViewers+=temp.arg( *anIt );
469       strViewers+="}";
470       myPopupMgr->setRule( eraseAll, QString( "client in %1" ).arg( strViewers ), QtxPopupMgr::VisibleRule );
471     }
472   }
473   return myPopupMgr;
474 }
475
476 /*!Gets preferences.*/
477 LightApp_Preferences* LightApp_Module::preferences() const
478 {
479   LightApp_Preferences* pref = 0;
480   if ( getApp() )
481     pref = getApp()->preferences();
482   return pref;
483 }
484
485 /*!Add preference to preferences.*/
486 int LightApp_Module::addPreference( const QString& label )
487 {
488   LightApp_Preferences* pref = preferences();
489   if ( !pref )
490     return -1;
491
492   int catId = pref->addPreference( moduleName(), -1 );
493   if ( catId == -1 )
494     return -1;
495
496   return pref->addPreference( label, catId );
497 }
498
499 /*!Add preference to preferences.*/
500 int LightApp_Module::addPreference( const QString& label, const int pId, const int type,
501                                     const QString& section, const QString& param )
502 {
503   LightApp_Preferences* pref = preferences();
504   if ( !pref )
505     return -1;
506
507   return pref->addPreference( moduleName(), label, pId, type, section, param );
508 }
509
510 /*!Gets property of preferences.*/
511 QVariant LightApp_Module::preferenceProperty( const int id, const QString& prop ) const
512 {
513   QVariant var;
514   LightApp_Preferences* pref = preferences();
515   if ( pref )
516     var = pref->itemProperty( prop, id );
517   return var;
518 }
519
520 /*!Set property of preferences.*/
521 void LightApp_Module::setPreferenceProperty( const int id, const QString& prop, const QVariant& var )
522 {
523   LightApp_Preferences* pref = preferences();
524   if ( pref )
525     pref->setItemProperty( prop, var, id );
526 }
527
528 /*!
529  * \brief Starts operation with given identifier
530   * \param id - identifier of operation to be started
531 *
532 * Module stores operations in map. This method starts operation by id.
533 * If operation isn't in map, then it will be created by createOperation method
534 * and will be inserted to map
535 */
536 void LightApp_Module::startOperation( const int id )
537 {
538   LightApp_Operation* op = 0;
539   if( myOperations.contains( id ) && reusableOperation( id ) )
540     op = myOperations[ id ];
541   else
542   {
543     op = createOperation( id );
544     if( op )
545     {
546       myOperations.insert( id, op );
547       op->setModule( this );
548       connect( op, SIGNAL( stopped( SUIT_Operation* ) ), this, SLOT( onOperationStopped( SUIT_Operation* ) ) );
549       connect( op, SIGNAL( destroyed() ), this, SLOT( onOperationDestroyed() ) );
550     }
551   }
552
553   if( op )
554   {
555     // be sure that operation has correct study pointer
556     op->setStudy( application() ? application()->activeStudy() : 0 );
557     op->start();
558   }
559 }
560
561 /*!
562  * \brief Creates operation with given identifier
563   * \param id - identifier of operation to be started
564   * \return Pointer on created operation or NULL if operation is not created
565 *
566 * Creates operation with given id. You should not call this method, it will be called
567 * automatically from startOperation. You may redefine this method in concrete module to
568 * create operations. 
569 */
570 LightApp_Operation* LightApp_Module::createOperation( const int id ) const
571 {
572   if( id==-1 )
573     return 0;
574
575   if( id==myDisplay )
576     return new LightApp_ShowHideOp( LightApp_ShowHideOp::DISPLAY );
577   else if( id==myErase )
578     return new LightApp_ShowHideOp( LightApp_ShowHideOp::ERASE );
579   else if( id==myDisplayOnly )
580     return new LightApp_ShowHideOp( LightApp_ShowHideOp::DISPLAY_ONLY );
581   else if( id==myEraseAll )
582     return new LightApp_ShowHideOp( LightApp_ShowHideOp::ERASE_ALL );
583   else
584     return 0;
585 }
586
587 /*!
588  * \brief Virtual protected slot called when operation stopped
589  * \param theOp - stopped operation
590 *
591 * Virtual protected slot called when operation stopped. Redefine this slot if you want to
592 * perform actions after stopping operation
593 */
594 void LightApp_Module::onOperationStopped( SUIT_Operation* /*theOp*/ )
595 {
596 }
597
598 /*!
599  * \brief Virtual protected slot called when operation destroyed
600   * \param theOp - destroyed operation
601 *
602 * Virtual protected slot called when operation destroyed. Redefine this slot if you want to
603 * perform actions after destroying operation. Base implementation removes pointer on
604 * destroyed operation from the map of operations
605 */
606 void LightApp_Module::onOperationDestroyed()
607 {
608   const QObject* s = sender();
609   if( s && s->inherits( "LightApp_Operation" ) )
610   {
611     const LightApp_Operation* op = ( LightApp_Operation* )s;
612     MapOfOperation::const_iterator anIt = myOperations.begin(),
613                                    aLast = myOperations.end();
614     for( ; anIt!=aLast; anIt++ )
615       if( anIt.value()==op )
616       {
617         myOperations.remove( anIt.key() );
618         break;
619       }
620   }
621 }
622
623 /*!
624   Must be redefined in order to use standard displayer mechanism
625   \return displayer of module
626 */
627 LightApp_Displayer* LightApp_Module::displayer()
628 {
629   return 0;
630 }
631
632 /*!
633   SLOT: called on activating of standard operations show/hide
634 */
635 void LightApp_Module::onShowHide()
636 {
637   if( !sender()->inherits( "QAction" ) || !popupMgr() )
638     return;
639
640   QAction* act = ( QAction* )sender();
641   int id = actionId( act );
642   if( id!=-1 )
643     startOperation( id );
644 }
645
646 /*!
647   virtual SLOT: called on view manager adding
648 */
649 void LightApp_Module::onViewManagerAdded( SUIT_ViewManager* )
650 {
651 }
652
653 /*!
654   virtual SLOT: called on view manager removing
655 */
656 void LightApp_Module::onViewManagerRemoved( SUIT_ViewManager* )
657 {
658 }
659
660 /*!
661   \brief Returns instance of operation by its id; if there is no operation
662   corresponding to this id, null pointer is returned
663   \param id - operation id 
664   \return operation instance
665 */
666 LightApp_Operation* LightApp_Module::operation( const int id ) const
667 {
668   return myOperations.contains( id ) ? myOperations[id] : 0;
669 }
670
671 /*!
672   virtual method called to manage the same operations
673 */
674 bool LightApp_Module::reusableOperation( const int id )
675 {
676  return true;
677
678
679 /*!
680   virtual method
681   \return true if module can copy the current selection
682 */
683 bool LightApp_Module::canCopy() const
684 {
685   return false;
686 }
687
688 /*!
689   virtual method
690   \return true if module can paste previously copied data
691 */
692 bool LightApp_Module::canPaste() const
693 {
694   return false;
695 }
696
697 /*!
698   virtual method
699   \brief Copies the current selection into clipboard
700 */
701 void LightApp_Module::copy()
702 {
703 }
704
705 /*!
706   virtual method
707   \brief Pastes the current data in the clipboard
708 */
709 void LightApp_Module::paste()
710 {
711 }
712
713 /*!
714   virtual method
715   \return true if module allows dragging the given object
716 */
717 bool LightApp_Module::isDraggable( const SUIT_DataObject* /*what*/ ) const
718 {
719   return false;
720 }
721
722 /*!
723   virtual method
724   \return true if module allows dropping one or more objects (currently selected) on the object \c where
725 */
726 bool LightApp_Module::isDropAccepted( const SUIT_DataObject* /*where*/ ) const
727 {
728   return false;
729 }
730
731 /*!
732   virtual method
733   Complete drag-n-drop operation by processing objects \a what being dragged, dropped to the line \a row
734   within the object \a where. The drop action being performed is specified by \a action.
735 */
736 void LightApp_Module::dropObjects( const DataObjectList& /*what*/, SUIT_DataObject* /*where*/,
737                                    const int /*row*/, Qt::DropAction /*action*/ )
738 {
739 }
740
741 /*!
742   \brief Return \c true if object can be renamed
743 */
744 bool LightApp_Module::renameAllowed( const QString& /*entry*/ ) const
745 {
746   return false;
747 }
748
749 /*!
750   Rename object by entry.
751   \param entry entry of the object
752   \param name new name of the object
753   \brief Return \c true if rename operation finished successfully, \c false otherwise.
754 */
755 bool LightApp_Module::renameObject( const QString& /*entry*/, const QString& /*name*/ )
756 {
757   return false;
758 }