16 #include "graphlistconnector.h"
19 #include <QPushButton>
20 #include <QTableWidget>
21 #include <QApplication>
28 XGraphListConnector::XGraphListConnector(
const shared_ptr<XGraphList> &node, QTableWidget *item,
29 QPushButton *btnnew, QPushButton *btndelete) :
38 QApplication::style()->standardIcon(QStyle::SP_FileDialogStart));
40 QApplication::style()->standardIcon(QStyle::SP_DialogCloseButton));
42 connect(item, SIGNAL( cellClicked(
int,
int)),
43 this, SLOT(cellClicked(
int,
int)) );
44 m_pItem->setColumnCount(4);
45 const double def = 50;
46 m_pItem->setColumnWidth(0, (
int)(def * 2.0));
47 m_pItem->setColumnWidth(1, (
int)(def * 2.0));
48 m_pItem->setColumnWidth(2, (
int)(def * 2.0));
49 m_pItem->setColumnWidth(3, (
int)(def * 2.0));
51 labels += i18n(
"Name");
52 labels += i18n(
"Axis X");
53 labels += i18n(
"Axis Y");
54 labels += i18n(
"Axis Z");
55 m_pItem->setHorizontalHeaderLabels(labels);
59 for(
int idx = 0; idx < shot.size(); ++idx) {
61 e.emitter = node.get();
62 e.caught = shot.list()->at(idx);
69 m_lsnNewGraph = tr[ *m_newGraph].onTouch().connectWeakly(
70 shared_from_this(), &XGraphListConnector::onNewGraph, XListener::FLAG_MAIN_THREAD_CALL);
73 m_lsnDeleteGraph = tr[ *m_deleteGraph].onTouch().connectWeakly(
74 shared_from_this(), &XGraphListConnector::onDeleteGraph, XListener::FLAG_MAIN_THREAD_CALL);
80 static int graphidx = 1;
81 m_graphlist->createByTypename(
"", formatString(
"Graph-%d", graphidx++));
85 int n = m_pItem->currentRow();
87 if(shot_this.size()) {
88 if((n >= 0) && (n < (int)shot_this.list()->size())) {
89 shared_ptr<XNode> node = shot_this.list()->at(n);
90 m_graphlist->release(node);
95 XGraphListConnector::cellClicked (
int row,
int col) {
100 if((row >= 0) && (row < (int)shot.list()->size())) {
101 dynamic_pointer_cast<
XValGraph>(shot.list()->at(row))->showGraph();
112 for(
auto it = m_cons.begin(); it != m_cons.end();) {
113 if(it->node == e.released) {
114 for(
int i = 0; i < m_pItem->rowCount(); i++) {
115 if(m_pItem->cellWidget(i, 1) == it->widget) m_pItem->removeRow(i);
117 it = m_cons.erase(it);
126 shared_ptr<XValGraph> graph = static_pointer_cast<
XValGraph>(e.caught);
127 int i = m_pItem->rowCount();
128 m_pItem->insertRow(i);
129 m_pItem->setItem(i, 0,
new QTableWidgetItem(graph->getLabel().c_str()));
131 Snapshot shot_entries( *m_graphlist->entries());
134 QComboBox *cmbX =
new QComboBox(m_pItem);
135 con.conx = xqcon_create<XQComboBoxConnector>(graph->axisX(), cmbX, shot_entries);
136 m_pItem->setCellWidget(i, 1, cmbX);
137 QComboBox *cmbY1 =
new QComboBox(m_pItem);
138 con.cony1 = xqcon_create<XQComboBoxConnector>(graph->axisY1(), cmbY1, shot_entries);
139 m_pItem->setCellWidget(i, 2, cmbY1);
140 QComboBox *cmbZ =
new QComboBox(m_pItem);
141 con.conz = xqcon_create<XQComboBoxConnector>(graph->axisZ(), cmbZ, shot_entries);
142 m_pItem->setCellWidget(i, 3, cmbZ);
144 con.widget = m_pItem->cellWidget(i, 1);
145 m_cons.push_back(con);