Salome HOME
Merge remote branch 'origin/akl/22379'
[modules/gui.git] / src / LightApp / LightApp_Preferences.cxx
index 95ea10457831e24ab93087a40153df72cd949d33..9ae6c60552802d39f9dc38470226aba1aae67627 100644 (file)
@@ -1,17 +1,35 @@
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
 // File:      LightApp_Preferences.cxx
 // Author:    Sergey TELKOV
-
+//
 #include "LightApp_Preferences.h"
 
-#include <QtxListResourceEdit.h>
-
-#include <qlayout.h>
-
 /*!
   Constructor.Initialize by resource manager and parent QWidget.
 */
 LightApp_Preferences::LightApp_Preferences( QtxResourceMgr* resMgr, QWidget* parent )
-: QtxListResourceEdit( resMgr, parent )
+: SUIT_PreferenceMgr( resMgr, parent )
 {
 }
 
@@ -28,7 +46,7 @@ LightApp_Preferences::~LightApp_Preferences()
 int LightApp_Preferences::addPreference( const QString& label, const int pId, const int type,
                                          const QString& section, const QString& param )
 {
-  return addItem( label, pId, type, section, param );
+  return addItem( label, pId, (SUIT_PreferenceMgr::PrefItemType)type, section, param );
 }
 
 /*!
@@ -37,23 +55,34 @@ int LightApp_Preferences::addPreference( const QString& label, const int pId, co
 int LightApp_Preferences::addPreference( const QString& mod, const QString& label, const int pId,
                                          const int type, const QString& section, const QString& param )
 {
-  int id = addItem( label, pId, type, section, param );
+  int id = addItem( label, pId, (SUIT_PreferenceMgr::PrefItemType)type, section, param );
   if ( id != -1 && !mod.isEmpty() )
     myPrefMod.insert( id, mod );
   return id;
 }
 
-/*
+/*!
   Checks: is preferences has module with name \a mod.
 */
 bool LightApp_Preferences::hasModule( const QString& mod ) const
 {
   bool res = false;
   for ( PrefModuleMap::ConstIterator it = myPrefMod.begin(); it != myPrefMod.end() && !res; ++it )
-    res = it.data() == mod;
+    res = it.value() == mod;
   return res;
 }
 
+void LightApp_Preferences::activateItem( const QString& mod ) const
+{
+  QtxPreferenceItem* item = findItem( mod, true );
+
+  if ( !item )
+    return;
+
+  item->ensureVisible();
+  item->activate();
+}
+
 /*!Do nothing.*/
 void LightApp_Preferences::onHelp()
 {
@@ -66,9 +95,10 @@ void LightApp_Preferences::onApply()
 }
 
 /*!Emit preference changed.*/
-void LightApp_Preferences::changedResources( const QMap<Item*, QString>& map )
+void LightApp_Preferences::changedResources( const ResourceMap& map )
 {
-  for ( QMap<Item*, QString>::ConstIterator it = map.begin(); it != map.end(); ++it )
+  for ( ResourceMap::ConstIterator it = map.begin(); 
+        it != map.end(); ++it )
   {
     QString sec, param;
     it.key()->resource( sec, param );