[opengtl-commits] [619] implement the source parameters widget

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 619
Author:   cyrille
Date:     2009-03-14 14:13:47 +0100 (Sat, 14 Mar 2009)

Log Message:
-----------
implement the source parameters widget

Modified Paths:
--------------
    trunk/libQtGTL/QtShiva/KernelParametersWidget.h
    trunk/libQtGTL/QtShiva/ParametersWidgetBase.h
    trunk/libQtGTL/QtShiva/SourceParametersWidget.cpp
    trunk/libQtGTL/QtShiva/SourceParametersWidget.h


Modified: trunk/libQtGTL/QtShiva/KernelParametersWidget.h
===================================================================
--- trunk/libQtGTL/QtShiva/KernelParametersWidget.h	2009-03-14 12:29:58 UTC (rev 618)
+++ trunk/libQtGTL/QtShiva/KernelParametersWidget.h	2009-03-14 13:13:47 UTC (rev 619)
@@ -22,6 +22,10 @@
 
 #include <QtShiva/ParametersWidgetBase.h>
 
+namespace OpenShiva {
+  class Kernel;
+};
+
 namespace QtShiva {
   
   class KernelParametersWidget : public ParametersWidgetBase {

Modified: trunk/libQtGTL/QtShiva/ParametersWidgetBase.h
===================================================================
--- trunk/libQtGTL/QtShiva/ParametersWidgetBase.h	2009-03-14 12:29:58 UTC (rev 618)
+++ trunk/libQtGTL/QtShiva/ParametersWidgetBase.h	2009-03-14 13:13:47 UTC (rev 619)
@@ -22,10 +22,6 @@
 
 #include <QWidget>
 
-namespace OpenShiva {
-  class Kernel;
-};
-
 namespace QtShiva {
   class ParametersWidgetBase : public QWidget {
     Q_OBJECT

Modified: trunk/libQtGTL/QtShiva/SourceParametersWidget.cpp
===================================================================
--- trunk/libQtGTL/QtShiva/SourceParametersWidget.cpp	2009-03-14 12:29:58 UTC (rev 618)
+++ trunk/libQtGTL/QtShiva/SourceParametersWidget.cpp	2009-03-14 13:13:47 UTC (rev 619)
@@ -19,15 +19,69 @@
 
 #include "SourceParametersWidget.h"
 
+#include "ParametersWidgetBase_p.h"
+
 using namespace QtShiva;
 
+#include <GTLCore/Value.h>
+#include <OpenShiva/Source.h>
+#include <OpenShiva/Metadata.h>
+
+class SourceParametersWidget::SourceParametrisation : public ParametersWidgetBase::Parametrisation {
+  public:
+    SourceParametrisation() : m_source(0) {}
+    virtual const GTLCore::Metadata::Group* parameters() const;
+    virtual const GTLCore::String& name() const;
+    virtual void setParameter( const GTLCore::String& _name, GTLCore::Value );
+    void setSource( OpenShiva::Source* _kernel );
+    const std::map< GTLCore::String, GTLCore::Value>& parametersMap() const;
+  private:
+    OpenShiva::Source* m_source;
+    std::map< GTLCore::String, GTLCore::Value> m_parameters;
+};
+
+
+const GTLCore::Metadata::Group* SourceParametersWidget::SourceParametrisation::parameters() const
+{
+  if( m_source and m_source->metadata() )
+  {
+    return m_source->metadata()->parameters();
+  } else {
+    return 0;
+  }
+}
+
+const GTLCore::String& SourceParametersWidget::SourceParametrisation::name() const
+{
+  return m_source->name();
+}
+
+void SourceParametersWidget::SourceParametrisation::setParameter( const GTLCore::String& _name, GTLCore::Value _value)
+{
+  m_parameters[_name] = _value;
+}
+
+void SourceParametersWidget::SourceParametrisation::setSource( OpenShiva::Source* _source )
+{
+  m_source = _source;
+  p->regenerateWidget();
+}
+
+const std::map< GTLCore::String, GTLCore::Value>& SourceParametersWidget::SourceParametrisation::parametersMap() const
+{
+  return m_parameters;
+}
+
+
 struct SourceParametersWidget::Private {
-  
+  SourceParametrisation* parametrisation;
 };
 
 
 SourceParametersWidget::SourceParametersWidget( QWidget* parent ) : ParametersWidgetBase(parent), d(new Private)
 {
+  d->parametrisation = new SourceParametrisation;
+  setParametrisation(d->parametrisation);
 }
 
 SourceParametersWidget::~SourceParametersWidget()
@@ -35,3 +89,13 @@
   delete d;
 }
 
+void SourceParametersWidget::setSource( OpenShiva::Source* _source )
+{
+  d->parametrisation->setSource(_source);
+}
+
+const std::map< GTLCore::String, GTLCore::Value>& SourceParametersWidget::parameters() const
+{
+  return d->parametrisation->parametersMap();
+}
+

Modified: trunk/libQtGTL/QtShiva/SourceParametersWidget.h
===================================================================
--- trunk/libQtGTL/QtShiva/SourceParametersWidget.h	2009-03-14 12:29:58 UTC (rev 618)
+++ trunk/libQtGTL/QtShiva/SourceParametersWidget.h	2009-03-14 13:13:47 UTC (rev 619)
@@ -21,13 +21,26 @@
 #define _OPENSHIVA_SOURCE_PARAMETERS_WIDGET_H_
 
 #include <QtShiva/ParametersWidgetBase.h>
+#include <map>
 
+namespace GTLCore {
+  class String;
+  class Value;
+};
+
+namespace OpenShiva {
+  class Source;
+};
+
 namespace QtShiva {
   
   class SourceParametersWidget : public ParametersWidgetBase {
+    class SourceParametrisation;
     public:
       SourceParametersWidget( QWidget* );
       ~SourceParametersWidget();
+      void setSource( OpenShiva::Source* );
+      const std::map< GTLCore::String, GTLCore::Value>& parameters() const;
     private:
       struct Private;
       Private* const d;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/