+
+void HYDROGUI_ImportLandCoverMapDlg::FillCorrespondenceTable(const QStringList& theFirstColumn,
+ const QStringList& theSecondColumn,
+ const QVector<int> theDefCBIndices,
+ const QVector<QColor> theColors)
+{
+ int aFCSize = theFirstColumn.size(); // == theDefCBIndices.size() !
+ int aSCSize = theSecondColumn.size();
+
+ myStrColors = theColors;
+
+ myCorrTableWidget->setRowCount(aFCSize);
+ myCorrTableWidget->setColumnCount(3);
+ QTableWidgetItem* aHeader_1 = new QTableWidgetItem(QString(tr("TABLE_H1")), QTableWidgetItem::Type);
+ QTableWidgetItem* aHeader_2 = new QTableWidgetItem(QString(tr("TABLE_H2")), QTableWidgetItem::Type);
+ QTableWidgetItem* aHeader_3 = new QTableWidgetItem(QString(tr("TABLE_H3")), QTableWidgetItem::Type);
+ myCorrTableWidget->setHorizontalHeaderItem(0, aHeader_1);
+ myCorrTableWidget->setHorizontalHeaderItem(1, aHeader_2);
+ myCorrTableWidget->setHorizontalHeaderItem(2, aHeader_3);
+ myCorrTableWidget->horizontalHeader()->setSectionResizeMode( QHeaderView::ResizeToContents );
+ //
+ for (int i = 0; i < aFCSize; i++)
+ {
+ QTableWidgetItem* aTWI = new QTableWidgetItem();
+ aTWI->setText(theFirstColumn.at(i));
+ aTWI->setFlags(Qt::ItemIsUserCheckable);
+ myCorrTableWidget->setItem(i, 0, aTWI);
+ }
+ //
+ QSignalMapper* signalMap = new QSignalMapper();
+ for (int i = 0; i < aFCSize; i++)
+ {
+ QComboBox* aCB = new QComboBox();
+ connect(aCB, SIGNAL(currentIndexChanged(int)), signalMap, SLOT(map()));
+ signalMap->setMapping(aCB, i);
+ aCB->addItems(theSecondColumn);
+ aCB->setCurrentIndex(theDefCBIndices[i]);
+ myCorrTableWidget->setCellWidget(i, 1, aCB);
+ }
+ connect(signalMap, SIGNAL(mapped(int)), this, SLOT(onComboBoxColorChanged(int)));
+
+ //
+ for (int i = 0; i < aFCSize; i++)
+ {
+ QTableWidgetItem* aTWI = new QTableWidgetItem;
+ aTWI->setBackground(myStrColors[theDefCBIndices[i]]);
+ aTWI->setFlags(Qt::NoItemFlags);
+ myCorrTableWidget->setItem(i, 2, aTWI);
+ }
+
+}
+
+QString HYDROGUI_ImportLandCoverMapDlg::getSelectedFieldName() const
+{
+ return myDBFAttrListWidget->selectedItems().first()->text();
+}
+
+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();
+ switch ( aCurrPage )
+ {
+ case 0:
+ {
+ //this method verifies first page
+ if (!CheckFirstPageFilling())
+ return false;
+ break;
+ }
+ case 1:
+ {
+ if (myDBFAttrListWidget->selectedItems().empty())
+ {
+ SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), tr ("ATTRS_ISNT_SELECTED"));
+ return false;
+ }
+ break;
+ }
+ case 2: //last page
+ {
+ if (this->isPolygonListEmpty())
+ {
+ SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), tr("POLYGONS_ISNT_SELECTED"));
+ return false;
+ }
+ break;
+ }
+ default:
+ return false;
+ }
+ return true;
+}
+
+void HYDROGUI_ImportLandCoverMapDlg::getValAttr2StricklerTypeCorr(QStringList& theAttrValues, QStringList& theST)
+{
+ int aRowCount = myCorrTableWidget->rowCount();
+ for (int i = 0; i < aRowCount; i++)
+ {
+ QTableWidgetItem* aTWI = myCorrTableWidget->item(i, 0);
+ theAttrValues.push_back(aTWI->text());
+ }
+
+ for (int i = 0; i < aRowCount; i++)
+ {
+ QWidget* aW = myCorrTableWidget->cellWidget(i, 1);
+ QComboBox* aCB = dynamic_cast<QComboBox*> (aW);
+ theST.push_back(aCB->currentText());
+ }
+}
+
+
+QVector<int> HYDROGUI_ImportLandCoverMapDlg::getSelectedPolygonIndices() const
+{
+ QVector<int> aSelectedIndices;
+
+ QModelIndexList aSelectedItems = myPolygonsListWidget->selectionModel()->selectedIndexes();
+ foreach( QModelIndex index, aSelectedItems ) {
+ aSelectedIndices << index.row();
+ }
+
+ return aSelectedIndices;
+}
+
+void HYDROGUI_ImportLandCoverMapDlg::onAttrCBChecked( bool theState )
+{
+ if (theState)
+ SetButtonsState ( false );
+ else
+ SetButtonsState ( true );
+}
+
+bool HYDROGUI_ImportLandCoverMapDlg::getAttrCheckBoxState() const
+{
+ return myAttrCheckBox->isChecked();
+}
+
+void HYDROGUI_ImportLandCoverMapDlg::onComboBoxColorChanged(int theInd)
+{
+ QComboBox* CB = qobject_cast<QComboBox*> (myCorrTableWidget->cellWidget(theInd, 1));
+ int aCurIndOfCB = CB->currentIndex();
+ myCorrTableWidget->item(theInd, 2)->setBackground(myStrColors[aCurIndOfCB]);
+}
+
+void HYDROGUI_ImportLandCoverMapDlg::setDbfState(bool theState)
+{
+ myDbfState = theState;
+}
+
+bool HYDROGUI_ImportLandCoverMapDlg::getDbfState() const
+{
+ return myDbfState;
+}
+
+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;
+}