Back to index

salome-gui  6.5.0
LightApp_Preferences.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // File:      LightApp_Preferences.cxx
00024 // Author:    Sergey TELKOV
00025 //
00026 #include "LightApp_Preferences.h"
00027 
00031 LightApp_Preferences::LightApp_Preferences( QtxResourceMgr* resMgr, QWidget* parent )
00032 : SUIT_PreferenceMgr( resMgr, parent )
00033 {
00034 }
00035 
00039 LightApp_Preferences::~LightApp_Preferences()
00040 {
00041 }
00042 
00046 int LightApp_Preferences::addPreference( const QString& label, const int pId, const int type,
00047                                          const QString& section, const QString& param )
00048 {
00049   return addItem( label, pId, (SUIT_PreferenceMgr::PrefItemType)type, section, param );
00050 }
00051 
00055 int LightApp_Preferences::addPreference( const QString& mod, const QString& label, const int pId,
00056                                          const int type, const QString& section, const QString& param )
00057 {
00058   int id = addItem( label, pId, (SUIT_PreferenceMgr::PrefItemType)type, section, param );
00059   if ( id != -1 && !mod.isEmpty() )
00060     myPrefMod.insert( id, mod );
00061   return id;
00062 }
00063 
00067 bool LightApp_Preferences::hasModule( const QString& mod ) const
00068 {
00069   bool res = false;
00070   for ( PrefModuleMap::ConstIterator it = myPrefMod.begin(); it != myPrefMod.end() && !res; ++it )
00071     res = it.value() == mod;
00072   return res;
00073 }
00074 
00075 void LightApp_Preferences::activateItem( const QString& mod ) const
00076 {
00077   QtxPreferenceItem* item = findItem( mod, true );
00078 
00079   if ( !item )
00080     return;
00081 
00082   item->ensureVisible();
00083   item->activate();
00084 }
00085 
00087 void LightApp_Preferences::onHelp()
00088 {
00089 }
00090 
00092 void LightApp_Preferences::onApply()
00093 {
00094   store();
00095 }
00096 
00098 void LightApp_Preferences::changedResources( const ResourceMap& map )
00099 {
00100   for ( ResourceMap::ConstIterator it = map.begin(); 
00101         it != map.end(); ++it )
00102   {
00103     QString sec, param;
00104     it.key()->resource( sec, param );
00105     QString mod = module( it.key()->id() );
00106     emit preferenceChanged( mod, sec, param );
00107   }
00108 }
00109 
00111 QString LightApp_Preferences::module( const int id ) const
00112 {
00113   QString mod;
00114   if ( myPrefMod.contains( id ) )
00115     mod = myPrefMod[id];
00116   return mod;
00117 }