14 #include "entrylistconnector.h"
18 #include <QPushButton>
20 #include <QTableWidget>
21 #include <QDoubleSpinBox>
25 XEntryListConnector::XEntryListConnector
26 (
const shared_ptr<XScalarEntryList> &node, QTableWidget *item,
const shared_ptr<XChartList> &chartlist)
28 m_chartList(chartlist) {
29 connect(item, SIGNAL( cellClicked(
int,
int)),
30 this, SLOT(cellClicked(
int,
int)) );
31 m_pItem->setColumnCount(4);
32 const double def = 50;
33 m_pItem->setColumnWidth(0, (
int)(def * 2.5));
34 m_pItem->setColumnWidth(1, (
int)(def * 2.0));
35 m_pItem->setColumnWidth(2, (
int)(def * 0.8));
36 m_pItem->setColumnWidth(3, (
int)(def * 2.5));
38 labels += i18n(
"Entry");
39 labels += i18n(
"Value");
40 labels += i18n(
"Store");
41 labels += i18n(
"Delta");
42 m_pItem->setHorizontalHeaderLabels(labels);
46 for(
int idx = 0; idx < shot.size(); ++idx) {
48 e.emitter = node.get();
49 e.caught = shot.list()->at(idx);
57 for(tconslist::iterator it = m_cons.begin(); it != m_cons.end(); it++) {
58 if(( *it)->entry->driver().get() == driver) {
59 ( *it)->label->setText(shot[ *( *it)->entry->value()].to_str());
65 XEntryListConnector::cellClicked (
int row,
int col) {
71 if((row >= 0) && (row < (int)shot.list()->size())) {
72 dynamic_pointer_cast<
XValChart>(shot.list()->at(row))->showChart();
83 for(tconslist::iterator it = m_cons.begin(); it != m_cons.end();) {
84 assert(m_pItem->rowCount() == (int)m_cons.size());
85 if(( *it)->entry == e.released) {
86 for(
int i = 0; i < m_pItem->rowCount(); i++) {
87 if(m_pItem->cellWidget(i, 1) == ( *it)->label) m_pItem->removeRow(i);
89 it = m_cons.erase(it);
98 shared_ptr<XScalarEntry> entry = static_pointer_cast<
XScalarEntry>(e.caught);
99 int i = m_pItem->rowCount();
100 m_pItem->insertRow(i);
101 m_pItem->setItem(i, 0,
new QTableWidgetItem(entry->getLabel().c_str()));
103 shared_ptr<XDriver> driver = entry->driver();
105 m_cons.push_back(std::make_shared<tcons>());
106 m_cons.back()->entry = entry;
107 m_cons.back()->label =
new QLabel(m_pItem);
108 m_pItem->setCellWidget(i, 1, m_cons.back()->label);
109 QCheckBox *ckbStore =
new QCheckBox(m_pItem);
110 m_cons.back()->constore = xqcon_create<XQToggleButtonConnector>(entry->store(), ckbStore);
111 m_pItem->setCellWidget(i, 2, ckbStore);
112 QDoubleSpinBox *numDelta =
new QDoubleSpinBox(m_pItem);
113 numDelta->setRange(-1, 1e4);
114 numDelta->setSingleStep(1);
115 numDelta->setValue(0);
116 numDelta->setDecimals(5);
117 m_cons.back()->condelta = xqcon_create<XQDoubleSpinBoxConnector>(entry->delta(), numDelta);
118 m_pItem->setCellWidget(i, 3, numDelta);
119 m_cons.back()->driver = driver;
121 m_cons.back()->lsnOnRecord = tr[ *driver].onRecord().connectWeakly(
122 shared_from_this(), &XEntryListConnector::onRecord,
123 XListener::FLAG_MAIN_THREAD_CALL | XListener::FLAG_AVOID_DUP | XListener::FLAG_DELAY_ADAPTIVE);
126 assert(m_pItem->rowCount() == (int)m_cons.size());