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

#include <CQTimeSeriesWidget.h>

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

Public Member Functions

 CQTimeSeriesWidget (QWidget *parent=0)
 
virtual bool leave ()
 
virtual bool loadResult (const CCopasiTask *pTask)
 
virtual void setFramework (int framework)
 
virtual void setTitle (const QString &title)
 
virtual bool update (ListViews::ObjectType objectType, ListViews::Action action, const std::string &key)
 
virtual ~CQTimeSeriesWidget ()
 
- 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 ()
 
void setIgnoreUpdates (bool v)
 

Protected Member Functions

virtual bool enterProtected ()
 

Private Slots

void slotSave ()
 

Private Attributes

CQTimeSeriesDMmpDataModel
 
const CTimeSeriesmpTimeSeries
 

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 18 of file CQTimeSeriesWidget.h.

Constructor & Destructor Documentation

CQTimeSeriesWidget::CQTimeSeriesWidget ( QWidget *  parent = 0)

Definition at line 15 of file CQTimeSeriesWidget.cpp.

References mpDataModel.

15  :
16  CopasiWidget(parent),
17  mpTimeSeries(NULL),
18  mpDataModel(NULL)
19 {
20  setupUi(this);
21 
22  mpDataModel = new CQTimeSeriesDM(this);
23  mpTableView->setModel(mpDataModel);
24 }
CQTimeSeriesDM * mpDataModel
CopasiWidget(QWidget *parent=0, const char *name=0, Qt::WFlags f=0)
const CTimeSeries * mpTimeSeries
CQTimeSeriesWidget::~CQTimeSeriesWidget ( )
virtual

Definition at line 26 of file CQTimeSeriesWidget.cpp.

27 {
28  // TODO Auto-generated destructor stub
29 }

Member Function Documentation

bool CQTimeSeriesWidget::enterProtected ( )
protectedvirtual

Reimplemented from CopasiWidget.

Definition at line 117 of file CQTimeSeriesWidget.cpp.

118 {
119  return true;
120 }
bool CQTimeSeriesWidget::leave ( )
virtual

Reimplemented from CopasiWidget.

Definition at line 62 of file CQTimeSeriesWidget.cpp.

63 {
64  return true;
65 }
bool CQTimeSeriesWidget::loadResult ( const CCopasiTask pTask)
virtual

Definition at line 88 of file CQTimeSeriesWidget.cpp.

References getTimeSeriesFromTask(), mpDataModel, mpTimeSeries, CQTimeSeriesDM::rowCount(), and CQTimeSeriesDM::setTimeSeries().

Referenced by CQCrossSectionTaskWidget::taskFinishedEvent(), CQTrajectoryWidget::taskFinishedEvent(), and update().

89 {
92 
93  // mpTableView->resizeRowsToContents(); This is to slow
94  int RowCount = mpDataModel->rowCount();
95 
96  if (RowCount > 0)
97  {
98  mpTableView->resizeRowToContents(0);
99  int RowHeight = mpTableView->rowHeight(0);
100 
101  mpTableView->verticalHeader()->setDefaultSectionSize(RowHeight);
102  }
103 
104  // mpTableView->resizeColumnsToContents(); This is to slow
105 
106  return true;
107 }
CQTimeSeriesDM * mpDataModel
void setTimeSeries(const CTimeSeries *pTimeSeries)
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
const CTimeSeries * getTimeSeriesFromTask(const CCopasiTask *pTask)
const CTimeSeries * mpTimeSeries
void CQTimeSeriesWidget::setFramework ( int  framework)
virtual

Reimplemented from CopasiWidget.

Definition at line 110 of file CQTimeSeriesWidget.cpp.

References mpDataModel, CQTimeSeriesDM::setFramework(), and CopasiWidget::setFramework().

111 {
112  CopasiWidget::setFramework(framework);
113  mpDataModel->setFramework(framework);
114 }
CQTimeSeriesDM * mpDataModel
void setFramework(int framework)
virtual void setFramework(int framework)
void CQTimeSeriesWidget::setTitle ( const QString &  title)
virtual

Definition at line 67 of file CQTimeSeriesWidget.cpp.

Referenced by CQCrossSectionTaskWidget::init().

68 {
69  mpLblResult->setText(title);
70 }
void CQTimeSeriesWidget::slotSave ( void  )
privateslot

Definition at line 122 of file CQTimeSeriesWidget.cpp.

References C_INT32, checkSelection(), CQMessageBox::critical(), FROM_UTF8, CopasiFileDialog::getSaveFileName(), CopasiWidget::mFramework, mpTimeSeries, CTimeSeries::save(), and TO_UTF8.

123 {
124  if (mpTimeSeries == NULL) return;
125 
126  C_INT32 Answer = QMessageBox::No;
127  QString fileName;
128 
129  while (Answer == QMessageBox::No)
130  {
131  fileName =
132  CopasiFileDialog::getSaveFileName(this, "Save File Dialog",
133  "untitled.txt", "TEXT Files (*.txt)", "Save to");
134 
135  if (fileName.isEmpty()) return;
136 
137  // Checks whether the file exists
138  Answer = checkSelection(fileName);
139 
140  if (Answer == QMessageBox::Cancel) return;
141  }
142 
143  int failed = 0;
144 
145  QCursor oldCursor = cursor();
146  setCursor(Qt::WaitCursor);
147  failed = mpTimeSeries->save(TO_UTF8(fileName), (mFramework == 1), "\t");
148  setCursor(oldCursor);
149 
150  if (failed)
151  {
152  std::string s = "Could not save data to ";
153  s += TO_UTF8(fileName);
154  CQMessageBox::critical(this, "Save Error", FROM_UTF8(s), QMessageBox::Ok, QMessageBox::Cancel);
155  }
156 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
int save(const std::string &fileName, bool writeConcentrations=false, const std::string &separator="\t") const
#define C_INT32
Definition: copasi.h:90
C_INT32 checkSelection(const QString &file)
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
const CTimeSeries * mpTimeSeries
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)
bool CQTimeSeriesWidget::update ( ListViews::ObjectType  objectType,
ListViews::Action  action,
const std::string &  key 
)
virtual

Reimplemented from CopasiWidget.

Definition at line 32 of file CQTimeSeriesWidget.cpp.

References ListViews::ADD, ListViews::DELETE, loadResult(), and ListViews::MODEL.

35 {
36  // We need to update the task when a new model is loaded.
37  switch (objectType)
38  {
39  case ListViews::MODEL:
40 
41  switch (action)
42  {
43  case ListViews::ADD:
44  case ListViews::DELETE:
45  loadResult(NULL);
46  break;
47 
48  default:
49  break;
50  }
51 
52  break;
53 
54  default:
55  break;
56  }
57 
58  return true;
59 }
objectType
virtual bool loadResult(const CCopasiTask *pTask)

Member Data Documentation

CQTimeSeriesDM* CQTimeSeriesWidget::mpDataModel
private

Definition at line 47 of file CQTimeSeriesWidget.h.

Referenced by CQTimeSeriesWidget(), loadResult(), and setFramework().

const CTimeSeries* CQTimeSeriesWidget::mpTimeSeries
private

Definition at line 46 of file CQTimeSeriesWidget.h.

Referenced by loadResult(), and slotSave().


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