Ejemplo n.º 1
0
void KstEventMonitorI::fillFieldsForEdit() {
  EventMonitorEntryPtr ep = kst_cast<EventMonitorEntry>(_dp);
  if (!ep) {
    return; // shouldn't be needed
  }
  ep->readLock();
  _tagName->setText(ep->tagName());

  _w->lineEditEquation->setText(ep->event());
  _w->lineEditDescription->setText(ep->description());
  _w->checkBoxDebug->setChecked(ep->logKstDebug());
  _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:
      _w->radioButtonLogNotice->setChecked(true);
      break;
    case KstDebug::Warning:
      _w->radioButtonLogWarning->setChecked(true);
      break;
    case KstDebug::Error:
      _w->radioButtonLogError->setChecked(true);
      break;
    default:
      _w->radioButtonLogWarning->setChecked(true);
      break;
  }

  ep->unlock();
  adjustSize();
  resize(minimumSizeHint());
  setFixedHeight(height());
}
Ejemplo n.º 2
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;
}