]> granicus.if.org Git - icinga2/commitdiff
Only show types which inherit from ConfigObject and aren't abstract in Icinga Studio
authorGunnar Beutner <gunnar@beutner.name>
Tue, 3 Nov 2015 07:27:36 +0000 (08:27 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Tue, 3 Nov 2015 07:27:36 +0000 (08:27 +0100)
fixes #10498

icinga-studio/mainform.cpp

index fd7ccff76613a07dea99f0e91ccc61ace45d7e0b..71198340f4b0ced0302a8006e804ce62b272d092 100644 (file)
@@ -72,37 +72,35 @@ void MainForm::TypesCompletionHandler(boost::exception_ptr eptr, const std::vect
 
        wxTreeItemId rootNode = m_TypesTree->AddRoot("root");
 
-       bool all = false;
-       std::map<String, wxTreeItemId> items;
-
-       m_Types.clear();
-
-       while (!all) {
-               all = true;
+       BOOST_FOREACH(const ApiType::Ptr& type, types) {
+               m_Types[type->Name] = type;
+       }
 
-               BOOST_FOREACH(const ApiType::Ptr& type, types) {
-                       std::string name = type->Name;
+       BOOST_FOREACH(const ApiType::Ptr& type, types) {
+               if (type->Abstract)
+                       continue;
 
-                       if (items.find(name) != items.end())
-                               continue;
+               bool configObject = false;
+               ApiType::Ptr currentType = type;
 
-                       all = false;
+               for (;;) {
+                       if (currentType->BaseName.IsEmpty())
+                               break;
 
-                       wxTreeItemId parent;
-                       
-                       if (type->BaseName.IsEmpty())
-                               parent = rootNode;
-                       else {
-                               std::map<String, wxTreeItemId>::const_iterator it = items.find(type->BaseName);
+                       currentType = m_Types[currentType->BaseName];
 
-                               if (it == items.end())
-                                       continue;
+                       if (!currentType)
+                               break;
 
-                               parent = it->second;
+                       if (currentType->Name == "ConfigObject") {
+                               configObject = true;
+                               break;
                        }
+               }
 
-                       m_Types[name] = type;
-                       items[name] = m_TypesTree->AppendItem(parent, name, 0);
+               if (configObject) {
+                       std::string name = type->Name;
+                       m_TypesTree->AppendItem(rootNode, name, 0);
                }
        }
 }