From 94fb2f9dc29fe7b27194819c533b5e1de9765697 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 3 Nov 2015 08:27:36 +0100 Subject: [PATCH] Only show types which inherit from ConfigObject and aren't abstract in Icinga Studio fixes #10498 --- icinga-studio/mainform.cpp | 44 ++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/icinga-studio/mainform.cpp b/icinga-studio/mainform.cpp index fd7ccff76..71198340f 100644 --- a/icinga-studio/mainform.cpp +++ b/icinga-studio/mainform.cpp @@ -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 items; + BOOST_FOREACH(const ApiType::Ptr& type, types) { + m_Types[type->Name] = type; + } - m_Types.clear(); + BOOST_FOREACH(const ApiType::Ptr& type, types) { + if (type->Abstract) + continue; - while (!all) { - all = true; + bool configObject = false; + ApiType::Ptr currentType = type; - BOOST_FOREACH(const ApiType::Ptr& type, types) { - std::string name = type->Name; + for (;;) { + if (currentType->BaseName.IsEmpty()) + break; - if (items.find(name) != items.end()) - continue; + currentType = m_Types[currentType->BaseName]; - all = false; + if (!currentType) + break; - wxTreeItemId parent; - - if (type->BaseName.IsEmpty()) - parent = rootNode; - else { - std::map::const_iterator it = items.find(type->BaseName); - - if (it == items.end()) - continue; - - 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); } } }