2022-04-07 22:21:23 +00:00
|
|
|
#include "library_display.h"
|
|
|
|
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QListWidget>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
namespace display {
|
|
|
|
|
|
|
|
Library::Library()
|
|
|
|
{
|
|
|
|
auto layout = new QVBoxLayout();
|
|
|
|
this->setLayout(layout);
|
|
|
|
|
2022-05-23 06:48:13 +00:00
|
|
|
componentList = new LibraryList(this);
|
|
|
|
busList = new LibraryList(this);
|
2022-04-07 22:21:23 +00:00
|
|
|
|
|
|
|
layout->setMargin(4);
|
|
|
|
layout->addWidget(new QLabel("Components:"));
|
|
|
|
layout->addWidget(componentList, 1);
|
|
|
|
layout->addSpacing(8);
|
|
|
|
layout->addWidget(new QLabel("Buses:"));
|
|
|
|
layout->addWidget(busList, 1);
|
|
|
|
|
|
|
|
setLibrary(library);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Library::setLibrary(std::optional<domain::Library> library) {
|
|
|
|
|
|
|
|
componentList->clear();
|
|
|
|
busList->clear();
|
|
|
|
|
|
|
|
if(!library) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(auto& component: library->getComponents()) {
|
2022-05-23 06:48:13 +00:00
|
|
|
auto item = new LibraryListItem{component.getName(), "comdel/component", component.getName(), componentList};
|
2022-04-07 22:21:23 +00:00
|
|
|
item->setToolTip(QString::fromStdString(component.getTooltip()));
|
|
|
|
componentList->addItem(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(auto& bus: library->getBuses()) {
|
|
|
|
if(bus.getType() == domain::Bus::REGULAR) {
|
2022-05-23 06:48:13 +00:00
|
|
|
auto item = new LibraryListItem{bus.getName(), "comdel/bus", bus.getName(), busList};
|
2022-04-07 22:21:23 +00:00
|
|
|
item->setToolTip(QString::fromStdString(bus.getTooltip()));
|
|
|
|
busList->addItem(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace display
|