forked from mirror/openmw-tes3mp
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.
This commit is contained in:
parent
491fd3d0be
commit
0dcb6a9bd4
2 changed files with 26 additions and 15 deletions
|
@ -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<CSMWorld::Pathgrid>& pathgrids = getData().getPathgrids();
|
||||
const CSMWorld::IdCollection<CSMWorld::Cell>& 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<CSMWorld::Pathgrid>& pathgrids = getData().getPathgrids();
|
||||
const CSMWorld::IdCollection<CSMWorld::Cell>& 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);
|
||||
}
|
||||
|
|
|
@ -40,6 +40,9 @@ namespace CSVWorld
|
|||
|
||||
/// \brief Check user input for errors.
|
||||
void cellChanged();
|
||||
|
||||
/// \brief Setup cells in combo box.
|
||||
void setupCellsInput();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue