From 0dcb6a9bd4b788964b84e42f25b9c687dc413612 Mon Sep 17 00:00:00 2001 From: Rob Cutmore Date: Sat, 18 Mar 2017 10:20:16 -0400 Subject: [PATCH] Editor: update pathgrid creator input on changes When data changes the cell input for pathgrid creator is repopulated with valid choices. This handles the case where a cell is added or removed, and also when a cell's pathgrid is added or completely removed. --- apps/opencs/view/world/pathgridcreator.cpp | 38 +++++++++++++--------- apps/opencs/view/world/pathgridcreator.hpp | 3 ++ 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/apps/opencs/view/world/pathgridcreator.cpp b/apps/opencs/view/world/pathgridcreator.cpp index ae9ce7242d..980c031ca0 100644 --- a/apps/opencs/view/world/pathgridcreator.cpp +++ b/apps/opencs/view/world/pathgridcreator.cpp @@ -33,22 +33,9 @@ CSVWorld::PathgridCreator::PathgridCreator( mCell->setModel(proxyModel); insertBeforeButtons(mCell, true); - // Populate combo box with cells that don't have a pathgrid yet. - const CSMWorld::IdCollection& pathgrids = getData().getPathgrids(); - const CSMWorld::IdCollection& cells = getData().getCells(); - const int cellCount = cells.getSize(); - for (int i = 0; i < cellCount; ++i) - { - std::string cellId = cells.getId(i); - if (pathgrids.searchId(cellId) == -1) - { - mCell->addItem(QString::fromStdString(cellId)); - } - } - - mCell->model()->sort(0); - mCell->setCurrentIndex(0); + setupCellsInput(); + connect(&getData(), SIGNAL (idListChanged()), this, SLOT (setupCellsInput())); connect(mCell, SIGNAL (currentIndexChanged(const QString&)), this, SLOT (cellChanged())); } @@ -91,3 +78,24 @@ void CSVWorld::PathgridCreator::cellChanged() { update(); } + +void CSVWorld::PathgridCreator::setupCellsInput() +{ + mCell->clear(); + + // Populate combo box with cells that don't have a pathgrid yet. + const CSMWorld::IdCollection& pathgrids = getData().getPathgrids(); + const CSMWorld::IdCollection& cells = getData().getCells(); + const int cellCount = cells.getSize(); + for (int i = 0; i < cellCount; ++i) + { + std::string cellId = cells.getId(i); + if (pathgrids.searchId(cellId) == -1) + { + mCell->addItem(QString::fromStdString(cellId)); + } + } + + mCell->model()->sort(0); + mCell->setCurrentIndex(0); +} diff --git a/apps/opencs/view/world/pathgridcreator.hpp b/apps/opencs/view/world/pathgridcreator.hpp index 6ed8004e2f..7c4f7f7051 100644 --- a/apps/opencs/view/world/pathgridcreator.hpp +++ b/apps/opencs/view/world/pathgridcreator.hpp @@ -40,6 +40,9 @@ namespace CSVWorld /// \brief Check user input for errors. void cellChanged(); + + /// \brief Setup cells in combo box. + void setupCellsInput(); }; }