COPASI API  4.16.103
Public Member Functions | Protected Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
CQReportDefinition Class Reference

#include <CQReportDefinition.h>

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

Public Member Functions

 CQReportDefinition (QWidget *parent=0, const char *name=0)
 
virtual bool leave ()
 
virtual bool update (ListViews::ObjectType objectType, ListViews::Action action, const std::string &key)
 
 ~CQReportDefinition ()
 
- Public Member Functions inherited from CopasiWidget
 CopasiWidget (QWidget *parent=0, const char *name=0, Qt::WFlags f=0)
 
bool enter (const std::string &key)
 
CCopasiDataModelgetDataModel ()
 
bool getIgnoreUpdates ()
 
virtual void setFramework (int framework)
 
void setIgnoreUpdates (bool v)
 

Protected Member Functions

virtual bool enterProtected ()
 

Private Slots

void btnAdvancedClicked ()
 
void btnCommitClicked ()
 
void btnCopyReportClicked ()
 
void btnDeleteClicked ()
 
void btnDeleteReportClicked ()
 
void btnDownClicked ()
 
void btnItemClicked ()
 
void btnNewReportClicked ()
 
void btnRevertClicked ()
 
void btnSeparatorClicked ()
 
void btnTextClicked ()
 
void btnUpClicked ()
 
void chkTabClicked ()
 
void chkTitleClicked ()
 
void commentChanged ()
 
void nameChanged (const QString &string)
 
void precisionChanged (const QString &string)
 
void separatorChanged (const QString &string)
 
void taskChanged (const QString &string)
 

Private Member Functions

bool load ()
 
bool save ()
 
bool setAdvancedMode (const bool &advanced)
 

Private Attributes

bool mAdvanced
 
bool mChanged
 
QString mOldComment
 
CReportDefinitionmpReportDefinition
 

Additional Inherited Members

- Protected Slots inherited from CopasiWidget
virtual bool protectedNotify (ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
 
- Protected Attributes inherited from CopasiWidget
int mFramework
 
bool mIgnoreUpdates
 
std::string mKey
 
CCopasiDataModelmpDataModel
 
ListViewsmpListView
 
CCopasiObjectmpObject
 

Detailed Description

Definition at line 28 of file CQReportDefinition.h.

Constructor & Destructor Documentation

CQReportDefinition::CQReportDefinition ( QWidget *  parent = 0,
const char *  name = 0 
)

Definition at line 34 of file CQReportDefinition.cpp.

References C_INT32, FROM_UTF8, CopasiWidget::mKey, mpReportDefinition, setAdvancedMode(), and CCopasiTask::TypeName.

35  : CopasiWidget(parent, name)
36 {
37  setupUi(this);
38 
39  mKey = "";
40  mpReportDefinition = NULL;
41 
42  // We start with the table since this is simpler.
43  setAdvancedMode(false);
44 
45  unsigned C_INT32 i;
46 
47  QStringList TaskNames;
48 
49  for (i = 0; CCopasiTask::TypeName[i] != ""; i++)
50  {
51  TaskNames.append(FROM_UTF8(CCopasiTask::TypeName[i]));
52  }
53 
54  mpTaskBox->addItems(TaskNames);
55 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
static const std::string TypeName[]
Definition: CCopasiTask.h:67
#define C_INT32
Definition: copasi.h:90
CopasiWidget(QWidget *parent=0, const char *name=0, Qt::WFlags f=0)
CReportDefinition * mpReportDefinition
bool setAdvancedMode(const bool &advanced)
std::string mKey
Definition: copasiWidget.h:63
CQReportDefinition::~CQReportDefinition ( )

Definition at line 60 of file CQReportDefinition.cpp.

61 {
62  destroy();
63  // no need to delete child widgets, Qt does it all for us
64 }

Member Function Documentation

void CQReportDefinition::btnAdvancedClicked ( )
privateslot

Definition at line 91 of file CQReportDefinition.cpp.

References C_INT32, load(), mAdvanced, mChanged, CopasiWidget::mpDataModel, mpReportDefinition, CReportDefinition::preCompileTable(), CQMessageBox::question(), save(), setAdvancedMode(), CReportDefinition::setIsTable(), and TO_UTF8.

92 {
93  if (mAdvanced)
94  {
95  if (CQMessageBox::question(NULL, "Report Conversion",
96  "Converting an advanced report to a table may result in loss of customization.\n"
97  "Do you want to proceed?",
98  QMessageBox::Ok | QMessageBox::Cancel,
99  QMessageBox::Cancel) == QMessageBox::Ok)
100  {
101  // We convert the body without the separators to a table.
102  mpTableList->clear();
103 
104  unsigned C_INT32 i, imax;
105 
106  for (i = 0, imax = mpBodyList->count(); i < imax; i++)
107  if (static_cast<CQReportListItem *>(mpBodyList->item(i))->getCN().getObjectType()
108  != "Separator")
109  new CQReportListItem(static_cast<CQReportListItem *>(mpBodyList->item(i))->getCN());
110 
111  mpHeaderList->clear();
112  mpBodyList->clear();
113  mpFooterList->clear();
114 
115  setAdvancedMode(false);
116 
117  mChanged = true;
118  }
119  }
120  else
121  {
122  // To achieve the same result as with the table we use the preCompileTable
123  // method of CReportDefinition. Since we must not change the existing report,
124  // which may only be done by btnCommitClicked or leave, we create a temporary
125  // copy.
127 
128  // We avoid the renaming signal.
130 
131  mChanged = true;
132  save();
133 
136 
137  load();
138 
139  delete mpReportDefinition;
140 
141  mpReportDefinition = pStore;
142 
143  mChanged = true;
144  }
145 }
#define C_INT32
Definition: copasi.h:90
void setIsTable(bool table)
CCopasiDataModel * mpDataModel
Definition: copasiWidget.h:65
CReportDefinition * mpReportDefinition
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
bool setAdvancedMode(const bool &advanced)
bool preCompileTable(const std::vector< CCopasiContainer * > &listOfContainer=CCopasiContainer::EmptyList)
static StandardButton question(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
void CQReportDefinition::btnCommitClicked ( )
privateslot

Definition at line 467 of file CQReportDefinition.cpp.

References save().

Referenced by btnCopyReportClicked(), and btnNewReportClicked().

468 {save();}
void CQReportDefinition::btnCopyReportClicked ( )
privateslot

Definition at line 408 of file CQReportDefinition.cpp.

References ListViews::ADD, CCopasiVectorN< CType >::add(), btnCommitClicked(), C_INVALID_INDEX, CopasiWidget::enter(), CCopasiVectorN< CType >::getIndex(), CReportDefinition::getKey(), CCopasiRootContainer::getKeyFactory(), CCopasiObject::getObjectDataModel(), CCopasiObject::getObjectName(), CCopasiDataModel::getReportDefinitionList(), CopasiWidget::mKey, CopasiWidget::mpListView, CopasiWidget::mpObject, CopasiWidget::protectedNotify(), ListViews::REPORT, CCopasiObject::setObjectName(), ListViews::switchToOtherWidget(), and TO_UTF8.

409 {
411 
413  if (pDataModel == NULL) return;
414 
415  CReportDefinition * pRep = new CReportDefinition(*dynamic_cast<CReportDefinition*>(CCopasiRootContainer::getKeyFactory()->get(mKey)));
416 
417  std::string baseName = pRep->getObjectName() + "_copy";
418  std::string name = baseName;
419 
420  int i =1;
421 
422  while (pDataModel->getReportDefinitionList()->getIndex(name) != C_INVALID_INDEX)
423  {
424  i++;
425  name = baseName + TO_UTF8(QString::number(i));
426  }
427  pRep->setObjectName(name);
428 
429  pDataModel->getReportDefinitionList()->add(pRep, true);
430 
431  std::string key = pRep->getKey();
433  enter(key);
435 }
CCopasiDataModel * getObjectDataModel()
void switchToOtherWidget(const size_t &id, const std::string &key)
Definition: listviews.cpp:926
const std::string & getObjectName() const
CCopasiObject * mpObject
Definition: copasiWidget.h:64
#define C_INVALID_INDEX
Definition: copasi.h:222
virtual size_t getIndex(const std::string &name) const
const CReportDefinitionVector * getReportDefinitionList() const
virtual bool add(const CType &src)
ListViews * mpListView
Definition: copasiWidget.h:62
virtual bool protectedNotify(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
virtual const std::string & getKey() const
static CKeyFactory * getKeyFactory()
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
bool setObjectName(const std::string &name)
std::string mKey
Definition: copasiWidget.h:63
bool enter(const std::string &key)
void CQReportDefinition::btnDeleteClicked ( )
privateslot

Definition at line 213 of file CQReportDefinition.cpp.

References mChanged.

214 {
215  QListWidget * pList = static_cast< QListWidget * >(mpReportSectionTab->currentWidget());
216 
217  QListWidgetItem * pNewSelection = NULL;
218 
219  int i, multipleSelection;
220 
221  for (i = pList->count() - 1, multipleSelection = 0; 0 <= i; i--)
222  if (pList->item(i)->isSelected())
223  {
224  delete pList->takeItem(i);
225 
226  if (!pNewSelection && i < pList->count())
227  {
228  pNewSelection = pList->item(i); // We select the next.
229  }
230 
231  multipleSelection++;
232  }
233 
234  if (multipleSelection == 0) return; // Nothing selected,
235 
236  mChanged = true;
237  pList->clearSelection();
238 
239  if (multipleSelection > 1) return;
240 
241  // Only one item was select and we move the selection to the next
242  if (!pNewSelection && pList->count()) // We have removed item at the end.
243  pNewSelection = pList->item(pList->count() - 1);
244 
245  // pNewSelection is NULL if the list is empty
246  if (pNewSelection)
247  {
248  pNewSelection->setSelected(true);
249  }
250 
251  return;
252 }
void CQReportDefinition::btnDeleteReportClicked ( )
privateslot

Definition at line 329 of file CQReportDefinition.cpp.

References CCopasiDataModel::appendDependentTasks(), CQMessageBox::confirmDelete(), ListViews::DELETE, CopasiWidget::enter(), FROM_UTF8, CCopasiVector< T >::getIndex(), CCopasiObject::getKey(), CCopasiObject::getObjectName(), CCopasiDataModel::getReportDefinitionList(), min, CopasiWidget::mpDataModel, CopasiWidget::mpObject, CopasiWidget::protectedNotify(), pTask, CCopasiVector< T >::remove(), ListViews::REPORT, and CCopasiVector< T >::size().

330 {
331  if (mpDataModel == NULL)
332  return;
333 
334  std::set< const CCopasiObject * > Tasks;
335  std::set< const CCopasiObject * > DeletedObjects;
336  DeletedObjects.insert(mpObject);
337 
338  QMessageBox::StandardButton choice =
339  CQMessageBox::confirmDelete(this, "report",
341  DeletedObjects);
342 
343  switch (choice)
344  {
345  case QMessageBox::Ok:
346  {
348 
349  if (pReportList == NULL)
350  return;
351 
352  if (mpDataModel->appendDependentTasks(DeletedObjects, Tasks))
353  {
354  std::set< const CCopasiObject * >::iterator it = Tasks.begin();
355  std::set< const CCopasiObject * >::iterator end = Tasks.end();
356 
357  for (; it != end; ++it)
358  {
359  const CCopasiTask * pTask = static_cast< const CCopasiTask *>(*it);
360  const_cast< CCopasiTask * >(pTask)->getReport().setReportDefinition(NULL);
361  }
362  }
363 
364  size_t Index = pReportList->getIndex(mpObject);
365  std::string DeletedKey = mpObject->getKey();
366 
367  pReportList->remove(Index);
368 
369  size_t Size = pReportList->size();
370 
371  if (Size > 0)
372  enter((*pReportList)[std::min(Index, Size - 1)]->getKey());
373  else
374  enter("");
375 
377  break;
378  }
379 
380  default:
381  break;
382  }
383 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const std::string & getObjectName() const
bool appendDependentTasks(std::set< const CCopasiObject * > candidates, std::set< const CCopasiObject * > &dependentTasks) const
virtual size_t size() const
CCopasiObject * mpObject
Definition: copasiWidget.h:64
const CReportDefinitionVector * getReportDefinitionList() const
virtual const std::string & getKey() const
CTSSATask * pTask
static StandardButton confirmDelete(QWidget *parent, const QString &objectType, const QString &objects, const std::set< const CCopasiObject * > &deletedObjects)
virtual bool protectedNotify(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
virtual void remove(const size_t &index)
CCopasiDataModel * mpDataModel
Definition: copasiWidget.h:65
virtual size_t getIndex(const CCopasiObject *pObject) const
#define min(a, b)
Definition: f2c.h:175
bool enter(const std::string &key)
void CQReportDefinition::btnDownClicked ( )
privateslot

Definition at line 291 of file CQReportDefinition.cpp.

References mChanged.

292 {
293  QListWidget * pList = static_cast< QListWidget * >(mpReportSectionTab->currentWidget());
294  int i, imax, to, multipleSelection;
295 
296  QListWidgetItem * pMove;
297 
298  // Find the index of the first selected item.
299  for (i = 0, imax = pList->count(), to = -1, multipleSelection = 0; i < imax; i++)
300  if (pList->item(i)->isSelected())
301  {
302  if (multipleSelection == 0) to = i;
303 
304  multipleSelection++;
305  }
306  else if (multipleSelection > 0)
307  {
308  pMove = pList->takeItem(i);
309 
310  if (pMove)
311  {
312  pList->insertItem(to, pMove);
313 
314  multipleSelection = 0;
315  mChanged = true;
316  }
317  }
318 
319  // Unselect things we can not move.
320  for (i = pList->count() - multipleSelection, imax = pList->count(); i < imax; i++)
321  pList->item(i)->setSelected(false);
322 
323  return;
324 }
void CQReportDefinition::btnItemClicked ( )
privateslot

Definition at line 147 of file CQReportDefinition.cpp.

References CQSimpleSelectionTree::AnyObject, CCopasiRootContainer::getDatamodelList(), CCopasiSelectionDialog::getObjectVector(), and mChanged.

148 {
149  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
150  CModel* pModel = (*CCopasiRootContainer::getDatamodelList())[0]->getModel();
151 
152  if (!pModel) return;
153 
154  std::vector< const CCopasiObject * > SelectedVector =
155  // CCopasiSelectionDialog::getObjectVector(this, CQSimpleSelectionTree::NO_RESTRICTION);
157 
158  CQReportListItem * pItem;
159 
160  if (SelectedVector.size() != 0)
161  {
162  QListWidget * pList = static_cast< QListWidget * >(mpReportSectionTab->currentWidget());
163  std::vector< const CCopasiObject * >::const_iterator it = SelectedVector.begin();
164  std::vector< const CCopasiObject * >::const_iterator end = SelectedVector.end();
165 
166  for (; it != end; ++it)
167  {
168  pItem = new CQReportListItem(*it);
169  pList->addItem(pItem);
170  }
171 
172  mChanged = true;
173  }
174 
175  return;
176 }
static std::vector< const CCopasiObject * > getObjectVector(QWidget *pParent, const CQSimpleSelectionTree::ObjectClasses &classes, const std::vector< const CCopasiObject * > *pCurrentSelection=NULL)
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
Definition: CModel.h:50
void CQReportDefinition::btnNewReportClicked ( )
privateslot

Definition at line 385 of file CQReportDefinition.cpp.

References ListViews::ADD, btnCommitClicked(), C_INVALID_INDEX, CopasiWidget::enter(), CCopasiRootContainer::getDatamodelList(), CReportDefinition::getKey(), CopasiWidget::mpListView, CopasiWidget::protectedNotify(), ListViews::REPORT, ListViews::switchToOtherWidget(), and TO_UTF8.

386 {
388 
389  std::string Name = "report";
390 
391  int i = 0;
392  CReportDefinition* pRep;
393  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
394 
395  while (!(pRep = (*CCopasiRootContainer::getDatamodelList())[0]->getReportDefinitionList()->createReportDefinition(Name, "")))
396  {
397  i++;
398  Name = "report_";
399  Name += TO_UTF8(QString::number(i));
400  }
401 
402  std::string key = pRep->getKey();
404  enter(key);
406 }
void switchToOtherWidget(const size_t &id, const std::string &key)
Definition: listviews.cpp:926
#define C_INVALID_INDEX
Definition: copasi.h:222
ListViews * mpListView
Definition: copasiWidget.h:62
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
virtual bool protectedNotify(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
virtual const std::string & getKey() const
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
bool enter(const std::string &key)
void CQReportDefinition::btnRevertClicked ( )
privateslot

Definition at line 464 of file CQReportDefinition.cpp.

References load().

465 {load();}
void CQReportDefinition::btnSeparatorClicked ( )
privateslot

Definition at line 178 of file CQReportDefinition.cpp.

References CCopasiObject::getCN(), mChanged, and TO_UTF8.

179 {
180  CCopasiReportSeparator Separator;
181 
182  if (mpTabCheck->isChecked())
183  Separator = "\t";
184  else
185  Separator = TO_UTF8(mpSeparator->text());
186 
187  static_cast<QListWidget *>(mpReportSectionTab->currentWidget())->addItem(new CQReportListItem(Separator.getCN()));
188 
189  mChanged = true;
190 
191  return;
192 }
virtual CCopasiObjectName getCN() const
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
void CQReportDefinition::btnTextClicked ( )
privateslot

Definition at line 194 of file CQReportDefinition.cpp.

References CCopasiObject::getCN(), CQTextDialog::getText(), mChanged, and TO_UTF8.

195 {
196  CQTextDialog * pDialog = new CQTextDialog(this);
197 
198  if (pDialog->exec() == QDialog::Accepted &&
199  pDialog->getText() != "")
200  {
201  CCopasiStaticString Text(TO_UTF8(pDialog->getText()));
202 
203  static_cast<QListWidget *>(mpReportSectionTab->currentWidget())->addItem(new CQReportListItem(Text.getCN()));
204  }
205 
206  delete pDialog;
207 
208  mChanged = true;
209 
210  return;
211 }
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
QString getText()
void CQReportDefinition::btnUpClicked ( )
privateslot

Definition at line 254 of file CQReportDefinition.cpp.

References mChanged.

255 {
256  QListWidget * pList = static_cast< QListWidget * >(mpReportSectionTab->currentWidget());
257  int i, to, multipleSelection;
258 
259  QListWidgetItem * pMove;
260 
261  for (i = pList->count() - 1, to = -1, multipleSelection = 0; i >= 0; i--)
262  if (pList->item(i)->isSelected())
263  {
264  if (multipleSelection == 0)
265  {
266  to = i;
267  }
268 
269  multipleSelection++;
270  }
271  else if (multipleSelection > 0)
272  {
273  pMove = pList->takeItem(i);
274 
275  if (pMove)
276  {
277  pList->insertItem(to, pMove);
278 
279  multipleSelection = 0;
280  mChanged = true;
281  }
282  }
283 
284  // Unselect things we can not move.
285  for (i = 0; i < multipleSelection; i++)
286  pList->item(i)->setSelected(false);
287 
288  return;
289 }
void CQReportDefinition::chkTabClicked ( )
privateslot

Definition at line 81 of file CQReportDefinition.cpp.

References mChanged.

82 {
83  mChanged = true;
84 
85  if (mpTabCheck->isChecked())
86  mpSeparator->setEnabled(false);
87  else
88  mpSeparator->setEnabled(true);
89 }
void CQReportDefinition::chkTitleClicked ( )
privateslot

Definition at line 326 of file CQReportDefinition.cpp.

References mChanged.

327 {mChanged = true;}
void CQReportDefinition::commentChanged ( )
privateslot

Definition at line 72 of file CQReportDefinition.cpp.

References mChanged.

73 {mChanged = true;}
bool CQReportDefinition::enterProtected ( )
protectedvirtual

Reimplemented from CopasiWidget.

Definition at line 504 of file CQReportDefinition.cpp.

References load(), CopasiWidget::mKey, CopasiWidget::mpListView, CopasiWidget::mpObject, mpReportDefinition, and ListViews::switchToOtherWidget().

505 {
506  mpReportDefinition = dynamic_cast<CReportDefinition *>(mpObject);
507 
508  if (!mpReportDefinition)
509  {
511  return false;
512  }
513 
514  load();
515 
516  mpNotes->enter(mKey);
517 
518  return true;
519 }
void switchToOtherWidget(const size_t &id, const std::string &key)
Definition: listviews.cpp:926
CCopasiObject * mpObject
Definition: copasiWidget.h:64
ListViews * mpListView
Definition: copasiWidget.h:62
CReportDefinition * mpReportDefinition
std::string mKey
Definition: copasiWidget.h:63
bool CQReportDefinition::leave ( )
virtual

Reimplemented from CopasiWidget.

Definition at line 493 of file CQReportDefinition.cpp.

References save().

494 {
495  mpBtnCommit->setFocus();
496 
497  save();
498 
499  mpNotes->leave();
500 
501  return true;
502 }
bool CQReportDefinition::load ( )
private

Definition at line 521 of file CQReportDefinition.cpp.

References FROM_UTF8, CReportDefinition::getBodyAddr(), CReportDefinition::getFooterAddr(), CReportDefinition::getHeaderAddr(), CCopasiObject::getObjectName(), CReportDefinition::getPrecision(), CReportDefinition::getSeparator(), CCopasiStaticString::getStaticString(), CReportDefinition::getTableAddr(), CReportDefinition::getTaskType(), CReportDefinition::getTitle(), CReportDefinition::isTable(), mChanged, mpReportDefinition, and setAdvancedMode().

Referenced by btnAdvancedClicked(), btnRevertClicked(), enterProtected(), and update().

522 {
523  if (!mpReportDefinition) return false;
524 
525  // Reset everything.
526  mpHeaderList->clear();
527  mpBodyList->clear();
528  mpFooterList->clear();
529  mpTableList->clear();
530 
531  mpName->setText(FROM_UTF8(mpReportDefinition->getObjectName()));
532  mpTaskBox->setCurrentIndex(mpReportDefinition->getTaskType());
533 
534  //separator
536  {
537  mpSeparator->setEnabled(false);
538  mpTabCheck->setChecked(true);
539  }
540  else
541  {
542  mpSeparator->setEnabled(true);
543  mpTabCheck->setChecked(false);
544  mpSeparator->setText(FROM_UTF8(mpReportDefinition->getSeparator().getStaticString()));
545  }
546 
547  mpPrecision->setText(QString::number(mpReportDefinition->getPrecision()));
548 
549  std::vector< CRegisteredObjectName > * pList = NULL;
550  std::vector< CRegisteredObjectName >::const_iterator it;
551  std::vector< CRegisteredObjectName >::const_iterator end;
552 
553  // Toggle the display mode.
555  {
556  setAdvancedMode(false);
557 
558  mpTitleCheck->setChecked(mpReportDefinition->getTitle());
559 
560  pList = mpReportDefinition->getTableAddr();
561 
562  for (it = pList->begin(), end = pList->end(); it != end; ++it)
563  mpTableList->addItem(new CQReportListItem(*it));
564  }
565  else
566  {
567  setAdvancedMode(true);
568 
570 
571  for (it = pList->begin(), end = pList->end(); it != end; ++it)
572  mpHeaderList->addItem(new CQReportListItem(*it));
573 
574  pList = mpReportDefinition->getBodyAddr();
575 
576  for (it = pList->begin(), end = pList->end(); it != end; ++it)
577  mpBodyList->addItem(new CQReportListItem(*it));
578 
580 
581  for (it = pList->begin(), end = pList->end(); it != end; ++it)
582  mpFooterList->addItem(new CQReportListItem(*it));
583  }
584 
585  mChanged = false;
586  return true;
587 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const std::string & getObjectName() const
const CCopasiTask::Type & getTaskType() const
const CCopasiReportSeparator & getSeparator() const
const unsigned C_INT32 & getPrecision() const
const std::string & getStaticString() const
std::vector< CRegisteredObjectName > * getTableAddr()
std::vector< CRegisteredObjectName > * getFooterAddr()
CReportDefinition * mpReportDefinition
std::vector< CRegisteredObjectName > * getBodyAddr()
bool setAdvancedMode(const bool &advanced)
std::vector< CRegisteredObjectName > * getHeaderAddr()
void CQReportDefinition::nameChanged ( const QString &  string)
privateslot

Definition at line 66 of file CQReportDefinition.cpp.

References mChanged.

67 {mChanged = true;}
void CQReportDefinition::precisionChanged ( const QString &  string)
privateslot

Definition at line 78 of file CQReportDefinition.cpp.

References mChanged.

79 {mChanged = true;}
bool CQReportDefinition::save ( )
private

Definition at line 589 of file CQReportDefinition.cpp.

References C_INT32, FROM_UTF8, CReportDefinition::getBodyAddr(), CCopasiObject::getCN(), CCopasiRootContainer::getDatamodelList(), CReportDefinition::getFooterAddr(), CReportDefinition::getHeaderAddr(), CCopasiObject::getObjectName(), CReportDefinition::getTableAddr(), CQMessageBox::information(), mAdvanced, mChanged, CopasiWidget::mKey, mpReportDefinition, CopasiWidget::protectedNotify(), ListViews::RENAME, ListViews::REPORT, CReportDefinition::setIsTable(), CCopasiObject::setObjectName(), CReportDefinition::setPrecision(), CReportDefinition::setSeparator(), CReportDefinition::setTaskType(), CReportDefinition::setTitle(), and TO_UTF8.

Referenced by btnAdvancedClicked(), btnCommitClicked(), and leave().

590 {
591  if (!mChanged) return true;
592 
593  if (!mpReportDefinition) return false;
594 
595  if (mpReportDefinition->getObjectName() != TO_UTF8(mpName->text()))
596  {
597  if (!mpReportDefinition->setObjectName(TO_UTF8(mpName->text())))
598  {
599  QString msg;
600  msg = "Unable to rename report '" + FROM_UTF8(mpReportDefinition->getObjectName()) + "'\n"
601  + "to '" + mpName->text() + "' since a report with that name already exists.";
602 
604  "Unable to rename Report",
605  msg,
606  QMessageBox::Ok, QMessageBox::Ok);
607 
608  mpName->setText(FROM_UTF8(mpReportDefinition->getObjectName()));
609  }
610  else
612  }
613 
614  mpReportDefinition->setTaskType((CCopasiTask::Type) mpTaskBox->currentIndex());
615 
616  CCopasiReportSeparator Separator;
617 
618  if (mpTabCheck->isChecked())
619  Separator = "\t";
620  else
621  Separator = TO_UTF8(mpSeparator->text());
622 
623  mpReportDefinition->setSeparator(Separator);
624 
625  mpReportDefinition->setPrecision(mpPrecision->text().toULong());
626 
627  mpReportDefinition->getHeaderAddr()->clear();
628  mpReportDefinition->getBodyAddr()->clear();
629  mpReportDefinition->getFooterAddr()->clear();
630  mpReportDefinition->getTableAddr()->clear();
631 
632  std::vector< CRegisteredObjectName > * pList = NULL;
633  unsigned C_INT32 i, imax;
634 
635  if (mAdvanced)
636  {
638 
640 
641  for (i = 0, imax = mpHeaderList->count(); i < imax; i++)
642  if (static_cast<CQReportListItem *>(mpHeaderList->item(i))->getCN().getObjectType()
643  == "Separator")
644  pList->push_back(Separator.getCN());
645  else
646  pList->push_back(static_cast<CQReportListItem *>(mpHeaderList->item(i))->getCN());
647 
648  pList = mpReportDefinition->getBodyAddr();
649 
650  for (i = 0, imax = mpBodyList->count(); i < imax; i++)
651  if (static_cast<CQReportListItem *>(mpBodyList->item(i))->getCN().getObjectType()
652  == "Separator")
653  pList->push_back(Separator.getCN());
654  else
655  pList->push_back(static_cast<CQReportListItem *>(mpBodyList->item(i))->getCN());
656 
658 
659  for (i = 0, imax = mpFooterList->count(); i < imax; i++)
660  if (static_cast<CQReportListItem *>(mpFooterList->item(i))->getCN().getObjectType()
661  == "Separator")
662  pList->push_back(Separator.getCN());
663  else
664  pList->push_back(static_cast<CQReportListItem *>(mpFooterList->item(i))->getCN());
665  }
666  else
667  {
669 
670  mpReportDefinition->setTitle(mpTitleCheck->isChecked());
671 
672  pList = mpReportDefinition->getTableAddr();
673 
674  for (i = 0, imax = mpTableList->count(); i < imax; i++)
675  pList->push_back(static_cast<CQReportListItem *>(mpTableList->item(i))->getCN());
676  }
677 
678  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
679  (*CCopasiRootContainer::getDatamodelList())[0]->changed();
680 
681  mChanged = false;
682  return false;
683 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
virtual CCopasiObjectName getCN() const
bool setTaskType(const CCopasiTask::Type &taskType)
const std::string & getObjectName() const
void setTitle(bool title)
static StandardButton information(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
void setSeparator(const CCopasiReportSeparator &Separator)
#define C_INT32
Definition: copasi.h:90
void setIsTable(bool table)
std::vector< CRegisteredObjectName > * getTableAddr()
std::vector< CRegisteredObjectName > * getFooterAddr()
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
virtual bool protectedNotify(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
void setPrecision(const unsigned C_INT32 &precision)
CReportDefinition * mpReportDefinition
std::vector< CRegisteredObjectName > * getBodyAddr()
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
bool setObjectName(const std::string &name)
std::string mKey
Definition: copasiWidget.h:63
std::vector< CRegisteredObjectName > * getHeaderAddr()
void CQReportDefinition::separatorChanged ( const QString &  string)
privateslot

Definition at line 75 of file CQReportDefinition.cpp.

References mChanged.

76 {mChanged = true;}
bool CQReportDefinition::setAdvancedMode ( const bool &  advanced)
private

Definition at line 685 of file CQReportDefinition.cpp.

References mAdvanced.

Referenced by btnAdvancedClicked(), CQReportDefinition(), and load().

686 {
687  if (advanced)
688  {
689  mAdvanced = true;
690 
691  mpBtnAdvanced->setText("Advanced <<");
692  mpReportSectionTab->setTabEnabled(mpReportSectionTab->indexOf(mpTableList), false);
693  mpReportSectionTab->setTabEnabled(mpReportSectionTab->indexOf(mpHeaderList), true);
694  mpReportSectionTab->setTabEnabled(mpReportSectionTab->indexOf(mpBodyList), true);
695  mpReportSectionTab->setTabEnabled(mpReportSectionTab->indexOf(mpFooterList), true);
696  mpReportSectionTab->setCurrentIndex(2);
697  mpBtnSeparator->show();
698  mpBtnText->show();
699  mpTitleCheck->hide();
700  }
701  else
702  {
703  mAdvanced = false;
704 
705  mpBtnAdvanced->setText("Advanced >>");
706  mpReportSectionTab->setTabEnabled(mpReportSectionTab->indexOf(mpTableList), true);
707  mpReportSectionTab->setTabEnabled(mpReportSectionTab->indexOf(mpHeaderList), false);
708  mpReportSectionTab->setTabEnabled(mpReportSectionTab->indexOf(mpBodyList), false);
709  mpReportSectionTab->setTabEnabled(mpReportSectionTab->indexOf(mpFooterList), false);
710  mpReportSectionTab->setCurrentIndex(0);
711  mpBtnSeparator->hide();
712  mpBtnText->hide();
713  mpTitleCheck->show();
714  }
715 
716  return true;
717 }
void CQReportDefinition::taskChanged ( const QString &  string)
privateslot

Definition at line 69 of file CQReportDefinition.cpp.

References mChanged.

70 {mChanged = true;}
bool CQReportDefinition::update ( ListViews::ObjectType  objectType,
ListViews::Action  action,
const std::string &  key 
)
virtual

Reimplemented from CopasiWidget.

Definition at line 470 of file CQReportDefinition.cpp.

References ListViews::ADD, ListViews::DELETE, load(), CopasiWidget::mIgnoreUpdates, CopasiWidget::mKey, ListViews::MODEL, mpReportDefinition, and ListViews::REPORT.

473 {
474  // If the model is deleted or a new model is loaded the existing pointer
475  // becomes invalid.
476  if (objectType == ListViews::MODEL &&
477  (action == ListViews::DELETE ||
478  action == ListViews::ADD))
479  {
480  mpReportDefinition = NULL;
481  return true;
482  }
483 
484  if (mIgnoreUpdates ||
486  key != mKey ||
487  action == ListViews::DELETE)
488  return true;
489 
490  return load();
491 }
objectType
bool mIgnoreUpdates
Definition: copasiWidget.h:67
CReportDefinition * mpReportDefinition
std::string mKey
Definition: copasiWidget.h:63

Member Data Documentation

bool CQReportDefinition::mAdvanced
private

Definition at line 45 of file CQReportDefinition.h.

Referenced by btnAdvancedClicked(), save(), and setAdvancedMode().

bool CQReportDefinition::mChanged
private
QString CQReportDefinition::mOldComment
private

Definition at line 48 of file CQReportDefinition.h.

CReportDefinition* CQReportDefinition::mpReportDefinition
private

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