]> granicus.if.org Git - icinga2/commitdiff
Improve property tree for Icinga Studio
authorGunnar Beutner <gunnar@beutner.name>
Wed, 30 Sep 2015 12:13:18 +0000 (14:13 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Wed, 30 Sep 2015 12:13:18 +0000 (14:13 +0200)
refs #10042

icinga-studio/mainform.cpp

index 9075b35e8ecb5e3380c463481b2328014015f847..453365ada58e5f4f508915a9ac137ea151bbc452 100644 (file)
@@ -246,8 +246,8 @@ void MainForm::ObjectDetailsCompletionHandler(boost::exception_ptr eptr, const s
 
        std::map<String, wxStringProperty *> parents;
 
-       typedef std::pair<String, Value> kv_pair;
-       BOOST_FOREACH(const kv_pair& kv, object->Attrs) {
+       typedef std::pair<String, Value> kv_pair_attr;
+       BOOST_FOREACH(const kv_pair_attr& kv, object->Attrs) {
                std::vector<String> 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, "<object>");
-                       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<String, wxStringProperty *> kv_pair_prop;
+       BOOST_FOREACH(const kv_pair_prop& kv, parents) {
+               m_PropertyGrid->Append(kv.second);
+               m_PropertyGrid->SetPropertyReadOnly(kv.second);
        }
 }