Salome HOME
LCM // Import/Export of SHP p.3
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImportLandCoverMapDlg.cxx
index 5c7c5ccd2f1057ed4ed915fca6b7dcf1f13aeced..40add2d825d6d226635243fc0383b7eda33f5c56 100644 (file)
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_Session.h>
 #include <SUIT_FileDlg.h>
-
+#include <HYDROGUI_Module.h>
+#include <SUIT_MessageBox.h>
+#include <LightApp_Application.h>
 #include <QTableWidget>
 #include <QHeaderView>
 #include <QComboBox>
+#include <QStackedWidget>
 
 HYDROGUI_ImportLandCoverMapDlg::HYDROGUI_ImportLandCoverMapDlg( HYDROGUI_Module* theModule, const QString& theTitle )
 : HYDROGUI_Wizard( theModule, theTitle )
@@ -39,6 +42,7 @@ HYDROGUI_ImportLandCoverMapDlg::HYDROGUI_ImportLandCoverMapDlg( HYDROGUI_Module*
   addPage( createPage1() );
   addPage( createPage2() );
   addPage( createPage3() );
+  myFirstPageState = false;
 }
 
 QWizardPage* HYDROGUI_ImportLandCoverMapDlg::createPage1() {
@@ -117,7 +121,7 @@ QWizardPage* HYDROGUI_ImportLandCoverMapDlg::createPage2() {
 
 
   myDBFAttr = new QListWidget( aPage );
-  myDBFAttr->setSelectionMode( QListWidget::ExtendedSelection );
+  myDBFAttr->setSelectionMode( QListWidget::SingleSelection );
   myDBFAttr->setEditTriggers( QListWidget::NoEditTriggers );
   myDBFAttr->setViewMode( QListWidget::ListMode );
   myDBFAttr->setSortingEnabled( false );
@@ -141,20 +145,6 @@ QWizardPage* HYDROGUI_ImportLandCoverMapDlg::createPage3() {
   
   myTableW = new QTableWidget();
 
-  myTableW->setRowCount(5);
-  myTableW->setColumnCount(2);
-
-  QStringList list;
-  list << "1" << "2" << "3";
-
-  for (int i = 0; i < 5; i++)
-    for (int j = 0; j < 2; j++)
-    {
-      QComboBox* CB = new QComboBox();
-      CB->addItems(list);
-      myTableW->setCellWidget(i,j,CB);
-    }
-
   // Layout
   QVBoxLayout* aPageLayout = new QVBoxLayout;
   aPageLayout->setMargin( 5 );
@@ -173,6 +163,7 @@ HYDROGUI_ImportLandCoverMapDlg::~HYDROGUI_ImportLandCoverMapDlg()
 void HYDROGUI_ImportLandCoverMapDlg::reset()
 {
   myPolygons->clear();
+  myDBFAttr->clear();
 }
 
 void HYDROGUI_ImportLandCoverMapDlg::setPolygonNames( const QStringList& theNames )
@@ -181,7 +172,13 @@ void HYDROGUI_ImportLandCoverMapDlg::setPolygonNames( const QStringList& theName
   myPolygons->addItems( theNames );
 }
 
-void HYDROGUI_ImportLandCoverMapDlg::removePolygonNames( const QStringList& theNames )
+void HYDROGUI_ImportLandCoverMapDlg::setAttributeNames( const QStringList& theAttrNames )
+{
+  myDBFAttr->clear();
+  myDBFAttr->addItems( theAttrNames );
+}
+
+/*void HYDROGUI_ImportLandCoverMapDlg::removePolygonNames( const QStringList& theNames )
 {
   QList<QListWidgetItem*> aFoundItems;
 
@@ -192,7 +189,7 @@ void HYDROGUI_ImportLandCoverMapDlg::removePolygonNames( const QStringList& theN
       delete anItem;
     }
   }
-}
+}*/
 
 void HYDROGUI_ImportLandCoverMapDlg::setSelectedPolygonNames( const QStringList& theNames )
 {
@@ -224,6 +221,7 @@ QStringList HYDROGUI_ImportLandCoverMapDlg::getSelectedPolygonNames() const
 }
 
 
+
 void HYDROGUI_ImportLandCoverMapDlg::onBrowse()
 {
   QString aFilter( tr( "LANDCOVERMAP_FILTER" ) );
@@ -260,3 +258,92 @@ QString HYDROGUI_ImportLandCoverMapDlg::getFileName() const
   return myFileName->text();
 }
 
+
+void HYDROGUI_ImportLandCoverMapDlg::FillCorrTable(const QStringList& theFirstColumn, const QStringList& theSecondColumn)
+{
+  int FCSize = theFirstColumn.size();
+  int SCSize = theSecondColumn.size();
+  myTableW->setRowCount(FCSize);
+  myTableW->setColumnCount(2);
+
+  for (int i = 0; i < FCSize; i++)
+  {
+    QTableWidgetItem* aTWI = new QTableWidgetItem();
+    aTWI->setText(theFirstColumn.at(i));
+    aTWI->setFlags(Qt::ItemIsUserCheckable);
+    myTableW->setItem(i, 0, aTWI);
+  }
+  
+  for (int i = 0; i < FCSize; i++)
+  {
+    QComboBox* aCB = new QComboBox();
+    aCB->addItems(theSecondColumn);
+    myTableW->setCellWidget(i, 1, aCB);
+  }
+}
+
+QString HYDROGUI_ImportLandCoverMapDlg::getSelectedFieldName() const
+{
+  return myDBFAttr->selectedItems().first()->text();
+}
+
+void HYDROGUI_ImportLandCoverMapDlg::setFirstPageState(bool bState)
+{
+  myFirstPageState = bState;
+}
+
+bool HYDROGUI_ImportLandCoverMapDlg::acceptCurrent() const
+{
+  //Check the state of curent page
+  int CurrPage = wizard()->currentIndex();
+  switch ( CurrPage )
+  {
+    case 0:
+    {
+      if (!myFirstPageState)
+        return false;
+      break;
+    }
+    case 1:
+    {
+      if (this->myDBFAttr->selectedItems().empty())
+        return false;
+      break;
+    }
+    default:
+     return false;
+  }
+  return true;
+
+}
+
+void HYDROGUI_ImportLandCoverMapDlg::GetAttribute2StricklerCorr(QStringList& AttrValues, QStringList& ST)
+{
+  int aRowCount = myTableW->rowCount();
+  for (int i = 0; i < aRowCount; i++)
+  {
+    QTableWidgetItem* aTWI = myTableW->item(i, 0);
+    AttrValues.push_back(aTWI->text());
+  }
+
+  for (int i = 0; i < aRowCount; i++)
+  {
+    QWidget* aW = myTableW->cellWidget(i, 1);
+    QComboBox* aCB = dynamic_cast<QComboBox*> (aW);
+    ST.push_back(aCB->currentText());
+  }
+}
+
+
+QVector<int> HYDROGUI_ImportLandCoverMapDlg::getSelectedPolygonIndices() const
+{
+  QVector<int> aSelectedIndices;
+
+  QModelIndexList aSelectedItems = myPolygons->selectionModel()->selectedIndexes();
+  foreach( QModelIndex index, aSelectedItems ) {
+    aSelectedIndices << index.row();
+  }
+
+  return aSelectedIndices;
+}
\ No newline at end of file