61 lines
1.8 KiB
C++
61 lines
1.8 KiB
C++
#include "library_display.h"
|
|
#include "message_source.h"
|
|
|
|
#include <QLabel>
|
|
#include <QListWidget>
|
|
#include <QVBoxLayout>
|
|
#include <application.h>
|
|
|
|
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);
|
|
|
|
componentsLabel = new QLabel(QMESSAGE("msg_sidebar_components"));
|
|
busLabel = new QLabel(QMESSAGE("msg_sidebar_busses"));
|
|
|
|
layout->addWidget(componentsLabel);
|
|
layout->addWidget(componentList, 1);
|
|
layout->addSpacing(8);
|
|
layout->addWidget(busLabel);
|
|
layout->addWidget(busList, 1);
|
|
}
|
|
|
|
void Library::refreshContent() {
|
|
library = Application::instance()->getLibrary();
|
|
|
|
componentsLabel->setText(QMESSAGE("msg_sidebar_components"));
|
|
busLabel->setText(QMESSAGE("msg_sidebar_busses"));
|
|
|
|
componentList->clear();
|
|
busList->clear();
|
|
|
|
if (!library) {
|
|
return;
|
|
}
|
|
|
|
for (auto &component: library->getComponents()) {
|
|
auto item = new LibraryListItem{component.getDisplayName(), "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.getDisplayName(), "comdel/bus", bus.getName(), busList};
|
|
item->setToolTip(QString::fromStdString(bus.getTooltip()));
|
|
busList->addItem(item);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
} // namespace display
|