Connect TreeWidget when scene is updated.

This commit is contained in:
Shaun Reed 2023-03-11 11:21:26 -05:00
parent 0659df94bd
commit e6bcd131b7
3 changed files with 9 additions and 3 deletions

View File

@ -76,5 +76,5 @@ Qtk::QtkWidget * MainWindow::getQtkWidget(const QString & name) {
void MainWindow::refreshScene(QString sceneName) { void MainWindow::refreshScene(QString sceneName) {
// TODO: Select TreeView using sceneName> // TODO: Select TreeView using sceneName>
ui_->qtk__TreeView->updateView(getQtkWidget(sceneName)->getScene()); ui_->qtk__TreeView->updateView(getQtkWidget()->getScene());
} }

View File

@ -108,7 +108,13 @@ void QtkWidget::paintGL() {
} }
void QtkWidget::setScene(Qtk::Scene * scene) { void QtkWidget::setScene(Qtk::Scene * scene) {
if (mScene != Q_NULLPTR) {
delete mScene; delete mScene;
connect(
scene, &Qtk::Scene::sceneUpdated, MainWindow::getMainWindow(),
&MainWindow::refreshScene);
}
mScene = scene; mScene = scene;
if(mScene != Q_NULLPTR) { if(mScene != Q_NULLPTR) {
mConsole->setTitle(mScene->getSceneName()); mConsole->setTitle(mScene->getSceneName());

View File

@ -45,7 +45,7 @@ void Qtk::TreeView::updateView(const Qtk::Scene * scene) {
void Qtk::TreeView::itemFocus(QTreeWidgetItem * item, int column) { void Qtk::TreeView::itemFocus(QTreeWidgetItem * item, int column) {
QString name = item->text(column); QString name = item->text(column);
auto scene = auto scene =
MainWindow::getMainWindow()->getQtkWidget(mSceneName)->getScene(); MainWindow::getMainWindow()->getQtkWidget()->getScene();
auto & transform = scene->getCamera().getTransform(); auto & transform = scene->getCamera().getTransform();
auto object = scene->getObject(name); auto object = scene->getObject(name);
if (object == Q_NULLPTR) { if (object == Q_NULLPTR) {