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

#include <CQTabWidget.h>

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

Signals

void copyClicked ()
 
void deleteClicked ()
 
void newClicked ()
 

Public Member Functions

 CQTabWidget (const ListViews::ObjectType &objectType, CopasiWidget *pCopasiWidget, QWidget *parent=0, Qt::WindowFlags f=0)
 
virtual bool leave ()
 
void selectTab (int index) const
 
virtual bool update (ListViews::ObjectType objectType, ListViews::Action action, const std::string &key)
 
virtual ~CQTabWidget ()
 
- 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 ()
 
void load ()
 
bool save ()
 

Private Slots

void slotBtnCommit ()
 
void slotBtnCopy ()
 
void slotBtnDelete ()
 
void slotBtnNew ()
 
void slotBtnRevert ()
 

Private Attributes

bool mIgnoreLeave
 
ListViews::ObjectType mObjectType
 
std::vector< CopasiWidget * > mPages
 

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 22 of file CQTabWidget.h.

Constructor & Destructor Documentation

CQTabWidget::CQTabWidget ( const ListViews::ObjectType objectType,
CopasiWidget pCopasiWidget,
QWidget *  parent = 0,
Qt::WindowFlags  f = 0 
)

Definition at line 24 of file CQTabWidget.cpp.

References copyClicked(), deleteClicked(), FROM_UTF8, mObjectType, ListViews::MODEL, ListViews::MODELPARAMETERSET, mPages, newClicked(), ListViews::ObjectTypeName, slotBtnCopy(), slotBtnDelete(), and slotBtnNew().

25  :
26  CopasiWidget(parent, NULL, f),
27  mPages(),
29  mIgnoreLeave(false)
30 {
31  setupUi(this);
32 
33  mpLblName->setText("<h3>" + FROM_UTF8(ListViews::ObjectTypeName[mObjectType]) + "</h3>");
34 
35  mpTabWidget->addTab(pCopasiWidget, "Details");
36  mPages.push_back(pCopasiWidget);
37 
38  switch (mObjectType)
39  {
40  case ListViews::MODEL:
41  mpBtnNew->hide();
42  mpBtnCopy->hide();
43  mpBtnDelete->hide();
44  break;
45 
47  mpBtnNew->setText("Apply");
48  mpBtnNew->setToolTip("Apply the current parameters to the model.");
49 
50  // The break statement is intentionally missing
51 
52  default:
53  CQNotes* pNotes = new CQNotes(mpTabWidget);
54  mPages.push_back(pNotes);
55  mpTabWidget->addTab(pNotes, "Notes");
56 
57  connect(this, SIGNAL(newClicked()), pCopasiWidget, SLOT(slotBtnNew()));
58  connect(this, SIGNAL(copyClicked()), pCopasiWidget, SLOT(slotBtnCopy()));
59  connect(this, SIGNAL(deleteClicked()), pCopasiWidget, SLOT(slotBtnDelete()));
60  connect(this, SIGNAL(copyClicked()), pNotes, SLOT(slotBtnCopy()));
61  break;
62  }
63 
64  CQMiriamWidget* pMIRIAMWidget = new CQMiriamWidget(mpTabWidget);
65  mPages.push_back(pMIRIAMWidget);
66  mpTabWidget->addTab(pMIRIAMWidget, "Annotation");
67  connect(this, SIGNAL(copyClicked()), pMIRIAMWidget, SLOT(slotBtnCopy()));
68 
69  CQRDFTreeView* pRDFTreeView = new CQRDFTreeView(mpTabWidget);
70  mPages.push_back(pRDFTreeView);
71  mpTabWidget->addTab(pRDFTreeView, "RDF Browser");
72 }
objectType
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
void copyClicked()
void newClicked()
void slotBtnDelete()
void slotBtnCopy()
std::vector< CopasiWidget * > mPages
Definition: CQTabWidget.h:56
CopasiWidget(QWidget *parent=0, const char *name=0, Qt::WFlags f=0)
void deleteClicked()
void slotBtnNew()
static const std::string ObjectTypeName[]
Definition: listviews.h:107
ListViews::ObjectType mObjectType
Definition: CQTabWidget.h:57
bool mIgnoreLeave
Definition: CQTabWidget.h:58
CQTabWidget::~CQTabWidget ( )
virtual

Definition at line 74 of file CQTabWidget.cpp.

75 {
76  // TODO Auto-generated destructor stub
77 }

Member Function Documentation

void CQTabWidget::copyClicked ( )
signal

Referenced by CQTabWidget(), and slotBtnCopy().

void CQTabWidget::deleteClicked ( )
signal

Referenced by CQTabWidget(), and slotBtnDelete().

bool CQTabWidget::enterProtected ( )
protectedvirtual

Reimplemented from CopasiWidget.

Definition at line 94 of file CQTabWidget.cpp.

References load(), CopasiWidget::mKey, and mPages.

Referenced by slotBtnCommit(), and slotBtnRevert().

95 {
96  load();
97 
98  std::vector< CopasiWidget * >::iterator it = mPages.begin();
99  std::vector< CopasiWidget * >::iterator end = mPages.end();
100 
101  for (; it != end; ++it)
102  (*it)->enter(mKey);
103 
104  return true;
105 }
std::vector< CopasiWidget * > mPages
Definition: CQTabWidget.h:56
std::string mKey
Definition: copasiWidget.h:63
bool CQTabWidget::leave ( )
virtual

Reimplemented from CopasiWidget.

Definition at line 79 of file CQTabWidget.cpp.

References mIgnoreLeave, mPages, and save().

Referenced by slotBtnCommit(), slotBtnCopy(), and slotBtnNew().

80 {
81  if (mIgnoreLeave) return true;
82 
83  bool success = save();
84 
85  std::vector< CopasiWidget * >::iterator it = mPages.begin();
86  std::vector< CopasiWidget * >::iterator end = mPages.end();
87 
88  for (; it != end; ++it)
89  success &= (*it)->leave();
90 
91  return true;
92 }
std::vector< CopasiWidget * > mPages
Definition: CQTabWidget.h:56
bool mIgnoreLeave
Definition: CQTabWidget.h:58
void CQTabWidget::load ( )
protected

Definition at line 138 of file CQTabWidget.cpp.

References FROM_UTF8, ListViews::FUNCTION, CKeyFactory::get(), CCopasiRootContainer::getKeyFactory(), CCopasiObject::getObjectName(), CEvaluationTree::getType(), CEvaluationTree::MassAction, CopasiWidget::mKey, mObjectType, CopasiWidget::mpObject, and CEvaluationTree::PreDefined.

Referenced by enterProtected(), and update().

139 {
140  // mpObject can not be trusted
142 
143  if (mpObject != NULL)
144  {
145  mpEditName->setText(FROM_UTF8(mpObject->getObjectName()));
146 
148  {
149  const CFunction * pFunction = static_cast< const CFunction * >(mpObject);
150 
151  bool readOnly =
152  (pFunction->getType() == CFunction::PreDefined ||
153  pFunction->getType() == CFunction::MassAction);
154 
155  mpEditName->setReadOnly(readOnly);
156  mpBtnCommit->setEnabled(!readOnly);
157  mpBtnRevert->setEnabled(!readOnly);
158  mpBtnDelete->setEnabled(!readOnly);
159  }
160  }
161  else
162  {
163  mpEditName->setText("");
164  }
165 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const std::string & getObjectName() const
CCopasiObject * get(const std::string &key)
CCopasiObject * mpObject
Definition: copasiWidget.h:64
const CEvaluationTree::Type & getType() const
static CKeyFactory * getKeyFactory()
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
ListViews::ObjectType mObjectType
Definition: CQTabWidget.h:57
std::string mKey
Definition: copasiWidget.h:63
void CQTabWidget::newClicked ( )
signal
bool CQTabWidget::save ( )
protected

Definition at line 167 of file CQTabWidget.cpp.

References CCopasiDataModel::changed(), FROM_UTF8, CKeyFactory::get(), CCopasiRootContainer::getKeyFactory(), CCopasiObject::getObjectName(), CQMessageBox::information(), CopasiWidget::mKey, mObjectType, mPages, CopasiWidget::mpDataModel, CopasiWidget::mpObject, ListViews::ObjectTypeName, CopasiWidget::protectedNotify(), ListViews::RENAME, CCopasiObject::setObjectName(), and TO_UTF8.

Referenced by leave().

168 {
169  // mpObject can not be trusted
171 
172  if (mpObject == NULL) return false;
173 
174  // We need to tell the sub-widgets to ignore all notifications
175  std::vector< CopasiWidget * >::iterator it = mPages.begin();
176  std::vector< CopasiWidget * >::iterator end = mPages.end();
177 
178  for (; it != end; ++it)
179  (*it)->setIgnoreUpdates(true);
180 
181  if (mpObject->getObjectName() != TO_UTF8(mpEditName->text()))
182  {
183  if (!mpObject->setObjectName(TO_UTF8(mpEditName->text())))
184  {
185  QString msg;
186  msg = "Unable to rename " + FROM_UTF8(ListViews::ObjectTypeName[mObjectType]).toLower() + " '" + FROM_UTF8(mpObject->getObjectName()) + "'\n"
187  + "to '" + mpEditName->text() + "' since a " + FROM_UTF8(ListViews::ObjectTypeName[mObjectType]).toLower() + " with that name already exists.\n";
188 
190  "Unable to rename " + FROM_UTF8(ListViews::ObjectTypeName[mObjectType]),
191  msg,
192  QMessageBox::Ok, QMessageBox::Ok);
193 
194  mpEditName->setText(FROM_UTF8(mpObject->getObjectName()));
195  }
196  else
197  {
199 
200  if (mpDataModel != NULL)
201  {
202  mpDataModel->changed();
203  }
204  }
205  }
206 
207  // We need to tell the sub-widgets to accept notifications again
208  it = mPages.begin();
209  end = mPages.end();
210 
211  for (; it != end; ++it)
212  (*it)->setIgnoreUpdates(false);
213 
214  return true;
215 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const std::string & getObjectName() const
CCopasiObject * get(const std::string &key)
CCopasiObject * mpObject
Definition: copasiWidget.h:64
static StandardButton information(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
void changed(const bool &changed=true)
std::vector< CopasiWidget * > mPages
Definition: CQTabWidget.h:56
virtual bool protectedNotify(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
CCopasiDataModel * mpDataModel
Definition: copasiWidget.h:65
static CKeyFactory * getKeyFactory()
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
static const std::string ObjectTypeName[]
Definition: listviews.h:107
ListViews::ObjectType mObjectType
Definition: CQTabWidget.h:57
bool setObjectName(const std::string &name)
std::string mKey
Definition: copasiWidget.h:63
void CQTabWidget::selectTab ( int  index) const
void CQTabWidget::slotBtnCommit ( )
privateslot

Definition at line 217 of file CQTabWidget.cpp.

References enterProtected(), and leave().

218 {
219  mpBtnCommit->setFocus();
220 
221  leave();
222  enterProtected();
223 }
virtual bool enterProtected()
Definition: CQTabWidget.cpp:94
virtual bool leave()
Definition: CQTabWidget.cpp:79
void CQTabWidget::slotBtnCopy ( )
privateslot

Definition at line 248 of file CQTabWidget.cpp.

References CQSpeciesDetail::copy(), CQCompartment::copy(), ReactionsWidget1::copy(), copyClicked(), leave(), mIgnoreLeave, mPages, and newClicked().

Referenced by CQTabWidget().

249 {
250  mpBtnCopy->setFocus();
251 
252  leave();
253 
254  mIgnoreLeave = true;
255 
256  // CQCompartments and CQSpecies have copy options, use CModelExpansion, and do their own switching.
257  if (QString(mPages[0]->metaObject()->className()) == "CQCompartment")
258  {
259  CQCompartment * pQCompartment = dynamic_cast< CQCompartment * >(mPages[0]);
260  pQCompartment->copy();
261  }
262  else if (QString(mPages[0]->metaObject()->className()) == "CQSpeciesDetail")
263  {
264  CQSpeciesDetail * pQSpeciesDetail = dynamic_cast< CQSpeciesDetail * >(mPages[0]);
265  pQSpeciesDetail->copy();
266  }
267  else if (QString(mPages[0]->metaObject()->className()) == "ReactionsWidget1")
268  {
269  ReactionsWidget1 * pReactionsWidget1 = dynamic_cast< ReactionsWidget1 * >(mPages[0]);
270  pReactionsWidget1->copy();
271  }
272  else
273  {
274  emit copyClicked();
275  emit newClicked();
276  }
277 
278  mIgnoreLeave = false;
279 }
void copyClicked()
void newClicked()
std::vector< CopasiWidget * > mPages
Definition: CQTabWidget.h:56
virtual bool leave()
Definition: CQTabWidget.cpp:79
bool mIgnoreLeave
Definition: CQTabWidget.h:58
void CQTabWidget::slotBtnDelete ( )
privateslot

Definition at line 230 of file CQTabWidget.cpp.

References deleteClicked(), and mIgnoreLeave.

Referenced by CQTabWidget().

231 {
232  mIgnoreLeave = true;
233  emit deleteClicked();
234  mIgnoreLeave = false;
235 }
void deleteClicked()
bool mIgnoreLeave
Definition: CQTabWidget.h:58
void CQTabWidget::slotBtnNew ( )
privateslot

Definition at line 237 of file CQTabWidget.cpp.

References leave(), mIgnoreLeave, and newClicked().

Referenced by CQTabWidget().

238 {
239  mpBtnNew->setFocus();
240 
241  leave();
242 
243  mIgnoreLeave = true;
244  emit newClicked();
245  mIgnoreLeave = false;
246 }
void newClicked()
virtual bool leave()
Definition: CQTabWidget.cpp:79
bool mIgnoreLeave
Definition: CQTabWidget.h:58
void CQTabWidget::slotBtnRevert ( )
privateslot

Definition at line 225 of file CQTabWidget.cpp.

References enterProtected().

226 {
227  enterProtected();
228 }
virtual bool enterProtected()
Definition: CQTabWidget.cpp:94
bool CQTabWidget::update ( ListViews::ObjectType  objectType,
ListViews::Action  action,
const std::string &  key 
)
virtual

Reimplemented from CopasiWidget.

Definition at line 107 of file CQTabWidget.cpp.

References ListViews::DELETE, load(), CopasiWidget::mIgnoreUpdates, CopasiWidget::mKey, mObjectType, CopasiWidget::mpObject, and ListViews::RENAME.

108 {
109  if (mIgnoreUpdates) return true;
110 
111  if (objectType == mObjectType &&
112  key == mKey)
113  {
114  switch (action)
115  {
116  case ListViews::RENAME:
117  load();
118  break;
119 
120  case ListViews::DELETE:
121  mpObject = NULL;
122  break;
123 
124  default:
125  break;
126  }
127  }
128 
129  // We do not need to update the child pages as they are directly called from listviews.
130  return true;
131 }
objectType
CCopasiObject * mpObject
Definition: copasiWidget.h:64
bool mIgnoreUpdates
Definition: copasiWidget.h:67
ListViews::ObjectType mObjectType
Definition: CQTabWidget.h:57
std::string mKey
Definition: copasiWidget.h:63

Member Data Documentation

bool CQTabWidget::mIgnoreLeave
private

Definition at line 58 of file CQTabWidget.h.

Referenced by leave(), slotBtnCopy(), slotBtnDelete(), and slotBtnNew().

ListViews::ObjectType CQTabWidget::mObjectType
private

Definition at line 57 of file CQTabWidget.h.

Referenced by CQTabWidget(), load(), save(), and update().

std::vector< CopasiWidget * > CQTabWidget::mPages
private

Definition at line 56 of file CQTabWidget.h.

Referenced by CQTabWidget(), enterProtected(), leave(), save(), and slotBtnCopy().


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