X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMToolsGUI%2FGEOMToolsGUI_DeleteDlg.cxx;h=4cde20102489d1d677a33887248156293a42fc43;hb=2dbe613765884256942925d8a95293e3c473caec;hp=20fd8d847dc2862d41f046f432cb3f7009d80c09;hpb=89ddec5a6bb7f1ccd95e775d901e0f84cfe68b14;p=modules%2Fgeom.git diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_DeleteDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_DeleteDlg.cxx index 20fd8d847..4cde20102 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_DeleteDlg.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_DeleteDlg.cxx @@ -30,12 +30,53 @@ #include #include #include +#include + +static bool isEntryLess( const QString& e1, const QString& e2 ) +{ + QStringList el1 = e1.split(":"); + QStringList el2 = e2.split(":"); + int e1c = el1.count(), e2c = el2.count(); + for ( int i = 0; i < e1c && i < e2c; i++ ) { + int id1 = el1[i].toInt(); + int id2 = el2[i].toInt(); + if ( id1 < id2 ) return true; + else if ( id2 < id1 ) return false; + } + return el1.count() < el2.count(); +} + +static QStringList objectsToNames( const QMap& objects ) +{ + QStringList entries; + for ( QMap::ConstIterator it = objects.begin(); it != objects.end(); ++it ) { + QString entry = it.key(); + QStringList::Iterator it; + bool added = false; + for ( it = entries.begin(); it != entries.end() && !added; ++it ) { + if ( isEntryLess( entry, *it ) ) { + entries.insert( it, entry ); + added = true; + } + } + if ( !added ) + entries.append( entry ); + } + QStringList names; + for ( int i = 0; i < entries.count(); i++ ) { + int level = entries[i].count(":")-3; + names.append( QString( level*2, ' ' ) + objects[ entries[i] ] ); + } + return names; +} /*! \brief Constructor. \param parent parent widget */ -GEOMToolsGUI_DeleteDlg::GEOMToolsGUI_DeleteDlg( QWidget* parent, const QStringList& objects ) +GEOMToolsGUI_DeleteDlg::GEOMToolsGUI_DeleteDlg( QWidget* parent, + const QMap& objects, + bool deleteAll ) : QDialog( parent ) { setModal( true ); @@ -49,18 +90,37 @@ GEOMToolsGUI_DeleteDlg::GEOMToolsGUI_DeleteDlg( QWidget* parent, const QStringLi topLayout->setSpacing( 6 ); topLayout->setMargin( 11 ); - QLabel* lab = new QLabel( tr( "GEOM_REALLY_DELETE" ).arg( objects.count() ), this ); + QLabel* pix = new QLabel( this ); + pix->setPixmap( SUIT_MessageBox::standardIcon( QMessageBox::Question ) ); + pix->setScaledContents( false ); + pix->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); + topLayout->addWidget( pix, 0, 0, 1, 1 ); - QTextBrowser* viewer = new QTextBrowser( this ); - viewer->setText( QString( "-%1" ).arg( objects.join( "
-" ) ) ); + QLabel* lab = new QLabel( this ); + lab->setAlignment( Qt::AlignCenter ); + topLayout->addWidget( lab, 0, 1, 1, 1 ); + + if ( !deleteAll ) { + lab->setText( tr( "GEOM_REALLY_DELETE" ).arg( objects.count() ) ); + QTextBrowser* viewer = new QTextBrowser( this ); + viewer->setText( QString( " - %1" ).arg( objectsToNames( objects ).join( "\n - " ) ) ); + topLayout->addWidget( viewer, 1, 0, 1, 2 ); + } + else { + lab->setText( tr( "GEOM_REALLY_DELETE_ALL" ) ); + } QPushButton* buttonYes = new QPushButton( tr( "GEOM_BUT_YES" ), this ); QPushButton* buttonNo = new QPushButton( tr( "GEOM_BUT_NO" ), this ); - - topLayout->addWidget( lab, 0, 0, 1, 3 ); - topLayout->addWidget( viewer, 1, 0, 1, 3 ); - topLayout->addWidget( buttonYes, 2, 0 ); - topLayout->addWidget( buttonNo, 2, 2 ); + QHBoxLayout* btnLayout = new QHBoxLayout; + btnLayout->setMargin( 0 ); + btnLayout->setSpacing( 6 ); + btnLayout->addWidget( buttonYes ); + btnLayout->addSpacing( 10 ); + btnLayout->addStretch(); + btnLayout->addWidget( buttonNo ); + int rc = topLayout->rowCount(); + topLayout->addLayout( btnLayout, rc, 0, 1, 2 ); /* signals and slots connections */ connect( buttonYes, SIGNAL( clicked() ), this, SLOT( accept() ) ); @@ -70,6 +130,3 @@ GEOMToolsGUI_DeleteDlg::GEOMToolsGUI_DeleteDlg( QWidget* parent, const QStringLi GEOMToolsGUI_DeleteDlg::~GEOMToolsGUI_DeleteDlg() { } - - -