COPASI API  4.16.103
Macros | Functions
qtUtilities.h File Reference
#include <QtCore/QString>
#include "utilities/CCopasiParameter.h"
Include dependency graph for qtUtilities.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FROM_UTF8(__x)   QString::fromUtf8((__x).c_str())
 
#define TO_UTF8(__x)   (__x).toUtf8().data()
 

Functions

C_INT32 checkSelection (const QString &file)
 
QString getParameterValue (const CCopasiParameterGroup *group, const size_t &index, CCopasiParameter::Type *type=NULL)
 
QString getParameterValue (const CCopasiParameterGroup *group, const std::string &name, CCopasiParameter::Type *type=NULL)
 
bool setParameterValue (CCopasiParameterGroup *group, const size_t &index, const QString &value)
 
bool setParameterValue (CCopasiParameterGroup *group, const std::string &name, const QString &value)
 
void vectorOfStrings2QStringList (std::vector< std::string > vs, QStringList &qsl)
 

Macro Definition Documentation

#define FROM_UTF8 (   __x)    QString::fromUtf8((__x).c_str())

Convert a utf8 encoded std::string to a QString

Definition at line 73 of file qtUtilities.h.

Referenced by CopasiUI3Window::about(), CQPlotSubwidget::addPlotItem(), CQParameterOverviewDM::assignmentData(), SliderSettingsDialog::browseButtonPressed(), CQReportDefinition::btnDeleteReportClicked(), DataModelGUI::buildChangedObjects(), CQParameterOverviewWidget::buildSelectionList(), Curve2DWidget::buttonPressedX(), HistoWidget::buttonPressedX(), BandedGraphWidget::buttonPressedX(), Curve2DWidget::buttonPressedY(), BandedGraphWidget::buttonPressedYone(), BandedGraphWidget::buttonPressedYtwo(), CopasiUI3Window::checkPendingMessages(), CCopasiSelectionDialog::chooseCellMatrix(), CQMessageBox::confirmDelete(), CopasiUI3Window::CopasiUI3Window(), CQSpeciesDetail::copy(), ReactionsWidget1::copy(), CQCompartment::CQCompartment(), CQCompartmentDM::CQCompartmentDM(), CQGlobalQuantityDM::CQGlobalQuantityDM(), CQMiriamWidget::CQMiriamWidget(), CQReportDefinition::CQReportDefinition(), CQReportListItem::CQReportListItem(), CQSpecieDM::CQSpecieDM(), CQSpeciesDetail::CQSpeciesDetail(), CQTabWidget::CQTabWidget(), CQQtImageTexturizer::create_texture_for_image(), CQBrowserPaneDM::createStaticDM(), CQParameterSetsDM::data(), CQModifiedDM::data(), CQReportDM::data(), CQLayoutsDM::data(), CQPlotDM::data(), CQBiologicalDescriptionDM::data(), CQReferenceDM::data(), CQCreatorDM::data(), CQReactionDM::data(), CQFunctionDM::data(), CQEventDM::data(), CQEFMNetReactionDM::data(), CQFluxModeDM::data(), CQGlobalQuantityDM::data(), CQCompartmentDM::data(), CQSpecieDM::data(), CQTSSAResultSubWidget::displayResult(), CQGLNetworkPainter::drawStringAt(), CQOptimizationResult::enterProtected(), CQFittingResult::enterProtected(), CQRDFTreeView::enterProtected(), SensWidgetComboBox::fillFromList(), DefaultPlotDialog::fillList(), CQArrayAnnotationsWidget::fillTable1(), CQArrayAnnotationsWidget::fillTableN(), CQMergingData::fillTree(), ReactionsWidget1::FillWidgetFromRI(), CQGlobalQuantityDM::flags(), CQCompartmentDM::flags(), CQSpecieDM::flags(), CQExpressionWidget::getExpression(), ObjectBrowserWidget::getFieldCopasiObject(), ParameterTable::getListOfAllCompartmentNames(), ParameterTable::getListOfAllGlobalParameterNames(), getParameterValue(), CopasiFileDialog::getSaveFileName(), CQTimeSeriesDM::headerData(), CQEFMReactionDM::headerData(), CQReactionDM::headerData(), CQEFMSpeciesDM::headerData(), CQCompartmentDM::headerData(), CQSpecieDM::headerData(), CQSplashWidget::init(), CQPreferenceDialog::init(), CQModelValue::init(), CQOptimizationWidget::init(), CQExperimentData::init(), SensitivitiesWidget::initCombos(), CScanWidgetRandom::initFromObject(), CScanWidgetScan::initFromObject(), CQProgressItemText::initFromProcessReportItem(), CQProgressItemBar::initFromProcessReportItem(), CopasiPlot::initFromSpec(), CQGLNetworkPainter::initializeGraphPainter(), CQArrayAnnotationsWidget::initSelectionTable(), FunctionWidget1::leave(), CQMoietiesTaskResult::load(), CQExperimentSelection::load(), CScanWidgetRandom::load(), CQTabWidget::load(), CQExperimentData::load(), CScanWidgetScan::load(), CQModelWidget::load(), CQReportDefinition::load(), CQSpeciesDetail::load(), CQCompartment::load(), CQModelValue::load(), CQExpandModelData::load(), CQNotes::load(), CQBrowserPaneDM::load(), StateSubwidget::loadAll(), ObjectBrowserWidget::loadChild(), StateSubwidget::loadCompartments(), CQExperimentData::loadExperiment(), ObjectBrowserWidget::loadField(), Curve2DWidget::LoadFromCurveSpec(), BandedGraphWidget::LoadFromCurveSpec(), HistoWidget::LoadFromCurveSpec(), CQEventWidget1::loadFromEvent(), CQPlotSubwidget::loadFromPlotSpec(), StateSubwidget::loadJacobian(), StateSubwidget::loadMetabolites(), CQCompartment::loadMetaboliteTable(), CQTaskMethodWidget::loadMethod(), StateSubwidget::loadModelValues(), CQUpdatesWidget::loadObjectsTable(), CQUpdatesWidget::loadOneTable(), CQLNAWidget::loadParameterTable(), CQMCAWidget::loadParameterTable(), FunctionWidget1::loadParameterTable(), StateSubwidget::loadReactions(), CQSpeciesDetail::loadReactionTable(), CQReportDefinitionSelect::loadReportDefinitionVector(), CQFittingItemWidget::loadSelection(), CQExperimentData::loadTable(), SensitivitiesWidget::loadTask(), CQOptimizationWidget::loadTask(), FunctionWidget1::loadUsageTable(), main(), CQParameterOverviewDM::nameData(), CopasiFileDialog::openExampleDir(), CopasiUI3Window::openInitialDocument(), CQSimpleSelectionTree::populateTree(), CQSpeciesWidget::refreshCompartments(), CopasiUI3Window::refreshRecentFileMenu(), CopasiUI3Window::refreshRecentSBMLFileMenu(), CQReportListItem::refreshText(), CQParameterSetsDM::removeRows(), CQReportDM::removeRows(), CQLayoutsDM::removeRows(), CQReactionDM::removeRows(), CQFunctionDM::removeRows(), CQEventDM::removeRows(), CQGlobalQuantityDM::removeRows(), CQCompartmentDM::removeRows(), CQSpecieDM::removeRows(), CQTabWidget::save(), CQReportDefinition::save(), CQSpeciesDetail::save(), CQNotes::save(), CQBarChart::saveDataToFile(), CQExpressionMmlStackedWidget::savePNG(), CQDifferentialEquations::savePNG(), CQOptimizationWidget::saveTask(), CQExpressionMmlStackedWidget::saveTeX(), CQDifferentialEquations::saveTeX(), ReactionsWidget1::saveToReaction(), CQExperimentData::selectModelObject(), CQSimpleSelectionTree::selectObjects(), CopasiUI3Window::setApplicationFont(), CQMatrixDialog::setArray(), CQArrayAnnotationsWidget::setArrayAnnotation(), CopasiPlot::setAxisUnits(), CQFunctionDM::setData(), CQGlobalQuantityDM::setData(), CQCompartmentDM::setData(), CQSpecieDM::setData(), CQReactionDM::setEquation(), CQExpressionWidget::setExpression(), CQSpeciesDetail::setFramework(), ReactionsWidget1::setFramework(), CQExpressionWidget::setFunction(), CProgressBar::setName(), CQCurrentValueTable::setRowInTable(), CQCrossSectionTaskWidget::setSingleObject(), SliderSettingsDialog::setSlider(), CQFittingItemWidget::setTableText(), CQTaskHeaderWidget::setTaskName(), CQRDFTreeViewItem::setTriplet(), CQTaskMethodWidget::setValidMethods(), CQProgressItemText::setValueFromSTRING(), CQMiriamWidget::showEvent(), CQCrossSectionTaskWidget::showUnits(), StateSubwidget::showUnits(), CQTrajectoryWidget::showUnits(), CQEventWidget1::slotAddTarget(), FunctionWidget1::slotBtnDelete(), ReactionsWidget1::slotBtnDelete(), CQSpeciesDetail::slotBtnDelete(), CQCompartment::slotBtnDelete(), CQModelValue::slotBtnDelete(), CQParameterOverviewWidget::slotBtnNew(), CQPreferenceDialog::slotBtnOk(), CQParameterOverviewWidget::slotBtnSaveAs(), CQExperimentData::slotCheckFrom(), CopasiUI3Window::slotCheckModel(), SensitivitiesWidget::slotChooseSingleFunction(), SensitivitiesWidget::slotChooseSingleVariable(), SensitivitiesWidget::slotChooseSingleVariable2(), CQExpandModelData::slotCompartmentActivated(), CQTSSAWidget::slotDuration(), CQTrajectoryWidget::slotDuration(), CQExperimentData::slotExperimentAdd(), CQExperimentData::slotExperimentChanged(), CopasiUI3Window::slotExportMathModel(), CopasiUI3Window::slotExportSBML(), CopasiUI3Window::slotExportSBMLToStringFinished(), CQExperimentData::slotFileAdd(), CQExperimentData::slotFileChanged(), CopasiUI3Window::slotFileOpenFinished(), CopasiUI3Window::slotFileSave(), CopasiUI3Window::slotFileSaveFinished(), CopasiUI3Window::slotImportSBMLFinished(), CopasiUI3Window::slotImportSBMLFromStringFinished(), CQTSSAWidget::slotIntervals(), CQTrajectoryWidget::slotIntervals(), CQTSSAWidget::slotIntervalSize(), CQTrajectoryWidget::slotIntervalSize(), CQFittingItemWidget::slotLowerEdit(), CQFittingItemWidget::slotLowerLostFocus(), CQBrowserPaneDM::slotNotify(), CCopasiPlotSelectionDialog::slotOKButtonClicked(), CopasiUI3Window::slotOpenRecentFile(), CopasiUI3Window::slotOpenRecentSBMLFile(), CQCrossSectionTaskWidget::slotOutputConvergence(), CQCrossSectionTaskWidget::slotOutputCrossings(), CQCrossSectionTaskWidget::slotOutputDelay(), CQTimeSeriesWidget::slotSave(), PlotWindow::slotSaveData(), DefaultPlotDialog::slotSelect(), CQEventWidget1::slotSelectObject(), CQExpressionWidget::slotSelectObject(), CQCompartment::slotTypeChanged(), CQExperimentData::slotTypeChanged(), CQCrossSectionTaskWidget::slotUpdateConvergence(), CQCrossSectionTaskWidget::slotUpdateCrossings(), CopasiUI3Window::slotUpdateMIRIAMFinished(), CQDifferentialEquations::slotUpdateWidget(), CQFittingItemWidget::slotUpperEdit(), CQFittingItemWidget::slotUpperLostFocus(), CQSplashWidget::slotViewLicense(), CopasiFileDialog::StartWith(), CQPlotSubwidget::storeChanges(), CQExperimentData::syncExperiments(), CQParameterOverviewDM::typeData(), CQParameterOverviewDM::unitData(), CQMiriamWidget::update(), CopasiSlider::updateLabel(), CQMiriamWidget::updateResourcesList(), ObjectBrowserWidget::updateSelectedItemsView(), ParameterTable::updateTable(), CopasiUI3Window::updateTitle(), CQExpressionMmlStackedWidget::updateWidget(), CQMmlScrollView::updateWidget(), and vectorOfStrings2QStringList().

#define TO_UTF8 (   __x)    (__x).toUtf8().data()

Definition at line 74 of file qtUtilities.h.

Referenced by CQReportDefinitionSelect::accept(), CQPlotSubwidget::addPlot(), CQPlotSubwidget::addPlotItem(), CQReportDefinition::btnAdvancedClicked(), CQReportDefinition::btnCopyReportClicked(), CQReportDefinition::btnNewReportClicked(), CQReportDefinition::btnSeparatorClicked(), CQReportDefinition::btnTextClicked(), CQTaskMethodWidget::changeMethod(), CStructureParser::characters(), checkSelection(), CCopasiSelectionDialog::chooseCellMatrix(), COutputHandlerPlot::compile(), CQPlotSubwidget::copyPlot(), CQExpressionWidget::getExpression(), CQExpressionWidget::getFunction(), CopasiFileDialog::getOpenFileName(), CopasiFileDialog::getSaveFileName(), CQReportDM::insertRows(), CQPlotDM::insertRows(), CQReactionDM::insertRows(), CQFunctionDM::insertRows(), CQEventDM::insertRows(), CQGlobalQuantityDM::insertRows(), CQCompartmentDM::insertRows(), CQSpecieDM::insertRows(), CQReportDefinitionSelect::loadReportDefinitionVector(), operator<<(), CQTabWidget::save(), CQModelWidget::save(), CQReportDefinition::save(), CQSpeciesDetail::save(), CQNotes::save(), CQTSSAResultSubWidget::saveDataToFile(), CQBarChart::saveDataToFile(), CQExperimentData::saveExperiment(), CQExpressionMmlStackedWidget::saveMML(), CQDifferentialEquations::saveMML(), CQFittingItemWidget::saveSelection(), CQExperimentData::saveTable(), CQOptimizationWidget::saveTask(), CQExpressionMmlStackedWidget::saveTeX(), CQDifferentialEquations::saveTeX(), Curve2DWidget::SaveToCurveSpec(), BandedGraphWidget::SaveToCurveSpec(), HistoWidget::SaveToCurveSpec(), CQLyapResultWidget::saveToFile(), CQSensResultWidget::saveToFile(), CQPlotSubwidget::saveToPlotSpec(), CopasiUI3Window::setApplicationFont(), CQModifiedDM::setData(), CQParameterOverviewDM::setData(), CQReportDM::setData(), CQPlotDM::setData(), CQReferenceDM::setData(), CQBiologicalDescriptionDM::setData(), CQCreatorDM::setData(), CQReactionDM::setData(), CQFunctionDM::setData(), CQEventDM::setData(), CQGlobalQuantityDM::setData(), CQCompartmentDM::setData(), CQSpecieDM::setData(), CQReactionDM::setEquation(), CQExpressionWidget::setExpression(), setParameterValue(), CQParameterOverviewWidget::slotBtnCopy(), CQParameterOverviewWidget::slotBtnNew(), FunctionWidget1::slotBtnNew(), ReactionsWidget1::slotBtnNew(), CQSpeciesDetail::slotBtnNew(), CQCompartment::slotBtnNew(), CQModelValue::slotBtnNew(), CQEventWidget1::slotBtnNew(), CQPreferenceDialog::slotBtnOk(), CQParameterOverviewWidget::slotBtnSaveAs(), CQParameterOverviewWidget::slotBtnSaveToFile(), CQExperimentData::slotCheckFrom(), CQFittingItemWidget::slotCheckLowerInf(), CQFittingItemWidget::slotCheckUpperInf(), ReactionsWidget1::slotComboBoxSelectionChanged(), CQSpeciesDetail::slotCompartmentChanged(), CQMiriamWidget::slotCreatedDTChanged(), CQMoietiesTaskResult::slotCreateGlobalQuantity(), CQFittingItemWidget::slotCrossValidations(), CQExperimentData::slotExperimentChanged(), CQExperimentData::slotExperimentDelete(), CQFittingItemWidget::slotExperiments(), CopasiUI3Window::slotExportMathModel(), CopasiUI3Window::slotExportSBML(), FunctionWidget1::slotFcnDescriptionChanged(), CQExperimentData::slotFileAdd(), CQExperimentData::slotFileChanged(), CQExperimentData::slotFileDelete(), CopasiUI3Window::slotFileOpen(), CopasiUI3Window::slotFileOpenFinished(), CopasiUI3Window::slotFileSaveAs(), CopasiUI3Window::slotFontSelection(), CopasiUI3Window::slotFunctionDBLoad(), CopasiUI3Window::slotFunctionDBSave(), CopasiUI3Window::slotImportSBML(), ReactionsWidget1::slotLineEditChanged(), CQFittingItemWidget::slotLowerLostFocus(), CQCompartment::slotMetaboliteTableCurrentChanged(), ReactionsWidget1::slotNewFunction(), CQSteadyStateResult::slotSave(), CQTimeSeriesWidget::slotSave(), CQMoietiesTaskResult::slotSave(), CLNAResultSubwidget::slotSave(), CMCAResultSubwidget::slotSave(), CQOptimizationResult::slotSave(), CQFittingResult::slotSave(), CQEFMResultWidget::slotSave(), PlotWindow::slotSaveData(), CQExperimentData::slotSeparator(), CProgressBar::slotSetName(), CQFittingItemWidget::slotStartLostFocus(), CQSpeciesDetail::slotSwitchToReaction(), ReactionsWidget1::slotTableChanged(), CQExperimentData::slotTypeChanged(), CQFittingItemWidget::slotUpperLostFocus(), CopasiFileDialog::StartWith(), CQExperimentData::syncExperiments(), CopasiUI3Window::updateTitle(), ChemEqValidator::validate(), and CQExperimentDataValidator::validate().

Function Documentation

C_INT32 checkSelection ( const QString &  file)

Checks whether the file exists. If the file exist the user is prompted whether to overwrite the file. The return value is one of QMessageBox::Yes, QMessageBox::No, or QMessageBox::Cancel. If the file does not exist QMessageBox::Yes is returned. param const QString & file

Returns
C_INT32 overwrite

Definition at line 179 of file qtUtilities.cpp.

References CQMessageBox::information(), CDirEntry::isWritable(), CQMessageBox::question(), and TO_UTF8.

Referenced by PlotWindow::printAsImage(), CQTSSAResultSubWidget::saveDataToFile(), CQBarChart::saveDataToFile(), CQLyapResultWidget::saveToFile(), CQSensResultWidget::saveToFile(), CQParameterOverviewWidget::slotBtnSaveToFile(), CopasiUI3Window::slotCapture(), CopasiUI3Window::slotExportMathModel(), CopasiUI3Window::slotExportSBML(), CopasiUI3Window::slotFileSaveAs(), CopasiUI3Window::slotFunctionDBSave(), CQDifferentialEquations::slotSave(), CQSteadyStateResult::slotSave(), CQTimeSeriesWidget::slotSave(), CQMoietiesTaskResult::slotSave(), CQOptimizationResult::slotSave(), CMCAResultSubwidget::slotSave(), CLNAResultSubwidget::slotSave(), CQFittingResult::slotSave(), CQEFMResultWidget::slotSave(), PlotWindow::slotSaveData(), and CQExpressionMmlStackedWidget::slotSaveExpression().

180 {
181 
182 #ifdef DEBUG_UI
183  qDebug() << "Filename on checkSelection = " << file;
184 #endif
185 
186  if (QFileInfo(file).exists())
187  {
188  if (CDirEntry::isWritable(TO_UTF8(file)))
189  return CQMessageBox::question(NULL, "File exists!",
190  "Overwrite existing file " + file + "?",
191  QMessageBox::Ok | QMessageBox::Cancel,
192  QMessageBox::Cancel);
193  else
194  {
195  CQMessageBox::information(NULL, "File read-only",
196  "The file is read-only. Please select another file!",
197  QMessageBox::Ok, QMessageBox::Ok);
198  return QMessageBox::Cancel;
199  }
200  }
201  else
202  return QMessageBox::Ok;
203 }
static StandardButton information(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
static bool isWritable(const std::string &path)
Definition: CDirEntry.cpp:95
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
static StandardButton question(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
QString getParameterValue ( const CCopasiParameterGroup group,
const size_t &  index,
CCopasiParameter::Type type = NULL 
)

Retrieve a parameter from a parameter group and convert it to a QString.

Parameters
constCCopasiParameterGroup * group
constsize_t & index
CCopasiParameter::Type* type (default: NULL)
Returns
QString value

Definition at line 28 of file qtUtilities.cpp.

References CCopasiParameter::BOOL, CCopasiParameter::CN, CCopasiParameter::DOUBLE, FROM_UTF8, CCopasiParameterGroup::getName(), CCopasiParameterGroup::getType(), CCopasiParameterGroup::getValue(), CCopasiParameter::GROUP, CCopasiParameter::INT, CCopasiParameter::INVALID, CCopasiParameter::KEY, CCopasiParameter::Value::pBOOL, CCopasiParameter::Value::pCN, CCopasiParameter::Value::pDOUBLE, CCopasiParameter::Value::pINT, CCopasiParameter::Value::pKEY, CCopasiParameter::Value::pSTRING, CCopasiParameter::Value::pUINT, CCopasiParameterGroup::size(), CCopasiParameter::STRING, CCopasiParameter::UDOUBLE, and CCopasiParameter::UINT.

Referenced by getParameterValue(), CScanWidgetRandom::load(), CQTaskMethodWidget::loadMethod(), CQLNAWidget::loadParameterTable(), CQMCAWidget::loadParameterTable(), CQTaskMethodWidget::saveMethod(), CQMCAWidget::saveParameterTable(), CQLNAWidget::saveParameterTable(), and setParameterValue().

31 {
32  if (index >= group->size())
33  return QString::fromLatin1("INVALID");
34 
35  if (type) *type = group->getType(index);
36 
37  switch (group->getType(index))
38  {
40  return QString::number(* group->getValue(index).pDOUBLE);
41  break;
42 
44  return QString::number(* group->getValue(index).pDOUBLE);
45  break;
46 
48  return QString::number(* group->getValue(index).pINT);
49  break;
50 
52  return QString::number(* group->getValue(index).pUINT);
53  break;
54 
56  return QString::number(* group->getValue(index).pBOOL);
57  break;
58 
60  return
61  FROM_UTF8(* group->getValue(index).pSTRING);
62  break;
63 
65  return
66  FROM_UTF8(* group->getValue(index).pKEY);
67  break;
68 
70  return
71  FROM_UTF8(* group->getValue(index).pCN);
72  break;
73 
75  return FROM_UTF8((group->getName(index)));
76  break;
77 
79  return QString::fromUtf8("INVALID");
80  break;
81 
82  default:
83  break;
84  }
85 
86  return QString::fromLatin1("INVALID");
87 }
virtual const std::string & getName(const size_t &index) const
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
CCopasiParameter::Type getType(const std::string &name) const
CRegisteredObjectName * pCN
unsigned C_INT32 * pUINT
const CCopasiParameter::Value & getValue(const std::string &name) const
QString getParameterValue ( const CCopasiParameterGroup group,
const std::string &  name,
CCopasiParameter::Type type = NULL 
)

Retrieve a parameter from a parameter group and convert it to a QString.

Parameters
constCCopasiParameterGroup * group
conststd::string & name
CCopasiParameter::Type* type (default: NULL)
Returns
QString value

Definition at line 89 of file qtUtilities.cpp.

References CCopasiParameterGroup::getIndex(), and getParameterValue().

92 {return getParameterValue(group, group->getIndex(name), type);}
size_t getIndex(const std::string &name) const
QString getParameterValue(const CCopasiParameterGroup *group, const size_t &index, CCopasiParameter::Type *type)
Definition: qtUtilities.cpp:28
bool setParameterValue ( CCopasiParameterGroup group,
const size_t &  index,
const QString &  value 
)

Set a parameter of a parameter group from a value given as a QString. Success = true is returned when the set operation was succesful, i.e., value == getParameterValue.

Parameters
CCopasiParameterGroup* group
constsize_t & index
constQString & value
Returns
bool success.

Definition at line 94 of file qtUtilities.cpp.

References CCopasiParameter::BOOL, C_FLOAT64, C_INT32, CCopasiParameter::CN, CCopasiParameter::DOUBLE, getParameterValue(), CCopasiParameterGroup::getType(), CCopasiParameter::GROUP, CCopasiParameter::INT, CCopasiParameter::INVALID, CCopasiParameter::KEY, CCopasiParameterGroup::setValue(), CCopasiParameterGroup::size(), CCopasiParameter::STRING, TO_UTF8, CCopasiParameter::UDOUBLE, and CCopasiParameter::UINT.

Referenced by CQTaskMethodWidget::changeMethod(), CQTaskMethodWidget::saveMethod(), CQMCAWidget::saveParameterTable(), CQLNAWidget::saveParameterTable(), and setParameterValue().

97 {
98  if (index >= group->size())
99  return false;
100 
101  if (getParameterValue(group, index) == value) return true;
102 
103  bool ok;
104 
105  C_FLOAT64 DOUBLE;
106  C_INT32 INT;
107  unsigned C_INT32 UINT;
108  bool BOOL;
109  std::string STRING;
111 
112  switch (group->getType(index))
113  {
116  DOUBLE = value.toDouble(&ok);
117 
118  if (!ok) return false;
119 
120  return group->setValue(index, DOUBLE);
121  break;
122 
124  INT = value.toInt(&ok);
125 
126  if (!ok) return false;
127 
128  return group->setValue(index, INT);
129  break;
130 
132  UINT = value.toUInt(&ok);
133 
134  if (!ok) return false;
135 
136  return group->setValue(index, UINT);
137  break;
138 
140  UINT = value.toUShort(&ok);
141 
142  if (!ok) return false;
143 
144  if (UINT == 1) BOOL = true;
145  else if (UINT == 0) BOOL = false;
146  else return false;
147 
148  return group->setValue(index, BOOL);
149  break;
150 
153  STRING = TO_UTF8(value);
154  return group->setValue(index, STRING);
155  break;
156 
158  CN = std::string(TO_UTF8(value));
159  return group->setValue(index, CN);
160  break;
161 
164  return false;
165  break;
166 
167  default:
168  break;
169  }
170 
171  return false;
172 }
CCopasiParameter::Type getType(const std::string &name) const
#define C_INT32
Definition: copasi.h:90
bool setValue(const std::string &name, const CType &value)
QString getParameterValue(const CCopasiParameterGroup *group, const size_t &index, CCopasiParameter::Type *type)
Definition: qtUtilities.cpp:28
#define C_FLOAT64
Definition: copasi.h:92
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
bool setParameterValue ( CCopasiParameterGroup group,
const std::string &  name,
const QString &  value 
)

Set a parameter of a parameter group from a value given as a QString. Success = true is returned when the set operation was succesful, i.e., value == getParameterValue.

Parameters
CCopasiParameterGroup* group
conststd::string & name
constQString & value
Returns
bool success.

Definition at line 174 of file qtUtilities.cpp.

References CCopasiParameterGroup::getIndex(), and setParameterValue().

177 {return setParameterValue(group, group->getIndex(name), value);}
size_t getIndex(const std::string &name) const
bool setParameterValue(CCopasiParameterGroup *group, const size_t &index, const QString &value)
Definition: qtUtilities.cpp:94
void vectorOfStrings2QStringList ( std::vector< std::string >  vs,
QStringList &  qsl 
)

This converts a std::vector<std::string> into a QStringList

Definition at line 205 of file qtUtilities.cpp.

References FROM_UTF8.

Referenced by ReactionsWidget1::FillWidgetFromRI(), CQArrayAnnotationsWidget::initSelectionTable(), and ParameterTable::updateTable().

206 {
207  qsl.clear();
208  size_t i, imax = vs.size();
209 
210  for (i = 0; i < imax; ++i) qsl += FROM_UTF8(vs[i]);
211 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73