diff --git a/apps/opencs/view/world/pathgridcreator.cpp b/apps/opencs/view/world/pathgridcreator.cpp index ae9ce7242..980c031ca 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 6ed8004e2..7c4f7f705 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(); }; }