From acdc0e399c63593e775cdf4f8b6ec2a52e5d0a05 Mon Sep 17 00:00:00 2001 From: adv Date: Fri, 27 Dec 2013 05:55:51 +0000 Subject: [PATCH] Dialog for delete operation (Bug #300). --- src/HYDROGUI/CMakeLists.txt | 2 + src/HYDROGUI/HYDROGUI_DeleteDlg.cxx | 82 +++++++++++++++++++++++ src/HYDROGUI/HYDROGUI_DeleteDlg.h | 48 +++++++++++++ src/HYDROGUI/HYDROGUI_DeleteOp.cxx | 11 ++- src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 19 ++++-- 5 files changed, 149 insertions(+), 13 deletions(-) create mode 100644 src/HYDROGUI/HYDROGUI_DeleteDlg.cxx create mode 100644 src/HYDROGUI/HYDROGUI_DeleteDlg.h diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index a9100150..942135c3 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -14,6 +14,7 @@ set(PROJECT_HEADERS HYDROGUI_DataBrowser.h HYDROGUI_DataModel.h HYDROGUI_DataObject.h + HYDROGUI_DeleteDlg.h HYDROGUI_DeleteOp.h HYDROGUI_DigueDlg.h HYDROGUI_DigueOp.h @@ -98,6 +99,7 @@ set(PROJECT_SOURCES HYDROGUI_DataBrowser.cxx HYDROGUI_DataModel.cxx HYDROGUI_DataObject.cxx + HYDROGUI_DeleteDlg.cxx HYDROGUI_DeleteOp.cxx HYDROGUI_DigueDlg.cxx HYDROGUI_DigueOp.cxx diff --git a/src/HYDROGUI/HYDROGUI_DeleteDlg.cxx b/src/HYDROGUI/HYDROGUI_DeleteDlg.cxx new file mode 100644 index 00000000..e7c93fa3 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_DeleteDlg.cxx @@ -0,0 +1,82 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// 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 +// + +#include "HYDROGUI_DeleteDlg.h" + +#include + +#include +#include +#include +#include + +HYDROGUI_DeleteDlg::HYDROGUI_DeleteDlg( QWidget* theParent ) +: QtxDialog( theParent, false, true, QtxDialog::YesNo ) +{ + setWindowTitle( tr( "DELETE_OBJECTS" ) ); + setButtonPosition( Left, Yes ); + setButtonPosition( Right, No ); + + QLabel* anIconLabelLabel = new QLabel( mainFrame() ); + anIconLabelLabel->setPixmap( SUIT_MessageBox::standardIcon( QMessageBox::Question ) ); + anIconLabelLabel->setScaledContents( false ); + anIconLabelLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); + + myObjectsLabel = new QLabel( tr( "CONFIRM_DELETION" ), mainFrame() ); + myObjects = new QTextEdit( mainFrame() ); + myObjects->setReadOnly( true ); + + QGridLayout* aLayout = new QGridLayout( mainFrame() ); + aLayout->setMargin( 5 ); + aLayout->setSpacing( 5 ); + aLayout->addWidget( anIconLabelLabel, 0, 0 ); + aLayout->addWidget( myObjectsLabel, 0, 1 ); + aLayout->addWidget( myObjects, 1, 0, 1, 2 ); + + if ( QPushButton* aYesBtn = ::qobject_cast( button( Yes ) ) ) + { + setFocusProxy( aYesBtn ); + aYesBtn->setDefault( true ); + } + + setMinimumSize( 275, 250 ); +} + +HYDROGUI_DeleteDlg::~HYDROGUI_DeleteDlg() +{ +} + +void HYDROGUI_DeleteDlg::setObjectsToRemove( const QStringList& theObjects ) +{ + myObjectsLabel->setText( tr( "CONFIRM_DELETION" ).arg( theObjects.length() ) ); + + QStringList anObjects; + + QStringListIterator anIter( theObjects ); + while ( anIter.hasNext() ) + { + QString anObject = anIter.next(); + anObjects.append( anObject.prepend( "- " ) ); + } + + myObjects->setPlainText( anObjects.join( "\n" ) ); +} diff --git a/src/HYDROGUI/HYDROGUI_DeleteDlg.h b/src/HYDROGUI/HYDROGUI_DeleteDlg.h new file mode 100644 index 00000000..ad519757 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_DeleteDlg.h @@ -0,0 +1,48 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// 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 +// + +#ifndef HYDROGUI_DeleteDlg_H +#define HYDROGUI_DeleteDlg_H + +#include + +class QLabel; +class QTextEdit; + +class HYDROGUI_DeleteDlg : public QtxDialog +{ + Q_OBJECT + +public: + HYDROGUI_DeleteDlg( QWidget* = 0 ); + virtual ~HYDROGUI_DeleteDlg(); + +public: + + void setObjectsToRemove( const QStringList& theObjects ); + +private: + QLabel* myObjectsLabel; + QTextEdit* myObjects; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_DeleteOp.cxx b/src/HYDROGUI/HYDROGUI_DeleteOp.cxx index 8d55ce79..6694e4c2 100644 --- a/src/HYDROGUI/HYDROGUI_DeleteOp.cxx +++ b/src/HYDROGUI/HYDROGUI_DeleteOp.cxx @@ -22,6 +22,7 @@ #include "HYDROGUI_DeleteOp.h" +#include "HYDROGUI_DeleteDlg.h" #include "HYDROGUI_Module.h" #include "HYDROGUI_Tool.h" #include "HYDROGUI_UpdateFlags.h" @@ -114,13 +115,9 @@ void HYDROGUI_DeleteOp::startOperation() return; } - QString aNamesList = anObjNames.join( "\n" ); - int anAnswer = SUIT_MessageBox::question( module()->getApp()->desktop(), - tr( "DELETE_OBJECTS" ), - tr( "CONFIRM_DELETION" ).arg( aNamesList ), - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No ); - if( anAnswer == QMessageBox::No ) + HYDROGUI_DeleteDlg aDeleteDlg( module()->getApp()->desktop() ); + aDeleteDlg.setObjectsToRemove( anObjNames ); + if ( aDeleteDlg.exec() != HYDROGUI_DeleteDlg::Accepted ) { abort(); return; diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index e4af5158..d3575e9e 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -333,11 +333,6 @@ All supported formats (*.brep *.iges *.igs *.step *.stp) DELETE_OBJECTS Delete objects - - CONFIRM_DELETION - Do you really want to delete following objects: -%1 ? - DELETE_OBJECTS_IMPOSIBLE One or more selected objects can not be deleted separately from parent object. @@ -358,7 +353,19 @@ First remove objects which are created on their basis. Object "%1" is used for %2 - + + + HYDROGUI_DeleteDlg + + DELETE_OBJECTS + Delete objects + + + CONFIRM_DELETION + Do you really want to delete %1 object(s)? + + + HYDROGUI_ExportImageOp -- 2.39.2