From: isn Date: Fri, 20 Nov 2015 08:50:38 +0000 (+0300) Subject: refs #728 + minor code revision X-Git-Tag: v1.5~9^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ea1e1782c3738436bfc935b993e32c1070bfd937;p=modules%2Fhydro.git refs #728 + minor code revision --- diff --git a/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.cxx b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.cxx index 73ec62d0..f075284d 100644 --- a/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.cxx @@ -198,7 +198,7 @@ void HYDROGUI_ImportLandCoverMapDlg::setSelectedPolygonNames( const QStringList& void HYDROGUI_ImportLandCoverMapDlg::onItemSelectionChanged() { - int aCurIndex = GetCurrentWizardIndex(); + int aCurIndex = getCurrentWizardIndex(); if (aCurIndex == 0 && getViewerState()) emit selectionChanged( getSelectedPolygonNames() ); } @@ -310,43 +310,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")); + //this method verifies first page + if (!CheckFirstPageFilling()) return false; - } - if (myPolygonsListWidget->selectedItems().empty()) - { - SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), tr("POLYGONS_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: { 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; @@ -419,7 +413,7 @@ bool HYDROGUI_ImportLandCoverMapDlg::getDbfState() const return myDbfState; } -int HYDROGUI_ImportLandCoverMapDlg::GetCurrentWizardIndex() const +int HYDROGUI_ImportLandCoverMapDlg::getCurrentWizardIndex() const { return wizard()->currentIndex(); } @@ -432,4 +426,29 @@ void HYDROGUI_ImportLandCoverMapDlg::setViewerState(bool 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 diff --git a/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.h b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.h index e3c05903..524f41a6 100644 --- a/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.h +++ b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.h @@ -56,13 +56,17 @@ public: QString getFileName() const; void setFirstPageState(bool theState); + bool getFirstPageState() const; bool getAttrCheckBoxState() const; void getValAttr2StricklerTypeCorr(QStringList& theAttrValues, QStringList& theST); QVector getSelectedPolygonIndices() const; + bool isPolygonListEmpty() const; + + bool CheckFirstPageFilling() const; void setDbfState(bool theState); bool getDbfState() const; - int GetCurrentWizardIndex() const; + int getCurrentWizardIndex() const; void setViewerState(bool theState); bool getViewerState() const; diff --git a/src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.cxx b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.cxx index 403a2263..f40b69a2 100644 --- a/src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.cxx @@ -337,18 +337,16 @@ void HYDROGUI_ImportLandCoverMapOp::onViewerSelectionChanged() return; int aCurIndex = -1; - aCurIndex = aPanel->GetCurrentWizardIndex(); + aCurIndex = aPanel->getCurrentWizardIndex(); if (aCurIndex != 0) return; OCCViewer_ViewManager* aViewManager = getPreviewManager(); Handle(AIS_InteractiveContext) aCtx = NULL; - if ( aViewManager ) { - if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) { + if ( aViewManager ) + if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) aCtx = aViewer->getAISContext(); - } - } if ( !aCtx.IsNull() ) { @@ -464,6 +462,13 @@ void HYDROGUI_ImportLandCoverMapOp::onNext( const int theIndex ) void HYDROGUI_ImportLandCoverMapOp::onApply() { + HYDROGUI_ImportLandCoverMapDlg* aPanel = ::qobject_cast( inputPanel() ); + if ( !aPanel ) + return; + + if (!aPanel->CheckFirstPageFilling()) + return; + QApplication::setOverrideCursor( Qt::WaitCursor ); int anUpdateFlags = 0; QString anErrorMsg; diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 31619c9c..a3533687 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -2379,7 +2379,12 @@ file cannot be correctly imported for an Obstacle definition. POLYGONS_ISNT_SELECTED Polygons isn't selected - + + ATTRS_ISNT_SELECTED + Attribute isn't selected + + + DBF_LOAD_ERR_MESS Cant open DBF file or it's corrupted @@ -2400,7 +2405,10 @@ file cannot be correctly imported for an Obstacle definition. DEF_POLYGON_NAME polygon - + + LCM_IMPORT_WARNING + Import of Land cover map + CANNT_IMPORT_LCM Cannot import land cover map;