Fix: Root TreeItem (Object and Array) are not editable

Prevent enter in edit mode when "double click" on root item,
The root item represent objects and arrays
This commit is contained in:
Marcelo M. A 2018-03-23 20:23:36 -03:00
parent eab788618b
commit b7c5d9e279

View File

@ -312,8 +312,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);