mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-01 00:45:32 +00:00
Refactor dynamic casts in the editor
This commit is contained in:
parent
a21792657a
commit
059a8fd32a
4 changed files with 8 additions and 44 deletions
|
@ -198,12 +198,7 @@ CSMWorld::ModifyCommand::ModifyCommand (QAbstractItemModel& model, const QModelI
|
|||
|
||||
if (mIndex.parent().isValid())
|
||||
{
|
||||
CSMWorld::IdTree* tree = dynamic_cast<CSMWorld::IdTree*>(mModel);
|
||||
if (tree == nullptr)
|
||||
{
|
||||
throw std::logic_error("CSMWorld::ModifyCommand: Attempt to add nested values to the non-nested model");
|
||||
}
|
||||
|
||||
CSMWorld::IdTree* tree = &dynamic_cast<CSMWorld::IdTree&>(*mModel);
|
||||
setText ("Modify " + tree->nestedHeaderData (
|
||||
mIndex.parent().column(), mIndex.column(), Qt::Horizontal, Qt::DisplayRole).toString());
|
||||
}
|
||||
|
@ -249,12 +244,7 @@ void CSMWorld::CreateCommand::applyModifications()
|
|||
{
|
||||
if (!mNestedValues.empty())
|
||||
{
|
||||
CSMWorld::IdTree *tree = dynamic_cast<CSMWorld::IdTree *>(&mModel);
|
||||
if (tree == nullptr)
|
||||
{
|
||||
throw std::logic_error("CSMWorld::CreateCommand: Attempt to add nested values to the non-nested model");
|
||||
}
|
||||
|
||||
CSMWorld::IdTree* tree = &dynamic_cast<CSMWorld::IdTree&>(mModel);
|
||||
std::map<int, std::pair<int, QVariant> >::const_iterator current = mNestedValues.begin();
|
||||
std::map<int, std::pair<int, QVariant> >::const_iterator end = mNestedValues.end();
|
||||
for (; current != end; ++current)
|
||||
|
|
|
@ -224,11 +224,7 @@ namespace CSVRender
|
|||
|
||||
void Pathgrid::applyPoint(CSMWorld::CommandMacro& commands, const osg::Vec3d& worldPos)
|
||||
{
|
||||
CSMWorld::IdTree* model = dynamic_cast<CSMWorld::IdTree*>(mData.getTableModel(CSMWorld::UniversalId::Type_Pathgrids));
|
||||
if (model == nullptr)
|
||||
{
|
||||
throw std::logic_error("CSVRender::Pathgrid: Attempt to add nested values to the non-nested model");
|
||||
}
|
||||
CSMWorld::IdTree* model = &dynamic_cast<CSMWorld::IdTree&>(*mData.getTableModel(CSMWorld::UniversalId::Type_Pathgrids));
|
||||
|
||||
const CSMWorld::Pathgrid* source = getPathgridSource();
|
||||
if (source)
|
||||
|
@ -360,11 +356,7 @@ namespace CSVRender
|
|||
const CSMWorld::Pathgrid* source = getPathgridSource();
|
||||
if (source)
|
||||
{
|
||||
CSMWorld::IdTree* model = dynamic_cast<CSMWorld::IdTree*>(mData.getTableModel(CSMWorld::UniversalId::Type_Pathgrids));
|
||||
if (model == nullptr)
|
||||
{
|
||||
throw std::logic_error("CSVRender::Pathgrid: Attempt to add nested values to the non-nested model");
|
||||
}
|
||||
CSMWorld::IdTree* model = &dynamic_cast<CSMWorld::IdTree&>(*mData.getTableModel(CSMWorld::UniversalId::Type_Pathgrids));
|
||||
|
||||
// Want to remove nodes from end of list first
|
||||
std::sort(mSelected.begin(), mSelected.end(), std::greater<int>());
|
||||
|
@ -464,12 +456,7 @@ namespace CSVRender
|
|||
}
|
||||
}
|
||||
|
||||
CSMWorld::IdTree* model = dynamic_cast<CSMWorld::IdTree*>(mData.getTableModel(CSMWorld::UniversalId::Type_Pathgrids));
|
||||
if (model == nullptr)
|
||||
{
|
||||
throw std::logic_error("CSVRender::Pathgrid: Attempt to add nested values to the non-nested model");
|
||||
}
|
||||
|
||||
CSMWorld::IdTree* model = &dynamic_cast<CSMWorld::IdTree&>(*mData.getTableModel(CSMWorld::UniversalId::Type_Pathgrids));
|
||||
int parentColumn = mPathgridCollection.findColumnIndex(CSMWorld::Columns::ColumnId_PathgridEdges);
|
||||
|
||||
std::set<int, std::greater<int> >::iterator row;
|
||||
|
@ -642,11 +629,7 @@ namespace CSVRender
|
|||
void Pathgrid::addEdge(CSMWorld::CommandMacro& commands, const CSMWorld::Pathgrid& source, unsigned short node1,
|
||||
unsigned short node2)
|
||||
{
|
||||
CSMWorld::IdTree* model = dynamic_cast<CSMWorld::IdTree*>(mData.getTableModel(CSMWorld::UniversalId::Type_Pathgrids));
|
||||
if (model == nullptr)
|
||||
{
|
||||
throw std::logic_error("CSVRender::Pathgrid: Attempt to add nested values to the non-nested model");
|
||||
}
|
||||
CSMWorld::IdTree* model = &dynamic_cast<CSMWorld::IdTree&>(*mData.getTableModel(CSMWorld::UniversalId::Type_Pathgrids));
|
||||
|
||||
int recordIndex = mPathgridCollection.getIndex(mId);
|
||||
int parentColumn = mPathgridCollection.findColumnIndex(CSMWorld::Columns::ColumnId_PathgridEdges);
|
||||
|
|
|
@ -24,11 +24,7 @@ std::string CSVWorld::CellCreator::getId() const
|
|||
|
||||
void CSVWorld::CellCreator::configureCreateCommand(CSMWorld::CreateCommand& command) const
|
||||
{
|
||||
CSMWorld::IdTree *model = dynamic_cast<CSMWorld::IdTree *>(getData().getTableModel(getCollectionId()));
|
||||
if (model == nullptr)
|
||||
{
|
||||
throw std::logic_error("CSVWorld::CellCreator: Attempt to add nested values to the non-nested model");
|
||||
}
|
||||
CSMWorld::IdTree* model = &dynamic_cast<CSMWorld::IdTree&>(*getData().getTableModel(getCollectionId()));
|
||||
|
||||
int parentIndex = model->findColumnIndex(CSMWorld::Columns::ColumnId_Cell);
|
||||
int index = model->findNestedColumnIndex(parentIndex, CSMWorld::Columns::ColumnId_Interior);
|
||||
|
|
|
@ -555,12 +555,7 @@ void CSVWorld::EditWidget::remake(int row)
|
|||
if (mTable->hasChildren(mTable->index(row, i)) &&
|
||||
!(flags & CSMWorld::ColumnBase::Flag_Dialogue_List))
|
||||
{
|
||||
CSMWorld::IdTree *innerTable = dynamic_cast<CSMWorld::IdTree*>(mTable);
|
||||
if (innerTable == nullptr)
|
||||
{
|
||||
throw std::logic_error("CSVWorld::EditWidget: Attempt to add nested values to the non-nested model");
|
||||
}
|
||||
|
||||
CSMWorld::IdTree* innerTable = &dynamic_cast<CSMWorld::IdTree&>(*mTable);
|
||||
mNestedModels.push_back(new CSMWorld::NestedTableProxyModel (mTable->index(row, i), display, innerTable));
|
||||
|
||||
int idColumn = mTable->findColumnIndex (CSMWorld::Columns::ColumnId_Id);
|
||||
|
|
Loading…
Reference in a new issue