COPASI API  4.16.103
CQExperimentSelection.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/UI/CQExperimentSelection.cpp,v $
3 // $Revision: 1.11 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/10/13 20:28:40 $
7 // End CVS Header
8 
9 // Copyright (C) 2011 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 #include "CQExperimentSelection.h"
15 
16 #include <QtGui/QComboBox>
17 
18 #include "copasi.h"
19 
20 #include "qtUtilities.h"
21 
24 
25 /*
26  * Constructs a CQExperimentSelection as a child of 'parent', with the
27  * name 'name' and widget flags set to 'f'.
28  *
29  * The dialog will by default be modeless, unless you set 'modal' to
30  * true to construct a modal dialog.
31  */
32 CQExperimentSelection::CQExperimentSelection(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
33  : QDialog(parent, fl)
34 {
35  setObjectName(QString::fromUtf8(name));
36  setModal(modal);
37  setupUi(this);
38 
39  init();
40 }
41 
42 /*
43  * Destroys the object and frees any allocated resources
44  */
46 {
47  // no need to delete child widgets, Qt does it all for us
48 }
49 
51 {
52  mpBox->clear();
53 
54  if (mpList->selectedItems().count() != mpList->count())
55  {
56  QListWidgetItem * pItem;
57  QStringList Items;
58  int i, imax = mpList->count();
59 
60  for (i = 0; i != imax; ++i)
61  {
62  pItem = mpList->item(i);
63 
64  if (pItem->isSelected())
65  {
66  Items.append(pItem->text());
67  }
68  }
69 
70  mpBox->addItems(Items);
71  }
72 
73  accept();
74 }
75 
77 {
78  reject();
79 }
80 
82 {
83  mpList->selectAll();
84 }
85 
87 {
88  mpList->clearSelection();
89 }
90 
91 void CQExperimentSelection::load(QComboBox * pBox, const CExperimentSet * pExperimentSet)
92 {
93  mpBox = pBox;
94  mpList->clear();
95 
96  QStringList Items;
97  size_t i, imax = pExperimentSet->getExperimentCount();
98 
99  for (i = 0; i < imax; i++)
100  {
101  Items.append(FROM_UTF8(pExperimentSet->getExperiment(i)->getObjectName()));
102  }
103 
104  mpList->addItems(Items);
105 
106  int j, jmax = mpBox->count();
107 
108  if (jmax == 0)
109  {
110  slotBtnAll();
111  return;
112  }
113 
114  for (j = 0; j < jmax; j++)
115  {
116  QList< QListWidgetItem * > Found = mpList->findItems(mpBox->itemText(j), Qt::MatchExactly);
117 
118  if (Found.size() > 0)
119  {
120  Found[0]->setSelected(true);
121  }
122  }
123 }
124 
126 {
127  mpBox = NULL;
128 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const std::string & getObjectName() const
CExperiment * getExperiment(const size_t &index)
virtual void load(QComboBox *pBox, const CExperimentSet *pExperimentSet)
CQExperimentSelection(QWidget *parent=0, const char *name=0, bool modal=false, Qt::WindowFlags fl=0)
bool fl(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
size_t getExperimentCount() const