Salome HOME
new presentation using DTM
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_DeleteDlg.cxx
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #include "HYDROGUI_DeleteDlg.h"
20
21 #include <SUIT_MessageBox.h>
22
23 #include <QTextEdit>
24 #include <QVBoxLayout>
25 #include <QLabel>
26 #include <QPushButton>
27
28 HYDROGUI_DeleteDlg::HYDROGUI_DeleteDlg( QWidget* theParent )
29 : QtxDialog( theParent, false, true, QtxDialog::YesNo )
30 {
31   setWindowTitle( tr( "DELETE_OBJECTS" ) );
32   setButtonPosition( Left, Yes );
33   setButtonPosition( Right, No );
34
35   QLabel* anIconLabelLabel = new QLabel( mainFrame() );
36   anIconLabelLabel->setPixmap( SUIT_MessageBox::standardIcon( QMessageBox::Question ) );
37   anIconLabelLabel->setScaledContents( false );
38   anIconLabelLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
39
40   myObjectsLabel = new QLabel( tr( "CONFIRM_DELETION" ), mainFrame() );
41   myObjects = new QTextEdit( mainFrame() );
42   myObjects->setReadOnly( true );
43   myObjects->setFocusPolicy( Qt::NoFocus );
44
45   QGridLayout* aLayout = new QGridLayout( mainFrame() );
46   aLayout->setMargin( 5 );
47   aLayout->setSpacing( 5 );
48   aLayout->addWidget( anIconLabelLabel, 0, 0 );
49   aLayout->addWidget( myObjectsLabel, 0, 1 );
50   aLayout->addWidget( myObjects, 1, 0, 1, 2 );
51
52   if ( QPushButton* aYesBtn = ::qobject_cast<QPushButton*>( button( Yes ) ) )
53   {
54     setFocusProxy( aYesBtn );
55     aYesBtn->setAutoDefault( true );
56     aYesBtn->setDefault( true );
57   }
58   if ( QPushButton* aNoBtn = ::qobject_cast<QPushButton*>( button( No ) ) )
59   {
60     aNoBtn->setAutoDefault( true );
61   }
62
63   setMinimumSize( 275, 250 );
64 }
65
66 HYDROGUI_DeleteDlg::~HYDROGUI_DeleteDlg()
67 {
68 }
69
70 void HYDROGUI_DeleteDlg::setObjectsToRemove( const QStringList& theObjects )
71 {
72   myObjectsLabel->setText( tr( "CONFIRM_DELETION" ).arg( theObjects.length() ) );
73
74   QStringList anObjects;
75
76   QStringListIterator anIter( theObjects );
77   while ( anIter.hasNext() )
78   {
79     QString anObject = anIter.next();
80     anObjects.append( anObject.prepend( "- " ) );
81   }
82
83   myObjects->setPlainText( anObjects.join( "\n" ) );
84 }