From afe4bdf41d827b496d1cbdbe11d4ff9190ce3602 Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Tue, 3 Aug 2021 15:35:30 +0200 Subject: [PATCH] UI: The property view is never editable! --- src/UI/PropertyModel.cc | 17 +---------------- src/UI/PropertyModel.hh | 4 ---- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/src/UI/PropertyModel.cc b/src/UI/PropertyModel.cc index 5dd71eaa..d80604ca 100644 --- a/src/UI/PropertyModel.cc +++ b/src/UI/PropertyModel.cc @@ -261,22 +261,7 @@ PropertyModel::columnCount(const QModelIndex & /* parent */) const noexcept Qt::ItemFlags PropertyModel::flags(const QModelIndex &index) const noexcept { - // Handle the case where the model is not editable - if (!editableState) { - return /* Qt::ItemIsSelectable | */ QAbstractItemModel::flags(index); - } - - // Here the model is editable - const int col = index.column(); - const Item *item = static_cast<Item *>(index.internalPointer()); - const bool isArray = QJsonValue::Array == item->getType(); - const bool isObject = QJsonValue::Object == item->getType(); - - if ((col == 1) && !(isArray || isObject)) - return Qt::ItemIsSelectable | Qt::ItemIsEditable | QAbstractItemModel::flags(index); - - else - return QAbstractItemModel::flags(index); + return QAbstractItemModel::flags(index); } // Get the json stored inside the model diff --git a/src/UI/PropertyModel.hh b/src/UI/PropertyModel.hh index c79f0aa8..d22ab6ec 100644 --- a/src/UI/PropertyModel.hh +++ b/src/UI/PropertyModel.hh @@ -71,10 +71,7 @@ public: root->setKey(object.getElementName()); } - ~PropertyModel() noexcept = default; - void loadJson(const QJsonDocument &json); - void setEditable(const bool); QVariant data(const QModelIndex &, int role) const noexcept override; bool setData(const QModelIndex &, const QVariant &v, int r = Qt::EditRole) noexcept override; @@ -96,7 +93,6 @@ private: QJsonValue generateJson(Item *) const noexcept; std::unique_ptr<Item> root{ nullptr }; QStringList headers{}; - bool editableState{ false }; }; } -- GitLab