Salome HOME
NPAL19658: Deletion problem. Invalid actions were called by shortcuts.
authorjfa <jfa@opencascade.com>
Tue, 20 May 2008 07:31:51 +0000 (07:31 +0000)
committerjfa <jfa@opencascade.com>
Tue, 20 May 2008 07:31:51 +0000 (07:31 +0000)
src/SUPERVGUI/SUPERVGUI.cxx
src/SUPERVGUI/SUPERVGUI_ArrayView.cxx
src/SUPERVGUI/SUPERVGUI_CanvasView.cxx
src/SUPERVGUI/SUPERV_msg_en.po

index aced7fee3dae189f5d4a204c08d1993f7f734417..669dda4876b17e055e1a67f6d0cdc43dc9a76775 100644 (file)
@@ -17,7 +17,7 @@
 //  License along with this library; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
@@ -206,7 +206,7 @@ void SUPERVGUI::initialize( CAM_Application* app )
   // ----- create popup for object browser items -------------
   QtxPopupMgr* mgr = popupMgr();
   mgr->insert( action(  311 ), -1, -1 ); // rename dataflow
-  mgr->setRule( action( 311 ), "$type in {'Dataflow'} and selcount=1", true );
+  mgr->setRule( action( 311 ), "$type in {'Dataflow'} and selcount>0", true );
   mgr->insert( action(  312 ), -1, -1 ); // display dataflow
   mgr->setRule( action( 312 ), "$type in {'Dataflow'} and selcount=1", true );
   mgr->insert( separator(), -1, -1 ); // -----------
@@ -222,12 +222,13 @@ bool SUPERVGUI::activateModule( SUIT_Study* theStudy )
   if ( !SalomeApp_Module::activateModule( theStudy ) )
     return false;
 
-
-
   //---------------------------------------
   setMenuShown( true );
   setToolShown( true );
 
+  action(311)->setEnabled(true); // Rename: Key_F2
+  action(313)->setEnabled(true); // Delete: Key_Delete
+
   study = application()->activeStudy();
 
   connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
@@ -254,6 +255,9 @@ bool SUPERVGUI::deactivateModule( SUIT_Study* theStudy )
   setMenuShown( false );
   setToolShown( false );
 
+  action(311)->setEnabled(false); // Rename: Key_F2
+  action(313)->setEnabled(false); // Delete: Key_Delete
+
   disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
               this, SLOT( setMain( SUIT_ViewWindow* ) ) );
   //---------------------------------------
@@ -386,7 +390,7 @@ void SUPERVGUI::onGraphClosed(SUIT_ViewWindow* theViewWindow) {
        }
       }
       // mkr: PAL12449 <---
-      
+
       unregisterGraph(aGraph);
       SUPERV_Graph aDataFlow = aGraph->getDataflow();
       if ( !SUPERV_isNull( aDataFlow ) ) {
@@ -402,7 +406,7 @@ void SUPERVGUI::onGraphClosed(SUIT_ViewWindow* theViewWindow) {
              // Kill() sends KillEvent and KillState to SUPERVGUI_Thread
              // while sets myIsActive flag to false when it receives such event/state
              // after myIsActive is false it calls QThread::exit() to terminate.
-             
+
              // why while() { qApp->processEvents() } ?
              // because: SUPERVGUI_Thread::run() receives events, and calls myMain->execute()
              // method using SALOME_Event paradigm, ProcessVoidEvent() function -
@@ -528,11 +532,13 @@ void SUPERVGUI::displayDataflow() {
 }
 
 
-void SUPERVGUI::renameDataflow() {
+void SUPERVGUI::renameDataflow()
+{
   SALOME_ListIO aList;
   aList.Clear();
   (( SalomeApp_Application* )application())->selectionMgr()->selectedObjects( aList );
 
+  bool isAny = false;
   SALOME_ListIteratorOfListIO It( aList );
   for ( ; It.More(); It.Next() ) {
     Handle(SALOME_InteractiveObject) IObject = It.Value();
@@ -544,30 +550,32 @@ void SUPERVGUI::renameDataflow() {
       if ( obj->FindAttribute(anAttr, "AttributeName") ) {
         _PTR(AttributeName) aName ( anAttr );
         QString nm = QString( aName->Value().c_str() );
-       bool ok;
-       nm = QInputDialog::getText( tr( "Rename" ), tr( "Enter new name:" ), QLineEdit::Normal,
-                                    nm, &ok, application()->desktop() );
-        if ( ok && !nm.isEmpty() ) {
-          // sak : 24.11.04 : fix for PAL6898 : if rename fails (study locked),
-          // a message box is displayed, and cursor is "wait cursor".  We think that "wait cursor"
-          // is not neccessary here, because the rename operation is fast.
-          //QApplication::setOverrideCursor( Qt::waitCursor );
-          //study->renameIObject( IObject, nm );
-
-          //--->
-          aName->SetValue( nm.latin1() );
-          //rename Interactive object
-          IObject->setName( ( char* )nm.latin1() );
-          //<---
-
-          updateObjBrowser();
-          //QApplication::restoreOverrideCursor();
-
-         // mkr : PAL7037 => rename engine of the graph (i.e. corresponding SUPERV_Graph) -->
-          if ( obj->FindAttribute(anAttr, "AttributeIOR") ) {
-            _PTR(AttributeIOR) anIOR ( anAttr );
-            SUPERV_Graph aDataFlow = engine->getGraph(anIOR->Value().c_str());
-            if ( !SUPERV_isNull(aDataFlow) ) {
+
+        if ( obj->FindAttribute(anAttr, "AttributeIOR") ) {
+          _PTR(AttributeIOR) anIOR ( anAttr );
+          SUPERV_Graph aDataFlow = engine->getGraph(anIOR->Value().c_str());
+          if ( !SUPERV_isNull(aDataFlow) ) {
+            isAny = true;
+            bool ok;
+            nm = QInputDialog::getText( tr( "Rename" ), tr( "Enter new name:" ), QLineEdit::Normal,
+                                        nm, &ok, application()->desktop() );
+            if ( ok && !nm.isEmpty() ) {
+              // sak : 24.11.04 : fix for PAL6898 : if rename fails (study locked),
+              // a message box is displayed, and cursor is "wait cursor".  We think that "wait cursor"
+              // is not neccessary here, because the rename operation is fast.
+              //QApplication::setOverrideCursor( Qt::waitCursor );
+              //study->renameIObject( IObject, nm );
+
+              //--->
+              aName->SetValue( nm.latin1() );
+              //rename Interactive object
+              IObject->setName( ( char* )nm.latin1() );
+              //<---
+
+              updateObjBrowser();
+              //QApplication::restoreOverrideCursor();
+
+              // mkr : PAL7037 => rename engine of the graph (i.e. corresponding SUPERV_Graph) -->
               if ( aDataFlow->IsStreamGraph() ) {
                SUPERV_StreamGraph aStreamDataFlow = aDataFlow->ToStreamGraph();
                 if ( !SUPERV_isNull(aStreamDataFlow) )
@@ -578,13 +586,20 @@ void SUPERVGUI::renameDataflow() {
               }
 
               // update "Save" icon and menu state, if dataflow is published
-              SUPERVGUI_Main::setModifiedFlag();  
+              SUPERVGUI_Main::setModifiedFlag();
+              // mkr : PAL7037 <--
             }
           }
-         // mkr : PAL7037 <--
         }
       }
     }
+  } // for
+
+  if (!isAny) {
+    SUIT_MessageBox::warn1(application()->desktop(),
+                           tr("WARNING"),
+                           tr("SUPERV_WRN_NO_APPROPRIATE_SELECTION"),
+                           tr("BUT_OK") );
   }
 }
 
@@ -908,7 +923,8 @@ void SUPERVGUI::whatIsSelected(const _PTR(SObject)& theObj, bool& theIsOwner, bo
   }
 }
 
-void SUPERVGUI::deleteObject() {
+void SUPERVGUI::deleteObject()
+{
   SALOME_ListIO aList;
   aList.Clear();
   (( SalomeApp_Application* )application())->selectionMgr()->selectedObjects( aList, QString::null, false );
@@ -929,23 +945,36 @@ void SUPERVGUI::deleteObject() {
                            QMessageBox::Yes, QMessageBox::No) != QMessageBox::Yes)
     return;
 
+  bool isAny = false;
   SALOME_ListIteratorOfListIO It( aList );
-  for(;It.More();It.Next()) {
+  for (; It.More(); It.Next()) {
     Handle(SALOME_InteractiveObject) anIObj = It.Value();
-    //bool aIsOwner, aIsDataflow;
-    //whatIsSelected(anIObj, aIsOwner, aIsDataflow);
 
     _PTR(SObject) aObj ( aStudy->FindObjectID( anIObj->getEntry() ) );
     if ( aObj ) {
-      SUIT_Operation* op = new SalomeApp_ImportOperation( application() );
-      _PTR(StudyBuilder) aBuilder ( aStudy->NewBuilder() );
-      op->start();
-      aBuilder->RemoveObjectWithChildren( aObj );
-      op->commit();
+      bool aIsOwner, aIsDataflow;
+      whatIsSelected(aObj, aIsOwner, aIsDataflow);
+      if (aIsOwner) {
+        isAny = true;
+        SUIT_Operation* op = new SalomeApp_ImportOperation( application() );
+        _PTR(StudyBuilder) aBuilder ( aStudy->NewBuilder() );
+        op->start();
+        aBuilder->RemoveObjectWithChildren( aObj );
+        op->commit();
+      }
     }
+  } // for
+
+  if (!isAny) {
+    SUIT_MessageBox::warn1(application()->desktop(),
+                           tr("WARNING"),
+                           tr("SUPERV_WRN_NO_APPROPRIATE_SELECTION"),
+                           tr("BUT_OK") );
+  }
+  else {
+    (( SalomeApp_Application* )application())->selectionMgr()->clearSelected();
+    updateObjBrowser();
   }
-  (( SalomeApp_Application* )application())->selectionMgr()->clearSelected();
-  updateObjBrowser();
 }
 
 void SUPERVGUI::OnGUIEvent()
@@ -1084,7 +1113,7 @@ bool SUPERVGUI::updateDataFlowSOName( SUPERV::Graph_ptr theDataflow ) {
        aName->SetValue( theDataflow->Name() );
        updateObjBrowser();
        return true;
-      }    
+      }
   }
   return false;
 }
index da2af8a0ffc6f42d7303051a9f0bff4fa40796ec..b3809099ad6a29616cbb40029b0a138057cb9836 100644 (file)
 
 #include <qcolordialog.h>
 
-#if QT_VERSION >= 0x030005
-QCursor PanCursor(Qt::SizeAllCursor);
-#else
-QCursor PanCursor(SizeAllCursor);
-#endif
-
 SUPERVGUI_ArrayView::SUPERVGUI_ArrayView(SUPERVGUI_CanvasArray* theArray, SUPERVGUI_Main* theMain):
   QCanvasView(theArray, theMain),
   myMain(theMain)
@@ -153,6 +147,12 @@ void SUPERVGUI_ArrayView::contentsMousePressEvent(QMouseEvent* theEvent) {
     viewport()->setMouseTracking(false); //widget only receives mouse move events when at least one 
                                          //mouse button is pressed down while the mouse is being moved
     myCursor = cursor();
+
+#if QT_VERSION >= 0x030005
+    QCursor PanCursor(Qt::SizeAllCursor);
+#else
+    QCursor PanCursor(SizeAllCursor);
+#endif
     setCursor(PanCursor);
     return;
   } 
index a77154438b7c599646cdff77ed2d7b651b6ead69..63410a5b6f623a912dbc98f8689fe105c09ff79f 100644 (file)
@@ -81,16 +81,6 @@ const char* imageZoomCursor[] = {
 "................................",
 "................................"};
 
-QPixmap zoomPix(imageZoomCursor);
-QCursor zoom2Cursor(zoomPix);
-QCursor handCursor(Qt::PointingHandCursor);
-
-#if QT_VERSION >= 0x030005
-QCursor pan2Cursor(Qt::SizeAllCursor);
-#else
-QCursor pan2Cursor(SizeAllCursor);
-#endif
-
 SUPERVGUI_CanvasView::SUPERVGUI_CanvasView(SUPERVGUI_Canvas* theCanvas, SUPERVGUI_Main* theMain):
   QCanvasView(theCanvas, theMain),
   myMain(theMain), myCurrentItem(0), myHilighted(0), myLinkBuilder(0)
@@ -200,6 +190,12 @@ void SUPERVGUI_CanvasView::contentsMousePressEvent(QMouseEvent* theEvent)
       myIsPanBtnClicked) {
     myIsPanActivated = true;
     myCursor = cursor();
+
+#if QT_VERSION >= 0x030005
+    QCursor pan2Cursor(Qt::SizeAllCursor);
+#else
+    QCursor pan2Cursor(SizeAllCursor);
+#endif
     setCursor(pan2Cursor);
     return;
   }
@@ -209,6 +205,9 @@ void SUPERVGUI_CanvasView::contentsMousePressEvent(QMouseEvent* theEvent)
       myIsZoomActivated) {
     myIsZoomActivated = true;
     myCursor = cursor();
+
+    QPixmap zoomPix (imageZoomCursor);
+    QCursor zoom2Cursor (zoomPix);
     setCursor(zoom2Cursor);
     return;
   }
@@ -792,6 +791,7 @@ void SUPERVGUI_CanvasView::fitWithinRect()
   myIsFitWRActivated = true;
   viewport()->setMouseTracking(false);
   myCursor = cursor();
+  QCursor handCursor (Qt::PointingHandCursor);
   setCursor(handCursor);
 }
 
index 0c7e9f2bb9f95d96787a4e4d66a32da6f98090d1..1fc20f0249a8a21b8d6f2eacf5110408f8d82b97 100644 (file)
@@ -17,7 +17,7 @@
 #  License along with this library; if not, write to the Free Software 
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
 # 
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 #
 #
@@ -102,6 +102,9 @@ msgstr "Supervisor Warning"
 msgid "SUPERVGUI_Service::WARNING"
 msgstr "Supervisor Warning"
 
+msgid "SUPERV_WRN_NO_APPROPRIATE_SELECTION"
+msgstr "No appropriate objects selected"
+
 #:SUPERVGUI_Main.cxx:147
 msgid "MSG_DF_RUNNING"
 msgstr "Dataflow Is Currently Running"