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