Fix editor being created for a non-editable item.

test
cc9cii 10 years ago
parent a632b2cfeb
commit ce7e2e06c1

@ -108,7 +108,19 @@ Qt::ItemFlags CSMWorld::IdTree::flags (const QModelIndex & index) const
if (!index.isValid())
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)

@ -110,7 +110,7 @@ bool CSMWorld::NestedTableProxyModel::setData (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

@ -120,7 +120,7 @@ void CSVWorld::CommandDelegate::setModelDataImp (QWidget *editor, QAbstractItemM
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_));
}

Loading…
Cancel
Save