1 #include "BlocksToConfigureWidget.h"
2 #include <QTreeWidgetItem>
3 #include "ParametersWindow.h"
6 BlocksToConfigureWidget::BlocksToConfigureWidget(QList<AbstractBlock *> blocksList, Parameters *_params, QWidget *parent) :
11 layout = new QGridLayout;
12 tree = new QTreeWidget(this);
13 configureButton = new QPushButton("configure", this);
14 configureButton->setEnabled(false);
16 connect(tree, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(clicked()));
17 connect(tree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(doubleClicked()));
18 connect(configureButton, SIGNAL(clicked()), this, SLOT(configure()));
21 tree->setHeaderLabel("blocks to configure");
22 layout->addWidget(tree);
23 layout->addWidget(configureButton);
25 this->setLayout(layout);
26 this->setFixedSize(300,230);
29 void BlocksToConfigureWidget::updateNamesList()
32 QTreeWidgetItem *item = NULL;
33 foreach(AbstractBlock *block, blocks){
34 item = new QTreeWidgetItem(tree->invisibleRootItem());
35 item->setData(0, Qt::DisplayRole, block->getName());
40 void BlocksToConfigureWidget::updateBlocksList()
42 blocks = params->getBlocksToConfigure();
46 void BlocksToConfigureWidget::closeEvent(QCloseEvent *event)
48 //when parameters validation is over,
49 //we start connections validation.
50 params->connectionsValidation();
53 void BlocksToConfigureWidget::clicked()
55 if(tree->selectedItems().length() > 0)
56 configureButton->setEnabled(true);
58 configureButton->setEnabled(false);
61 void BlocksToConfigureWidget::doubleClicked()
66 void BlocksToConfigureWidget::configure()
68 if(tree->selectedItems().length() > 0){
69 bool firstItem = true; // We take only the first selected item
70 for (int i=0; i<tree->topLevelItemCount(); i++){
71 if(firstItem && tree->topLevelItem(i)->isSelected()){
73 new ParametersWindow(blocks.at(i), params, this);