diff options
-rw-r--r-- | src/xmlmenu.cpp | 46 | ||||
-rw-r--r-- | src/xmlmenu.h | 5 |
2 files changed, 27 insertions, 24 deletions
diff --git a/src/xmlmenu.cpp b/src/xmlmenu.cpp index 94369bd..145e867 100644 --- a/src/xmlmenu.cpp +++ b/src/xmlmenu.cpp @@ -28,7 +28,7 @@ void XmlMenu::loadXmlMenu() { //Walk the tree: const Node* pNode = parser.get_document()->get_root_node(); //deleted by DomParser. - parseNode(pNode,0,NULL); + parseNode(pNode,0); } } catch(const std::exception& ex) @@ -40,12 +40,11 @@ void XmlMenu::loadXmlMenu() } } -void XmlMenu::parseNode(const Node* a_node, unsigned int Parent, MenuNode* parentNode) +void XmlMenu::parseNode(const Node* a_node, unsigned int Parent) { const ContentNode* nodeContent = dynamic_cast<const ContentNode*>(a_node); const TextNode* nodeText = dynamic_cast<const TextNode*>(a_node); const CommentNode* nodeComment = dynamic_cast<const CommentNode*>(a_node); - MenuNode* newparentNode; /**** MenuNode* subMenu1 =_rootMenuNode.AddChild(new SubMenuItem("Custom menu 1")); @@ -70,7 +69,7 @@ void XmlMenu::parseNode(const Node* a_node, unsigned int Parent, MenuNode* paren if (nodename == "menus") { //cout << Parent << "-" << MainMenuIndex << "-" << myMenuNr << "-ROOT" << endl; - + isyslog("ROOT Node passed"); } else if (nodename == "system") { @@ -81,10 +80,11 @@ void XmlMenu::parseNode(const Node* a_node, unsigned int Parent, MenuNode* paren { const Attribute* attribute = *iter; //cout << Parent << "-" << MainMenuIndex << "-" << myMenuNr << "-SystemItem=" << attribute->get_value() << endl; - if (parentNode == NULL) - newparentNode =_rootMenuNode.AddChild(new VdrMenuItem(tr(attribute->get_value().data()), geteOSState(attribute->get_value()))); + isyslog("SystemItem=%s",attribute->get_value().data()); + if(_subMenu[Parent-1]) + _subMenu[Parent-1]->AddChild(new VdrMenuItem(tr(attribute->get_value().data()), geteOSState(attribute->get_value()))); else - newparentNode = parentNode->AddChild(new VdrMenuItem(tr(attribute->get_value().data()), geteOSState(attribute->get_value()))); + _rootMenuNode.AddChild(new VdrMenuItem(tr(attribute->get_value().data()), geteOSState(attribute->get_value()))); } } } @@ -97,11 +97,13 @@ void XmlMenu::parseNode(const Node* a_node, unsigned int Parent, MenuNode* paren { const Attribute* attribute = *iter; //cout << Parent << "-" << MainMenuIndex << "-" << myMenuNr << "-MenuItem=" << attribute->get_value() << endl; - if (parentNode == NULL) - newparentNode =_rootMenuNode.AddChild(new SubMenuItem(attribute->get_value().data())); + isyslog("MenuItem=%s",attribute->get_value().data()); + + if(_subMenu[Parent-1]) + _subMenu[Parent-1]->AddChild(new SubMenuItem(attribute->get_value().data())); else - newparentNode = parentNode->AddChild(new SubMenuItem(attribute->get_value().data())); - } + _rootMenuNode.AddChild(new SubMenuItem(attribute->get_value().data())); + } } } else if (nodename == "plugin") @@ -113,17 +115,15 @@ void XmlMenu::parseNode(const Node* a_node, unsigned int Parent, MenuNode* paren { const Attribute* attribute = *iter; //cout << Parent << "-" << MainMenuIndex << "-" << myMenuNr << "-PluginItem=" << attribute->get_value() << endl; - //TODO: get this running! -/* + isyslog("PluginItem=%s",attribute->get_value().data()); PluginItemAndIndex *myPlugin = getPlugin(attribute->get_value()); if (myPlugin) { - if (parentNode == NULL) - newparentNode =_rootMenuNode.AddChild(new PluginMenuItem(myPlugin->item, myPlugin->index)); + if(_subMenu[Parent-1]) + _subMenu[Parent-1]->AddChild(new PluginMenuItem(myPlugin->item, myPlugin->index)); else - newparentNode = parentNode->AddChild(new PluginMenuItem(myPlugin->item, myPlugin->index)); + _rootMenuNode.AddChild(new PluginMenuItem(myPlugin->item, myPlugin->index)); } -*/ } } } @@ -134,7 +134,7 @@ void XmlMenu::parseNode(const Node* a_node, unsigned int Parent, MenuNode* paren Node::NodeList list = a_node->get_children(); for(Node::NodeList::iterator iter = list.begin(); iter != list.end(); ++iter) { - parseNode(*iter, Parent+1, newparentNode); //recursive + parseNode(*iter, Parent+1); //recursive } } } @@ -236,9 +236,9 @@ eOSState XmlMenu::geteOSState(const Glib::ustring& name) return osContinue; } -PluginItemAndIndex XmlMenu::getPlugin(const Glib::ustring& name) +PluginItemAndIndex* XmlMenu::getPlugin(const Glib::ustring& name) { - PluginItemAndIndex returnVar; + PluginItemAndIndex* returnVar; /* returnVar.item = NULL; returnVar.index = NULL; @@ -249,9 +249,11 @@ PluginItemAndIndex XmlMenu::getPlugin(const Glib::ustring& name) if (const char *item = p->MainMenuEntry()) { if (name == (const Glib::ustring) p->Name()) - returnVar.item = item; - returnVar.index = i; + { + returnVar->item = item; + returnVar->index = i; break; + } } i++; } diff --git a/src/xmlmenu.h b/src/xmlmenu.h index a5849fd..3f24644 100644 --- a/src/xmlmenu.h +++ b/src/xmlmenu.h @@ -16,9 +16,10 @@ class XmlMenu { private: //void createMenu(); // create the Menu Node - void parseNode(const Node* a_node, unsigned int Parent, MenuNode *parentNode); + void parseNode(const Node* a_node, unsigned int Parent); eOSState geteOSState(const Glib::ustring& name); // gets the eOSState for the given string - PluginItemAndIndex getPlugin(const Glib::ustring& name); // gets the plugin for the given string + PluginItemAndIndex* getPlugin(const Glib::ustring& name); // gets the plugin for the given string + MenuNode* _subMenu[30]; // holds the submenus public: MenuNode _rootMenuNode; // hold the Menue Nodes void loadXmlMenu(); // load the xmlfile |