Example #1
0
void CQNotes::save()
{
  if (mpObject != NULL &&
      mValidity == QValidator::Acceptable)
    {
      QString Notes;

      CAnnotation * pAnnotation = CAnnotation::castObject(mpObject);
      CReportDefinition * pReportDefinition = static_cast< CReportDefinition * >(mpObject);

      if (pAnnotation != NULL)
        {
          Notes = FROM_UTF8(pAnnotation->getNotes());
        }
      else if (pReportDefinition != NULL)
        {
          Notes = FROM_UTF8(pReportDefinition->getComment());
        }

      if (mpEdit->toPlainText() != Notes)
        {
          std::string PlainText = TO_UTF8(mpEdit->toPlainText());

          if (mpValidatorXML->needsWrap())
            {
              // We wrap the HTML in a body element if it does not contain a top level html or body element.
              PlainText = "<body xmlns=\"http://www.w3.org/1999/xhtml\">" + PlainText + "</body>";
            }

          if (pAnnotation != NULL)
            {
              pAnnotation->setNotes(PlainText);
            }
          else if (pReportDefinition != NULL)
            {
              pReportDefinition->setComment(PlainText);
            }

          mChanged = true;
        }
    }

  if (mChanged)
    {
      if (mpDataModel != NULL)
        {
          mpDataModel->changed();
        }

      protectedNotify(ListViews::MODEL, ListViews::CHANGE, mKey);
      mChanged = false;
    }

  return;
}
CReportDefinition* CReportDefinitionVector::createReportDefinition(const std::string & name, const std::string & comment)
{
  size_t i;

  for (i = 0; i < size(); i++)
    if (operator[](i).getObjectName() == name)
      return NULL; // duplicate name

  CReportDefinition* pNewReportDef = new CReportDefinition(name, this);
  pNewReportDef->setComment(comment);
  pNewReportDef->setObjectName(name);

  add(pNewReportDef, true);
  return pNewReportDef;
}