]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Dialog for delete operation (Bug #300).
authoradv <adv@opencascade.com>
Fri, 27 Dec 2013 05:55:51 +0000 (05:55 +0000)
committeradv <adv@opencascade.com>
Fri, 27 Dec 2013 05:55:51 +0000 (05:55 +0000)
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_DeleteDlg.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_DeleteDlg.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_DeleteOp.cxx
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index a9100150a296c39530a63b060c6e1168de91cb34..942135c30e342fd68969485c14d4ae97202c0071 100644 (file)
@@ -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 (file)
index 0000000..e7c93fa
--- /dev/null
@@ -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 <SUIT_MessageBox.h>
+
+#include <QTextEdit>
+#include <QVBoxLayout>
+#include <QLabel>
+#include <QPushButton>
+
+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<QPushButton*>( 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 (file)
index 0000000..ad51975
--- /dev/null
@@ -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 <QtxDialog.h>
+
+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
index 8d55ce79def2d30e95395ec4ad2490f3ddb5fab7..6694e4c294faf02ab21a475f62443750de377a15 100644 (file)
@@ -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;
index e4af51583e7c50e9880465303ee579f5481aa65e..d3575e9e401e9e228b43055851de399549bdb767 100644 (file)
@@ -333,11 +333,6 @@ All supported formats (*.brep *.iges *.igs *.step *.stp)</translation>
       <source>DELETE_OBJECTS</source>
       <translation>Delete objects</translation>
     </message>
-    <message>
-      <source>CONFIRM_DELETION</source>
-      <translation>Do you really want to delete following objects:
-%1 ?</translation>
-    </message>
     <message>
       <source>DELETE_OBJECTS_IMPOSIBLE</source>
       <translation>One or more selected objects can not be deleted separately from parent object.</translation>
@@ -358,7 +353,19 @@ First remove objects which are created on their basis.
       <translation>Object "%1" is used for %2</translation>
     </message>
   </context>
-  
+
+  <context>
+    <name>HYDROGUI_DeleteDlg</name>
+    <message>
+      <source>DELETE_OBJECTS</source>
+      <translation>Delete objects</translation>
+    </message>
+    <message>
+      <source>CONFIRM_DELETION</source>
+      <translation>Do you really want to delete %1 object(s)?</translation>
+    </message>
+  </context>
+
   <context>
     <name>HYDROGUI_ExportImageOp</name>
     <message>