diff options
author | svntcreutz <svntcreutz@cd0d6b48-d4f9-0310-940f-ab8c4eb44d3f> | 2007-08-28 20:24:18 +0000 |
---|---|---|
committer | svntcreutz <svntcreutz@cd0d6b48-d4f9-0310-940f-ab8c4eb44d3f> | 2007-08-28 20:24:18 +0000 |
commit | 97339954a86489d9f5fe451ed17a9c9915b29017 (patch) | |
tree | 4458d99d987da30787412ca36659abd1d7d04c57 /src | |
parent | 9d7b5af5135a30bc7d0be7773acb00a8b8b4684b (diff) | |
download | vdr-plugin-menuorg-97339954a86489d9f5fe451ed17a9c9915b29017.tar.gz vdr-plugin-menuorg-97339954a86489d9f5fe451ed17a9c9915b29017.tar.bz2 |
added new class with base cOsdItem and the needed modifications
git-svn-id: file:///home/tobias/sandbox/vdr/--/vdr-pkg/vdr-pkg/menuorg/trunk@6102 cd0d6b48-d4f9-0310-940f-ab8c4eb44d3f
Diffstat (limited to 'src')
-rw-r--r-- | src/menuitemsetup.cpp | 8 | ||||
-rw-r--r-- | src/menuitemsetup.h | 9 | ||||
-rw-r--r-- | src/menusetup.cpp | 8 | ||||
-rw-r--r-- | src/osdxmlitem.cpp | 121 | ||||
-rw-r--r-- | src/osdxmlitem.h | 72 |
5 files changed, 204 insertions, 14 deletions
diff --git a/src/menuitemsetup.cpp b/src/menuitemsetup.cpp index 382cfee..5e4ade7 100644 --- a/src/menuitemsetup.cpp +++ b/src/menuitemsetup.cpp @@ -20,13 +20,11 @@ * */ -#include "menuitemsetup.h" #include <iostream> -#include <libxml++/libxml++.h> - -using namespace xmlpp; +#include "menuitemsetup.h" +#include "osdxmlitem.h" -cMenuItemSetup::cMenuItemSetup(const Element* xmlElement) +cMenuItemSetup::cMenuItemSetup(cOsdXmlItem* osdXmlItem) :cOsdMenu(tr("Item Setup")) { itemTypeText[0] = "System"; diff --git a/src/menuitemsetup.h b/src/menuitemsetup.h index c268d0f..3598dc3 100644 --- a/src/menuitemsetup.h +++ b/src/menuitemsetup.h @@ -24,19 +24,16 @@ #define ___MENUITEMSETUP_H #include <vdr/menu.h> -#include <libxml++/libxml++.h> - -namespace xmlpp { class Element; } +#include "osdxmlitem.h" class cMenuItemSetup : public cOsdMenu { private: - int _itemType; - const xmlpp::Element* _xmlElement; + cOsdXmlItem::sItemType _newItemType; const char* itemTypeText[4]; public: - cMenuItemSetup(const xmlpp::Element* xmlElement); + cMenuItemSetup(cOsdXmlItem* osdXmlItem); virtual eOSState ProcessKey(eKeys Key); }; diff --git a/src/menusetup.cpp b/src/menusetup.cpp index 5d8bfef..d53626b 100644 --- a/src/menusetup.cpp +++ b/src/menusetup.cpp @@ -23,6 +23,7 @@ #include "menusetup.h" #include "menuconfiguration.h" #include "menuitemsetup.h" +#include "osdxmlitem.h" #include <vdr/menu.h> #include <vdr/interface.h> #include <libxml++/libxml++.h> @@ -63,7 +64,7 @@ void cMenuOrgSetup::CreateMenuItems(const Element* menuRoot, int iCount) if ( type == "menu" && _flatMenuSetup) { name = "+" + name; - Add(new cOsdItem(name.c_str()), true); + Add(new cOsdXmlItem(name.c_str(), childElement)); CreateMenuItems(childElement, iCount+1); } else @@ -71,7 +72,7 @@ void cMenuOrgSetup::CreateMenuItems(const Element* menuRoot, int iCount) if(iCount > 0) name = " " + name; - Add(new cOsdItem(name.c_str()), true); + Add(new cOsdXmlItem(name.c_str(), childElement)); } } } @@ -100,7 +101,8 @@ eOSState cMenuOrgSetup::ProcessKey(eKeys Key) break; case kGreen: - state = AddSubMenu(new cMenuItemSetup(NULL)); + cOsdXmlItem *item=Get(Current()); + state = AddSubMenu(new cMenuItemSetup(item)); break; case kYellow: diff --git a/src/osdxmlitem.cpp b/src/osdxmlitem.cpp new file mode 100644 index 0000000..653f932 --- /dev/null +++ b/src/osdxmlitem.cpp @@ -0,0 +1,121 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + * + */ + +#include <vdr/menu.h> +#include <libxml++/libxml++.h> + +cOsdXmlItem::cOsdXmlItem(const char* Text, const xmlpp::Element* xmlElement, eOSState State=osUnknown) +{ + text = NULL; + offset = -1; + state = State; + selectable = true; + fresh = true; + _xmlElement = xmlElement; + parseXmlElement(); + SetText(Text); +} + +void cOsdXmlItem::parseXmlElement(void) +{ + const Attribute* nameAttribute = _xmlElement->get_attribute("name"); + + string type = childElement->get_name(); + string name = nameAttribute->get_value(); + + setNameAttribute(name); + + if (type == "system") + { + setItemType(SYSTEM); + const Attribute* titleAttribute = childElement->get_attribute("title"); + string title = titleAttribute ? (string) titleAttribute->get_value() : ""; + setTitleAttribute(title); + } + else if (type == "plugin") + { + setItemType(PLUGIN); + const Attribute* titleAttribute = childElement->get_attribute("title"); + string title = titleAttribute ? (string) titleAttribute->get_value() : ""; + setTitleAttribute(title); + } + else if ( type == "menu") + { + setItemType(MENU); + } + else if (type == "command") + { + setItemType(COMMAND); + setCommandAttribute(); + setConfirmAttribute(); + } +} + +sItemType getItemType(void) +{ + return _ItemType; +} + +string getNameAttribute(void) +{ + return _nameAttribute; +} + +string getTitleAttribute(void) +{ + return _titleAttribute; +} + +string getCommandAttribute(void) +{ + return _commandAttribute; +} + +string getConfirmAttribute(void) +{ + return _confirmAttribute; +} + +void setItemType(sItemType type) +{ + _ItemType = type; +} + +void setNameAttribute(string name); +{ + _nameAttribute = name; +} + +void setTitleAttribute(string title) +{ + _titleAttribute = title; +} + +void setCommandAttribute(string command) +{ + _commandAttribute = command; +} + +void setConfirmAttribute(string confirm) +{ + _confirmAttribute = confirm; +} diff --git a/src/osdxmlitem.h b/src/osdxmlitem.h new file mode 100644 index 0000000..6f00709 --- /dev/null +++ b/src/osdxmlitem.h @@ -0,0 +1,72 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + * + */ + +#ifndef ___OSDXMLITEM_H +#define ___OSDXMLITEM_H + +#include <string> +#include <vdr/menu.h> +#include <libxml++/libxml++.h> + +using namespace std; +namespace xmlpp { class Element; } + +class cOsdXmlItem: cOsdItem +{ + public: + const xmlpp::Element* _xmlElement; + + enum sItemType + { + SYSTEM = 0, + PLUGIN = 1, + MENU = 2, + COMMAND = 3 + }; + + private: + sItemType _ItemType; + string _nameAttribute; + string _titleAttribute; + string _commandAttribute; + string _confirmAttribute; + + public: + cOsdXmlItem(const char* Text, const xmlpp::Element* xmlElement, eOSState State=osUnknown); + + sItemType getItemType(void); + string getNameAttribute(void); + string getTitleAttribute(void); + string getCommandAttribute(void); + string getConfirmAttribute(void); + + void setItemType(sItemType type); + void setNameAttribute(string name); + void setTitleAttribute(string title); + void setCommandAttribute(string command); + void setConfirmAttribute(string confirm); + + private: + void parseXmlElement(void); // parse the xml element and set the private attributes +}; + +#endif |