From de9806b14c2d83e7f42e670c5fc4d45c6e8d7137 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 30 Sep 2015 14:13:18 +0200 Subject: [PATCH] Improve property tree for Icinga Studio refs #10042 --- icinga-studio/mainform.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/icinga-studio/mainform.cpp b/icinga-studio/mainform.cpp index 9075b35e8..453365ada 100644 --- a/icinga-studio/mainform.cpp +++ b/icinga-studio/mainform.cpp @@ -246,8 +246,8 @@ void MainForm::ObjectDetailsCompletionHandler(boost::exception_ptr eptr, const s std::map parents; - typedef std::pair kv_pair; - BOOST_FOREACH(const kv_pair& kv, object->Attrs) { + typedef std::pair kv_pair_attr; + BOOST_FOREACH(const kv_pair_attr& kv, object->Attrs) { std::vector tokens; boost::algorithm::split(tokens, kv.first, boost::is_any_of(".")); @@ -257,14 +257,28 @@ void MainForm::ObjectDetailsCompletionHandler(boost::exception_ptr eptr, const s if (it == parents.end()) { parent = new wxStringProperty(tokens[0].GetData(), wxPG_LABEL, ""); - m_PropertyGrid->Append(parent); parents[tokens[0]] = parent; } else parent = it->second; wxPGProperty *prop = ValueToProperty(tokens[1], kv.second); parent->AppendChild(prop); - m_PropertyGrid->SetPropertyReadOnly(prop); + } + + /* Make sure the property node for the real object (as opposed to joined objects) is the first one */ + String propName = type->Name.ToLower(); + wxStringProperty *objProp = parents[propName]; + + if (objProp) { + m_PropertyGrid->Append(objProp); + m_PropertyGrid->SetPropertyReadOnly(objProp); + parents.erase(propName); + } + + typedef std::pair kv_pair_prop; + BOOST_FOREACH(const kv_pair_prop& kv, parents) { + m_PropertyGrid->Append(kv.second); + m_PropertyGrid->SetPropertyReadOnly(kv.second); } } -- 2.40.0