Back to index

salome-gui  6.5.0
Style_ResourceMgr.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 // File   : Style_ResourceMgr.cxx
00021 // Author : Vadim SANDLER, Open CASCADE S.A.S (vadim.sandler@opencascade.com)
00022 //
00023 #include "Style_ResourceMgr.h"
00024 
00043 Style_ResourceMgr::Style_ResourceMgr()
00044   : QtxResourceMgr( "SalomeStyle", "%1Config" )
00045 {
00046   if ( dirList().isEmpty() && ::getenv( "GUI_ROOT_DIR" ) )
00047     setDirList( QStringList() << Qtx::addSlash( ::getenv( "GUI_ROOT_DIR" ) ) + "share/salome/resources/gui" );
00048   setCurrentFormat( "xml" );
00049 }
00050 
00054 Style_ResourceMgr::~Style_ResourceMgr()
00055 {
00056 }
00057 
00064 QStringList Style_ResourceMgr::styles( StyleType type, bool sort )
00065 {
00066   QStringList sl;
00067   
00068   WorkingMode m = workingMode();
00069 
00070   switch ( type ) {
00071   case Global:
00072     setWorkingMode( IgnoreUserValues );
00073     sl = sections();
00074     break;
00075   case User:
00076     {
00077       setWorkingMode( AllowUserValues );
00078       sl = sections();
00079       setWorkingMode( IgnoreUserValues );
00080       QMutableListIterator<QString> it( sl );
00081       while ( it.hasNext() ) {
00082         QString s = it.next();
00083         if ( hasSection( s ) ) it.remove();
00084       }
00085     }
00086     break;
00087   case All:
00088     setWorkingMode( AllowUserValues );
00089     sl = sections();
00090     break;
00091   default:
00092     break;
00093   }
00094 
00095   setWorkingMode( m );
00096 
00097   if ( sort )
00098     qSort( sl );
00099 
00100   return sl;
00101 }