void UnplacedComponentsDock::on_btnAdd_clicked() { if (mBoard && mSelectedComponent && mSelectedDevice && mSelectedPackage && (!mSelectedFootprintUuid.isNull())) { addDeviceManually(*mSelectedComponent, mSelectedDevice->getUuid(), mSelectedFootprintUuid); } updateComponentsList(); }
void UnplacedComponentsDock::setBoard(Board* board) { // clean up mBoard = nullptr; disconnect(mBoardConnection1); mBoardConnection1 = QMetaObject::Connection(); disconnect(mBoardConnection2); mBoardConnection2 = QMetaObject::Connection(); updateComponentsList(); // load new board mBoard = board; if (board) { mBoardConnection1 = connect(board, &Board::componentAdded, [this](ComponentInstance& c){Q_UNUSED(c); updateComponentsList();}); mBoardConnection2 = connect(board, &Board::componentRemoved, [this](ComponentInstance& c){Q_UNUSED(c); updateComponentsList();}); mNextPosition = Point::fromMm(0, -20).mappedToGrid(board->getGridProperties().getInterval()); updateComponentsList(); } }
UnplacedComponentsDock::UnplacedComponentsDock(ProjectEditor& editor) : QDockWidget(0), mProjectEditor(editor), mProject(editor.getProject()), mBoard(nullptr), mUi(new Ui::UnplacedComponentsDock), mFootprintPreviewGraphicsView(nullptr), mFootprintPreviewGraphicsScene(nullptr), mSelectedGenComp(nullptr), mSelectedComponent(nullptr), mCircuitConnection1(), mCircuitConnection2(), mBoardConnection1(), mBoardConnection2(), mDisableListUpdate(false) { mUi->setupUi(this); mFootprintPreviewGraphicsScene = new GraphicsScene(); mFootprintPreviewGraphicsView = new GraphicsView(); mFootprintPreviewGraphicsView->setScene(mFootprintPreviewGraphicsScene); mCircuitConnection1 = connect(&mProject.getCircuit(), &Circuit::genCompAdded, [this](GenCompInstance& gc){Q_UNUSED(gc); updateComponentsList();}); mCircuitConnection2 = connect(&mProject.getCircuit(), &Circuit::genCompRemoved, [this](GenCompInstance& gc){Q_UNUSED(gc); updateComponentsList();}); updateComponentsList(); }
void UnplacedComponentsDock::on_pushButton_clicked() { if ((!mBoard) || (!mSelectedComponent) || (!mSelectedDevice) || (!mSelectedPackage) || (mSelectedFootprintUuid.isNull())) return; Uuid componentLibUuid = mSelectedComponent->getLibComponent().getUuid(); Uuid deviceLibUuid = mSelectedDevice->getUuid(); beginUndoCmdGroup(); for (int i = 0; i < mUi->lstUnplacedComponents->count(); i++) { Uuid componentUuid(mUi->lstUnplacedComponents->item(i)->data(Qt::UserRole).toString()); Q_ASSERT(componentUuid.isNull() == false); ComponentInstance* component = mProject.getCircuit().getComponentInstanceByUuid(componentUuid); if (!component) continue; if (component->getLibComponent().getUuid() != componentLibUuid) continue; addNextDeviceToCmdGroup(*component, deviceLibUuid, mSelectedFootprintUuid); } commitUndoCmdGroup(); updateComponentsList(); }
void UnplacedComponentsDock::on_pushButton_clicked() { if ((!mBoard) || (!mSelectedGenComp) || (!mSelectedComponent)) return; QUuid genCompLibUuid = mSelectedGenComp->getGenComp().getUuid(); QUuid compLibUuid = mSelectedComponent->getUuid(); mDisableListUpdate = true; for (int i = 0; i < mUi->lstUnplacedComponents->count(); i++) { QUuid genCompUuid = mUi->lstUnplacedComponents->item(i)->data(Qt::UserRole).toUuid(); Q_ASSERT(genCompUuid.isNull() == false); GenCompInstance* genComp = mProject.getCircuit().getGenCompInstanceByUuid(genCompUuid); if (!genComp) continue; if (genComp->getGenComp().getUuid() != genCompLibUuid) continue; addComponent(*genComp, compLibUuid); } mDisableListUpdate = false; updateComponentsList(); }
void UnplacedComponentsDock::on_btnAddAll_clicked() { if (!mBoard) return; mDisableListUpdate = true; for (int i = 0; i < mUi->lstUnplacedComponents->count(); i++) { QUuid genCompUuid = mUi->lstUnplacedComponents->item(i)->data(Qt::UserRole).toUuid(); Q_ASSERT(genCompUuid.isNull() == false); GenCompInstance* genComp = mProject.getCircuit().getGenCompInstanceByUuid(genCompUuid); if (genComp) { QList<QUuid> components = mProjectEditor.getWorkspace().getLibrary(). getComponentsOfGenericComponent(genComp->getGenComp().getUuid()).toList(); if (components.count() > 0) addComponent(*genComp, components.first()); } } mDisableListUpdate = false; updateComponentsList(); }
void UnplacedComponentsDock::on_btnAddAll_clicked() { if (!mBoard) return; beginUndoCmdGroup(); for (int i = 0; i < mUi->lstUnplacedComponents->count(); i++) { Uuid componentUuid(mUi->lstUnplacedComponents->item(i)->data(Qt::UserRole).toString()); Q_ASSERT(componentUuid.isNull() == false); ComponentInstance* component = mProject.getCircuit().getComponentInstanceByUuid(componentUuid); if (component) { QList<Uuid> devices = mProjectEditor.getWorkspace().getLibrary(). getDevicesOfComponent(component->getLibComponent().getUuid()).toList(); if (devices.count() > 0) addNextDeviceToCmdGroup(*component, devices.first(), Uuid()); } } commitUndoCmdGroup(); updateComponentsList(); }
void UnplacedComponentsDock::on_btnAdd_clicked() { if (mBoard && mSelectedGenComp && mSelectedComponent) addComponent(*mSelectedGenComp, mSelectedComponent->getUuid()); updateComponentsList(); }