[Kst] branches/work/kst/viewupdates/kst/src/libkstapp
George Staikos
staikos at kde.org
Sun May 28 20:23:14 CEST 2006
SVN commit 545991 by staikos:
Make script execution work
M +26 -0 eventmonitorwidget.ui
M +31 -1 ksteventmonitor_i.cpp
M +2 -0 ksteventmonitor_i.h
M +5 -5 ksteventmonitorentry.cpp
--- branches/work/kst/viewupdates/kst/src/libkstapp/eventmonitorwidget.ui #545990:545991
@@ -321,6 +321,32 @@
</widget>
</grid>
</widget>
+ <widget class="QGroupBox" row="4" column="0">
+ <property name="name">
+ <cstring>groupBoxScript</cstring>
+ </property>
+ <property name="title">
+ <string>KstScript</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>_useScript</cstring>
+ </property>
+ <property name="text">
+ <string>Execute:</string>
+ </property>
+ </widget>
+ <widget class="QTextEdit">
+ <property name="name">
+ <cstring>_script</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
<widget class="QGroupBox" row="3" column="0">
<property name="name">
<cstring>groupBoxELOG</cstring>
--- branches/work/kst/viewupdates/kst/src/libkstapp/ksteventmonitor_i.cpp #545990:545991
@@ -20,6 +20,7 @@
#include <qlineedit.h>
#include <qlistbox.h>
#include <qradiobutton.h>
+#include <qtextedit.h>
#include <qvbox.h>
// include files for KDE
@@ -62,6 +63,8 @@
connect(_w->checkBoxDebug, SIGNAL(clicked()), this, SLOT(setcheckBoxDebugDirty()));
connect(_w->checkBoxEMailNotify, SIGNAL(clicked()), this, SLOT(setcheckBoxEMailNotifyDirty()));
connect(_w->checkBoxELOGNotify, SIGNAL(clicked()), this, SLOT(setcheckBoxELOGNotifyDirty()));
+ connect(_w->_useScript, SIGNAL(clicked()), this, SLOT(setScriptDirty()));
+ connect(_w->_script, SIGNAL(textChanged()), this, SLOT(setScriptDirty()));
setFixedHeight(height());
}
@@ -85,6 +88,8 @@
_w->checkBoxEMailNotify->setChecked(ep->logEMail());
_w->checkBoxELOGNotify->setChecked(ep->logELOG());
_w->lineEditEMailRecipients->setText(ep->eMailRecipients());
+ _w->_useScript->setEnabled(!ep->scriptCode().isEmpty());
+ _w->_script->setText(ep->scriptCode());
switch (ep->level()) {
case KstDebug::Notice:
@@ -121,6 +126,8 @@
_w->checkBoxEMailNotify->setChecked(false);
_w->checkBoxELOGNotify->setChecked(false);
_w->lineEditEMailRecipients->setText(QString::null);
+ _w->_useScript->setChecked(false);
+ _w->_script->setText(QString::null);
adjustSize();
resize(minimumSizeHint());
setFixedHeight(height());
@@ -140,6 +147,7 @@
event->setLogEMail(_w->checkBoxEMailNotify->isChecked());
event->setLogELOG(_w->checkBoxELOGNotify->isChecked());
event->setEMailRecipients(_w->lineEditEMailRecipients->text());
+ event->setScriptCode(_w->_useScript->isChecked() ? _w->_script->text() : QString::null);
if (_w->radioButtonLogNotice->isChecked()) {
event->setLevel(KstDebug::Notice);
@@ -228,7 +236,15 @@
if (_lineEditEMailRecipientsDirty) {
emPtr->setEMailRecipients(_w->lineEditEMailRecipients->text());
}
-
+
+ if (_scriptDirty) {
+ if (_w->_useScript->isChecked()) {
+ emPtr->setScriptCode(_w->_script->text());
+ } else {
+ emPtr->setScriptCode(QString::null);
+ }
+ }
+
if (_w->radioButtonLogNotice->isChecked()) {
emPtr->setLevel(KstDebug::Notice);
} else if (_w->radioButtonLogWarning->isChecked()) {
@@ -300,6 +316,7 @@
_checkBoxEMailNotifyDirty = true;
_lineEditEMailRecipientsDirty = true;
_checkBoxELOGNotifyDirty = true;
+ _scriptDirty = true;
if (!editSingleObject(ep)) {
return false;
}
@@ -337,6 +354,12 @@
_w->radioButtonLogNotice->setEnabled(true);
_w->radioButtonLogWarning->setEnabled(true);
_w->radioButtonLogError->setEnabled(true);
+
+ _w->_useScript->setTristate(true);
+ _w->_useScript->setNoChange();
+ _w->_useScript->setChecked(false);
+ _w->_script->setEnabled(false);
+ _w->_script->setText("");
// and clean all the fields
_lineEditEquationDirty = false;
@@ -348,9 +371,16 @@
_checkBoxEMailNotifyDirty = false;
_lineEditEMailRecipientsDirty = false;
_checkBoxELOGNotifyDirty = false;
+ _scriptDirty = false;
}
+void KstEventMonitorI::setScriptDirty() {
+ _w->_useScript->setTristate(false);
+ _scriptDirty = true;
+}
+
+
void KstEventMonitorI::setcheckBoxDebugDirty() {
_w->checkBoxDebug->setTristate(false);
_checkBoxDebugDirty = true;
--- branches/work/kst/viewupdates/kst/src/libkstapp/ksteventmonitor_i.h #545990:545991
@@ -57,12 +57,14 @@
bool _checkBoxEMailNotifyDirty : 1;
bool _lineEditEMailRecipientsDirty : 1;
bool _checkBoxELOGNotifyDirty : 1;
+ bool _scriptDirty : 1;
bool editSingleObject(EventMonitorEntryPtr emPtr);
private slots:
void setcheckBoxDebugDirty();
void setcheckBoxEMailNotifyDirty();
void setcheckBoxELOGNotifyDirty();
+ void setScriptDirty();
private:
void fillFieldsForEdit();
--- branches/work/kst/viewupdates/kst/src/libkstapp/ksteventmonitorentry.cpp #545990:545991
@@ -94,7 +94,7 @@
// wait for the initial update, as we don't want to trigger elog entries
// until we are sure the document is open.
- QTimer::singleShot(500, this, SLOT(slotUpdate()));
+ //QTimer::singleShot(500, this, SLOT(slotUpdate()));
}
@@ -264,7 +264,7 @@
bool EventMonitorEntry::needToEvaluate() {
- return _logKstDebug || _logEMail || _logELOG;
+ return _logKstDebug || _logEMail || _logELOG || !_script.isEmpty();
}
@@ -326,9 +326,9 @@
bool EventMonitorEntry::event(QEvent *e) {
if (e->type() == EventMonitorEventType) {
- writeLock();
+ readLock();
doLog(static_cast<EventMonitorEvent*>(e)->logMessage);
- writeUnlock();
+ readUnlock();
return true;
}
return false;
@@ -351,7 +351,7 @@
if (!_script.isEmpty()) {
DCOPRef ref(QString("kst-%1").arg(getpid()).latin1(), "KstScript");
- ref.call("evaluate", _script);
+ ref.send("evaluate", _script);
}
}
More information about the Kst
mailing list