Пример #1
0
bool KstEventMonitorI::editSingleObject(EventMonitorEntryPtr emPtr) {
  emPtr->writeLock();
  
  if (_lineEditEquationDirty) {
    emPtr->setEvent(_w->lineEditEquation->text());
  }
  
  if (_lineEditDescriptionDirty) {
    emPtr->setDescription(_w->lineEditDescription->text());
  }
  
  if (_checkBoxDebugDirty) {
    if (!(_w->radioButtonLogNotice->isChecked() ||
          _w->radioButtonLogWarning->isChecked() ||
          _w->radioButtonLogError->isChecked()) && _w->checkBoxDebug->isChecked()) {
      KMessageBox::sorry(this, i18n("Select a Debug Log type."));
      emPtr->unlock();
      return false;
    }
    emPtr->setLogKstDebug(_w->checkBoxDebug->isChecked());
  }
  
  if (_checkBoxEMailNotifyDirty) {
    emPtr->setLogEMail(_w->checkBoxEMailNotify->isChecked());
  }
  
  if (_checkBoxELOGNotifyDirty) {
    emPtr->setLogELOG(_w->checkBoxELOGNotify->isChecked());
  }
  
  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()) {
    emPtr->setLevel(KstDebug::Warning);
  } else if (_w->radioButtonLogError->isChecked()) {
    emPtr->setLevel(KstDebug::Error);
  }
  
  emPtr->reparse();
  emPtr->unlock();
  
  return true;
}
Пример #2
0
KstDataObjectPtr EventMonitorEntry::makeDuplicate(KstDataObjectDataObjectMap& duplicatedMap) {
  QString name(tagName() + '\'');
  while (KstData::self()->dataTagNameNotUnique(name, false)) {
    name += '\'';
  }
  EventMonitorEntryPtr event = new EventMonitorEntry(name);
  event->setEvent(_event);
  event->setDescription(_description);
  event->setLevel(_level);
  event->setLogKstDebug(_logKstDebug);
  event->setLogEMail(_logEMail);
  event->setLogELOG(_logELOG);
  event->setEMailRecipients(_eMailRecipients);

  duplicatedMap.insert(this, KstDataObjectPtr(event));
  return KstDataObjectPtr(event);
}
Пример #3
0
void KstEventMonitorI::fillEvent(EventMonitorEntryPtr& event) {
  event->setEvent(_w->lineEditEquation->text());
  event->setDescription(_w->lineEditDescription->text());
  event->setLogKstDebug(_w->checkBoxDebug->isChecked());
  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);
  } else if (_w->radioButtonLogWarning->isChecked()) {
    event->setLevel(KstDebug::Warning);
  } else if (_w->radioButtonLogError->isChecked()) {
    event->setLevel(KstDebug::Error);
  }

  event->reparse();
}
Пример #4
0
ObjectPtr EventMonitorDialog::createNewDataObject() const {
  Q_ASSERT(_document && _document->objectStore());
  EventMonitorEntryPtr eventMonitor = _document->objectStore()->createObject<EventMonitorEntry>(ObjectTag::fromString(tagString()));

  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->writeLock();
  eventMonitor->update(0);
  eventMonitor->unlock();

  return ObjectPtr(eventMonitor.data());
}
Пример #5
0
QString KstIfaceImpl::createEvent(const QString& name,
    const QString& expression,
    const QString& description,
    int debugLogType,
    const QString& email) {

  //suggest a name if not supplied
  QString evtag_end;
  if (name.isEmpty())
    evtag_end = QString(expression);
  else
    evtag_end = QString(name);

  //count number of events and make a unique name
  KstEventMonitorEntryList evlist = kstObjectSubList<KstDataObject,EventMonitorEntry>(KST::dataObjectList);
  int i = evlist.count() + 1;
  QString stringnum;
  stringnum = stringnum.setNum(i);

  QString evtag = "E" + stringnum + "-" + evtag_end;

  while (KstData::self()->dataTagNameNotUnique(evtag, false)) {
    stringnum.setNum(++i);
    evtag = "E" + stringnum + "-" + evtag_end;
  }

  EventMonitorEntryPtr event = new EventMonitorEntry(evtag);

  event->setEvent(expression);
  event->setDescription(description);

  if (debugLogType <= 3 && debugLogType >= 1) {
    event->setLogKstDebug(true);
    switch (debugLogType) {
      case 1:
        event->setLevel(KstDebug::Notice);
      break;
      case 2:
        event->setLevel(KstDebug::Warning);
      break;
      case 3:
        event->setLevel(KstDebug::Error);
      break;
      default:
        event->setLevel(KstDebug::Notice);
      break;
    }
  }
  else {
    event->setLogKstDebug(false);
  }

  if (email.isEmpty()) {
    event->setLogEMail(false);
  } else {
    event->setLogEMail(true);
    event->setEMailRecipients(email);
  }

  KST::dataObjectList.lock().writeLock();
  KST::dataObjectList.append(KstDataObjectPtr(event));
  KST::dataObjectList.lock().unlock();

  _doc->forceUpdate();
  _doc->setModified();

  return evtag;

}