37 lines
807 B
C++
37 lines
807 B
C++
|
#include "hierarchy.h"
|
||
|
|
||
|
#include <QVBoxLayout>
|
||
|
|
||
|
#include "context.h"
|
||
|
#include "ecs.h"
|
||
|
#include "worldmanager.h"
|
||
|
|
||
|
Hierarchy::Hierarchy(Context& context, QWidget* parent) : QWidget(parent), context(context) {
|
||
|
setWindowTitle("Hierarchy");
|
||
|
|
||
|
QVBoxLayout* layout = new QVBoxLayout();
|
||
|
setLayout(layout);
|
||
|
|
||
|
listView = new QListView();
|
||
|
layout->addWidget(listView);
|
||
|
|
||
|
listModel = new QStringListModel();
|
||
|
listView->setModel(listModel);
|
||
|
|
||
|
rebuild();
|
||
|
}
|
||
|
|
||
|
void Hierarchy::rebuild() {
|
||
|
const auto entities = ECS::getWorldEntities(worldManager.getCurrentWorld());
|
||
|
|
||
|
QStringList list;
|
||
|
|
||
|
for(auto entity : entities) {
|
||
|
const auto info = ECS::getComponent<InfoComponent>(entity);
|
||
|
if(info)
|
||
|
list << info->name.c_str();
|
||
|
}
|
||
|
|
||
|
listModel->setStringList(list);
|
||
|
}
|