From: Gunnar Beutner Date: Wed, 30 Sep 2015 12:13:18 +0000 (+0200) Subject: Improve property tree for Icinga Studio X-Git-Tag: v2.4.0~238 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=de9806b14c2d83e7f42e670c5fc4d45c6e8d7137;p=icinga2 Improve property tree for Icinga Studio refs #10042 --- 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); } }