From: vsr Date: Wed, 2 Jul 2008 08:42:55 +0000 (+0000) Subject: IMP 001989: multi selection in "Import" dialog boxes X-Git-Tag: V4_1_0_maintainance_20080703 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=23fbaec1b78bd98130f820c167257fd1ceeb6a8a;p=modules%2Fvisu.git IMP 001989: multi selection in "Import" dialog boxes --- diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index d91aef28..1515c716 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -2495,3 +2495,18 @@ msgstr "File size (bytes)" msgid "VisuGUI_FileInfoDlg::MED_VERSION" msgstr "MED version" + +msgid "VisuGUI::ERR_ERROR_IN_THE_FILE" +msgstr "Error in the file" + +msgid "VisuGUI::TLT_IMPORT_TABLE" +msgstr "Import table" + +msgid "VisuGUI::ERR_FILE_NOT_EXISTS" +msgstr "File does not exist" + +msgid "VisuGUI::UNKNOWN_IMPORT_ERROR" +msgstr "Unknown error" + +msgid "VisuGUI::IMPORT_ERRORS" +msgstr "Import operation has finished with errors:" diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index bd362c51..709affe7 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -53,6 +53,7 @@ #include "SUIT_ViewWindow.h" #include "SUIT_ViewManager.h" +#include "SUIT_OverrideCursor.h" #include "CAM_Module.h" @@ -187,7 +188,7 @@ VisuGUI SUIT_ResourceMgr* aResourceMgr = GetResourceMgr(); - // Get file name + // Get file name(s) QStringList aFilter; aFilter.append( tr( "FLT_MED_FILES" ) ); aFilter.append( tr( "FLT_DISTRIBUTED_MED_FILES" ) ); @@ -195,58 +196,86 @@ VisuGUI bool toUseBuildProgress = aResourceMgr->booleanValue("VISU", "use_build_progress", false); - SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( GetDesktop(this), true, tr("USE_BUILD_PROGRESS") ); - fd->setCaption( tr( "IMPORT_FROM_FILE" ) ); - fd->setFilters( aFilter ); - fd->SetChecked( toUseBuildProgress ); + SalomeApp_CheckFileDlg fd( GetDesktop(this), true, tr("USE_BUILD_PROGRESS") ); + fd.setCaption( tr( "IMPORT_FROM_FILE" ) ); + fd.setMode( SalomeApp_CheckFileDlg::ExistingFiles ); + fd.setFilters( aFilter ); + fd.SetChecked( toUseBuildProgress ); if ( SalomeApp_CheckFileDlg::getLastVisitedPath().isEmpty() ) - fd->setDir( QDir::currentDirPath() ); - fd->exec(); - QFileInfo aFileInfo( fd->selectedFile() ); - toUseBuildProgress = fd->IsChecked(); - delete fd; - - // Check the file name - if ( !aFileInfo.exists() ) - return; + fd.setDir( QDir::currentDirPath() ); + + QStringList fileNames; + if ( !fd.exec() ) + return; // cancelled, return + + fileNames = fd.selectedFiles(); + toUseBuildProgress = fd.IsChecked(); + + if ( fileNames.count() == 0 ) + return; // nothing selected, return + + SUIT_OverrideCursor wc; + QStringList errors; + + for ( QStringList::ConstIterator it = fileNames.begin(); it != fileNames.end(); ++it ) { + QFileInfo aFileInfo( *it ); - if ( !toUseBuildProgress ) - { - bool toBuildFields = aResourceMgr->booleanValue( "VISU", "build_fields", true ); - bool toBuildMinMax = aResourceMgr->booleanValue( "VISU", "build_min_max", true ); - bool toBuildGroups = aResourceMgr->booleanValue( "VISU", "build_groups", true ); - bool toBuildAll = aResourceMgr->booleanValue( "VISU", "full_med_loading", false ); - bool toBuildAtOnce = aResourceMgr->booleanValue( "VISU", "build_at_once", false ); - - QString anInfo("Importing From File " + aFileInfo.filePath() + "..." ); - application()->putInfo( anInfo ); - - QApplication::setOverrideCursor(Qt::waitCursor); - VISU::Result_var aResult = GetVisuGen(this)->CreateResult( aFileInfo.filePath() ); - - if (CORBA::is_nil(aResult.in())) { - SUIT_MessageBox::warn1(GetDesktop(this), - tr("WRN_VISU"), - VisuGUI_BuildProgressDlg::tr("ERR_ERROR_IN_THE_FILE"), - tr("BUT_OK")); - QApplication::restoreOverrideCursor(); - }else{ - aResult->SetBuildFields( toBuildFields, toBuildMinMax ); - aResult->SetBuildGroups( toBuildGroups ); - aResult->Build( toBuildAll, toBuildAtOnce ); - - UpdateObjBrowser(this); - application()->putInfo( anInfo + tr("INF_DONE")); - QApplication::restoreOverrideCursor(); - } - } - else - { - VisuGUI_BuildProgressDlg* aBuildProgressDlg = new VisuGUI_BuildProgressDlg( GetDesktop(this) ); - aBuildProgressDlg->setFileName( aFileInfo.filePath() ); - aBuildProgressDlg->setGenerator( GetVisuGen(this) ); - aBuildProgressDlg->show(); + if ( !aFileInfo.exists() ) { + // file not exist + errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ). + arg( tr( "ERR_FILE_NOT_EXISTS" ) ) ); } + else { + try { + if ( !toUseBuildProgress ) { + // build progress is not used, use build flags from settings + bool toBuildFields = aResourceMgr->booleanValue( "VISU", "build_fields", true ); + bool toBuildMinMax = aResourceMgr->booleanValue( "VISU", "build_min_max", true ); + bool toBuildGroups = aResourceMgr->booleanValue( "VISU", "build_groups", true ); + bool toBuildAll = aResourceMgr->booleanValue( "VISU", "full_med_loading", false ); + bool toBuildAtOnce = aResourceMgr->booleanValue( "VISU", "build_at_once", false ); + + QString anInfo( tr( "IMPORT_FROM_FILE" ) + " " + aFileInfo.filePath() + " ... " ); + application()->putInfo( anInfo ); + + VISU::Result_var aResult = GetVisuGen( this )->CreateResult( aFileInfo.filePath() ); + + if ( CORBA::is_nil( aResult.in() ) ) { + errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ). + arg( tr( "ERR_ERROR_IN_THE_FILE" ) ) ); + } + else { + aResult->SetBuildFields( toBuildFields, toBuildMinMax ); + aResult->SetBuildGroups( toBuildGroups ); + aResult->Build( toBuildAll, toBuildAtOnce ); + application()->putInfo( anInfo + tr("INF_DONE") ); + } + } // if ( !toUseBuildProgress ) + else { + // use build progress + wc.suspend(); + VisuGUI_BuildProgressDlg* aBuildProgressDlg = new VisuGUI_BuildProgressDlg( GetDesktop(this) ); + aBuildProgressDlg->setFileName( aFileInfo.filePath() ); + aBuildProgressDlg->setGenerator( GetVisuGen(this) ); + aBuildProgressDlg->exec(); + wc.resume(); + } + } // try + catch(...) { + errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).arg( tr( "UNKNOWN_IMPORT_ERROR" ) ) ); + } + } // else // if ( !aFileInfo.exists() ) + } // for (...) + + if ( errors.count() > 0 ) { + SUIT_MessageBox::error1( GetDesktop(this), + tr("ERR_ERROR"), + tr("IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ), + tr("BUT_OK") ); + } + else { + UpdateObjBrowser(this); + } } void @@ -265,26 +294,50 @@ VisuGUI if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() ) anInitialPath = QDir::currentDirPath(); - QFileInfo aFileInfo = - SUIT_FileDlg::getFileName(GetDesktop(this), - anInitialPath, - aFilter, - tr("MEN_IMPORT_TABLE"), - true); - if (aFileInfo.exists()) { - application()->putInfo( tr("MEN_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." ); + QStringList aFiles = SUIT_FileDlg::getOpenFileNames(GetDesktop(this), + anInitialPath, + aFilter, + tr("TLT_IMPORT_TABLE")); + if ( aFiles.count() == 0 ) + return; // nothing selected - CORBA::Object_var anObject = GetVisuGen(this)->ImportTables(aFileInfo.filePath()); + QStringList errors; + for ( QStringList::ConstIterator it = aFiles.begin(); it != aFiles.end(); ++it ) { + QFileInfo aFileInfo( *it ); - if (CORBA::is_nil(anObject.in())) { - SUIT_MessageBox::warn1(GetDesktop(this), - tr("WRN_VISU"), - tr("ERR_ERROR_IN_THE_FILE"), - tr("BUT_OK")); - } else { - application()->putInfo(aFileInfo.filePath()+tr("INF_DONE")); - UpdateObjBrowser(this); + if ( !aFileInfo.exists() ) { + errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ). + arg( tr( "ERR_FILE_NOT_EXISTS" ) ) ); } + else { + try { + QString anInfo( tr("TLT_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." ); + application()->putInfo( anInfo ); + + CORBA::Object_var anObject = GetVisuGen(this)->ImportTables(aFileInfo.filePath()); + + if (CORBA::is_nil(anObject.in())) { + errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ). + arg( tr( "ERR_ERROR_IN_THE_FILE" ) ) ); + } + else { + application()->putInfo( anInfo + tr("INF_DONE") ); + } + } + catch(...) { + errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).arg( tr( "UNKNOWN_IMPORT_ERROR" ) ) ); + } + } + } + + if ( errors.count() > 0 ) { + SUIT_MessageBox::error1( GetDesktop(this), + tr("ERR_ERROR"), + tr("IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ), + tr("BUT_OK") ); + } + else { + UpdateObjBrowser(this); } }