]> SALOME platform Git repositories - modules/hydro.git/blobdiff - src/HYDROGUI/HYDROGUI_GeoreferencementDlg.cxx
Salome HOME
Creat\Edit stream operation.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_GeoreferencementDlg.cxx
index feb21b2952b59011ae47672af27949f1bc255f9d..57bfafb6f4df207c3210b54852eb9be1f1d6f736 100644 (file)
@@ -34,6 +34,7 @@
 #include <QItemDelegate>
 #include <QHeaderView>
 #include <QRadioButton>
+#include <QPushButton>
 #include <QLineEdit>
 #include <QButtonGroup>
 #include <QGroupBox>
@@ -122,7 +123,7 @@ void HYDROGUI_GeoreferencementDlg::Delegate::setModelData(
 }
 
 HYDROGUI_GeoreferencementDlg::HYDROGUI_GeoreferencementDlg( HYDROGUI_Module* theModule, const QString& theTitle )
-: HYDROGUI_InputPanel( theModule, theTitle )
+: HYDROGUI_InputPanel( theModule, theTitle ), myIsModified( false )
 {
   // Mode selector (all/selected)
   QGroupBox* aModeGroup = new QGroupBox( tr( "PROFILES" ), this );
@@ -140,6 +141,13 @@ HYDROGUI_GeoreferencementDlg::HYDROGUI_GeoreferencementDlg( HYDROGUI_Module* the
   aModeSelectorLayout->addWidget( anAllRB );
   aModeSelectorLayout->addWidget( aSelectedRB );
 
+  // Update selection button
+  myUpdateSelBtn = new QPushButton( mainFrame() );
+  myUpdateSelBtn->setText( tr("UPDATE_SELECTION") );
+  QBoxLayout* anUpdateSelLayout = new QHBoxLayout( mainFrame() );
+  anUpdateSelLayout->addWidget( myUpdateSelBtn );
+  anUpdateSelLayout->addStretch();
+
   // Table
   myTable = new QTableWidget( mainFrame() );
   myTable->setItemDelegate( new Delegate( this ) );
@@ -154,10 +162,14 @@ HYDROGUI_GeoreferencementDlg::HYDROGUI_GeoreferencementDlg( HYDROGUI_Module* the
 
   // Layout
   addWidget( aModeGroup );
+  addLayout( anUpdateSelLayout );
   addWidget( myTable );
 
   // Connect signals and slots
   connect( myModeButtons, SIGNAL( buttonClicked( int ) ), this, SLOT( onModeActivated( int ) ) );
+  connect( myUpdateSelBtn, SIGNAL( clicked() ), this, SIGNAL( updateSelection() ) );
+  connect( myTable->model(), SIGNAL( dataChanged ( const QModelIndex&, const QModelIndex& ) ), 
+           this, SLOT( onDataChanged() ) );
 }
 
 HYDROGUI_GeoreferencementDlg::~HYDROGUI_GeoreferencementDlg()
@@ -166,6 +178,7 @@ HYDROGUI_GeoreferencementDlg::~HYDROGUI_GeoreferencementDlg()
 
 void HYDROGUI_GeoreferencementDlg::onModeActivated( int theMode )
 {
+  myUpdateSelBtn->setEnabled( theMode == SelectedProfiles );
   emit modeActivated( theMode );
 }
 
@@ -187,11 +200,16 @@ void HYDROGUI_GeoreferencementDlg::setMode( const int theMode )
     aModeButton->setChecked( true );
   }
 
+  myUpdateSelBtn->setEnabled( theMode == SelectedProfiles );
+
   myModeButtons->blockSignals( isBlocked );
 }
 
 void HYDROGUI_GeoreferencementDlg::setData( const ProfilesGeoDataMap& theMap )
 {
+  disconnect( myTable->model(), SIGNAL( dataChanged ( const QModelIndex&, const QModelIndex& ) ), 
+              this, SLOT( onDataChanged() ) );
+
   myTable->setRowCount( 0 );
 
   foreach ( const QString& aProfileName, theMap.keys() ) {
@@ -236,6 +254,12 @@ void HYDROGUI_GeoreferencementDlg::setData( const ProfilesGeoDataMap& theMap )
   }
 
   myTable->resizeColumnToContents( 0 );
+  myTable->resizeRowsToContents();
+
+  myIsModified = false;
+  
+  connect( myTable->model(), SIGNAL( dataChanged ( const QModelIndex&, const QModelIndex& ) ), 
+           this, SLOT( onDataChanged() ) );
 }
 
 void HYDROGUI_GeoreferencementDlg::getData( ProfilesGeoDataMap& theMap )
@@ -291,4 +315,14 @@ void HYDROGUI_GeoreferencementDlg::onMousePress(
 QString HYDROGUI_GeoreferencementDlg::getString( const double theNumber ) const
 {
   return QString::number( theNumber, 'g', 12 );
+}
+
+void HYDROGUI_GeoreferencementDlg::onDataChanged()
+{
+  myIsModified = true;
+}
+
+bool HYDROGUI_GeoreferencementDlg::isModified() const
+{
+  return myIsModified;
 }
\ No newline at end of file