COPASI API  4.16.103
Public Member Functions | Private Slots | Private Member Functions | List of all members
CQPreferenceDialog Class Reference

#include <CQPreferenceDialog.h>

Inheritance diagram for CQPreferenceDialog:
Inheritance graph
[legend]
Collaboration diagram for CQPreferenceDialog:
Collaboration graph
[legend]

Public Member Functions

 CQPreferenceDialog (QWidget *parent=0, const char *name=0, bool modal=false, Qt::WindowFlags fl=0)
 
 ~CQPreferenceDialog ()
 

Private Slots

virtual void slotBtnCancel ()
 
virtual void slotBtnOk ()
 
virtual void slotItemDoubleClicked (QTreeWidgetItem *, int)
 

Private Member Functions

void init ()
 

Detailed Description

Definition at line 24 of file CQPreferenceDialog.h.

Constructor & Destructor Documentation

CQPreferenceDialog::CQPreferenceDialog ( QWidget *  parent = 0,
const char *  name = 0,
bool  modal = false,
Qt::WindowFlags  fl = 0 
)

Definition at line 32 of file CQPreferenceDialog.cpp.

References init().

33  : QDialog(parent, fl)
34 {
35  setObjectName(QString::fromUtf8(name));
36  setModal(modal);
37  setupUi(this);
38 
39  init();
40 }
bool fl(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
CQPreferenceDialog::~CQPreferenceDialog ( )

Definition at line 45 of file CQPreferenceDialog.cpp.

46 {
47  // no need to delete child widgets, Qt does it all for us
48 }

Member Function Documentation

void CQPreferenceDialog::init ( )
private

Definition at line 50 of file CQPreferenceDialog.cpp.

References COL_NAME, COL_VALUE, FROM_UTF8, CCopasiRootContainer::getConfiguration(), CCopasiParameterGroup::getParameter(), CConfigurationFile::getRecentFiles(), CConfigurationFile::getRecentSBMLFiles(), CCopasiParameter::getValue(), CCopasiParameter::Value::pBOOL, CCopasiParameter::Value::pSTRING, and CCopasiParameter::Value::pUINT.

Referenced by CQPreferenceDialog().

51 {
52  mpTreeWidget->setColumnWidth(COL_NAME, 150);
53  mpTreeWidget->setColumnWidth(COL_VALUE, 100);
54 
56 
57  CCopasiParameter * pParameter = configFile->getRecentFiles().getParameter("MaxFiles");
58 
59  if (pParameter != NULL)
60  {
61  QStringList Values;
62  Values.append("Max Last Visited Files");
63  Values.append(QString::number(*pParameter->getValue().pUINT));
64 
65  new QTreeWidgetItem(mpTreeWidget, Values);
66  }
67 
68  pParameter = configFile->getRecentSBMLFiles().getParameter("MaxFiles");
69 
70  if (pParameter != NULL)
71  {
72  QStringList Values;
73  Values.append("Max Last Visited SBML Files");
74  Values.append(QString::number(*pParameter->getValue().pUINT));
75 
76  new QTreeWidgetItem(mpTreeWidget, Values);
77  }
78 
79  pParameter = configFile->getParameter("Application for opening URLs");
80 
81  if (pParameter != NULL)
82  {
83  QStringList Values;
84  Values.append("Application for opening URLs");
85  Values.append(FROM_UTF8(*pParameter->getValue().pSTRING));
86 
87  new QTreeWidgetItem(mpTreeWidget, Values);
88  }
89 
90  pParameter = configFile->getParameter("Validate Units");
91 
92  if (pParameter != NULL)
93  {
94  QStringList Values;
95  Values.append("Validate Units");
96  Values.append((*pParameter->getValue().pBOOL ? "YES" : "NO"));
97  new QTreeWidgetItem(mpTreeWidget, Values);
98  }
99 
100  pParameter = configFile->getParameter("Use OpenGL");
101 
102  if (pParameter != NULL)
103  {
104  QStringList Values;
105  Values.append("Use OpenGL");
106  Values.append((*pParameter->getValue().pBOOL ? "YES" : "NO"));
107  new QTreeWidgetItem(mpTreeWidget, Values);
108  }
109 
110  pParameter = configFile->getParameter("Use Advanced Sliders");
111 
112  if (pParameter != NULL)
113  {
114  QStringList Values;
115  Values.append("Use Advanced Sliders");
116  Values.append((*pParameter->getValue().pBOOL ? "YES" : "NO"));
117  new QTreeWidgetItem(mpTreeWidget, Values);
118  }
119 
120  pParameter = configFile->getParameter("Use Advanced Editing");
121 
122  if (pParameter != NULL)
123  {
124  QStringList Values;
125  Values.append("Use Advanced Editing");
126  Values.append((*pParameter->getValue().pBOOL ? "YES" : "NO"));
127  new QTreeWidgetItem(mpTreeWidget, Values);
128  }
129 
130  pParameter = configFile->getParameter("Normalize Weights per Experiment");
131 
132  if (pParameter != NULL)
133  {
134  QStringList Values;
135  Values.append("Normalize Weights per Experiment");
136  Values.append((*pParameter->getValue().pBOOL ? "YES" : "NO"));
137  new QTreeWidgetItem(mpTreeWidget, Values);
138  }
139 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
CRecentFiles & getRecentFiles()
#define COL_NAME
#define COL_VALUE
static CConfigurationFile * getConfiguration()
const Value & getValue() const
unsigned C_INT32 * pUINT
CRecentFiles & getRecentSBMLFiles()
CCopasiParameter * getParameter(const std::string &name)
void CQPreferenceDialog::slotBtnCancel ( )
privatevirtualslot

Definition at line 251 of file CQPreferenceDialog.cpp.

252 {
253  done(0);
254 }
void CQPreferenceDialog::slotBtnOk ( )
privatevirtualslot

Definition at line 141 of file CQPreferenceDialog.cpp.

References C_INT32, COL_VALUE, CQMessageBox::critical(), FROM_UTF8, CCopasiRootContainer::getConfiguration(), CCopasiParameterGroup::getParameter(), CConfigurationFile::getRecentFiles(), CConfigurationFile::getRecentSBMLFiles(), CCopasiParameter::getValue(), CCopasiParameter::Value::pSTRING, CCopasiParameter::Value::pUINT, CCopasiParameter::setValue(), and TO_UTF8.

142 {
143  // We need to commit the changes
144  unsigned C_INT32 newMaxFiles = 0;
146 
147  QList< QTreeWidgetItem *> Items = mpTreeWidget->findItems("Max Last Visited Files", 0, 0);
148  CCopasiParameter * pParameter = configFile->getRecentFiles().getParameter("MaxFiles");
149 
150  if (Items.size() > 0 &&
151  pParameter != NULL)
152  {
153  newMaxFiles = Items[0]->text(COL_VALUE).toUInt();
154  unsigned C_INT32 maxFiles = *pParameter->getValue().pUINT;
155 
156  if (newMaxFiles > 0 && newMaxFiles <= 20)
157  pParameter->setValue(newMaxFiles);
158  else
159  {
160  CQMessageBox::critical(this, "Incorrect Setting",
161  "Max Last Visited Files should be a number between 1 and 20.",
162  QMessageBox::Ok, QMessageBox::Ok);
163  Items[0]->setText(COL_VALUE, QString::number(maxFiles));
164 
165  return;
166  }
167  }
168 
169  Items = mpTreeWidget->findItems("Max Last Visited SBML Files", 0, 0);
170  pParameter = configFile->getRecentSBMLFiles().getParameter("MaxFiles");
171 
172  if (Items.size() > 0 &&
173  pParameter != NULL)
174  {
175  newMaxFiles = Items[0]->text(COL_VALUE).toUInt();
176  unsigned C_INT32 maxFiles = *pParameter->getValue().pUINT;
177 
178  if (newMaxFiles > 0 && newMaxFiles <= 20)
179  pParameter->setValue(newMaxFiles);
180  else
181  {
182  CQMessageBox::critical(this, "Incorrect Setting", "Max Last Visited SBML Files should be a number between 1 and 20.",
183  QMessageBox::Ok, QMessageBox::Ok);
184 
185  Items[0]->setText(COL_VALUE, QString::number(maxFiles));
186 
187  return;
188  }
189  }
190 
191  Items = mpTreeWidget->findItems("Application for opening URLs", 0, 0);
192  pParameter = configFile->getParameter("Application for opening URLs");
193 
194  if (Items.size() > 0 &&
195  pParameter != NULL)
196  {
197 
198  if (Items[0]->text(COL_VALUE) != FROM_UTF8(*pParameter->getValue().pSTRING))
199  pParameter->setValue(std::string(TO_UTF8(Items[0]->text(COL_VALUE))));
200  }
201 
202  Items = mpTreeWidget->findItems("Validate Units", 0, 0);
203  pParameter = configFile->getParameter("Validate Units");
204 
205  if (Items.size() > 0 &&
206  pParameter != NULL)
207  {
208  pParameter->setValue(Items[0]->text(COL_VALUE).toUpper() == "YES");
209  }
210 
211  Items = mpTreeWidget->findItems("Use OpenGL", 0, 0);
212  pParameter = configFile->getParameter("Use OpenGL");
213 
214  if (Items.size() > 0 &&
215  pParameter != NULL)
216  {
217  pParameter->setValue(Items[0]->text(COL_VALUE).toUpper() == "YES");
218  }
219 
220  Items = mpTreeWidget->findItems("Use Advanced Sliders", 0, 0);
221  pParameter = configFile->getParameter("Use Advanced Sliders");
222 
223  if (Items.size() > 0 &&
224  pParameter != NULL)
225  {
226  pParameter->setValue(Items[0]->text(COL_VALUE).toUpper() == "YES");
227  }
228 
229  Items = mpTreeWidget->findItems("Use Advanced Editing", 0, 0);
230  pParameter = configFile->getParameter("Use Advanced Editing");
231 
232  if (Items.size() > 0 &&
233  pParameter != NULL)
234  {
235  pParameter->setValue(Items[0]->text(COL_VALUE).toUpper() == "YES");
236  }
237 
238  Items = mpTreeWidget->findItems("Normalize Weights per Experiment", 0, 0);
239  pParameter = configFile->getParameter("Normalize Weights per Experiment");
240 
241  if (Items.size() > 0 &&
242  pParameter != NULL)
243  {
244  pParameter->setValue(Items[0]->text(COL_VALUE).toUpper() == "YES");
245  }
246 
247  done(1);
248 }
bool setValue(const CType &value)
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
CRecentFiles & getRecentFiles()
#define C_INT32
Definition: copasi.h:90
#define COL_VALUE
static CConfigurationFile * getConfiguration()
const Value & getValue() const
unsigned C_INT32 * pUINT
CRecentFiles & getRecentSBMLFiles()
CCopasiParameter * getParameter(const std::string &name)
static StandardButton critical(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
void CQPreferenceDialog::slotItemDoubleClicked ( QTreeWidgetItem *  pItem,
int  column 
)
privatevirtualslot

Definition at line 257 of file CQPreferenceDialog.cpp.

References COL_VALUE.

258 {
259  if (column == COL_VALUE)
260  {
261  Qt::ItemFlags Flags = pItem->flags();
262  pItem->setFlags(Flags | Qt::ItemIsEditable);
263 
264  mpTreeWidget->editItem(pItem, column);
265 
266  pItem->setFlags(Flags);
267  }
268 }
#define COL_VALUE

The documentation for this class was generated from the following files: