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

#include <CQReportDefinitionSelect.h>

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

Public Slots

int exec ()
 

Public Member Functions

void cleanup ()
 
 CQReportDefinitionSelect (QWidget *parent=0, Qt::WindowFlags f=0)
 
void loadReportDefinitionVector ()
 
void setReport (CReport *newReport)
 
virtual ~CQReportDefinitionSelect ()
 

Protected Slots

void accept ()
 
void reject ()
 
void slotBrowse ()
 
void slotEdit ()
 

Private Attributes

ListViewsmpListView
 
CReportmpReport
 
bool mShow
 

Detailed Description

Definition at line 24 of file CQReportDefinitionSelect.h.

Constructor & Destructor Documentation

CQReportDefinitionSelect::CQReportDefinitionSelect ( QWidget *  parent = 0,
Qt::WindowFlags  f = 0 
)

Definition at line 22 of file CQReportDefinitionSelect.cpp.

References CQIconResource::edit, CQIconResource::fileOpen, and CQIconResource::icon().

22  :
23  QDialog(parent, f),
24  mpListView(static_cast< ListViews * >(parent)),
25  mpReport(NULL),
26  mShow(true)
27 {
28  setupUi(this);
29 
30  mpBtnEdit->setIcon(CQIconResource::icon(CQIconResource::edit));
31  mpBtnBrowse->setIcon(CQIconResource::icon(CQIconResource::fileOpen));
32 
33 }
static const QIcon & icon(const IconID &id)
CQReportDefinitionSelect::~CQReportDefinitionSelect ( )
virtual

Definition at line 35 of file CQReportDefinitionSelect.cpp.

References cleanup().

36 {
37  cleanup();
38 }

Member Function Documentation

void CQReportDefinitionSelect::accept ( )
protectedslot

Definition at line 115 of file CQReportDefinitionSelect.cpp.

References C_INT32, cleanup(), CCopasiRootContainer::getDatamodelList(), mpReport, CReport::setAppend(), CReport::setConfirmOverwrite(), CReport::setReportDefinition(), CReport::setTarget(), and TO_UTF8.

Referenced by slotEdit().

116 {
117  if (!mpReport)
118  //exception made here
119  return;
120 
121  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
122  CReportDefinitionVector* pReportDefinitionVector = (*CCopasiRootContainer::getDatamodelList())[0]->getReportDefinitionList();
123  C_INT32 row;
124  row = mpComboDefinition->currentIndex();
125  mpReport->setReportDefinition((*(pReportDefinitionVector))[row]);
126  mpReport->setAppend(mpCheckAppend->isChecked());
127  mpReport->setConfirmOverwrite(mpCheckConfirmOverwrite->isChecked());
128  mpReport->setTarget(TO_UTF8(mpEditTarget->text()));
129  cleanup();
130  QDialog::done(QDialog::Accepted);
131 }
void setAppend(const bool &append)
Definition: CReport.cpp:98
void setConfirmOverwrite(const bool &confirmOverwrite)
Definition: CReport.cpp:104
#define C_INT32
Definition: copasi.h:90
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
void setTarget(const std::string &target)
Definition: CReport.cpp:92
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
void setReportDefinition(CReportDefinition *reportDef)
Definition: CReport.cpp:86
void CQReportDefinitionSelect::cleanup ( )

Definition at line 40 of file CQReportDefinitionSelect.cpp.

References mpReport.

Referenced by accept(), reject(), and ~CQReportDefinitionSelect().

41 {
42  mpReport = NULL;
43 }
int CQReportDefinitionSelect::exec ( )
slot

Definition at line 107 of file CQReportDefinitionSelect.cpp.

References mShow.

Referenced by TaskWidget::reportBtnClicked().

108 {
109  if (mShow)
110  return QDialog::exec();
111  else
112  return QDialog::Accepted;
113 }
void CQReportDefinitionSelect::loadReportDefinitionVector ( )

Definition at line 50 of file CQReportDefinitionSelect.cpp.

References CReport::append(), C_INT32, ListViews::CHANGE, CReport::confirmOverwrite(), FROM_UTF8, ListViews::getDataModel(), CCopasiRootContainer::getDatamodelList(), CCopasiObject::getObjectName(), CReport::getReportDefinition(), CReport::getTarget(), mpListView, mpReport, DataModelGUI::notify(), CQMessageBox::question(), ListViews::REPORT, CReport::setAppend(), CReport::setConfirmOverwrite(), CReport::setReportDefinition(), CReport::setTarget(), CCopasiVector< T >::size(), slotEdit(), and TO_UTF8.

Referenced by TaskWidget::reportBtnClicked().

51 {
52  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
53  CReportDefinitionVector* pReportDefinitionVector = (*CCopasiRootContainer::getDatamodelList())[0]->getReportDefinitionList();
54  unsigned C_INT32 i;
55 
56  for (i = 0; i < pReportDefinitionVector->size(); i++)
57  mpComboDefinition->
58  insertItem(mpComboDefinition->count(), FROM_UTF8((*(pReportDefinitionVector))[i]->getObjectName()));
59 
60  // if it is an empty list
61  if (mpComboDefinition->count() == 0)
62  {
63  std::string name = "ReportDefinition_0";
64  (*CCopasiRootContainer::getDatamodelList())[0]->getReportDefinitionList()->createReportDefinition(name, "");
65  mpComboDefinition->insertItem(mpComboDefinition->count(), FROM_UTF8(name));
66  mpComboDefinition->setCurrentIndex(1);
67  mpReport->setReportDefinition((*(*CCopasiRootContainer::getDatamodelList())[0]->getReportDefinitionList())[0]); //first one report definition
68  mpReport->setAppend(mpCheckAppend->isChecked());
69  mpReport->setConfirmOverwrite(mpCheckConfirmOverwrite->isChecked());
70  mpReport->setTarget(TO_UTF8(mpEditTarget->text()));
71  mpListView->getDataModel()->notify(ListViews::REPORT, ListViews::CHANGE, ""); //notify Table Definition to
72 
73  if (CQMessageBox::question(NULL, "No Report Template Defined",
74  "No report definition defined, COPASI has already created a new one for you.\n Do you want to switch to the GUI to edit it?",
75  QMessageBox::Ok | QMessageBox::No, QMessageBox::Ok) == QMessageBox::Ok)
76  slotEdit();
77 
78  return;
79  }
80 
82  {
83  C_INT32 row;
84  row = mpComboDefinition->currentIndex();
85  mpReport->setReportDefinition((*(pReportDefinitionVector))[row]);
86  mpReport->setAppend(mpCheckAppend->isChecked());
87  mpReport->setConfirmOverwrite(mpCheckConfirmOverwrite->isChecked());
88  mpReport->setTarget(TO_UTF8(mpEditTarget->text()));
89  return;
90  }
91  else
92  {
93  C_INT32 i;
94 
95  // no use to compare the last one
96  for (i = mpComboDefinition->count() - 1; i >= 1; i--)
97  if (mpComboDefinition->itemText(i) == FROM_UTF8(mpReport->getReportDefinition()->getObjectName()))
98  break;
99 
100  mpComboDefinition->setCurrentIndex(i);
101  mpCheckAppend->setChecked(mpReport->append());
102  mpCheckConfirmOverwrite->setChecked(mpReport->confirmOverwrite());
103  mpEditTarget->setText(FROM_UTF8(mpReport->getTarget()));
104  }
105 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const bool & confirmOverwrite() const
Definition: CReport.cpp:101
bool notify(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
const std::string & getObjectName() const
virtual size_t size() const
const std::string & getTarget() const
Definition: CReport.cpp:89
void setAppend(const bool &append)
Definition: CReport.cpp:98
void setConfirmOverwrite(const bool &confirmOverwrite)
Definition: CReport.cpp:104
#define C_INT32
Definition: copasi.h:90
const bool & append() const
Definition: CReport.cpp:95
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
void setTarget(const std::string &target)
Definition: CReport.cpp:92
DataModelGUI * getDataModel()
Definition: listviews.h:134
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
CReportDefinition * getReportDefinition()
Definition: CReport.cpp:83
void setReportDefinition(CReportDefinition *reportDef)
Definition: CReport.cpp:86
static StandardButton question(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
void CQReportDefinitionSelect::reject ( )
protectedslot

Definition at line 133 of file CQReportDefinitionSelect.cpp.

References cleanup().

134 {
135  cleanup();
136  QDialog::done(QDialog::Rejected);
137 }
void CQReportDefinitionSelect::setReport ( CReport newReport)

Definition at line 45 of file CQReportDefinitionSelect.cpp.

References mpReport.

Referenced by TaskWidget::reportBtnClicked().

46 {
47  mpReport = newReport;
48 }
void CQReportDefinitionSelect::slotBrowse ( )
protectedslot

Definition at line 150 of file CQReportDefinitionSelect.cpp.

References CopasiFileDialog::getSaveFileName().

151 {
152  QString reportFile =
153  CopasiFileDialog::getSaveFileName(this, "Save File Dialog", "untitled.txt", "TEXT Files (*.txt)",
154  "Choose to create a new a file");
155 
156  if (!reportFile.isNull())
157  {
158  mpEditTarget->setText(reportFile);
159  }
160 }
static QString getSaveFileName(QWidget *parent=0, const char *name=0, const QString &startWith=QString::null, const QString &filter=QString::null, const QString &caption=QString::null, QString *pSelectedFilter=NULL, QFileDialog::Options options=0)
void CQReportDefinitionSelect::slotEdit ( )
protectedslot

Definition at line 139 of file CQReportDefinitionSelect.cpp.

References accept(), C_INT32, C_INVALID_INDEX, CCopasiRootContainer::getDatamodelList(), mpListView, mShow, and ListViews::switchToOtherWidget().

Referenced by loadReportDefinitionVector().

140 {
141  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
142  CReportDefinitionVector* pReportDefinitionVector = (*CCopasiRootContainer::getDatamodelList())[0]->getReportDefinitionList();
143  C_INT32 row;
144  row = mpComboDefinition->currentIndex();
145  mpListView->switchToOtherWidget(C_INVALID_INDEX, (*pReportDefinitionVector)[row]->getKey());
146  accept(); // if shown then close
147  mShow = false; // if not shown then close
148 }
void switchToOtherWidget(const size_t &id, const std::string &key)
Definition: listviews.cpp:926
#define C_INVALID_INDEX
Definition: copasi.h:222
#define C_INT32
Definition: copasi.h:90
static CCopasiVector< CCopasiDataModel > * getDatamodelList()

Member Data Documentation

ListViews* CQReportDefinitionSelect::mpListView
private

Definition at line 49 of file CQReportDefinitionSelect.h.

Referenced by loadReportDefinitionVector(), and slotEdit().

CReport* CQReportDefinitionSelect::mpReport
private

Definition at line 50 of file CQReportDefinitionSelect.h.

Referenced by accept(), cleanup(), loadReportDefinitionVector(), and setReport().

bool CQReportDefinitionSelect::mShow
private

Definition at line 51 of file CQReportDefinitionSelect.h.

Referenced by exec(), and slotEdit().


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