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

#include <CQCurrentValueTable.h>

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

Signals

void valueChanged (int row)
 

Public Member Functions

 CQCurrentValueTable (QWidget *parent=0)
 
std::string getKeyForRow (int row) const
 
bool getValueForRow (int row) const
 
int numRows () const
 
void setNumCols (int columns)
 
void setNumRows (int rows)
 
void setRowInTable (int row, std::string key, std::string s, C_FLOAT64 val)
 
void updateRowInTable (int row, C_FLOAT64 val)
 
QHeaderView * verticalHeader ()
 
 ~CQCurrentValueTable ()
 

Protected Member Functions

void init ()
 
void setAllBoxesChecked (bool checked=true)
 
void setAllBoxesUnchecked ()
 
void setKeyIndex (std::string key, int row)
 
void setValue (int row, C_FLOAT64 val)
 

Protected Attributes

std::map< int, std::string > mIndexMap
 
QPushButton * mpCheckAllButton
 
QTableWidget * mpTable
 
QPushButton * mpUncheckAllButton
 

Private Slots

void slotCheckAllClicked ()
 
void slotUncheckAllClicked ()
 
void tableValueChanged (int row, int column)
 

Detailed Description

Definition at line 26 of file CQCurrentValueTable.h.

Constructor & Destructor Documentation

CQCurrentValueTable::CQCurrentValueTable ( QWidget *  parent = 0)

Definition at line 27 of file CQCurrentValueTable.cpp.

References init().

28  : QWidget(parent)
29 {
30  init();
31  this->show();
32 }
CQCurrentValueTable::~CQCurrentValueTable ( )

Definition at line 63 of file CQCurrentValueTable.cpp.

64 {}

Member Function Documentation

std::string CQCurrentValueTable::getKeyForRow ( int  row) const

Definition at line 144 of file CQCurrentValueTable.cpp.

References mIndexMap.

Referenced by CQLayoutMainWindow::parameterTableValueChanged(), and setAllBoxesChecked().

145 {
146  std::string s = "";
147 
148  std::map<int, std::string>::const_iterator itIndexObj = this->mIndexMap.find(row);
149 
150  if (itIndexObj != this->mIndexMap.end())
151  {
152  s = (*itIndexObj).second;
153  }
154 
155  return s;
156 }
std::map< int, std::string > mIndexMap
bool CQCurrentValueTable::getValueForRow ( int  row) const

Definition at line 158 of file CQCurrentValueTable.cpp.

References mpTable.

Referenced by CQLayoutMainWindow::parameterTableValueChanged().

159 {
160  QTableWidgetItem *pCell = this->mpTable->item(row, 0);
161  assert(pCell != NULL);
162  return pCell->checkState() == Qt::Checked;
163 }
void CQCurrentValueTable::init ( )
protected

Definition at line 34 of file CQCurrentValueTable.cpp.

References mpCheckAllButton, mpTable, mpUncheckAllButton, slotCheckAllClicked(), slotUncheckAllClicked(), tableValueChanged(), and verticalHeader().

Referenced by CQCurrentValueTable().

35 {
36  QVBoxLayout* pLayout = new QVBoxLayout(this);
37  this->mpTable = new QTableWidget(this);
38  pLayout->addWidget(this->mpTable);
39  this->mpTable->setRowCount(1);
40  this->mpTable->setColumnCount(2);
41  // set default entry
42  QHeaderView *header = this->mpTable->horizontalHeader();
43  this->mpTable->setHorizontalHeaderLabels(QStringList() << "Metabolite" << "Concentration");
44  header = this->verticalHeader();
45  header->hide();
46  QTableWidgetItem* pItem = new QTableWidgetItem("*** no time series load ***");
47  this->mpTable->setItem(0, 0, pItem);
48  pItem = new QTableWidgetItem("NaN");
49  this->mpTable->setItem(0, 1, pItem);
50  this->mpTable->item(0, 0)->setFlags(this->mpTable->item(0, 0)->flags() & ~Qt::ItemIsEditable);
51  QHBoxLayout *hLayout = new QHBoxLayout();
52  this->mpCheckAllButton = new QPushButton("Check all", this);
53  this->mpUncheckAllButton = new QPushButton("Uncheck all", this);
54  hLayout->addWidget(mpCheckAllButton);
55  hLayout->addWidget(mpUncheckAllButton);
56  pLayout->addLayout(hLayout);
57  connect(this->mpTable, SIGNAL(cellChanged(int, int)), this, SLOT(tableValueChanged(int, int)));
58  connect(this->mpCheckAllButton, SIGNAL(clicked()), this, SLOT(slotCheckAllClicked()));
59  connect(this->mpUncheckAllButton, SIGNAL(clicked()), this, SLOT(slotUncheckAllClicked()));
60  resize(QSize(202, 153).expandedTo(minimumSizeHint()));
61 }
QHeaderView * verticalHeader()
QPushButton * mpUncheckAllButton
void tableValueChanged(int row, int column)
QPushButton * mpCheckAllButton
int CQCurrentValueTable::numRows ( ) const

Definition at line 185 of file CQCurrentValueTable.cpp.

References mpTable.

Referenced by CQLayoutMainWindow::updateValueTable().

186 {
187  return this->mpTable->rowCount();
188 }
void CQCurrentValueTable::setAllBoxesChecked ( bool  checked = true)
protected

Definition at line 100 of file CQCurrentValueTable.cpp.

References CQLayoutMainWindow::addItemInAnimation(), getKeyForRow(), mpTable, and CQLayoutMainWindow::removeItemInAnimation().

Referenced by setAllBoxesUnchecked(), and slotCheckAllClicked().

101 {
102  int i;
103 
104  for (i = 0; i < this->mpTable->rowCount(); i++)
105  {
106  QTableWidgetItem *pCell = this->mpTable->item(i, 0);
107  assert(pCell != NULL);
108 
109  if (pCell->flags() & Qt::ItemIsUserCheckable)
110  {
111  // is cell a QCheckTableItem?
112  pCell->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
113  CQLayoutMainWindow * pTmp = dynamic_cast<CQLayoutMainWindow *>(parentWidget()->parentWidget()->parentWidget()->parentWidget());
114  assert(pTmp);
115 
116  if (pTmp)
117  {
118  if (checked == true)
119  {
120  pTmp->addItemInAnimation(this->getKeyForRow(i));
121  }
122  else
123  {
124  pTmp->removeItemInAnimation(this->getKeyForRow(i));
125  }
126  }
127  }
128  }
129 }
std::string getKeyForRow(int row) const
void removeItemInAnimation(std::string s)
void addItemInAnimation(std::string s)
void CQCurrentValueTable::setAllBoxesUnchecked ( )
protected

Definition at line 131 of file CQCurrentValueTable.cpp.

References setAllBoxesChecked().

Referenced by slotUncheckAllClicked().

132 {
133  this->setAllBoxesChecked(false);
134 }
void setAllBoxesChecked(bool checked=true)
void CQCurrentValueTable::setKeyIndex ( std::string  key,
int  row 
)
protected

Definition at line 137 of file CQCurrentValueTable.cpp.

References mIndexMap.

Referenced by setRowInTable().

138 {
139  this->mIndexMap.insert(std::pair<int, std::string>
140  (row,
141  key));
142 }
std::map< int, std::string > mIndexMap
void CQCurrentValueTable::setNumCols ( int  columns)

Definition at line 180 of file CQCurrentValueTable.cpp.

References mpTable.

Referenced by CQLayoutMainWindow::insertValueTable().

181 {
182  this->mpTable->setColumnCount(columns);
183 }
void CQCurrentValueTable::setNumRows ( int  rows)

Definition at line 175 of file CQCurrentValueTable.cpp.

References mpTable.

Referenced by CQLayoutMainWindow::insertValueTable().

176 {
177  this->mpTable->setRowCount(rows);
178 }
void CQCurrentValueTable::setRowInTable ( int  row,
std::string  key,
std::string  s,
C_FLOAT64  val 
)

Definition at line 67 of file CQCurrentValueTable.cpp.

References FROM_UTF8, mpTable, and setKeyIndex().

Referenced by CQLayoutMainWindow::insertValueTable().

68 {
69  QTableWidgetItem * pCheckItem = new QTableWidgetItem(FROM_UTF8(s));
70  // make the item a check item and make it non editable
71  pCheckItem->setFlags((pCheckItem->flags() & ~Qt::ItemIsEditable) | Qt::ItemIsUserCheckable);
72  this->mpTable->setItem(row, 0, pCheckItem);
73  pCheckItem->setCheckState(Qt::Checked); // initially checked
74  pCheckItem = new QTableWidgetItem(QString::number(val));
75  this->mpTable->setItem(row, 1, pCheckItem);
76  this->setKeyIndex(key, row); // remember which node key is in which row
77 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
void setKeyIndex(std::string key, int row)
void CQCurrentValueTable::setValue ( int  row,
C_FLOAT64  val 
)
protected

Definition at line 95 of file CQCurrentValueTable.cpp.

References updateRowInTable().

96 {
97  this->updateRowInTable(row, val);
98 }
void updateRowInTable(int row, C_FLOAT64 val)
void CQCurrentValueTable::slotCheckAllClicked ( )
privateslot

Definition at line 165 of file CQCurrentValueTable.cpp.

References setAllBoxesChecked().

Referenced by init().

166 {
167  this->setAllBoxesChecked();
168 }
void setAllBoxesChecked(bool checked=true)
void CQCurrentValueTable::slotUncheckAllClicked ( )
privateslot

Definition at line 170 of file CQCurrentValueTable.cpp.

References setAllBoxesUnchecked().

Referenced by init().

171 {
172  this->setAllBoxesUnchecked();
173 }
void CQCurrentValueTable::tableValueChanged ( int  row,
int  column 
)
privateslot

This slot is caled whenever a value in the table changes, i.e. whenever a species is activated or deactived by it's checkbox. This information is broadcasted by emitting another signal which contains the row number.

Definition at line 200 of file CQCurrentValueTable.cpp.

References valueChanged().

Referenced by init().

201 {
202  emit valueChanged(row);
203 }
void valueChanged(int row)
void CQCurrentValueTable::updateRowInTable ( int  row,
C_FLOAT64  val 
)

Definition at line 80 of file CQCurrentValueTable.cpp.

References mpTable.

Referenced by setValue(), and CQLayoutMainWindow::updateValueTable().

81 {
82  if (this->mpTable->item(row, 1) == NULL)
83  {
84  this->mpTable->setItem(row, 1, new QTableWidgetItem(QString::number(val)));
85  }
86  else
87  {
88  this->mpTable->item(row, 1)->setText(QString::number(val));
89  }
90 }
void CQCurrentValueTable::valueChanged ( int  row)
signal

Referenced by tableValueChanged().

QHeaderView * CQCurrentValueTable::verticalHeader ( )

Definition at line 190 of file CQCurrentValueTable.cpp.

References mpTable.

Referenced by init().

191 {
192  return this->mpTable->verticalHeader();
193 }

Member Data Documentation

std::map<int, std::string> CQCurrentValueTable::mIndexMap
protected

Definition at line 32 of file CQCurrentValueTable.h.

Referenced by getKeyForRow(), and setKeyIndex().

QPushButton* CQCurrentValueTable::mpCheckAllButton
protected

Definition at line 34 of file CQCurrentValueTable.h.

Referenced by init().

QTableWidget* CQCurrentValueTable::mpTable
protected
QPushButton* CQCurrentValueTable::mpUncheckAllButton
protected

Definition at line 35 of file CQCurrentValueTable.h.

Referenced by init().


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