2022-04-07 22:21:23 +00:00
|
|
|
#include "library_display.h"
|
2022-06-19 18:10:44 +00:00
|
|
|
#include "message_source.h"
|
2022-04-07 22:21:23 +00:00
|
|
|
|
|
|
|
#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);
|
2022-06-19 18:10:44 +00:00
|
|
|
|
|
|
|
componentsLabel = new QLabel(QMESSAGE("msg_sidebar_components"));
|
|
|
|
busLabel = new QLabel(QMESSAGE("msg_sidebar_busses"));
|
|
|
|
|
|
|
|
layout->addWidget(componentsLabel);
|
2022-05-27 06:18:17 +00:00
|
|
|
layout->addWidget(componentList, 1);
|
|
|
|
layout->addSpacing(8);
|
2022-06-19 18:10:44 +00:00
|
|
|
layout->addWidget(busLabel);
|
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-06-19 18:10:44 +00:00
|
|
|
componentsLabel->setText(QMESSAGE("msg_sidebar_components"));
|
|
|
|
busLabel->setText(QMESSAGE("msg_sidebar_busses"));
|
|
|
|
|
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()) {
|
2022-06-14 19:27:40 +00:00
|
|
|
auto item = new LibraryListItem{component.getDisplayName(), "comdel/component", component.getName(),
|
2022-05-27 06:18:17 +00:00
|
|
|
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) {
|
2022-06-14 19:27:40 +00:00
|
|
|
auto item = new LibraryListItem{bus.getDisplayName(), "comdel/bus", bus.getName(), busList};
|
2022-05-27 06:18:17 +00:00
|
|
|
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
|