Salome HOME
Fix for the bug #45: check and warning when the same image is used in 2 arguments.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_StreamDlg.cxx
index cc8ba0f8ec3ac368fab96e1ce35363f9d4d86150..b1a208a88ae35365146341bd62238da0f640de20 100644 (file)
@@ -49,11 +49,11 @@ HYDROGUI_StreamDlg::HYDROGUI_StreamDlg( HYDROGUI_Module* theModule, const QStrin
   // Stream parameters
   QGroupBox* aParamGroup = new QGroupBox( tr( "STREAM_PARAMETERS" ), mainFrame() );
 
-  myAxises = new QComboBox( aParamGroup );
-  myAxises->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  myAxes = new QComboBox( aParamGroup );
+  myAxes->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
   QBoxLayout* anAxisLayout = new QHBoxLayout();
   anAxisLayout->addWidget( new QLabel( tr( "STREAM_HYDRAULIC_AXIS" ) ) );
-  anAxisLayout->addWidget( myAxises );
+  anAxisLayout->addWidget( myAxes );
 
   myProfiles = new QListWidget( aParamGroup );
   myProfiles->setSelectionMode( QListWidget::MultiSelection );
@@ -85,7 +85,7 @@ HYDROGUI_StreamDlg::HYDROGUI_StreamDlg( HYDROGUI_Module* theModule, const QStrin
   addStretch();
 
   // Connect signals and slots
-  connect( myAxises, SIGNAL( currentIndexChanged( const QString & ) ), 
+  connect( myAxes, SIGNAL( currentIndexChanged( const QString & ) ), 
            this, SIGNAL( AxisChanged( const QString& ) ) );
   connect( myAddButton, SIGNAL( clicked() ), this, SIGNAL( AddProfiles() ) );
   connect( myRemoveButton, SIGNAL( clicked() ), this, SLOT( onRemoveProfiles() ) );
@@ -101,13 +101,12 @@ void HYDROGUI_StreamDlg::reset()
 
   myObjectName->clear();
 
-  myAxises->clear();
+  myAxes->clear();
   myProfiles->clear();
   myAddButton->setEnabled( false );
+  myRemoveButton->setEnabled( false );
 
   blockSignals( isBlocked );
-
-  onStreamDefChanged();
 }
 
 void HYDROGUI_StreamDlg::setObjectName( const QString& theName )
@@ -124,76 +123,47 @@ void HYDROGUI_StreamDlg::setAxisNames( const QStringList& theAxises )
 {
   bool isBlocked = blockSignals( true );
 
-  myAxises->clear();
-  myAxises->addItems( theAxises );
+  myAxes->clear();
+  myAxes->addItems( theAxises );
 
   blockSignals( isBlocked );
 }
 
 void HYDROGUI_StreamDlg::setAxisName( const QString& theName )
 {
-  myAddButton->setEnabled( !myAxises->currentText().isEmpty() );
+  bool isBlocked = blockSignals( true );
 
-  int aNewIdx = myAxises->findText( theName );
-  if ( aNewIdx != myAxises->currentIndex() )
-  {
-    myAxises->setCurrentIndex( aNewIdx );
-  }
-  else
-  {
-    onStreamDefChanged();
+  int aNewId = myAxes->findText( theName );
+  if ( aNewId != myAxes->currentIndex() ) {
+    myAxes->setCurrentIndex( aNewId );
   }
+  myAddButton->setEnabled( myAxes->currentIndex() > -1 );
+
+  blockSignals( isBlocked );
 }
 
 QString HYDROGUI_StreamDlg::getAxisName() const
 {
-  return myAxises->currentText();
+  return myAxes->currentText();
 }
 
-void HYDROGUI_StreamDlg::setSelectedProfiles( const QStringList& theProfiles )
+void HYDROGUI_StreamDlg::setProfiles( const QStringList& theProfiles )
 {
   bool isBlocked = blockSignals( true );
 
   myProfiles->setUpdatesEnabled( false );
   
   myProfiles->clear();
-  for ( int i = 0, n = theProfiles.length(); i < n; ++i )
-  {
-    const QString& aProfileName = theProfiles.at( i );
+  foreach ( const QString& aProfileName, theProfiles ) {
     QListWidgetItem* aListItem = new QListWidgetItem( aProfileName, myProfiles );
     aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
   }
 
+  myRemoveButton->setEnabled( myProfiles->count() > 0 );
+
   myProfiles->setUpdatesEnabled( true );
 
   blockSignals( isBlocked );
-
-  onStreamDefChanged();
-}
-
-QStringList HYDROGUI_StreamDlg::getSelectedProfiles() const
-{
-  QStringList aProfiles;
-
-  for ( int i = 0, n = myProfiles->count(); i < n; ++i )
-  {
-    QListWidgetItem* aListItem = myProfiles->item( i );
-    if ( !aListItem )
-      continue;
-
-    QString aProfileName = aListItem->text();
-    aProfiles << aProfileName;
-  }
-
-  return aProfiles;
-}
-
-void HYDROGUI_StreamDlg::onStreamDefChanged()
-{
-  if ( signalsBlocked() )
-    return;
-
-  emit CreatePreview();
 }
 
 void HYDROGUI_StreamDlg::onRemoveProfiles()