]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Preferences Editor.
authorstv <stv@opencascade.com>
Fri, 17 Jun 2005 08:34:50 +0000 (08:34 +0000)
committerstv <stv@opencascade.com>
Fri, 17 Jun 2005 08:34:50 +0000 (08:34 +0000)
src/SalomeApp/Makefile.in
src/SalomeApp/SalomeApp_Preferences.cxx [new file with mode: 0755]
src/SalomeApp/SalomeApp_Preferences.h [new file with mode: 0755]

index a0a1890251c4b5cf729b557592a4c3e7c39eb490..fe2749c620e38d87f89e87b3c824b72677f8f310 100755 (executable)
@@ -29,6 +29,7 @@ EXPORT_HEADERS= SalomeApp.h \
                SalomeApp_RootObject.h \
                SalomeApp_SelectionMgr.h \
                SalomeApp_EventFilter.h \
+               SalomeApp_Preferences.h \
                SalomeApp_PreferencesDlg.h \
                SalomeApp_Tools.h \
                SalomeApp_NameDlg.h \
@@ -62,6 +63,7 @@ LIB_SRC= SalomeApp_AboutDlg.cxx \
         SalomeApp_ExceptionHandler.cxx \
         SalomeApp_SelectionMgr.cxx \
         SalomeApp_EventFilter.cxx \
+        SalomeApp_Preferences.cxx \
         SalomeApp_PreferencesDlg.cxx \
         SalomeApp_PyInterp.cxx \
         SalomeApp_Tools.cxx \
@@ -87,6 +89,7 @@ LIB_MOC = SalomeApp_AboutDlg.h \
          SalomeApp_Study.h \
          SalomeApp_SelectionMgr.h \
          SalomeApp_WidgetContainer.h \
+         SalomeApp_Preferences.h \
          SalomeApp_PreferencesDlg.h \
          SalomeApp_NameDlg.h \
          SalomeApp_ModuleDlg.h \
diff --git a/src/SalomeApp/SalomeApp_Preferences.cxx b/src/SalomeApp/SalomeApp_Preferences.cxx
new file mode 100755 (executable)
index 0000000..8175f3b
--- /dev/null
@@ -0,0 +1,78 @@
+// File:      SalomeApp_Preferences.cxx
+// Author:    Sergey TELKOV
+
+#include "SalomeApp_Preferences.h"
+
+#include <QtxListResourceEdit.h>
+
+#include <qlayout.h>
+
+SalomeApp_Preferences::SalomeApp_Preferences( QtxResourceMgr* resMgr, QWidget* parent )
+: QtxListResourceEdit( resMgr, parent )
+{
+}
+
+SalomeApp_Preferences::~SalomeApp_Preferences()
+{
+}
+
+int SalomeApp_Preferences::addPreference( const QString& label, const int pId, const int type,
+                                         const QString& section, const QString& param )
+{
+  return addItem( label, pId, type, section, param );
+}
+
+int SalomeApp_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 );
+  if ( id != -1 && !mod.isEmpty() )
+    myPrefMod.insert( id, mod );
+  return id;
+}
+
+QVariant SalomeApp_Preferences::property( const int id, const QString& param ) const
+{
+  return QtxResourceEdit::property( id, param );
+}
+
+void SalomeApp_Preferences::setProperty( const int id, const QString& param, const QVariant& prop )
+{
+  QtxResourceEdit::setProperty( id, param, prop );
+}
+
+bool SalomeApp_Preferences::hasModule( const QString& mod ) const
+{
+  bool res = false;
+  for ( PrefModuleMap::ConstIterator it = myPrefMod.begin(); it != myPrefMod.end() && !res; ++it )
+    res = it.data() == mod;
+  return res;
+}
+
+void SalomeApp_Preferences::onHelp()
+{
+}
+
+void SalomeApp_Preferences::onApply()
+{
+  store();
+}
+
+void SalomeApp_Preferences::changedResources( const QMap<Item*, QString>& map )
+{
+  for ( QMap<Item*, QString>::ConstIterator it = map.begin(); it != map.end(); ++it )
+  {
+    QString sec, param;
+    it.key()->resource( sec, param );
+    QString mod = module( it.key()->id() );
+    emit preferenceChanged( mod, sec, param );
+  }
+}
+
+QString SalomeApp_Preferences::module( const int id ) const
+{
+  QString mod;
+  if ( myPrefMod.contains( id ) )
+    mod = myPrefMod[id];
+  return mod;
+}
diff --git a/src/SalomeApp/SalomeApp_Preferences.h b/src/SalomeApp/SalomeApp_Preferences.h
new file mode 100755 (executable)
index 0000000..9d76a90
--- /dev/null
@@ -0,0 +1,55 @@
+// File:      SalomeApp_Preferences.h
+// Author:    Sergey TELKOV
+
+#ifndef SALOMEAPP_PREFERENCES_H
+#define SALOMEAPP_PREFERENCES_H
+
+#include <SalomeApp.h>
+
+#include <QtxDialog.h>
+#include <QtxListResourceEdit.h>
+
+#include <qmap.h>
+
+class QtxResourceMgr;
+
+class SALOMEAPP_EXPORT SalomeApp_Preferences : public QtxListResourceEdit
+{
+  Q_OBJECT
+
+public:
+  enum { Space = QtxListResourceEdit::Space, Bool, Color, String, Selector, DblSpin, IntSpin, Double, Integer };
+
+public:
+  SalomeApp_Preferences( QtxResourceMgr*, QWidget* = 0 );
+  virtual ~SalomeApp_Preferences();
+
+  int                  addPreference( const QString& label, const int pId = -1, const int = -1,
+                                     const QString& section = QString::null, const QString& param = QString::null );
+  int                  addPreference( const QString& modName, const QString& label, const int pId = -1, const int = -1,
+                                     const QString& section = QString::null, const QString& param = QString::null );
+
+  QVariant             property( const int, const QString& ) const;
+  virtual void         setProperty( const int, const QString&, const QVariant& );
+
+  bool                 hasModule( const QString& ) const;
+
+signals:
+  void                 preferenceChanged( QString&, QString&, QString& );
+
+private slots:
+  void                 onHelp();
+  void                 onApply();
+  virtual void         changedResources( const QMap<Item*, QString>& );
+
+private:
+  QString              module( const int ) const;
+
+private:
+  typedef QMap<int, QString> PrefModuleMap;
+
+private:
+  PrefModuleMap        myPrefMod;
+};
+
+#endif