1 #include "channelform.h"
6 ChannelForm::ChannelForm(const int index
, QWidget
*parent
) : ConfigTaskWidget(parent
), m_index(index
)
9 ChannelForm::~ChannelForm()
12 int ChannelForm::index() const
17 void ChannelForm::moveTo(QGridLayout
&dstLayout
)
19 QGridLayout
*srcLayout
= dynamic_cast<QGridLayout
*>(layout());
23 // if we are the first row to be inserted then show the legend
24 bool showLegend
= (dstLayout
.rowCount() == 1);
27 // move legend row to target grid layout
28 moveRow(0, *srcLayout
, dstLayout
);
30 removeRow(0, *srcLayout
);
33 // move field row to target grid layout
34 moveRow(1, *srcLayout
, dstLayout
);
36 // this form is now empty so hide it
40 void ChannelForm::moveRow(int row
, QGridLayout
&srcLayout
, QGridLayout
&dstLayout
)
42 int dstRow
= dstLayout
.rowCount();
44 for (int col
= 0; col
< srcLayout
.columnCount(); col
++) {
45 QLayoutItem
*item
= srcLayout
.itemAtPosition(row
, col
);
49 QWidget
*widget
= item
->widget();
51 dstLayout
.addWidget(widget
, dstRow
, col
);
54 // TODO handle item of type QLayout
58 void ChannelForm::removeRow(int row
, QGridLayout
&layout
)
60 for (int col
= 0; col
< layout
.columnCount(); col
++) {
61 QLayoutItem
*item
= layout
.itemAtPosition(row
, col
);
65 QWidget
*widget
= item
->widget();
67 layout
.removeWidget(widget
);
71 // TODO handle item of type QLayout