mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-01 20:36:40 +00:00
Don't do mapToSource at executeModify
This commit is contained in:
parent
298db2ef76
commit
7801f42005
2 changed files with 9 additions and 18 deletions
|
@ -137,7 +137,7 @@ std::vector<CSMWorld::UniversalId> CSMWorld::CommandDispatcher::getExtendedTypes
|
||||||
return tables;
|
return tables;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMWorld::CommandDispatcher::executeModify (QAbstractItemModel *sourceModel, const QModelIndex& sourceIndex, const QVariant& new_)
|
void CSMWorld::CommandDispatcher::executeModify (QAbstractItemModel *model, const QModelIndex& index, const QVariant& new_)
|
||||||
{
|
{
|
||||||
if (mLocked)
|
if (mLocked)
|
||||||
return;
|
return;
|
||||||
|
@ -150,26 +150,17 @@ void CSMWorld::CommandDispatcher::executeModify (QAbstractItemModel *sourceModel
|
||||||
std::unique_ptr<CSMWorld::ModifyCommand> modifyData;
|
std::unique_ptr<CSMWorld::ModifyCommand> modifyData;
|
||||||
std::unique_ptr<CSMWorld::UpdateCellCommand> modifyCell;
|
std::unique_ptr<CSMWorld::UpdateCellCommand> modifyCell;
|
||||||
|
|
||||||
QAbstractItemModel *model(nullptr);
|
QAbstractItemModel* sourceModel = model;
|
||||||
QModelIndex index;
|
if (IdTableProxyModel* proxy = dynamic_cast<IdTableProxyModel*> (model))
|
||||||
|
sourceModel = proxy->sourceModel();
|
||||||
|
|
||||||
if (QAbstractProxyModel *proxy = dynamic_cast<QAbstractProxyModel *> (sourceModel))
|
CSMWorld::IdTable& table = dynamic_cast<CSMWorld::IdTable&>(*sourceModel); // for getId()
|
||||||
{
|
int stateColumn = table.findColumnIndex(Columns::ColumnId_Modification);
|
||||||
// Replace proxy with actual model
|
QModelIndex stateIndex = table.getModelIndex(table.getId(index.row()), stateColumn);
|
||||||
index = proxy->mapToSource (sourceIndex);
|
RecordBase::State state = static_cast<RecordBase::State> (sourceModel->data(stateIndex).toInt());
|
||||||
model = proxy->sourceModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!model) return;
|
|
||||||
|
|
||||||
int columnId = model->data (index, ColumnBase::Role_ColumnId).toInt();
|
int columnId = model->data (index, ColumnBase::Role_ColumnId).toInt();
|
||||||
|
|
||||||
int stateColumn = dynamic_cast<CSMWorld::IdTable&>(*model).findColumnIndex(Columns::ColumnId_Modification);
|
|
||||||
|
|
||||||
CSMWorld::IdTable& table = dynamic_cast<CSMWorld::IdTable&>(*model); // for getId()
|
|
||||||
QModelIndex stateIndex = table.getModelIndex(table.getId(index.row()), stateColumn);
|
|
||||||
RecordBase::State state = static_cast<RecordBase::State> (model->data(stateIndex).toInt());
|
|
||||||
|
|
||||||
// This is not guaranteed to be the same as \a model, since a proxy could be used.
|
// This is not guaranteed to be the same as \a model, since a proxy could be used.
|
||||||
IdTable& model2 = dynamic_cast<IdTable&> (*mDocument.getData().getTableModel(mId));
|
IdTable& model2 = dynamic_cast<IdTable&> (*mDocument.getData().getTableModel(mId));
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ namespace CSMWorld
|
||||||
///
|
///
|
||||||
/// \attention model must either be a model for the table operated on by this
|
/// \attention model must either be a model for the table operated on by this
|
||||||
/// dispatcher or a proxy of it.
|
/// dispatcher or a proxy of it.
|
||||||
void executeModify (QAbstractItemModel *sourceModel, const QModelIndex& sourceIndex, const QVariant& new_);
|
void executeModify (QAbstractItemModel *model, const QModelIndex& index, const QVariant& new_);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue