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

#include <CQReportsWidget.h>

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

Public Member Functions

 CQReportsWidget (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)
 
 ~CQReportsWidget ()
 
- 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 deleteSelectedReports ()
 
void updateDeleteBtns ()
 

Private Attributes

CQSortFilterProxyModelmpProxyModel
 
CQReportDMmpReportDM
 

Additional Inherited Members

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

Detailed Description

Definition at line 29 of file CQReportsWidget.h.

Constructor & Destructor Documentation

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

Definition at line 31 of file CQReportsWidget.cpp.

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

32  : CopasiWidget(parent, name)
33 {
34  setupUi(this);
35 
36  //Create Source Data Model.
37  mpReportDM = new CQReportDM(this);
38 
39  //Create the Proxy Model for sorting/filtering and set its properties.
41  mpProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
42  mpProxyModel->setFilterKeyColumn(-1);
43 
44  mpTblReports->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
45  mpTblReports->verticalHeader()->hide();
46  mpTblReports->sortByColumn(COL_ROW_NUMBER, Qt::AscendingOrder);
47 
49 
50  // Connect the table widget
51  connect(mpReportDM, SIGNAL(notifyGUI(ListViews::ObjectType, ListViews::Action, const std::string)),
52  this, SLOT(protectedNotify(ListViews::ObjectType, ListViews::Action, const std::string)));
53  connect(mpReportDM, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
54  this, SLOT(dataChanged(const QModelIndex&, const QModelIndex&)));
55  connect(mpLEFilter, SIGNAL(textChanged(const QString &)),
56  this, SLOT(slotFilterChanged()));
57 }
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="")
virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
CQReportDM * mpReportDM
virtual void slotFilterChanged()
virtual void setFramework(int framework)
#define COL_ROW_NUMBER
CQReportsWidget::~CQReportsWidget ( )

Definition at line 62 of file CQReportsWidget.cpp.

References mpProxyModel, mpReportDM, and pdelete.

63 {
66  // no need to delete child widgets, Qt does it all for us
67 }
CQSortFilterProxyModel * mpProxyModel
#define pdelete(p)
Definition: copasi.h:215
CQReportDM * mpReportDM

Member Function Documentation

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

Definition at line 189 of file CQReportsWidget.cpp.

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

Referenced by CQReportsWidget().

191 {
192  mpTblReports->resizeColumnsToContents();
195 }
virtual void setFramework(int framework)
void CQReportsWidget::deleteSelectedReports ( )
private

Definition at line 83 of file CQReportsWidget.cpp.

References mpProxyModel, mpReportDM, CQReportDM::removeRows(), and CQReportDM::rowCount().

Referenced by slotBtnDeleteClicked().

84 {
85  const QItemSelectionModel * pSelectionModel = mpTblReports->selectionModel();
86 
87  QModelIndexList mappedSelRows;
88  size_t i, imax = mpReportDM->rowCount();
89 
90  for (i = 0; i < imax; i++)
91  {
92  if (pSelectionModel->isRowSelected((int) i, QModelIndex()))
93  {
94  mappedSelRows.append(mpProxyModel->mapToSource(mpProxyModel->index((int) i, 0)));
95  }
96  }
97 
98  if (mappedSelRows.empty())
99  {return;}
100 
101  mpReportDM->removeRows(mappedSelRows);
102 }
CQSortFilterProxyModel * mpProxyModel
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
Definition: CQReportDM.cpp:29
CQReportDM * mpReportDM
bool removeRows(QModelIndexList rows, const QModelIndex &index=QModelIndex())
Definition: CQReportDM.cpp:210
bool CQReportsWidget::enterProtected ( )
protectedvirtual

Reimplemented from CopasiWidget.

Definition at line 133 of file CQReportsWidget.cpp.

References CopasiWidget::mFramework, mpProxyModel, mpReportDM, setFramework(), slotSelectionChanged(), and updateDeleteBtns().

Referenced by update().

134 {
135  if (mpTblReports->selectionModel() != NULL)
136  {
137  disconnect(mpTblReports->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
138  this, SLOT(slotSelectionChanged(const QItemSelection&, const QItemSelection&)));
139  }
140 
141  mpProxyModel->setSourceModel(mpReportDM);
142  //Set Model for the TableView
143  mpTblReports->setModel(NULL);
144  mpTblReports->setModel(mpProxyModel);
145  connect(mpTblReports->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
146  this, SLOT(slotSelectionChanged(const QItemSelection&, const QItemSelection&)));
148  mpTblReports->resizeColumnsToContents();
150 
151  return true;
152 }
CQSortFilterProxyModel * mpProxyModel
CQReportDM * mpReportDM
virtual void slotSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
virtual void setFramework(int framework)
void CQReportsWidget::keyPressEvent ( QKeyEvent *  ev)
protectedvirtual

Definition at line 222 of file CQReportsWidget.cpp.

References CQReportDM::columnCount(), mpProxyModel, mpReportDM, and slotBtnDeleteClicked().

223 {
224  if (ev->key() == Qt::Key_Delete)
226  else if (ev->key() == Qt::Key_C && (ev->modifiers() & Qt::ControlModifier))
227  {
228  QModelIndexList selRows = mpTblReports->selectionModel()->selectedRows(0);
229 
230  if (selRows.empty())
231  {return;}
232 
233  QString str;
234  QModelIndexList::const_iterator i;
235 
236  for (i = selRows.begin(); i != selRows.end(); ++i)
237  {
238  for (int x = 0; x < mpReportDM->columnCount(); ++x)
239  {
240  if (!mpTblReports->isColumnHidden(x))
241  {
242  if (!str.isEmpty())
243  str += "\t";
244 
245  str += mpReportDM->index(mpProxyModel->mapToSource(*i).row(), x).data().toString();
246  }
247  }
248 
249  str += "\n";
250  }
251 
252  QApplication::clipboard()->setText(str);
253  }
254 }
CQSortFilterProxyModel * mpProxyModel
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
Definition: CQReportDM.cpp:33
virtual void slotBtnDeleteClicked()
CQReportDM * mpReportDM
bool CQReportsWidget::leave ( )
virtual

Reimplemented from CopasiWidget.

Definition at line 128 of file CQReportsWidget.cpp.

129 {
130  return true;
131 }
void CQReportsWidget::setFramework ( int  framework)
virtual

Reimplemented from CopasiWidget.

Definition at line 262 of file CQReportsWidget.cpp.

References CopasiWidget::setFramework().

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

263 {
264  CopasiWidget::setFramework(framework);
265 }
virtual void setFramework(int framework)
void CQReportsWidget::slotBtnClearClicked ( )
protectedvirtualslot

Definition at line 104 of file CQReportsWidget.cpp.

References CQBaseDataModel::clear(), mpReportDM, CQMessageBox::question(), and updateDeleteBtns().

105 {
106 
107  int ret = CQMessageBox::question(this, tr("Confirm Delete"), "Delete all Reports?",
108  QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
109 
110  if (ret == QMessageBox::Yes)
111  {
112  mpReportDM->clear();
113  }
114 
116 }
virtual bool clear()
CQReportDM * mpReportDM
static StandardButton question(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
void CQReportsWidget::slotBtnDeleteClicked ( )
protectedvirtualslot

Definition at line 75 of file CQReportsWidget.cpp.

References deleteSelectedReports(), and updateDeleteBtns().

Referenced by keyPressEvent().

76 {
77  if (mpTblReports->hasFocus())
79 
81 }
void deleteSelectedReports()
void CQReportsWidget::slotBtnNewClicked ( )
protectedvirtualslot

Definition at line 69 of file CQReportsWidget.cpp.

References CQBaseDataModel::insertRow(), mpReportDM, and updateDeleteBtns().

Referenced by slotDoubleClicked().

70 {
73 }
CQReportDM * mpReportDM
void CQReportsWidget::slotDoubleClicked ( const QModelIndex  proxyIndex)
protectedvirtualslot

Definition at line 197 of file CQReportsWidget.cpp.

References C_INVALID_INDEX, CKeyFactory::get(), CCopasiRootContainer::getDatamodelList(), CCopasiRootContainer::getKeyFactory(), CCopasiDataModel::getModel(), CCopasiDataModel::getReportDefinitionList(), CQBaseDataModel::isDefaultRow(), CopasiWidget::mpListView, mpProxyModel, mpReportDM, slotBtnNewClicked(), and ListViews::switchToOtherWidget().

198 {
199  QModelIndex index = mpProxyModel->mapToSource(proxyIndex);
200 
201  if (index.row() < 0)
202  return;
203 
204  if (mpReportDM->isDefaultRow(index))
205  {
207  }
208 
209  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
211  assert(pDataModel != NULL);
212 
213  if (!pDataModel->getModel())
214  return;
215 
216  std::string key = pDataModel->getReportDefinitionList()->operator[](index.row())->getKey();
217 
220 }
CQSortFilterProxyModel * mpProxyModel
void switchToOtherWidget(const size_t &id, const std::string &key)
Definition: listviews.cpp:926
CCopasiObject * get(const std::string &key)
#define C_INVALID_INDEX
Definition: copasi.h:222
const CReportDefinitionVector * getReportDefinitionList() const
ListViews * mpListView
Definition: copasiWidget.h:62
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
virtual void slotBtnNewClicked()
CQReportDM * mpReportDM
static CKeyFactory * getKeyFactory()
virtual bool isDefaultRow(const QModelIndex &i) const
void CQReportsWidget::slotFilterChanged ( )
protectedvirtualslot

Definition at line 256 of file CQReportsWidget.cpp.

References mpProxyModel.

Referenced by CQReportsWidget().

257 {
258  QRegExp regExp(mpLEFilter->text() + "|New Report", Qt::CaseInsensitive, QRegExp::RegExp);
259  mpProxyModel->setFilterRegExp(regExp);
260 }
CQSortFilterProxyModel * mpProxyModel
void CQReportsWidget::slotSelectionChanged ( const QItemSelection &  selected,
const QItemSelection &  deselected 
)
protectedvirtualslot

Definition at line 183 of file CQReportsWidget.cpp.

References updateDeleteBtns().

Referenced by enterProtected().

185 {
187 }
bool CQReportsWidget::update ( ListViews::ObjectType  objectType,
ListViews::Action  action,
const std::string &  key 
)
virtual

Reimplemented from CopasiWidget.

Definition at line 118 of file CQReportsWidget.cpp.

References enterProtected(), and CopasiWidget::mIgnoreUpdates.

119 {
120  if (!mIgnoreUpdates)
121  {
122  enterProtected();
123  }
124 
125  return true;
126 }
virtual bool enterProtected()
bool mIgnoreUpdates
Definition: copasiWidget.h:67
void CQReportsWidget::updateDeleteBtns ( )
private

Definition at line 154 of file CQReportsWidget.cpp.

References CQBaseDataModel::isDefaultRow(), mpProxyModel, and mpReportDM.

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

155 {
156  bool selected = false;
157 
158  QModelIndexList selRows = mpTblReports->selectionModel()->selectedRows();
159 
160  if (selRows.size() == 0)
161  selected = false;
162  else
163  {
164  if (selRows.size() == 1)
165  {
166  if (mpReportDM->isDefaultRow(mpProxyModel->mapToSource(selRows[0])))
167  selected = false;
168  else
169  selected = true;
170  }
171  else
172  selected = true;
173  }
174 
175  mpBtnDelete->setEnabled(selected);
176 
177  if (mpProxyModel->rowCount() - 1)
178  mpBtnClear->setEnabled(true);
179  else
180  mpBtnClear->setEnabled(false);
181 }
CQSortFilterProxyModel * mpProxyModel
CQReportDM * mpReportDM
virtual bool isDefaultRow(const QModelIndex &i) const

Member Data Documentation

CQSortFilterProxyModel* CQReportsWidget::mpProxyModel
private
CQReportDM* CQReportsWidget::mpReportDM
private

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