2022-04-07 22:21:23 +00:00
|
|
|
#include "library_display.h"
|
|
|
|
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QListWidget>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
namespace display {
|
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
Library::Library() {
|
|
|
|
auto layout = new QVBoxLayout();
|
|
|
|
this->setLayout(layout);
|
2022-04-07 22:21:23 +00:00
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
componentList = new LibraryList(this);
|
|
|
|
busList = new LibraryList(this);
|
2022-04-07 22:21:23 +00:00
|
|
|
|
2022-05-27 06:18:17 +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);
|
2022-04-07 22:21:23 +00:00
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
setLibrary(library);
|
|
|
|
}
|
2022-04-07 22:21:23 +00:00
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
void Library::setLibrary(std::optional<domain::Library> library) {
|
2022-04-07 22:21:23 +00:00
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
componentList->clear();
|
|
|
|
busList->clear();
|
2022-04-07 22:21:23 +00:00
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
if (!library) {
|
|
|
|
return;
|
|
|
|
}
|
2022-04-07 22:21:23 +00:00
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
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);
|
|
|
|
}
|
2022-04-07 22:21:23 +00:00
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
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);
|
|
|
|
}
|
2022-04-07 22:21:23 +00:00
|
|
|
}
|
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
}
|
2022-04-07 22:21:23 +00:00
|
|
|
|
|
|
|
} // namespace display
|