| 36 | } |
| 37 | |
| 38 | void ComponentsView::setFile(int fileId) |
| 39 | { |
| 40 | setModel(new ComponentsModel(fileId, this)); |
| 41 | expandAll(); |
| 42 | |
| 43 | connect(selectionModel(), &QItemSelectionModel::selectionChanged, [this](const QItemSelection& selected, const QItemSelection& deselected) { |
| 44 | qDebug() << selected.size() << deselected.size(); |
| 45 | static QColor color; |
| 46 | if (!selected.indexes().empty()) { |
| 47 | auto node = reinterpret_cast<ComponentsNode*>(selected.indexes().front().internalPointer()); |
| 48 | if (node->item) { |
| 49 | color = node->item->brush().color(); |
| 50 | node->item->setBrush(Qt::white); |
| 51 | item = node->component.componentitem(); |
| 52 | item->setSelected(true); |
| 53 | App::graphicsView()->fitInView(node->item->boundingRect()); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | if (!deselected.indexes().empty()) { |
| 58 | auto node = reinterpret_cast<ComponentsNode*>(deselected.indexes().front().internalPointer()); |
| 59 | if (node->item) { |
| 60 | node->item->setBrush(color); |
| 61 | node->component.componentitem()->setSelected(false); |
| 62 | } |
| 63 | } |
| 64 | }); |
| 65 | } |
| 66 | |
| 67 | void ComponentsView::selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) |
| 68 | { |
no test coverage detected