Example #1
0
void CQPreferenceDialog::init()
{
  mpTreeWidget->setColumnWidth(COL_NAME, 150);
  mpTreeWidget->setColumnWidth(COL_VALUE, 100);

  CConfigurationFile * configFile = CCopasiRootContainer::getConfiguration();

  CCopasiParameter * pParameter = configFile->getRecentFiles().getParameter("MaxFiles");

  if (pParameter != NULL)
    {
      QStringList Values;
      Values.append("Max Last Visited Files");
      Values.append(QString::number(*pParameter->getValue().pUINT));

      new QTreeWidgetItem(mpTreeWidget, Values);
    }

  pParameter = configFile->getRecentSBMLFiles().getParameter("MaxFiles");

  if (pParameter != NULL)
    {
      QStringList Values;
      Values.append("Max Last Visited SBML Files");
      Values.append(QString::number(*pParameter->getValue().pUINT));

      new QTreeWidgetItem(mpTreeWidget, Values);
    }

  pParameter = configFile->getParameter("Application for opening URLs");

  if (pParameter != NULL)
    {
      QStringList Values;
      Values.append("Application for opening URLs");
      Values.append(FROM_UTF8(*pParameter->getValue().pSTRING));

      new QTreeWidgetItem(mpTreeWidget, Values);
    }

  pParameter = configFile->getParameter("Validate Units");

  if (pParameter != NULL)
    {
      QStringList Values;
      Values.append("Validate Units");
      Values.append((*pParameter->getValue().pBOOL ? "YES" : "NO"));
      new QTreeWidgetItem(mpTreeWidget, Values);
    }

  pParameter = configFile->getParameter("Use OpenGL");

  if (pParameter != NULL)
    {
      QStringList Values;
      Values.append("Use OpenGL");
      Values.append((*pParameter->getValue().pBOOL ? "YES" : "NO"));
      new QTreeWidgetItem(mpTreeWidget, Values);
    }

  pParameter = configFile->getParameter("Use Advanced Editing");

  if (pParameter != NULL)
    {
      QStringList Values;
      Values.append("Use Advanced Editing");
      Values.append((*pParameter->getValue().pBOOL ? "YES" : "NO"));
      new QTreeWidgetItem(mpTreeWidget, Values);
    }
}
Example #2
0
void CQPreferenceDialog::slotBtnOk()
{
  // We need to commit the changes
  unsigned C_INT32 newMaxFiles = 0;
  CConfigurationFile * configFile = CCopasiRootContainer::getConfiguration();

  QList< QTreeWidgetItem *> Items = mpTreeWidget->findItems("Max Last Visited Files", 0, 0);
  CCopasiParameter * pParameter = configFile->getRecentFiles().getParameter("MaxFiles");

  if (Items.size() > 0 &&
      pParameter != NULL)
    {
      newMaxFiles = Items[0]->text(COL_VALUE).toUInt();
      unsigned C_INT32 maxFiles = *pParameter->getValue().pUINT;

      if (newMaxFiles > 0 && newMaxFiles <= 20)
        pParameter->setValue(newMaxFiles);
      else
        {
          CQMessageBox::critical(this, "Incorrect Setting",
                                 "Max Last Visited Files should be a number between 1 and 20.",
                                 QMessageBox::Ok, QMessageBox::Ok);
          Items[0]->setText(COL_VALUE, QString::number(maxFiles));

          return;
        }
    }

  Items = mpTreeWidget->findItems("Max Last Visited SBML Files", 0, 0);
  pParameter = configFile->getRecentSBMLFiles().getParameter("MaxFiles");

  if (Items.size() > 0 &&
      pParameter != NULL)
    {
      newMaxFiles = Items[0]->text(COL_VALUE).toUInt();
      unsigned C_INT32 maxFiles = *pParameter->getValue().pUINT;

      if (newMaxFiles > 0 && newMaxFiles <= 20)
        pParameter->setValue(newMaxFiles);
      else
        {
          CQMessageBox::critical(this, "Incorrect Setting", "Max Last Visited SBML Files should be a number between 1 and 20.",
                                 QMessageBox::Ok, QMessageBox::Ok);

          Items[0]->setText(COL_VALUE, QString::number(maxFiles));

          return;
        }
    }

  Items = mpTreeWidget->findItems("Application for opening URLs", 0, 0);
  pParameter = configFile->getParameter("Application for opening URLs");

  if (Items.size() > 0 &&
      pParameter != NULL)
    {

      if (Items[0]->text(COL_VALUE) != FROM_UTF8(*pParameter->getValue().pSTRING))
        pParameter->setValue(std::string(TO_UTF8(Items[0]->text(COL_VALUE))));
    }

  Items = mpTreeWidget->findItems("Validate Units", 0, 0);
  pParameter = configFile->getParameter("Validate Units");

  if (Items.size() > 0 &&
      pParameter != NULL)
    {
      pParameter->setValue(Items[0]->text(COL_VALUE).toUpper() == "YES");
    }

  Items = mpTreeWidget->findItems("Use OpenGL", 0, 0);
  pParameter = configFile->getParameter("Use OpenGL");

  if (Items.size() > 0 &&
      pParameter != NULL)
    {
      pParameter->setValue(Items[0]->text(COL_VALUE).toUpper() == "YES");
    }

  Items = mpTreeWidget->findItems("Use Advanced Editing", 0, 0);
  pParameter = configFile->getParameter("Use Advanced Editing");

  if (Items.size() > 0 &&
      pParameter != NULL)
    {
      pParameter->setValue(Items[0]->text(COL_VALUE).toUpper() == "YES");
    }

  done(1);
}