mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-10 12:39:53 +00:00
Fix editor being created for a non-editable item.
This commit is contained in:
parent
a632b2cfeb
commit
ce7e2e06c1
@ -108,7 +108,19 @@ Qt::ItemFlags CSMWorld::IdTree::flags (const QModelIndex & index) const
|
|||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return IdTable::flags(index);
|
if (index.internalId() != 0)
|
||||||
|
{
|
||||||
|
std::pair<int, int> parentAddress(unfoldIndexAddress(index.internalId()));
|
||||||
|
|
||||||
|
Qt::ItemFlags flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
|
||||||
|
|
||||||
|
if (mNestedCollection->getNestableColumn(parentAddress.second)->nestedColumn(index.column()).isEditable())
|
||||||
|
flags |= Qt::ItemIsEditable;
|
||||||
|
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return IdTable::flags(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSMWorld::IdTree::removeRows (int row, int count, const QModelIndex& parent)
|
bool CSMWorld::IdTree::removeRows (int row, int count, const QModelIndex& parent)
|
||||||
|
@ -110,7 +110,7 @@ bool CSMWorld::NestedTableProxyModel::setData (const QModelIndex & index, const
|
|||||||
|
|
||||||
Qt::ItemFlags CSMWorld::NestedTableProxyModel::flags(const QModelIndex& index) const
|
Qt::ItemFlags CSMWorld::NestedTableProxyModel::flags(const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
return mMainModel->flags(mMainModel->index(0, mParentColumn));
|
return mMainModel->flags(mapToSource(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CSMWorld::NestedTableProxyModel::getParentId() const
|
std::string CSMWorld::NestedTableProxyModel::getParentId() const
|
||||||
|
@ -120,7 +120,7 @@ void CSVWorld::CommandDelegate::setModelDataImp (QWidget *editor, QAbstractItemM
|
|||||||
|
|
||||||
QVariant new_ = hack.getData();
|
QVariant new_ = hack.getData();
|
||||||
|
|
||||||
if (model->data (index)!=new_)
|
if ((model->data (index)!=new_) && (model->flags(index) & Qt::ItemIsEditable))
|
||||||
getUndoStack().push (new CSMWorld::ModifyCommand (*model, index, new_));
|
getUndoStack().push (new CSMWorld::ModifyCommand (*model, index, new_));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user