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.
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.
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
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_DeleteDlg.h"
21 #include <SUIT_MessageBox.h>
24 #include <QVBoxLayout>
26 #include <QPushButton>
28 HYDROGUI_DeleteDlg::HYDROGUI_DeleteDlg( QWidget* theParent )
29 : QtxDialog( theParent, false, true, QtxDialog::YesNo )
31 setWindowTitle( tr( "DELETE_OBJECTS" ) );
32 setButtonPosition( Left, Yes );
33 setButtonPosition( Right, No );
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 ) );
40 myObjectsLabel = new QLabel( tr( "CONFIRM_DELETION" ), mainFrame() );
41 myObjects = new QTextEdit( mainFrame() );
42 myObjects->setReadOnly( true );
43 myObjects->setFocusPolicy( Qt::NoFocus );
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 );
52 if ( QPushButton* aYesBtn = ::qobject_cast<QPushButton*>( button( Yes ) ) )
54 setFocusProxy( aYesBtn );
55 aYesBtn->setAutoDefault( true );
56 aYesBtn->setDefault( true );
58 if ( QPushButton* aNoBtn = ::qobject_cast<QPushButton*>( button( No ) ) )
60 aNoBtn->setAutoDefault( true );
63 setMinimumSize( 275, 250 );
66 HYDROGUI_DeleteDlg::~HYDROGUI_DeleteDlg()
70 void HYDROGUI_DeleteDlg::setObjectsToRemove( const QStringList& theObjects )
72 myObjectsLabel->setText( tr( "CONFIRM_DELETION" ).arg( theObjects.length() ) );
74 QStringList anObjects;
76 QStringListIterator anIter( theObjects );
77 while ( anIter.hasNext() )
79 QString anObject = anIter.next();
80 anObjects.append( anObject.prepend( "- " ) );
83 myObjects->setPlainText( anObjects.join( "\n" ) );