mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-17 10:10:23 +00:00
Get index and model from proxy
This commit is contained in:
parent
ee1ec53cd9
commit
f1d05a93bf
@ -3,6 +3,9 @@
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QAbstractProxyModel>
|
||||
|
||||
#include <components/misc/stringops.hpp>
|
||||
#include <components/misc/constants.hpp>
|
||||
|
||||
@ -134,7 +137,7 @@ std::vector<CSMWorld::UniversalId> CSMWorld::CommandDispatcher::getExtendedTypes
|
||||
return tables;
|
||||
}
|
||||
|
||||
void CSMWorld::CommandDispatcher::executeModify (QAbstractItemModel *model, const QModelIndex& index, const QVariant& new_)
|
||||
void CSMWorld::CommandDispatcher::executeModify (QAbstractItemModel *sourceModel, const QModelIndex& sourceIndex, const QVariant& new_)
|
||||
{
|
||||
if (mLocked)
|
||||
return;
|
||||
@ -147,6 +150,16 @@ void CSMWorld::CommandDispatcher::executeModify (QAbstractItemModel *model, cons
|
||||
std::unique_ptr<CSMWorld::ModifyCommand> modifyData;
|
||||
std::unique_ptr<CSMWorld::UpdateCellCommand> modifyCell;
|
||||
|
||||
QAbstractItemModel *model;
|
||||
QModelIndex index;
|
||||
|
||||
if (QAbstractProxyModel *proxy = dynamic_cast<QAbstractProxyModel *> (sourceModel))
|
||||
{
|
||||
// Replace proxy with actual model
|
||||
index = proxy->mapToSource (sourceIndex);
|
||||
model = proxy->sourceModel();
|
||||
}
|
||||
|
||||
int columnId = model->data (index, ColumnBase::Role_ColumnId).toInt();
|
||||
|
||||
int stateColumn = dynamic_cast<CSMWorld::IdTable&>(*model).findColumnIndex(Columns::ColumnId_Modification);
|
||||
|
@ -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 *model, const QModelIndex& index, const QVariant& new_);
|
||||
void executeModify (QAbstractItemModel *sourceModel, const QModelIndex& sourceIndex, const QVariant& new_);
|
||||
|
||||
public slots:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user