| 473 | } |
| 474 | |
| 475 | void ParamEditor::load(Param & param) |
| 476 | { |
| 477 | param_ = ¶m; |
| 478 | |
| 479 | tree_->clear(); |
| 480 | |
| 481 | QTreeWidgetItem * parent = tree_->invisibleRootItem(); |
| 482 | QTreeWidgetItem * item = nullptr; |
| 483 | |
| 484 | bool has_advanced_item = false; // will be true if @p param has any advanced items; if still false, we disable the 'show advanced checkbox' |
| 485 | |
| 486 | for (Param::ParamIterator it = param.begin(); it != param.end(); ++it) |
| 487 | { |
| 488 | //********handle opened/closed nodes******** |
| 489 | const std::vector<Param::ParamIterator::TraceInfo> & trace = it.getTrace(); |
| 490 | for (const Param::ParamIterator::TraceInfo& par : trace) |
| 491 | { |
| 492 | if (par.opened) //opened node |
| 493 | { |
| 494 | item = new QTreeWidgetItem(parent); |
| 495 | //name |
| 496 | item->setText(0, String(par.name).toQString()); |
| 497 | item->setForeground(0, Qt::darkGray); // color of nodes with children |
| 498 | |
| 499 | //description |
| 500 | item->setData(1, Qt::UserRole, String(par.description).toQString()); |
| 501 | //role |
| 502 | item->setData(0, Qt::UserRole, NODE); |
| 503 | //flags |
| 504 | if (param_ != nullptr) |
| 505 | { |
| 506 | item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); |
| 507 | } |
| 508 | else |
| 509 | { |
| 510 | item->setFlags(Qt::ItemIsEnabled); |
| 511 | } |
| 512 | parent = item; |
| 513 | } |
| 514 | else //closed node |
| 515 | { |
| 516 | parent = parent->parent(); |
| 517 | if (parent == nullptr) |
| 518 | { |
| 519 | parent = tree_->invisibleRootItem(); |
| 520 | } |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | //********handle item******** |
| 525 | item = new QTreeWidgetItem(parent); |
| 526 | |
| 527 | // grey out non-editable columns (leaf nodes) |
| 528 | bool is_required = it->tags.find("required") != it->tags.end(); |
| 529 | if (is_required) // special color for required parameters |
| 530 | { |
| 531 | item->setForeground(0, QColor(255, 140, 0, 255)); // orange |
| 532 | item->setForeground(2, QColor(255, 140, 0, 255)); |
no test coverage detected