35 #include <QItemSelectionModel>
37 #include <QInputDialog>
38 #include <QHeaderView>
46 using namespace YACS::HMI;
47 using namespace YACS::ENGINE;
62 QComboBox::hidePopup();
69 QComboBox::showPopup();
78 #ifndef QT_NO_WHEELEVENT
88 DEBTRACE(
"TablePortsEdition::TablePortsEdition");
93 if (tv_ports->horizontalHeader())
94 tv_ports->horizontalHeader()->setStretchLastSection(
true);
98 gridLayout1->addWidget(cb_insert, 0, 4, 1, 1);
99 cb_insert->setToolTip(
"port creation: select a port type");
101 connect(cb_insert, SIGNAL(popupHide()),
103 connect(cb_insert, SIGNAL(popupShow()),
106 connect(cb_insert, SIGNAL(activated(
const QString&)),
112 DEBTRACE(
"TablePortsEdition::~TablePortsEdition");
122 DEBTRACE(
"TablePortsEdition::on_pb_up_clicked");
129 DEBTRACE(
"TablePortsEdition::on_pb_down_clicked");
143 QModelIndexList items = tv_ports->selectionModel()->selection().indexes();
145 if (!items.isEmpty()) index = items.first();
169 QItemSelectionModel *selectionModel = tv_ports->selectionModel();
171 QItemSelection selection(topLeft, topLeft);
172 selectionModel->select(selection, QItemSelectionModel::Select);
178 DEBTRACE(
"TablePortsEdition::on_pb_insert_clicked");
183 QModelIndexList items = tv_ports->selectionModel()->selection().indexes();
185 if (!items.isEmpty()) index = items.first();
193 DataPort *port = spBefore->getPort();
195 bool isInput =
false;
196 if (dynamic_cast<SubjectInputPort*>(spBefore))
208 list<InputPort*>::iterator pos = plist.begin();
209 for (; (*pos) != port; pos++)
211 _nbUp = plist.size() -rang;
217 list<OutputPort*>::iterator pos = plist.begin();
218 for (; (*pos) != port; pos++)
220 _nbUp = plist.size() -rang;
224 cb_insert->showPopup();
229 DEBTRACE(
"TablePortsEdition::oncb_insert_activated " << text.toStdString());
231 QModelIndexList items = tv_ports->selectionModel()->selection().indexes();
233 if (!items.isEmpty()) index = items.first();
241 string portType = text.toStdString();
242 QStringList defaultTypes;
243 defaultTypes <<
"Int" <<
"Double" <<
"String" <<
"Bool";
244 if (defaultTypes.contains(text))
245 portType = text.toLower().toStdString();
266 DEBTRACE(
"TablePortsEdition::on_pb_remove_clicked");
269 QModelIndexList items = tv_ports->selectionModel()->selection().indexes();
271 if (!items.isEmpty()) index = items.first();
288 DEBTRACE(
"TablePortsEdition::adjustColumns");
289 if (!tv_ports->isColumnHidden(
YLabel))
290 tv_ports->resizeColumnToContents(
YLabel);
291 if (!tv_ports->isColumnHidden(
YType))
292 tv_ports->resizeColumnToContents(
YType);
298 DEBTRACE(
"TablePortsEdition::setEditablePorts " << isEditable);
301 tv_ports->setColumnHidden(
YType,
false);
302 tv_ports->setColumnHidden(
YValue,
false);
307 tv_ports->setColumnHidden(
YType,
true);
308 tv_ports->setColumnHidden(
YState,
false);
311 if (tv_ports->verticalHeader())
312 tv_ports->verticalHeader()->setVisible(
false);
315 pb_up->setEnabled(isEditable);
316 pb_down->setEnabled(isEditable);
317 pb_insert->setEnabled(isEditable);
318 pb_remove->setEnabled(isEditable);
319 cb_insert->setEnabled(isEditable);
340 DEBTRACE(
"TablePortsEdition::oncb_insert_popupHide");
341 if (cb_insert->currentIndex() < 0)
348 DEBTRACE(
"TablePortsEdition::oncb_insert_popupShow");