From 7f28bcfd18edaf709bd903e2ddb619794d47f1b0 Mon Sep 17 00:00:00 2001 From: sln Date: Fri, 20 Apr 2012 07:59:38 +0000 Subject: [PATCH] =?utf8?q?1)=20Backup=20is=20switched=20off=20if=20SALOME?= =?utf8?q?=5FBACKUP=5FFOLDER=20is=20not=20defined.=202)=20=C3=A2=C2=80?= =?utf8?q?=C2=9CActivate=20module=20by=20default=C3=A2=C2=80=C2=9D=20optio?= =?utf8?q?n=20is=20removed=20in=20preferences=20in=20case=20of=20one=20mod?= =?utf8?q?ule?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/LightApp/LightApp_Application.cxx | 33 +++++++++++++++++++-------- src/SUIT/SUIT_Session.cxx | 11 +++++---- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index dce1076b2..a19c39aec 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1846,7 +1846,9 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" ); pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" ); pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" ); - pref->addPreference( tr( "PREF_BACKUP" ), studyGroup, LightApp_Preferences::DblSpin, "Study", "backup_studies" ); + + if ( !SUIT_Session::session()->getBackupFolder().isEmpty() ) + pref->addPreference( tr( "PREF_BACKUP" ), studyGroup, LightApp_Preferences::DblSpin, "Study", "backup_studies" ); int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab ); QString platform; @@ -2123,14 +2125,27 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) } // Default Module Preferences - int moduleGroup = pref->addPreference( tr( "PREF_DEFAULT_MODULE" ), genTab ); - int moduleNameCombo = pref->addPreference( tr( "PREF_DEF_MODULE_NAME" ), moduleGroup, LightApp_Preferences::Selector, "Activate", "def_module" ); - aValuesList.clear(); - anIndicesList.clear(); - aValuesList << tr("PREF_DEF_MODULE_NONE") << tr("PREF_DEF_MODULE_CATHARE") << tr("PREF_DEF_MODULE_DIAGRAM"); - anIndicesList << 0 << 1 << 2 ; - pref->setItemProperty( "strings", aValuesList, moduleNameCombo ); - pref->setItemProperty( "indexes", anIndicesList, moduleNameCombo ); + QStringList aModuleNames; + modules( aModuleNames, false ); + if ( aModuleNames.count() > 1 ) + { + int moduleGroup = pref->addPreference( tr( "PREF_DEFAULT_MODULE" ), genTab ); + int moduleNameCombo = pref->addPreference( tr( "PREF_DEF_MODULE_NAME" ), moduleGroup, LightApp_Preferences::Selector, "Activate", "def_module" ); + aValuesList.clear(); + anIndicesList.clear(); + aValuesList.append( tr("PREF_DEF_MODULE_NONE") ); + anIndicesList.append( 0 ); + QStringList::iterator it = aModuleNames.begin(); + for ( int ind = 1; it != aModuleNames.end(); ++it, ++ind ) + { + const QString& modName = *it; + aValuesList.append( modName ); + anIndicesList.append( ind ); + } + + pref->setItemProperty( "strings", aValuesList, moduleNameCombo ); + pref->setItemProperty( "indexes", anIndicesList, moduleNameCombo ); + } // theme values Style_Model* aSModel = 0; diff --git a/src/SUIT/SUIT_Session.cxx b/src/SUIT/SUIT_Session.cxx index 9ab60b1ab..16b68a6fb 100755 --- a/src/SUIT/SUIT_Session.cxx +++ b/src/SUIT/SUIT_Session.cxx @@ -433,9 +433,6 @@ QString SUIT_Session::getBackupFolder() const if ( var ) aRes = var; - if ( aRes.isEmpty() || !QFileInfo( aRes ).exists() ) - aRes = QDir::tempPath(); - return aRes; } @@ -637,9 +634,13 @@ void SUIT_Session::restoreBackup() { QString pref = getBackupPrefix(); + QString bkpFold = getBackupFolder(); + if ( bkpFold .isEmpty() ) + return; + // checks whether temp folder contains old backups - QDir bkpDir( getBackupFolder() ); - + QDir bkpDir( bkpFold ); + QStringList filt; filt.append( pref + "*" ); bkpDir.setNameFilters( filt ); -- 2.39.2