Salome HOME
patch for install error on Linux
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImportLandCoverMapDlg.cxx
index 134239b8282cdccd24e5258fff55a6f45c1913c6..d99c13e4a83535de39e21cc95cb03a0a8078bb90 100644 (file)
@@ -47,6 +47,7 @@ HYDROGUI_ImportLandCoverMapDlg::HYDROGUI_ImportLandCoverMapDlg( HYDROGUI_Module*
   addPage( createPage3() );
   myFirstPageState = false;
   myDbfState = false;
+  myUpdateViewerState = false;
 }
 
 QWizardPage* HYDROGUI_ImportLandCoverMapDlg::createPage1() {
@@ -197,8 +198,8 @@ void HYDROGUI_ImportLandCoverMapDlg::setSelectedPolygonNames( const QStringList&
 
 void HYDROGUI_ImportLandCoverMapDlg::onItemSelectionChanged()
 { 
-  int aCurIndex = GetCurrentWizardIndex();
-  if (aCurIndex == 0)
+  int aCurIndex = getCurrentWizardIndex();
+  if (aCurIndex == 0 && getViewerState())
     emit selectionChanged( getSelectedPolygonNames() );
 }
 
@@ -293,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);
   }
 
 }
@@ -309,43 +312,37 @@ 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 = GetCurrentWizardIndex();
+  int aCurrPage = getCurrentWizardIndex();
   switch ( aCurrPage )
   {
     case 0:
     {
-      if (!myFirstPageState)
-      {
-        SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), tr("FILE_ISNT_CHOSEN"));
-        return false;
-      }
-      if (myPolygonsListWidget->selectedItems().empty())
-      {
-        SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), tr("POLYGONS_ISNT_SELECTED"));
+      //this method verifies first page
+      if (!CheckFirstPageFilling())
         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:
     {
       if (myDBFAttrListWidget->selectedItems().empty())
       {
-        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 ("ATTRS_ISNT_SELECTED"));
         return false;
       }
       break;
     }
     case 2: //last page
     {
-      if (myPolygonsListWidget->selectedItems().empty())
+      if (this->isPolygonListEmpty())
       {
         SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), tr("POLYGONS_ISNT_SELECTED"));
         return false;
@@ -418,7 +415,42 @@ bool HYDROGUI_ImportLandCoverMapDlg::getDbfState() const
   return myDbfState;
 }
 
-int HYDROGUI_ImportLandCoverMapDlg::GetCurrentWizardIndex() const
+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;
+  }
+  return true;
 }
\ No newline at end of file