Пример #1
0
void KstEventMonitorI::populateEditMultiple() {
  KstEventMonitorEntryList emlist = kstObjectSubList<KstDataObject,EventMonitorEntry>(KST::dataObjectList);
  _editMultipleWidget->_objectList->insertStringList(emlist.tagNames());

  // also intermediate state for multiple edit
  _w->lineEditEquation->setText("");
  _w->lineEditDescription->setText("");

  _w->checkBoxDebug->setTristate(true);
  _w->checkBoxDebug->setNoChange();
  _w->radioButtonLogNotice->setChecked(false);
  _w->radioButtonLogWarning->setChecked(false);
  _w->radioButtonLogError->setChecked(false);

  _w->checkBoxEMailNotify->setTristate(true);
  _w->checkBoxEMailNotify->setNoChange();
  _w->lineEditEMailRecipients->setText("");

  _w->checkBoxELOGNotify->setTristate(true);
  _w->checkBoxELOGNotify->setNoChange();
  
  _tagName->setText("");
  _tagName->setEnabled(false);
  
  _w->lineEditEMailRecipients->setEnabled(true); 
  _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;
  _lineEditDescriptionDirty = false;
  _checkBoxDebugDirty = false;
  _radioButtonLogNoticeDirty = false;
  _radioButtonLogWarningDirty = false;
  _radioButtonLogErrorDirty = false;
  _checkBoxEMailNotifyDirty = false;
  _lineEditEMailRecipientsDirty = false;
  _checkBoxELOGNotifyDirty = false;
  _scriptDirty = false;
}
Пример #2
0
void KstEventMonitorI::fillFieldsForNew() {
  KstEventMonitorEntryList events = kstObjectSubList<KstDataObject, EventMonitorEntry>(KST::dataObjectList);

  QString new_label = QString("E%1-").arg(events.count() + 1) + "<New_Event>";
  _tagName->setText(new_label);

  _w->radioButtonLogWarning->setChecked(true);
  _w->lineEditEquation->setText(QString::null);
  _w->lineEditDescription->setText(QString::null);
  _w->checkBoxDebug->setChecked(true);
  _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());
}
Пример #3
0
bool KstEventMonitorI::editObject() {
  KstEventMonitorEntryList emList = kstObjectSubList<KstDataObject,EventMonitorEntry>(KST::dataObjectList);
  
  // if editing multiple objects, edit each one
  if (_editMultipleMode) { 
    // if text fields are empty, treat as non-dirty
    _lineEditEquationDirty = !_w->lineEditEquation->text().isEmpty();
    _lineEditDescriptionDirty = !_w->lineEditDescription->text().isEmpty();
    _lineEditEMailRecipientsDirty = !_w->lineEditEMailRecipients->text().isEmpty();
    
    bool didEdit = false;
    
    for (uint i = 0; i < _editMultipleWidget->_objectList->count(); i++) {
      if (_editMultipleWidget->_objectList->isSelected(i)) {
        // get the pointer to the object
        KstEventMonitorEntryList::Iterator emIter = emList.findTag(_editMultipleWidget->_objectList->text(i));
        if (emIter == emList.end()) {
          return false;
        }
          
        EventMonitorEntryPtr emPtr = *emIter;

        if (!editSingleObject(emPtr)) {
          return false;
        }
        
        didEdit = true;
      }
    } 
    if (!didEdit) {
      KMessageBox::sorry(this, i18n("Select one or more objects to edit."));
      return false;  
    }
  } else {
    EventMonitorEntryPtr ep = kst_cast<EventMonitorEntry>(_dp);
    // verify that the curve name is unique
    QString tag_name = _tagName->text();
    if (!ep || (tag_name != ep->tagName() && KstData::self()->dataTagNameNotUnique(tag_name))) {
      _tagName->setFocus();
      return false;
    }
    
    ep->writeLock();
    ep->setTagName(tag_name);
    ep->unlock();
    
    // then edit the object
    _lineEditEquationDirty = true;
    _lineEditDescriptionDirty = true;
    _checkBoxDebugDirty = true;
    _radioButtonLogNoticeDirty = true;
    _radioButtonLogWarningDirty = true;
    _radioButtonLogErrorDirty = true;
    _checkBoxEMailNotifyDirty = true;
    _lineEditEMailRecipientsDirty = true;
    _checkBoxELOGNotifyDirty = true;
    _scriptDirty = true;
    if (!editSingleObject(ep)) {
      return false;
    }
  }
  emit modified();
  return true;
}
Пример #4
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;

}