X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/abbc64cf04a35ab3549d5c516f44c7c5921baa63..48f48e6a26a54751ecd0ab90b10ab972cc5e89cd:/BlockLibraryWidget.cpp diff --git a/BlockLibraryWidget.cpp b/BlockLibraryWidget.cpp index 0aa9ed1..544a1d1 100644 --- a/BlockLibraryWidget.cpp +++ b/BlockLibraryWidget.cpp @@ -10,10 +10,16 @@ BlockLibraryWidget::BlockLibraryWidget(Dispatcher* _dispatcher, params = _params; // creating the widget : tree, buttons, ... - layout = new QBoxLayout(QBoxLayout::TopToBottom, this); + QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom, this); tree = new QTreeWidget(this); - buttonAdd = new QPushButton("add", this); + + buttonAdd = new QPushButton("add to", this); buttonAdd->setEnabled(false); + comboScenes = new QComboBox(); + + QHBoxLayout* layBottom = new QHBoxLayout; + layBottom->addWidget(buttonAdd); + layBottom->addWidget(comboScenes); connect(tree, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(clicked())); connect(tree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(doubleClicked())); @@ -24,11 +30,10 @@ BlockLibraryWidget::BlockLibraryWidget(Dispatcher* _dispatcher, QTreeWidgetItem* item = tree->invisibleRootItem(); tree->setHeaderLabel("Blocks list"); - addChild(cat,item); layout->addWidget(tree); - layout->addWidget(buttonAdd); + layout->addLayout(layBottom); this->setLayout(layout); this->setFixedSize(300,230); @@ -81,7 +86,9 @@ void BlockLibraryWidget::addClicked() { if(item->data(1,Qt::DisplayRole).isValid() && item->data(2,Qt::DisplayRole).isValid()){ int idParent = item->data(1,Qt::DisplayRole).toInt(); int idBlock = item->data(2,Qt::DisplayRole).toInt(); - dispatcher->addBlock(idParent, idBlock); + QVariant v = comboScenes->currentData(); + cout << "adding block to scene " << v.toInt() << endl; + dispatcher->addBlock(idParent, idBlock, v.toInt()); } // only take the first selected @@ -89,9 +96,7 @@ void BlockLibraryWidget::addClicked() { // calling dispatcher addBlock() method. } - -void BlockLibraryWidget::clicked() -{ +void BlockLibraryWidget::clicked() { if(tree->selectedItems().length() > 0){ QTreeWidgetItem *item = tree->selectedItems().at(0); if(item->data(1,Qt::DisplayRole).isValid()) @@ -101,7 +106,16 @@ void BlockLibraryWidget::clicked() } } -void BlockLibraryWidget::doubleClicked() -{ +void BlockLibraryWidget::doubleClicked() { addClicked(); } + +void BlockLibraryWidget::updateComboScene() { + comboScenes->clear(); + QMap list = dispatcher->getAllGroupNames(); + QMapIterator iter(list); + while (iter.hasNext()) { + iter.next(); + comboScenes->addItem(iter.value(),QVariant(iter.key())); + } +}