[Kst] kdeextragear-2/kst/kst

Andrew Walker arwalker at sumusltd.com
Fri Apr 9 02:22:52 CEST 2004


CVS commit by arwalker: 

Add functionality to prepare event monitor for saving to kst file


  M +25 -3     ksteventmonitorentry.cpp   1.2
  M +5 -2      ksteventmonitorentry.h   1.2
  M +7 -1      kstvector.cpp   1.65


--- kdeextragear-2/kst/kst/ksteventmonitorentry.cpp  #1.1:1.2
@@ -24,5 +24,5 @@
 #include <assert.h>
 #include <kdebug.h>
-
+#include <klocale.h>
 #include "enodes.h"    
 #include "kstdoc.h"
@@ -40,4 +40,26 @@ EventMonitorEntry::EventMonitorEntry() {
 }
 
+EventMonitorEntry::EventMonitorEntry(QDomElement &e) {
+  QDomNode n = e.firstChild();
+  while( !n.isNull() ) {
+    QDomElement e = n.toElement(); // try to convert the node to an element.
+    if( !e.isNull() ) { // the node was really an element.
+      if (e.tagName() == "equation") {
+        strEvent = e.text();
+      } else if (e.tagName() == "loglevel") {
+        level = (KstDebug::LogLevel)e.text().toInt();
+      }
+    }
+    n = n.nextSibling();
+  }
+}
+
+void EventMonitorEntry::save(QTextStream &ts) {
+  ts << " <event>" << endl;
+  ts << "  <equation>" << strEvent << "</equation>" << endl;
+  ts << "  <loglevel>" << QString::number(level) << "</loglevel>" << endl;
+  ts << " </event>" << endl;  
+}
+
 EventMonitorEntry::~EventMonitorEntry() {
   delete pExpression;
@@ -80,5 +102,5 @@ bool EventMonitorEntry::evaluate( Equati
     dValue = pExpression->value(&ctx);
     if (dValue) {
-      KstDebug::self()->log( QString( "%1: %2" ).arg( ctx.i ).arg( strEvent ), level );
+      KstDebug::self()->log( i18n("Event Monitor: %1: %2").arg( ctx.i ).arg( strEvent ), level );
     } 
     bRetVal = FALSE;

--- kdeextragear-2/kst/kst/ksteventmonitorentry.h  #1.1:1.2
@@ -21,4 +21,5 @@
 #include <math.h>
 #include <qstring.h>
+#include <qtextstream.h>
 #include <qdom.h>
 #include <qdict.h>
@@ -35,8 +36,10 @@ class EventMonitorEntry {
 public:  
   EventMonitorEntry();
+  EventMonitorEntry(QDomElement &e);
  ~EventMonitorEntry();
   
   bool compile();
   bool evaluate(Equation::Context& ctx);
+  void save(QTextStream &ts);
  
   QString                                               strEvent;

--- kdeextragear-2/kst/kst/kstvector.cpp  #1.64:1.65
@@ -258,4 +258,10 @@ void KstVector::resize(int sz, bool rein
 
 void KstVector::setEventMonitors( EventMonitors* pEventMonitors ) {  
+  int i;
+  
+  for( i=0; i<(int)_eventMonitors.size(); i++ ) {      
+    delete _eventMonitors[i].pExpression;
+    _eventMonitors[i].pExpression = NULL;
+  }
   _eventMonitors = *pEventMonitors;
 }
@@ -496,5 +502,5 @@ KstVectorPtr KstVector::generateVector(d
   xv->UpdateScalars();
 
-return xv;
+  return xv;
 }
 





More information about the Kst mailing list