From: jfa Date: Tue, 20 May 2008 07:31:51 +0000 (+0000) Subject: NPAL19658: Deletion problem. Invalid actions were called by shortcuts. X-Git-Tag: V4_1_0_maintainance_20080609~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0ea57d7fbb206c0ae1defd291bd0c0854894217b;p=modules%2Fsuperv.git NPAL19658: Deletion problem. Invalid actions were called by shortcuts. --- diff --git a/src/SUPERVGUI/SUPERVGUI.cxx b/src/SUPERVGUI/SUPERVGUI.cxx index aced7fe..669dda4 100644 --- a/src/SUPERVGUI/SUPERVGUI.cxx +++ b/src/SUPERVGUI/SUPERVGUI.cxx @@ -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; } diff --git a/src/SUPERVGUI/SUPERVGUI_ArrayView.cxx b/src/SUPERVGUI/SUPERVGUI_ArrayView.cxx index da2af8a..b380909 100644 --- a/src/SUPERVGUI/SUPERVGUI_ArrayView.cxx +++ b/src/SUPERVGUI/SUPERVGUI_ArrayView.cxx @@ -32,12 +32,6 @@ #include -#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; } diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx index a771544..63410a5 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx @@ -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); } diff --git a/src/SUPERVGUI/SUPERV_msg_en.po b/src/SUPERVGUI/SUPERV_msg_en.po index 0c7e9f2..1fc20f0 100644 --- a/src/SUPERVGUI/SUPERV_msg_en.po +++ b/src/SUPERVGUI/SUPERV_msg_en.po @@ -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"