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

#include <CQParameterSetsWidget.h>

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

Public Member Functions

 CQParameterSetsWidget (QWidget *parent=0, const char *name=0)
 
virtual bool leave ()
 
virtual void setFramework (int framework)
 
virtual bool update (ListViews::ObjectType objectType, ListViews::Action action, const std::string &key)
 
 ~CQParameterSetsWidget ()
 
- 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 Slots

virtual void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight)
 
virtual void slotBtnClearClicked ()
 
virtual void slotBtnDeleteClicked ()
 
virtual void slotBtnNewClicked ()
 
virtual void slotDoubleClicked (const QModelIndex proxyIndex)
 
virtual void slotFilterChanged ()
 
virtual void slotSelectionChanged (const QItemSelection &selected, const QItemSelection &deselected)
 
- Protected Slots inherited from CopasiWidget
virtual bool protectedNotify (ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
 

Protected Member Functions

virtual bool enterProtected ()
 
virtual void keyPressEvent (QKeyEvent *ev)
 

Private Member Functions

void deleteSelected ()
 
void updateDeleteBtns ()
 

Private Attributes

CQParameterSetsDMmpParameterSetsDM
 
CQSortFilterProxyModelmpProxyModel
 

Additional Inherited Members

- Protected Attributes inherited from CopasiWidget
int mFramework
 
bool mIgnoreUpdates
 
std::string mKey
 
CCopasiDataModelmpDataModel
 
ListViewsmpListView
 
CCopasiObjectmpObject
 

Detailed Description

Definition at line 16 of file CQParameterSetsWidget.h.

Constructor & Destructor Documentation

CQParameterSetsWidget::CQParameterSetsWidget ( QWidget *  parent = 0,
const char *  name = 0 
)

Definition at line 26 of file CQParameterSetsWidget.cpp.

References COL_ROW_NUMBER, dataChanged(), CopasiWidget::mFramework, mpParameterSetsDM, mpProxyModel, CopasiWidget::protectedNotify(), setFramework(), and slotFilterChanged().

27  : CopasiWidget(parent, name)
28 {
29  setupUi(this);
30 
31  //Create Source Data Model.
33 
34  //Create the Proxy Model for sorting/filtering and set its properties.
36  mpProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
37  mpProxyModel->setFilterKeyColumn(-1);
38 
39  mpTblParameterSets->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
40  mpTblParameterSets->verticalHeader()->hide();
41  mpTblParameterSets->sortByColumn(COL_ROW_NUMBER, Qt::AscendingOrder);
42 
44 
45  // Connect the table widget
46  connect(mpParameterSetsDM, SIGNAL(notifyGUI(ListViews::ObjectType, ListViews::Action, const std::string)),
47  this, SLOT(protectedNotify(ListViews::ObjectType, ListViews::Action, const std::string)));
48  connect(mpParameterSetsDM, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
49  this, SLOT(dataChanged(const QModelIndex&, const QModelIndex&)));
50  connect(mpLEFilter, SIGNAL(textChanged(const QString &)),
51  this, SLOT(slotFilterChanged()));
52 }
virtual void setFramework(int framework)
CQSortFilterProxyModel * mpProxyModel
CopasiWidget(QWidget *parent=0, const char *name=0, Qt::WFlags f=0)
virtual bool protectedNotify(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
CQParameterSetsDM * mpParameterSetsDM
virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
#define COL_ROW_NUMBER
CQParameterSetsWidget::~CQParameterSetsWidget ( )

Definition at line 57 of file CQParameterSetsWidget.cpp.

References mpParameterSetsDM, mpProxyModel, and pdelete.

58 {
61  // no need to delete child widgets, Qt does it all for us
62 }
#define pdelete(p)
Definition: copasi.h:215
CQSortFilterProxyModel * mpProxyModel
CQParameterSetsDM * mpParameterSetsDM

Member Function Documentation

void CQParameterSetsWidget::dataChanged ( const QModelIndex &  topLeft,
const QModelIndex &  bottomRight 
)
protectedvirtualslot

Definition at line 202 of file CQParameterSetsWidget.cpp.

References CopasiWidget::mFramework, setFramework(), and updateDeleteBtns().

Referenced by CQParameterSetsWidget().

204 {
205  mpTblParameterSets->resizeColumnsToContents();
208 }
virtual void setFramework(int framework)
void CQParameterSetsWidget::deleteSelected ( )
private

Definition at line 78 of file CQParameterSetsWidget.cpp.

References mpParameterSetsDM, mpProxyModel, CQParameterSetsDM::removeRows(), and CQParameterSetsDM::rowCount().

Referenced by slotBtnDeleteClicked().

79 {
80  const QItemSelectionModel * pSelectionModel = mpTblParameterSets->selectionModel();
81 
82  QModelIndexList mappedSelRows;
83  size_t i, imax = mpParameterSetsDM->rowCount();
84 
85  for (i = 0; i < imax; i++)
86  {
87  if (pSelectionModel->isRowSelected((int) i, QModelIndex()))
88  {
89  mappedSelRows.append(mpProxyModel->mapToSource(mpProxyModel->index((int) i, 0)));
90  }
91  }
92 
93  if (mappedSelRows.empty())
94  {return;}
95 
96  mpParameterSetsDM->removeRows(mappedSelRows);
97 }
CQSortFilterProxyModel * mpProxyModel
CQParameterSetsDM * mpParameterSetsDM
bool removeRows(QModelIndexList rows, const QModelIndex &index=QModelIndex())
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
bool CQParameterSetsWidget::enterProtected ( )
protectedvirtual

Reimplemented from CopasiWidget.

Definition at line 137 of file CQParameterSetsWidget.cpp.

References CopasiWidget::mFramework, CopasiWidget::mpObject, mpParameterSetsDM, mpProxyModel, setFramework(), CQParameterSetsDM::setListOfModelParameterSets(), slotSelectionChanged(), and updateDeleteBtns().

138 {
139  if (mpObject == NULL)
140  {
141  return false;
142  }
143 
144  if (mpTblParameterSets->selectionModel() != NULL)
145  {
146  disconnect(mpTblParameterSets->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
147  this, SLOT(slotSelectionChanged(const QItemSelection&, const QItemSelection&)));
148  }
149 
150  mpParameterSetsDM->setListOfModelParameterSets(&static_cast< CModel * >(mpObject)->getModelParameterSets());
151  mpProxyModel->setSourceModel(mpParameterSetsDM);
152 
153  //Set Model for the TableView
154  mpTblParameterSets->setModel(NULL);
155  mpTblParameterSets->setModel(mpProxyModel);
156  connect(mpTblParameterSets->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
157  this, SLOT(slotSelectionChanged(const QItemSelection&, const QItemSelection&)));
159  mpTblParameterSets->resizeColumnsToContents();
161 
162  mpBtnNew->hide();
163 
164  return true;
165 }
void setListOfModelParameterSets(CCopasiVectorN< CModelParameterSet > *pListOfModelParameterSets)
virtual void setFramework(int framework)
CCopasiObject * mpObject
Definition: copasiWidget.h:64
CQSortFilterProxyModel * mpProxyModel
CQParameterSetsDM * mpParameterSetsDM
virtual void slotSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
void CQParameterSetsWidget::keyPressEvent ( QKeyEvent *  ev)
protectedvirtual

Definition at line 233 of file CQParameterSetsWidget.cpp.

References CQParameterSetsDM::columnCount(), mpParameterSetsDM, mpProxyModel, and slotBtnDeleteClicked().

234 {
235  if (ev->key() == Qt::Key_Delete)
237  else if (ev->key() == Qt::Key_C && (ev->modifiers() & Qt::ControlModifier))
238  {
239  QModelIndexList selRows = mpTblParameterSets->selectionModel()->selectedRows(0);
240 
241  if (selRows.empty())
242  {return;}
243 
244  QString str;
245  QModelIndexList::const_iterator i;
246 
247  for (i = selRows.begin(); i != selRows.end(); ++i)
248  {
249  for (int x = 0; x < mpParameterSetsDM->columnCount(); ++x)
250  {
251  if (!mpTblParameterSets->isColumnHidden(x))
252  {
253  if (!str.isEmpty())
254  str += "\t";
255 
256  str += mpParameterSetsDM->index(mpProxyModel->mapToSource(*i).row(), x).data().toString();
257  }
258  }
259 
260  str += "\n";
261  }
262 
263  QApplication::clipboard()->setText(str);
264  }
265 }
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
CQSortFilterProxyModel * mpProxyModel
CQParameterSetsDM * mpParameterSetsDM
bool CQParameterSetsWidget::leave ( )
virtual

Reimplemented from CopasiWidget.

Definition at line 132 of file CQParameterSetsWidget.cpp.

133 {
134  return true;
135 }
void CQParameterSetsWidget::setFramework ( int  framework)
virtual

Reimplemented from CopasiWidget.

Definition at line 273 of file CQParameterSetsWidget.cpp.

References CopasiWidget::setFramework().

Referenced by CQParameterSetsWidget(), dataChanged(), and enterProtected().

274 {
275  CopasiWidget::setFramework(framework);
276 }
virtual void setFramework(int framework)
void CQParameterSetsWidget::slotBtnClearClicked ( )
protectedvirtualslot

Definition at line 99 of file CQParameterSetsWidget.cpp.

References CQParameterSetsDM::clear(), mpParameterSetsDM, CQMessageBox::question(), and updateDeleteBtns().

100 {
101 
102  int ret = CQMessageBox::question(this, tr("Confirm Delete"), "Delete all Reports?",
103  QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
104 
105  if (ret == QMessageBox::Yes)
106  {
108  }
109 
111 }
virtual bool clear()
CQParameterSetsDM * mpParameterSetsDM
static StandardButton question(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
void CQParameterSetsWidget::slotBtnDeleteClicked ( )
protectedvirtualslot

Definition at line 70 of file CQParameterSetsWidget.cpp.

References deleteSelected(), and updateDeleteBtns().

Referenced by keyPressEvent().

71 {
72  if (mpTblParameterSets->hasFocus())
73  {deleteSelected();}
74 
76 }
void CQParameterSetsWidget::slotBtnNewClicked ( )
protectedvirtualslot
void CQParameterSetsWidget::slotDoubleClicked ( const QModelIndex  proxyIndex)
protectedvirtualslot

Definition at line 210 of file CQParameterSetsWidget.cpp.

References C_INVALID_INDEX, CModel::getKey(), CCopasiRootContainer::getKeyFactory(), CQParameterSetsDM::isDefaultRow(), CopasiWidget::mpListView, CopasiWidget::mpObject, mpParameterSetsDM, mpProxyModel, slotBtnNewClicked(), and ListViews::switchToOtherWidget().

211 {
212  QModelIndex index = mpProxyModel->mapToSource(proxyIndex);
213 
214  if (index.row() < 0)
215  return;
216 
217  if (mpParameterSetsDM->isDefaultRow(index))
218  {
220  }
221 
222  if (mpObject == NULL)
223  {
224  return;
225  }
226 
227  std::string key = static_cast< CModel * >(mpObject)->getModelParameterSets()[index.row()]->getKey();
228 
229  if (CCopasiRootContainer::getKeyFactory()->get(key))
231 }
void switchToOtherWidget(const size_t &id, const std::string &key)
Definition: listviews.cpp:926
virtual bool isDefaultRow(const QModelIndex &i) const
CCopasiObject * mpObject
Definition: copasiWidget.h:64
#define C_INVALID_INDEX
Definition: copasi.h:222
CQSortFilterProxyModel * mpProxyModel
ListViews * mpListView
Definition: copasiWidget.h:62
const std::string & getKey() const
Definition: CModel.cpp:1142
CQParameterSetsDM * mpParameterSetsDM
static CKeyFactory * getKeyFactory()
Definition: CModel.h:50
void CQParameterSetsWidget::slotFilterChanged ( )
protectedvirtualslot

Definition at line 267 of file CQParameterSetsWidget.cpp.

References mpProxyModel.

Referenced by CQParameterSetsWidget().

268 {
269  QRegExp regExp(mpLEFilter->text() + "|New Report", Qt::CaseInsensitive, QRegExp::RegExp);
270  mpProxyModel->setFilterRegExp(regExp);
271 }
CQSortFilterProxyModel * mpProxyModel
void CQParameterSetsWidget::slotSelectionChanged ( const QItemSelection &  selected,
const QItemSelection &  deselected 
)
protectedvirtualslot

Definition at line 196 of file CQParameterSetsWidget.cpp.

References updateDeleteBtns().

Referenced by enterProtected().

198 {
200 }
bool CQParameterSetsWidget::update ( ListViews::ObjectType  objectType,
ListViews::Action  action,
const std::string &  key 
)
virtual

Reimplemented from CopasiWidget.

Definition at line 113 of file CQParameterSetsWidget.cpp.

References ListViews::ADD, ListViews::DELETE, CopasiWidget::mIgnoreUpdates, CopasiWidget::mKey, ListViews::MODEL, CopasiWidget::mpDataModel, and CopasiWidget::mpObject.

114 {
115  if (mIgnoreUpdates)
116  {
117  return true;
118  }
119 
120  if (objectType == ListViews::MODEL &&
121  (action == ListViews::DELETE ||
122  action == ListViews::ADD))
123  {
124  mpDataModel = NULL;
125  mpObject = NULL;
126  mKey = "";
127  }
128 
129  return true;
130 }
objectType
CCopasiObject * mpObject
Definition: copasiWidget.h:64
bool mIgnoreUpdates
Definition: copasiWidget.h:67
CCopasiDataModel * mpDataModel
Definition: copasiWidget.h:65
std::string mKey
Definition: copasiWidget.h:63
void CQParameterSetsWidget::updateDeleteBtns ( )
private

Definition at line 167 of file CQParameterSetsWidget.cpp.

References CQParameterSetsDM::isDefaultRow(), mpParameterSetsDM, and mpProxyModel.

Referenced by dataChanged(), enterProtected(), slotBtnClearClicked(), slotBtnDeleteClicked(), slotBtnNewClicked(), and slotSelectionChanged().

168 {
169  bool selected = false;
170 
171  QModelIndexList selRows = mpTblParameterSets->selectionModel()->selectedRows();
172 
173  if (selRows.size() == 0)
174  selected = false;
175  else
176  {
177  if (selRows.size() == 1)
178  {
179  if (mpParameterSetsDM->isDefaultRow(mpProxyModel->mapToSource(selRows[0])))
180  selected = false;
181  else
182  selected = true;
183  }
184  else
185  selected = true;
186  }
187 
188  mpBtnDelete->setEnabled(selected);
189 
190  if (mpProxyModel->rowCount() - 1)
191  mpBtnClear->setEnabled(true);
192  else
193  mpBtnClear->setEnabled(false);
194 }
virtual bool isDefaultRow(const QModelIndex &i) const
CQSortFilterProxyModel * mpProxyModel
CQParameterSetsDM * mpParameterSetsDM

Member Data Documentation

CQParameterSetsDM* CQParameterSetsWidget::mpParameterSetsDM
private
CQSortFilterProxyModel* CQParameterSetsWidget::mpProxyModel
private

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