#include "library_display.h" #include #include #include #include namespace display { Library::Library() { auto layout = new QVBoxLayout(); this->setLayout(layout); componentList = new LibraryList(this); busList = new LibraryList(this); layout->setContentsMargins(4, 4, 4, 4); layout->addWidget(new QLabel("Komponente:")); layout->addWidget(componentList, 1); layout->addSpacing(8); layout->addWidget(new QLabel("Sabirnice:")); layout->addWidget(busList, 1); } void Library::refreshContent() { library = Application::instance()->getLibrary(); componentList->clear(); busList->clear(); if (!library) { return; } for (auto &component: library->getComponents()) { auto item = new LibraryListItem{component.getName(), "comdel/component", component.getName(), componentList}; item->setToolTip(QString::fromStdString(component.getTooltip())); componentList->addItem(item); } for (auto &bus: library->getBuses()) { if (bus.getType() == domain::Bus::REGULAR) { auto item = new LibraryListItem{bus.getName(), "comdel/bus", bus.getName(), busList}; item->setToolTip(QString::fromStdString(bus.getTooltip())); busList->addItem(item); } } } } // namespace display