mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-31 00: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;
|
||||
}
|
||||
|
||||
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)
|
||||
return;
|
||||
|
@ -150,26 +150,17 @@ void CSMWorld::CommandDispatcher::executeModify (QAbstractItemModel *sourceModel
|
|||
std::unique_ptr<CSMWorld::ModifyCommand> modifyData;
|
||||
std::unique_ptr<CSMWorld::UpdateCellCommand> modifyCell;
|
||||
|
||||
QAbstractItemModel *model(nullptr);
|
||||
QModelIndex index;
|
||||
QAbstractItemModel* sourceModel = model;
|
||||
if (IdTableProxyModel* proxy = dynamic_cast<IdTableProxyModel*> (model))
|
||||
sourceModel = proxy->sourceModel();
|
||||
|
||||
if (QAbstractProxyModel *proxy = dynamic_cast<QAbstractProxyModel *> (sourceModel))
|
||||
{
|
||||
// Replace proxy with actual model
|
||||
index = proxy->mapToSource (sourceIndex);
|
||||
model = proxy->sourceModel();
|
||||
}
|
||||
|
||||
if (!model) return;
|
||||
CSMWorld::IdTable& table = dynamic_cast<CSMWorld::IdTable&>(*sourceModel); // for getId()
|
||||
int stateColumn = table.findColumnIndex(Columns::ColumnId_Modification);
|
||||
QModelIndex stateIndex = table.getModelIndex(table.getId(index.row()), stateColumn);
|
||||
RecordBase::State state = static_cast<RecordBase::State> (sourceModel->data(stateIndex).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.
|
||||
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
|
||||
/// 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:
|
||||
|
||||
|
|
Loading…
Reference in a new issue