Merge pull request #9 from marcelino-m/master

Fix: Root TreeItem (Object and  Array) are not editable
This commit is contained in:
sacha schutz 2018-11-25 11:13:52 +01:00 committed by GitHub
commit 1386e400fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -337,8 +337,13 @@ int QJsonModel::columnCount(const QModelIndex &parent) const
Qt::ItemFlags QJsonModel::flags(const QModelIndex &index) const
{
int col = index.column();
if (col == 1) {
int col = index.column();
auto item = static_cast<QJsonTreeItem*>(index.internalPointer());
auto isArray = QJsonValue::Array == item->type();
auto isObject = QJsonValue::Object == item->type();
if ((col == 1) && !(isArray || isObject)) {
return Qt::ItemIsEditable | QAbstractItemModel::flags(index);
} else {
return QAbstractItemModel::flags(index);