Exemplo n.º 1
0
bool KstEqDialogI::editObject() {
  KstEquationList eqList = kstObjectSubList<KstDataObject,KstEquation>(KST::dataObjectList);
  
  // if editing multiple objects, edit each one
  if (_editMultipleMode) { 
    // if the user selected no vector, treat it as non-dirty
    _xVectorsDirty = _w->_xVectors->_vector->currentItem() != 0;
    _equationDirty = !_w->_equation->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
        KstEquationList::Iterator eqIter = eqList.findTag(_editMultipleWidget->_objectList->text(i));
        if (eqIter == eqList.end()) {
          return false;
        }
          
        KstEquationPtr eqPtr = *eqIter;
        if (!editSingleObject(eqPtr)) {
          return false;
        }
        didEdit = true;
      }
    } 
    if (!didEdit) {
      KMessageBox::sorry(this, i18n("Select one or more objects to edit."));
      return false;  
    }
  } else {
    // verify that the curve name is unique
    QString tag_name = _tagName->text();
    KstEquationPtr ep = kst_cast<KstEquation>(_dp);
    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
    _equationDirty = true;
    _xVectorsDirty = true;
    _doInterpolationDirty = true;
    if (!editSingleObject(ep)) {
      return false;
    }
  }
  emit modified();
  return true;
}
Exemplo n.º 2
0
bool KstEqDialog::editObject() {
  KstEquationList eqList;

  eqList = kstObjectSubList<KstDataObject,KstEquation>(KST::dataObjectList);

  if (_editMultipleMode) { 
    //
    // if the user selected no vector, treat it as non-dirty...
    //

    _xVectorsDirty = _w->_xVectors->_vector->currentIndex() != 0;
    _equationDirty = !_w->_equation->text().isEmpty();

    bool didEdit = false;
    int i;

    for (i = 0; i < _editMultipleWidget->_objectList->count(); i++) {
      if (_editMultipleWidget->_objectList->item(i)->isSelected()) {
        KstEquationList::iterator eqIter;
        KstEquationPtr eqPtr;

        eqIter = eqList.findTag(_editMultipleWidget->_objectList->item(i)->text());
        if (eqIter == eqList.end()) {
          return false;
        }

        eqPtr = *eqIter;
        if (!editSingleObject(eqPtr)) {
          return false;
        }
        didEdit = true;
      }
    } 
    if (!didEdit) {
      QMessageBox::warning(this, QObject::tr("Kst"), QObject::tr("Select one or more objects to edit."));
      return false;  
    }
  } else {
    QString tagName = _tagName->text();
    KstEquationPtr ep;

    //
    // verify that the curve name is unique...
    //

    ep = kst_cast<KstEquation>(_dp);
    if (!ep || (tagName != ep->tagName() && KstData::self()->dataTagNameNotUnique(tagName))) {
      _tagName->setFocus();
      return false;
    }

    ep->writeLock();
    ep->setTagName(tagName);
    ep->unlock();

    //
    // then edit the object...
    //

    _equationDirty = true;
    _xVectorsDirty = true;
    _doInterpolationDirty = true;
    if (!editSingleObject(ep)) {
      return false;
    }
  }

  emit modified();

  return true;
}