[Kst] branches/work/kst/portto4/kst/src

Mike Fenton mike at staikos.net
Thu Nov 15 20:00:33 CET 2007


SVN commit 737182 by fenton:

Add edit support for EventMonitorDialog.


 M  +3 -0      libkstapp/datamanager.cpp  
 M  +85 -3     libkstapp/eventmonitordialog.cpp  
 M  +17 -0     libkstapp/eventmonitordialog.h  
 M  +1 -0      libkstmath/eventmonitorentry.cpp  
 M  +2 -0      libkstmath/eventmonitorentry.h  


--- branches/work/kst/portto4/kst/src/libkstapp/datamanager.cpp #737181:737182
@@ -25,6 +25,7 @@
 #include "vector.h"
 #include "histogram.h"
 #include "psd.h"
+#include "eventmonitorentry.h"
 
 
 #include <QHeaderView>
@@ -155,6 +156,8 @@
       DialogLauncher::self()->showHistogramDialog(histogram);
     } else if (PSDPtr psd = kst_cast<PSD>(_currentObject)) {
       DialogLauncher::self()->showPowerSpectrumDialog(psd);
+    } else if (EventMonitorEntryPtr eventMonitorEntry = kst_cast<EventMonitorEntry>(_currentObject)) {
+      DialogLauncher::self()->showEventMonitorDialog(eventMonitorEntry);
     } else if (VectorPtr vector = kst_cast<Vector>(_currentObject)) {
       DialogLauncher::self()->showVectorDialog(vector);
     }
--- branches/work/kst/portto4/kst/src/libkstapp/eventmonitordialog.cpp #737181:737182
@@ -46,21 +46,41 @@
 }
 
 
+void EventMonitorTab::setScript(const QString script) {
+  return _script->setText(script);
+}
+
+
 QString EventMonitorTab::event() const {
   return _equation->text();
 }
 
 
+void EventMonitorTab::setEvent(const QString event) {
+  return _equation->setText(event);
+}
+
+
 QString EventMonitorTab::description() const {
   return _description->text();
 }
 
 
+void EventMonitorTab::setDescription(const QString description) {
+  return _description->setText(description);
+}
+
+
 QString EventMonitorTab::emailRecipients() const {
   return _emailRecipients->text();
 }
 
 
+void EventMonitorTab::setEmailRecipients(const QString emailRecipients) {
+  return _emailRecipients->setText(emailRecipients);
+}
+
+
 Debug::LogLevel EventMonitorTab::logLevel() const {
   if (_debugLogNotice->isChecked()) {
     return Debug::Notice;
@@ -72,21 +92,51 @@
 }
 
 
+void EventMonitorTab::setLogLevel(const Debug::LogLevel logLevel) {
+  switch (logLevel) {
+    case Debug::Notice:
+      _debugLogNotice->setChecked(true);
+      break;
+    case Debug::Warning:
+      _debugLogWarning->setChecked(true);
+      break;
+    case Debug::Error:
+      _debugLogError->setChecked(true);
+      break;
+  }
+}
+
+
 bool EventMonitorTab::logKstDebug() const {
   return _debugLog->isChecked();
 }
 
 
+void EventMonitorTab::setLogKstDebug(const bool logKstDebug) {
+  return _debugLog->setChecked(logKstDebug);
+}
+
+
 bool EventMonitorTab::logEMail() const {
   return _emailNotify->isChecked();
 }
 
 
+void EventMonitorTab::setLogEMail(const bool logEMail) {
+  return _emailNotify->setChecked(logEMail);
+}
+
+
 bool EventMonitorTab::logELOG() const {
   return _ELOGNotify->isChecked();
 }
 
 
+void EventMonitorTab::setLogELOG(const bool logELOG) {
+  return _ELOGNotify->setChecked(logELOG);
+}
+
+
 void EventMonitorTab::setObjectStore(ObjectStore *store) {
   _vectorSelector->setObjectStore(store);
   _scalarSelector->setObjectStore(store);
@@ -104,6 +154,10 @@
   _eventMonitorTab = new EventMonitorTab(this);
   addDataTab(_eventMonitorTab);
 
+  if (editMode() == Edit) {
+    configureTab(dataObject);
+  }
+
   connect(_eventMonitorTab, SIGNAL(optionsChanged()), this, SLOT(updateButtons()));
   updateButtons();
 }
@@ -118,6 +172,20 @@
 }
 
 
+void EventMonitorDialog::configureTab(ObjectPtr object) {
+  if (EventMonitorEntryPtr eventMonitorEntry = kst_cast<EventMonitorEntry>(object)) {
+    _eventMonitorTab->setScript(eventMonitorEntry->scriptCode());
+    _eventMonitorTab->setEvent(eventMonitorEntry->event());
+    _eventMonitorTab->setDescription(eventMonitorEntry->description());
+    _eventMonitorTab->setLogLevel(eventMonitorEntry->level());
+    _eventMonitorTab->setLogKstDebug(eventMonitorEntry->logKstDebug());
+    _eventMonitorTab->setLogEMail(eventMonitorEntry->logEMail());
+    _eventMonitorTab->setLogELOG(eventMonitorEntry->logELOG());
+    _eventMonitorTab->setEmailRecipients(eventMonitorEntry->eMailRecipients());
+  }
+}
+
+
 void EventMonitorDialog::updateButtons() {
   _buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!_eventMonitorTab->event().isEmpty());
 }
@@ -147,10 +215,24 @@
 
 
 ObjectPtr EventMonitorDialog::editExistingDataObject() const {
-  qDebug() << "editExistingDataObject" << endl;
-  return 0;
-}
+  if (EventMonitorEntryPtr eventMonitor = kst_cast<EventMonitorEntry>(dataObject())) {
+    eventMonitor->writeLock();
+    eventMonitor->setScriptCode(_eventMonitorTab->script());
+    eventMonitor->setEvent(_eventMonitorTab->event());
+    eventMonitor->setDescription(_eventMonitorTab->description());
+    eventMonitor->setLevel(_eventMonitorTab->logLevel());
+    eventMonitor->setLogKstDebug(_eventMonitorTab->logKstDebug());
+    eventMonitor->setLogEMail(_eventMonitorTab->logEMail());
+    eventMonitor->setLogELOG(_eventMonitorTab->logELOG());
+    eventMonitor->setEMailRecipients(_eventMonitorTab->emailRecipients());
 
+    eventMonitor->reparse();
+
+    eventMonitor->update(0);
+    eventMonitor->unlock();
+  }
+  return dataObject();}
+
 }
 
 // vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/eventmonitordialog.h #737181:737182
@@ -32,13 +32,28 @@
     void setObjectStore(ObjectStore *store);
 
     QString script() const;
+    void setScript(const QString script);
+
     QString event() const;
+    void setEvent(const QString event);
+
     QString description() const;
+    void setDescription(const QString description);
+
     Debug::LogLevel logLevel() const;
+    void setLogLevel(const Debug::LogLevel level);
+
     bool logKstDebug() const;
+    void setLogKstDebug(const bool logKstDebug);
+
     bool logEMail() const;
+    void setLogEMail(const bool logEMail);
+
     bool logELOG() const;
+    void setLogELOG(const bool logELOG);
+
     QString emailRecipients() const;
+    void setEmailRecipients(const QString emailRecipients);
 
   private Q_SLOTS:
     void selectionChanged();
@@ -62,6 +77,8 @@
     void updateButtons();
 
   private:
+    void configureTab(ObjectPtr object);
+
     EventMonitorTab *_eventMonitorTab;
 };
 
--- branches/work/kst/portto4/kst/src/libkstmath/eventmonitorentry.cpp #737181:737182
@@ -39,6 +39,7 @@
 
 namespace Kst {
 
+const QString EventMonitorEntry::staticTypeString = I18N_NOOP("Event Monitor");
 const QString EventMonitorEntry::staticTypeTag = I18N_NOOP("eventmonitor");
 
 namespace {
--- branches/work/kst/portto4/kst/src/libkstmath/eventmonitorentry.h #737181:737182
@@ -29,6 +29,8 @@
 class EventMonitorEntry : public DataObject {
   Q_OBJECT
   public:
+    static const QString staticTypeString;
+    const QString& typeString() const { return staticTypeString; }
     static const QString staticTypeTag;
 
     UpdateType update(int updateCounter = -1);


More information about the Kst mailing list