SalomeApp_RootObject.h \
SalomeApp_SelectionMgr.h \
SalomeApp_EventFilter.h \
+ SalomeApp_Preferences.h \
SalomeApp_PreferencesDlg.h \
SalomeApp_Tools.h \
SalomeApp_NameDlg.h \
SalomeApp_ExceptionHandler.cxx \
SalomeApp_SelectionMgr.cxx \
SalomeApp_EventFilter.cxx \
+ SalomeApp_Preferences.cxx \
SalomeApp_PreferencesDlg.cxx \
SalomeApp_PyInterp.cxx \
SalomeApp_Tools.cxx \
SalomeApp_Study.h \
SalomeApp_SelectionMgr.h \
SalomeApp_WidgetContainer.h \
+ SalomeApp_Preferences.h \
SalomeApp_PreferencesDlg.h \
SalomeApp_NameDlg.h \
SalomeApp_ModuleDlg.h \
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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