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

#include <CScanContainerWidget.h>

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

Signals

void copyWidget (int)
 
void itemDeleted ()
 

Public Member Functions

void addWidget (QWidget *widget, bool controls=true)
 
void clearWidgetList ()
 
 CScanContainerWidget (QWidget *parent=0, const char *name=0)
 
void enableCopy (const bool &enable)
 
std::vector< QWidget * > getWidgetList () const
 
void insertWidget (QWidget *widget, int row=-1)
 
 ~CScanContainerWidget ()
 

Protected Slots

void slotCopy (int index)
 
void slotDel (int index)
 
void slotDown (int index)
 
void slotUp (int index)
 

Protected Member Functions

void resizeEvent (QResizeEvent *event)
 
void updateIndices ()
 
void updateTable ()
 

Protected Attributes

bool mCopyEnabled
 

Detailed Description

This widget is a table that contains other widgets (arranged vertically) it adds buttons to delete, move up or down the widgets

Definition at line 33 of file CScanContainerWidget.h.

Constructor & Destructor Documentation

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

Definition at line 27 of file CScanContainerWidget.cpp.

References mCopyEnabled.

27  :
28  QTableWidget(parent)
29 {
30  if (!name)
31  setObjectName("CScanContainerWidget");
32 
33  horizontalHeader()->setStretchLastSection(true);
34 
35  horizontalHeader()->hide();
36  verticalHeader()->hide();
37 
38  setShowGrid(false);
39 
40  setColumnCount(2);
41  setAutoScroll(true);
42 
43  setSelectionMode(QAbstractItemView::NoSelection);
44 
45  mCopyEnabled = false;
46  //TODO maybe reimplement paintFocus() to make the focus completely invisible
47  // (it is already invisible most of the time)
48 }
CScanContainerWidget::~CScanContainerWidget ( )

Definition at line 50 of file CScanContainerWidget.cpp.

51 {}

Member Function Documentation

void CScanContainerWidget::addWidget ( QWidget *  widget,
bool  controls = true 
)

Definition at line 76 of file CScanContainerWidget.cpp.

References CUpDownSubwidget::enableCopy(), mCopyEnabled, CUpDownSubwidget::setIndex(), slotCopy(), slotDel(), slotDown(), slotUp(), updateIndices(), and updateTable().

Referenced by ScanWidget::loadTask().

77 {
78  setRowCount(rowCount() + 1);
79 
80  int i = rowCount() - 1;
81 
82  if (controls) //add control widget
83  {
84  CUpDownSubwidget * tmpUD = new CUpDownSubwidget(this);
85  tmpUD->setIndex(i, false, true); //assumes...
86  tmpUD->enableCopy(mCopyEnabled);
87  connect(tmpUD, SIGNAL(del(int)), this, SLOT(slotDel(int)));
88  connect(tmpUD, SIGNAL(up(int)), this, SLOT(slotUp(int)));
89  connect(tmpUD, SIGNAL(down(int)), this, SLOT(slotDown(int)));
90  connect(tmpUD, SIGNAL(copy(int)), this, SLOT(slotCopy(int)));
91  setCellWidget(i, 0, tmpUD);
92 
93  //tell the widget above that it is not the last anymore
94  if (i > 0)
95  {
96  CUpDownSubwidget* tmpWidget = dynamic_cast<CUpDownSubwidget*>(cellWidget(i - 1, 0));
97 
98  if (tmpWidget)
99  tmpWidget->setIndex(i - 1, false, false); //assumes...
100  }
101  }
102 
103  setCellWidget(i, 1, widget);
104 
105  updateIndices();
106  updateTable();
107 }
virtual void setIndex(int, bool, bool)
void enableCopy(const bool &)
void CScanContainerWidget::clearWidgetList ( )

Definition at line 71 of file CScanContainerWidget.cpp.

Referenced by ScanWidget::loadTask().

72 {
73  setRowCount(0);
74 }
void CScanContainerWidget::copyWidget ( int  )
signal

Referenced by slotCopy().

void CScanContainerWidget::enableCopy ( const bool &  enable)

Definition at line 219 of file CScanContainerWidget.cpp.

References mCopyEnabled.

220 {mCopyEnabled = enable;}
std::vector< QWidget * > CScanContainerWidget::getWidgetList ( ) const

Definition at line 53 of file CScanContainerWidget.cpp.

Referenced by ScanWidget::saveTask().

54 {
55  std::vector< QWidget * > ret;
56  QWidget* tmpWidget;
57 
58  int i, imax = rowCount();
59 
60  for (i = 0; i < imax; ++i)
61  {
62  tmpWidget = cellWidget(i, 1);
63 
64  if (tmpWidget)
65  ret.push_back(tmpWidget);
66  }
67 
68  return ret;
69 }
void CScanContainerWidget::insertWidget ( QWidget *  widget,
int  row = -1 
)

Definition at line 109 of file CScanContainerWidget.cpp.

References C_INT32, CUpDownSubwidget::enableCopy(), mCopyEnabled, slotCopy(), slotDel(), slotDown(), slotUp(), updateIndices(), and updateTable().

Referenced by ScanWidget::slotAddItem(), and slotDown().

110 {
111  if (row == -1)
112  {
113  if (rowCount() == 0)
114  row = 0;
115  else
116  row = rowCount() - 1;
117  }
118 
119  insertRow(row);
120 
121  unsigned C_INT32 i = row;
122 
123  if (true) //add control widget
124  {
125  CUpDownSubwidget * tmpUD = new CUpDownSubwidget(this);
126  tmpUD->enableCopy(mCopyEnabled);
127 
128  connect(tmpUD, SIGNAL(del(int)), this, SLOT(slotDel(int)));
129  connect(tmpUD, SIGNAL(up(int)), this, SLOT(slotUp(int)));
130  connect(tmpUD, SIGNAL(down(int)), this, SLOT(slotDown(int)));
131  connect(tmpUD, SIGNAL(copy(int)), this, SLOT(slotCopy(int)));
132 
133  setCellWidget(i, 0, tmpUD);
134  }
135 
136  setCellWidget(i, 1, widget);
137 
138  updateIndices();
139  updateTable();
140 }
#define C_INT32
Definition: copasi.h:90
void enableCopy(const bool &)
void CScanContainerWidget::itemDeleted ( )
signal
void CScanContainerWidget::resizeEvent ( QResizeEvent *  event)
protected

Definition at line 222 of file CScanContainerWidget.cpp.

223 {
224  QTableWidget::resizeEvent(e);
225 
226  resizeRowsToContents();
227  resizeColumnsToContents();
228 }
void CScanContainerWidget::slotCopy ( int  index)
protectedslot

Definition at line 187 of file CScanContainerWidget.cpp.

References copyWidget().

Referenced by addWidget(), and insertWidget().

188 {emit copyWidget(index);}
void CScanContainerWidget::slotDel ( int  index)
protectedslot

Definition at line 179 of file CScanContainerWidget.cpp.

References updateIndices(), and updateTable().

Referenced by addWidget(), and insertWidget().

180 {
181  removeRow(index);
182 
183  updateIndices();
184  updateTable();
185 }
void CScanContainerWidget::slotDown ( int  index)
protectedslot

Definition at line 149 of file CScanContainerWidget.cpp.

References insertWidget().

Referenced by addWidget(), insertWidget(), and slotUp().

150 {
151  if (index >= rowCount() - 1) return; //do nothing
152 
153  QWidget * pWidget = cellWidget(index, 1);
154  QWidget * pNewWidget = NULL;
155 
156  if (pWidget->objectName() == "CScanWidgetScan")
157  {
158  static_cast< CScanWidgetScan * >(pWidget)->save(NULL);
159  pNewWidget = new CScanWidgetScan(*static_cast< CScanWidgetScan * >(pWidget), this);
160  }
161  else if (pWidget->objectName() == "CScanWidgetRandom")
162  {
163  static_cast< CScanWidgetRandom * >(pWidget)->save(NULL);
164  pNewWidget = new CScanWidgetRandom(*static_cast< CScanWidgetRandom * >(pWidget), this);
165  }
166  else if (pWidget->objectName() == "CScanWidgetRepeat")
167  {
168  static_cast< CScanWidgetRepeat * >(pWidget)->save(NULL);
169  pNewWidget = new CScanWidgetRepeat(*static_cast< CScanWidgetRepeat * >(pWidget), this);
170  }
171 
172  if (pNewWidget != NULL)
173  {
174  removeRow(index);
175  insertWidget(pNewWidget, index + 1);
176  }
177 }
void insertWidget(QWidget *widget, int row=-1)
void CScanContainerWidget::slotUp ( int  index)
protectedslot

Definition at line 142 of file CScanContainerWidget.cpp.

References slotDown().

Referenced by addWidget(), and insertWidget().

143 {
144  if (index <= 0) return; //do nothing
145 
146  slotDown(index - 1);
147 }
void CScanContainerWidget::updateIndices ( )
protected

Definition at line 190 of file CScanContainerWidget.cpp.

References C_INT32, and CUpDownSubwidget::setIndex().

Referenced by addWidget(), insertWidget(), and slotDel().

191 {
192  //update the indices of the updown widgets
193  CUpDownSubwidget* tmp, *tmp_last, *tmp_next;
194 
195  C_INT32 i, imax = rowCount();
196 
197  for (i = 0; i < imax; ++i)
198  {
199  tmp_last = dynamic_cast<CUpDownSubwidget*>(cellWidget(i - 1, 0));
200  tmp = dynamic_cast<CUpDownSubwidget*>(cellWidget(i, 0));
201  tmp_next = dynamic_cast<CUpDownSubwidget*>(cellWidget(i + 1, 0));
202 
203  if (tmp)
204  {
205  tmp->setIndex(i, (tmp_last == NULL), (tmp_next == NULL));
206  }
207  }
208 }
virtual void setIndex(int, bool, bool)
#define C_INT32
Definition: copasi.h:90
void CScanContainerWidget::updateTable ( )
protected

Definition at line 211 of file CScanContainerWidget.cpp.

Referenced by addWidget(), insertWidget(), and slotDel().

212 {
213  qApp->processEvents();
214 
215  resizeRowsToContents();
216  resizeColumnsToContents();
217 }

Member Data Documentation

bool CScanContainerWidget::mCopyEnabled
protected

Definition at line 58 of file CScanContainerWidget.h.

Referenced by addWidget(), CScanContainerWidget(), enableCopy(), and insertWidget().


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