From: vsr Date: Tue, 21 Feb 2012 16:21:15 +0000 (+0000) Subject: 0021179: EDF 1654 SMESH GEOM: better look'n'feel X-Git-Tag: V6_5_0a1~58 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=dbca9b56bbdb39ccc2289d9008ebd01dfa6c8ab4;p=modules%2Fgeom.git 0021179: EDF 1654 SMESH GEOM: better look'n'feel Additional fix of bug: impossible to remove user's materials --- diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx index f895d65e9..77803fe92 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx @@ -427,6 +427,7 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget* setButtonPosition( Right, Close ); setDialogFlags( AlignOnce ); myMaterialList->setEditTriggers( QAbstractItemView::EditKeyPressed ); + myMaterialList->installEventFilter( this ); // ! RESOURCES QStringList globalMaterials = resourceMgr()->materials( Material_ResourceMgr::Global ); @@ -574,23 +575,26 @@ void GEOMToolsGUI_MaterialPropertiesDlg::accept() \brief Process key press event \param e key event */ -void GEOMToolsGUI_MaterialPropertiesDlg::keyPressEvent( QKeyEvent* e ) +bool GEOMToolsGUI_MaterialPropertiesDlg::eventFilter( QObject* o, QEvent* e ) { - if ( e->key() == Qt::Key_Delete ) { - QListWidgetItem* item = myMaterialList->currentItem(); - if ( item && item->data( TypeRole ).toInt() == User ) { - if ( QMessageBox::question( this, - tr( "Delete user material" ), - tr( "Remove material %1?" ).arg( item->text() ), - QMessageBox::Yes | QMessageBox::No, - QMessageBox::Yes ) == QMessageBox::Yes ) { - resourceMgr()->remove( item->data( NameRole ).toString() ); - resourceMgr()->save(); - delete item; + if ( o == myMaterialList && e->type() == QEvent::KeyPress ) { + QKeyEvent* ke = (QKeyEvent*)e; + if ( ke->key() == Qt::Key_Delete ) { + QListWidgetItem* item = myMaterialList->currentItem(); + if ( item && item->data( TypeRole ).toInt() == User ) { + if ( QMessageBox::question( this, + tr( "Delete user material" ), + tr( "Remove material %1?" ).arg( item->text() ), + QMessageBox::Yes | QMessageBox::No, + QMessageBox::Yes ) == QMessageBox::Yes ) { + resourceMgr()->remove( item->data( NameRole ).toString() ); + resourceMgr()->save(); + delete item; + } } } } - QtxDialog::keyPressEvent( e ); + return QtxDialog::eventFilter( o, e ); } /*! diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.h b/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.h index 77c4b263c..edaf28761 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.h +++ b/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.h @@ -63,8 +63,7 @@ public: void accept(); -protected: - void keyPressEvent( QKeyEvent* ); + bool eventFilter( QObject*, QEvent* ); private: Material_ResourceMgr* resourceMgr();