2022-04-07 22:21:23 +00:00
|
|
|
#include "library_display.h"
|
|
|
|
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QListWidget>
|
|
|
|
#include <QVBoxLayout>
|
2022-06-01 23:37:14 +00:00
|
|
|
#include <application.h>
|
2022-04-07 22:21:23 +00:00
|
|
|
|
|
|
|
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-06-09 18:24:27 +00:00
|
|
|
layout->setContentsMargins(4, 4, 4, 4);
|
|
|
|
layout->addWidget(new QLabel("Komponente:"));
|
2022-05-27 06:18:17 +00:00
|
|
|
layout->addWidget(componentList, 1);
|
|
|
|
layout->addSpacing(8);
|
2022-06-09 18:24:27 +00:00
|
|
|
layout->addWidget(new QLabel("Sabirnice:"));
|
2022-05-27 06:18:17 +00:00
|
|
|
layout->addWidget(busList, 1);
|
|
|
|
}
|
2022-04-07 22:21:23 +00:00
|
|
|
|
2022-06-01 23:37:14 +00:00
|
|
|
void Library::refreshContent() {
|
|
|
|
library = Application::instance()->getLibrary();
|
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
|