2022-10-02 19:45:46 +00:00
|
|
|
#include <memory>
|
|
|
|
#include "component_preview_grid_widget.h"
|
|
|
|
#include "component_list_model.h"
|
2022-10-03 00:06:25 +00:00
|
|
|
#include "document.h"
|
2022-10-02 19:45:46 +00:00
|
|
|
|
|
|
|
ComponentPreviewGridWidget::ComponentPreviewGridWidget(const Document *document, QWidget *parent):
|
|
|
|
PreviewGridView(parent),
|
|
|
|
m_document(document)
|
|
|
|
{
|
|
|
|
m_componentListModel = std::make_unique<ComponentListModel>(m_document);
|
|
|
|
setModel(m_componentListModel.get());
|
2022-10-03 00:06:25 +00:00
|
|
|
|
|
|
|
connect(this, &ComponentPreviewGridWidget::doubleClicked, [this](const QModelIndex &index) {
|
|
|
|
const SkeletonComponent *component = this->componentListModel()->modelIndexToComponent(index);
|
|
|
|
if (nullptr != component && !component->childrenIds.empty()) {
|
|
|
|
this->componentListModel()->setListingComponentId(component->id);
|
|
|
|
}
|
|
|
|
});
|
2022-10-02 19:45:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ComponentListModel *ComponentPreviewGridWidget::componentListModel()
|
|
|
|
{
|
|
|
|
return m_componentListModel.get();
|
|
|
|
}
|