Salome HOME
Merge branch 'BR_1328' into BR_DEMO
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImportLandCoverMapDlg.cxx
index 82e4b9d703bf2c846b771be3e8d2606d296cc23e..3ad5e1dcc1869bc7eabc66c51a6c28275a41ef40 100644 (file)
@@ -47,6 +47,7 @@ HYDROGUI_ImportLandCoverMapDlg::HYDROGUI_ImportLandCoverMapDlg( HYDROGUI_Module*
   addPage( createPage3() );
   myFirstPageState = false;
   myDbfState = false;
+  myUpdateViewerState = false;
 }
 
 QWizardPage* HYDROGUI_ImportLandCoverMapDlg::createPage1() {
@@ -83,7 +84,7 @@ QWizardPage* HYDROGUI_ImportLandCoverMapDlg::createPage1() {
   aLandcoverNameLayout->addWidget( aLandcoverNameLabel );
   aLandcoverNameLayout->addWidget( myObjectName );
 
-  QGroupBox* aPolygonsGroup = new QGroupBox( tr( "FOUNDED_POLYGONS" ) );
+  QGroupBox* aPolygonsGroup = new QGroupBox( tr( "FOUND_POLYGONS" ) );
   myPolygonsListWidget = new QListWidget( aPolygonsGroup );
   myPolygonsListWidget->setSelectionMode( QListWidget::ExtendedSelection );
   myPolygonsListWidget->setEditTriggers( QListWidget::NoEditTriggers );
@@ -196,8 +197,10 @@ void HYDROGUI_ImportLandCoverMapDlg::setSelectedPolygonNames( const QStringList&
 }
 
 void HYDROGUI_ImportLandCoverMapDlg::onItemSelectionChanged()
-{
-  emit selectionChanged( getSelectedPolygonNames() );
+{ 
+  int aCurIndex = getCurrentWizardIndex();
+  if (aCurIndex == 0 && getViewerState())
+    emit selectionChanged( getSelectedPolygonNames() );
 }
 
 QStringList HYDROGUI_ImportLandCoverMapDlg::getSelectedPolygonNames() const
@@ -266,7 +269,7 @@ void HYDROGUI_ImportLandCoverMapDlg::FillCorrespondenceTable(const QStringList&
   myCorrTableWidget->setHorizontalHeaderItem(0, aHeader_1);
   myCorrTableWidget->setHorizontalHeaderItem(1, aHeader_2);
   myCorrTableWidget->setHorizontalHeaderItem(2, aHeader_3);
-  myCorrTableWidget->horizontalHeader()->setResizeMode( QHeaderView::ResizeToContents );
+  myCorrTableWidget->horizontalHeader()->setSectionResizeMode( QHeaderView::ResizeToContents );
   //
   for (int i = 0; i < aFCSize; i++)
   {
@@ -291,8 +294,10 @@ void HYDROGUI_ImportLandCoverMapDlg::FillCorrespondenceTable(const QStringList&
   //
   for (int i = 0; i < aFCSize; i++)
   {
-    myCorrTableWidget->setItem(i, 2, new QTableWidgetItem);
-    myCorrTableWidget->item(i, 2)->setBackground(myStrColors[theDefCBIndices[i]]);
+    QTableWidgetItem* aTWI = new QTableWidgetItem;
+    aTWI->setBackground(myStrColors[theDefCBIndices[i]]);
+    aTWI->setFlags(Qt::NoItemFlags);
+    myCorrTableWidget->setItem(i, 2, aTWI);
   }
 
 }
@@ -307,36 +312,39 @@ void HYDROGUI_ImportLandCoverMapDlg::setFirstPageState(bool theState)
   myFirstPageState = theState;
 }
 
+bool HYDROGUI_ImportLandCoverMapDlg::getFirstPageState() const
+{
+  return myFirstPageState;
+}
+
+
 bool HYDROGUI_ImportLandCoverMapDlg::acceptCurrent() const
 {
   //Check the state of the current page
-  int aCurrPage = wizard()->currentIndex();
+  int aCurrPage = getCurrentWizardIndex();
   switch ( aCurrPage )
   {
     case 0:
     {
-      if (!myFirstPageState)
-      {
-        SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), tr("FILE_ISNT_CHOSEN"));
+      //this method verifies first page
+      if (!CheckFirstPageFilling())
         return false;
-      }
-      if (myPolygonsListWidget->selectedItems().empty())
+      break;
+    }
+    case 1:
+    {
+      if (myDBFAttrListWidget->selectedItems().empty())
       {
-        SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), tr("POLYGONS_ISNT_SELECTED"));
+        SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), tr ("ATTRS_ISNT_SELECTED"));
         return false;
       }
-      if (getAttrCheckBoxState() && !getDbfState())
-      {
-         SUIT_MessageBox::critical( module()->getApp()->desktop(), tr( "DBF_LOAD_ERROR" ), tr("DBF_LOAD_ERR_MESS"));
-         return false;
-      }
       break;
     }
-    case 1:
+    case 2: //last page
     {
-      if (myDBFAttrListWidget->selectedItems().empty())
+      if (this->isPolygonListEmpty())
       {
-        SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), "Attribute isn't selected");
+        SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), tr("POLYGONS_ISNT_SELECTED"));
         return false;
       }
       break;
@@ -405,4 +413,59 @@ void HYDROGUI_ImportLandCoverMapDlg::setDbfState(bool theState)
 bool HYDROGUI_ImportLandCoverMapDlg::getDbfState() const
 {
   return myDbfState;
-}
\ No newline at end of file
+}
+
+void HYDROGUI_ImportLandCoverMapDlg::setDbfRecordsNb(int theRecordsNbs)
+{
+  myDbfRecordsNbs = theRecordsNbs;
+}
+
+int HYDROGUI_ImportLandCoverMapDlg::getDbfRecordsNb() const
+{
+  return myDbfRecordsNbs;
+}
+
+int HYDROGUI_ImportLandCoverMapDlg::getCurrentWizardIndex() const
+{
+  return wizard()->currentIndex();
+}
+
+void HYDROGUI_ImportLandCoverMapDlg::setViewerState(bool theState)
+{
+  myUpdateViewerState = theState;
+}
+
+bool HYDROGUI_ImportLandCoverMapDlg::getViewerState() const
+{
+  return myUpdateViewerState;
+}
+
+bool HYDROGUI_ImportLandCoverMapDlg::isPolygonListEmpty() const
+{
+  return myPolygonsListWidget->selectedItems().empty();
+}
+
+bool HYDROGUI_ImportLandCoverMapDlg::CheckFirstPageFilling() const
+{
+  if (!this->getFirstPageState())
+  {
+    SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), tr("FILE_ISNT_CHOSEN"));
+    return false;
+  }
+  if (this->isPolygonListEmpty())
+  {
+    SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), tr("POLYGONS_ISNT_SELECTED"));
+    return false;
+  }
+  if (this->getAttrCheckBoxState() && !this->getDbfState())
+  {
+     SUIT_MessageBox::critical( module()->getApp()->desktop(), tr( "DBF_LOAD_ERROR" ), tr("DBF_LOAD_ERR_MESS"));
+     return false;
+  }
+  if (this->getAttrCheckBoxState() && this->getDbfRecordsNb() == 0)
+  {
+     SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "DBF_NB_RECORDS_IS_NULL" ), tr("DBF_NB_RECORDS_IS_NULL_MESS"));
+     return false;
+  }
+  return true;
+}