| 507 | } |
| 508 | |
| 509 | void |
| 510 | MultiInstancePanel::createMultiInstanceGui(QVBoxLayout* layout) |
| 511 | { |
| 512 | appendExtraGui(layout); |
| 513 | layout->addSpacing(20); |
| 514 | |
| 515 | std::list<KnobIPtr> instanceSpecificKnobs; |
| 516 | _imp->getInstanceSpecificKnobs(_imp->getMainInstance().get(), &instanceSpecificKnobs); |
| 517 | |
| 518 | _imp->view = new TableView( layout->parentWidget() ); |
| 519 | QObject::connect( _imp->view, SIGNAL(deleteKeyPressed()), this, SLOT(onDeleteKeyPressed()) ); |
| 520 | QObject::connect( _imp->view, SIGNAL(itemRightClicked(TableItem*)), this, SLOT(onItemRightClicked(TableItem*)) ); |
| 521 | TableItemDelegate* delegate = new TableItemDelegate(_imp->view, this); |
| 522 | _imp->view->setItemDelegate(delegate); |
| 523 | |
| 524 | _imp->model = new TableModel(0, 0, _imp->view); |
| 525 | QObject::connect( _imp->model, SIGNAL(s_itemChanged(TableItem*)), this, SLOT(onItemDataChanged(TableItem*)) ); |
| 526 | _imp->view->setTableModel(_imp->model); |
| 527 | |
| 528 | QItemSelectionModel *selectionModel = _imp->view->selectionModel(); |
| 529 | QObject::connect( selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, |
| 530 | SLOT(onSelectionChanged(QItemSelection,QItemSelection)) ); |
| 531 | QStringList dimensionNames; |
| 532 | for (std::list<KnobIPtr>::iterator it = instanceSpecificKnobs.begin(); it != instanceSpecificKnobs.end(); ++it) { |
| 533 | QString knobDesc( QString::fromUtf8( (*it)->getLabel().c_str() ) ); |
| 534 | int dims = (*it)->getDimension(); |
| 535 | for (int i = 0; i < dims; ++i) { |
| 536 | QString dimName(knobDesc); |
| 537 | if (dims > 1) { |
| 538 | dimName += QLatin1Char(' '); |
| 539 | dimName += QString::fromUtf8( (*it)->getDimensionName(i).c_str() ); |
| 540 | } |
| 541 | dimensionNames.push_back(dimName); |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | dimensionNames.prepend( QString::fromUtf8("Script-name") ); |
| 546 | dimensionNames.prepend( QString::fromUtf8("Enabled") ); |
| 547 | |
| 548 | _imp->view->setColumnCount( dimensionNames.size() ); |
| 549 | _imp->view->setHorizontalHeaderLabels(dimensionNames); |
| 550 | |
| 551 | _imp->view->setAttribute(Qt::WA_MacShowFocusRect, 0); |
| 552 | _imp->view->setUniformRowHeights(true); |
| 553 | |
| 554 | #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
| 555 | _imp->view->header()->setResizeMode(QHeaderView::ResizeToContents); |
| 556 | #else |
| 557 | _imp->view->header()->setSectionResizeMode(QHeaderView::ResizeToContents); |
| 558 | #endif |
| 559 | _imp->view->header()->setStretchLastSection(true); |
| 560 | |
| 561 | |
| 562 | layout->addWidget(_imp->view); |
| 563 | |
| 564 | _imp->buttonsContainer = new QWidget( layout->parentWidget() ); |
| 565 | _imp->buttonsLayout = new QHBoxLayout(_imp->buttonsContainer); |
| 566 | _imp->buttonsLayout->setContentsMargins(0, 0, 0, 0); |
no test coverage detected