diff options
author | GiWoong Kim <giwoong.kim@samsung.com> | 2015-12-11 17:03:14 +0900 |
---|---|---|
committer | GiWoong Kim <giwoong.kim@samsung.com> | 2015-12-14 16:04:57 +0900 |
commit | 9375772197bc5898101bca98c10926f5bd203ad7 (patch) | |
tree | 1e71943026bc25495154ff3c7ec57425d7fea502 /tizen | |
parent | d78b475e882c242050d248e5456c7743f3df60f8 (diff) | |
download | qemu-9375772197bc5898101bca98c10926f5bd203ad7.tar.gz qemu-9375772197bc5898101bca98c10926f5bd203ad7.tar.bz2 qemu-9375772197bc5898101bca98c10926f5bd203ad7.zip |
layout: use enum type variables for menu parsing
Change-Id: I65785ee1fbf3c3b3352e5c9c7eb4d4ad30c49252
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
Diffstat (limited to 'tizen')
-rw-r--r-- | tizen/src/ui/xmllayoutparser.cpp | 109 | ||||
-rw-r--r-- | tizen/src/ui/xmllayoutparser.h | 4 |
2 files changed, 52 insertions, 61 deletions
diff --git a/tizen/src/ui/xmllayoutparser.cpp b/tizen/src/ui/xmllayoutparser.cpp index 5e87848108..bceb6414cc 100644 --- a/tizen/src/ui/xmllayoutparser.cpp +++ b/tizen/src/ui/xmllayoutparser.cpp @@ -47,6 +47,23 @@ XmlLayoutParser::XmlLayoutParser(const QString &path, UiInformation *uiInfo) { this->xmlPath = path; this->uiInfo = uiInfo; + + menuItems.insert(SEPARATOR_MENU_KEYWORD, MenuItemType::separator); + menuItems.insert(ADVANCED_MENU_KEYWORD, MenuItemType::advancedItem); + menuItems.insert(INFO_MENU_KEYWORD, MenuItemType::infoItem); + menuItems.insert(ONTOP_MENU_KEYWORD, MenuItemType::onTopItem); + menuItems.insert(MOVE_MENU_KEYWORD, MenuItemType::moveItem); + menuItems.insert(SWITCH_MENU_KEYWORD, MenuItemType::switchItem); + menuItems.insert(SCALE_MENU_KEYWORD, MenuItemType::scaleItem); + menuItems.insert(CONTROLLER_MENU_KEYWORD, MenuItemType::controllerItem); + menuItems.insert(HOSTKBD_MENU_KEYWORD, MenuItemType::hostKeyboardItem); + menuItems.insert(SHELL_MENU_KEYWORD, MenuItemType::shellItem); + menuItems.insert(ECP_MENU_KEYWORD, MenuItemType::controlPanelItem); + menuItems.insert(SCREENSHOT_MENU_KEYWORD, MenuItemType::screenShotItem); + menuItems.insert(ABOUT_MENU_KEYWORD, MenuItemType::aboutItem); + menuItems.insert(SYSTEM_RESET_MENU_KEYWORD, MenuItemType::systemResetItem); + menuItems.insert(FORCECLOSE_MENU_KEYWORD, MenuItemType::forceCloseItem); + menuItems.insert(CLOSE_MENU_KEYWORD, MenuItemType::closeItem); } QString XmlLayoutParser::getIndenting(int depth) { @@ -527,71 +544,43 @@ int XmlLayoutParser::parseMenuList(QXmlStreamReader &xml, token == QXmlStreamReader::EndElement) == false) /* ~ </menuList> */ { if (token == QXmlStreamReader::StartElement) { - if (tokenName == SEPARATOR_MENU_KEYWORD) { - /* separator */ - item = new MenuItem(MenuItemType::separator, NULL); - } else if (tokenName == ADVANCED_MENU_KEYWORD) { - /* Advanced */ + const int menuType = menuItems.value(tokenName, -1); + + switch(menuType) { + case MenuItemType::separator: + // separator + item = new MenuItem(menuType, NULL); + break; + case MenuItemType::advancedItem: + // Advanced item = dynamic_cast<MenuItem *>( parseAdvancedMenuItem(xml, depth + 1)); - } else if (tokenName == INFO_MENU_KEYWORD) { - /* Detailed Info */ - item = parseGeneralMenuItem( - xml, depth + 1, MenuItemType::infoItem); - } else if (tokenName == ONTOP_MENU_KEYWORD) { - /* Always on Top */ - item = parseGeneralMenuItem( - xml, depth + 1, MenuItemType::onTopItem); - } else if (tokenName == MOVE_MENU_KEYWORD) { - /* Move */ - item = parseGeneralMenuItem( - xml, depth + 1, MenuItemType::moveItem); - } else if (tokenName == SWITCH_MENU_KEYWORD) { - /* Rotate */ - item = parseGeneralMenuItem( - xml, depth + 1, MenuItemType::switchItem); - } else if (tokenName == SCALE_MENU_KEYWORD) { - /* Scale */ + break; + case MenuItemType::scaleItem: + // Scale item = dynamic_cast<MenuItem *>( parseScaleMenuItem(xml, depth + 1)); - } else if (tokenName == CONTROLLER_MENU_KEYWORD) { - /* Controller */ - item = parseGeneralMenuItem( - xml, depth + 1, MenuItemType::controllerItem); - } else if (tokenName == HOSTKBD_MENU_KEYWORD) { - /* Host Keyboard */ - item = parseGeneralMenuItem( - xml, depth + 1, MenuItemType::hostKeyboardItem); - } else if (tokenName == SHELL_MENU_KEYWORD) { - /* Shell */ - item = parseGeneralMenuItem( - xml, depth + 1, MenuItemType::shellItem); - } else if (tokenName == ECP_MENU_KEYWORD) { - /* Control Panel */ - item = parseGeneralMenuItem( - xml, depth + 1, MenuItemType::controlPanelItem); - } else if (tokenName == SCREENSHOT_MENU_KEYWORD) { - /* Screen Shot */ - item = parseGeneralMenuItem( - xml, depth + 1, MenuItemType::screenShotItem); - } else if (tokenName == ABOUT_MENU_KEYWORD) { - /* About */ - item = parseGeneralMenuItem( - xml, depth + 1, MenuItemType::aboutItem); - } else if (tokenName == SYSTEM_RESET_MENU_KEYWORD) { - /* Reboot */ - item = parseGeneralMenuItem( - xml, depth + 1, MenuItemType::systemResetItem); - } else if (tokenName == FORCECLOSE_MENU_KEYWORD) { - /* Force Close */ - item = parseGeneralMenuItem( - xml, depth + 1, MenuItemType::forceCloseItem); - } else if (tokenName == CLOSE_MENU_KEYWORD) { - /* Close */ - item = parseGeneralMenuItem( - xml, depth + 1, MenuItemType::closeItem); - } else { + break; + case MenuItemType::infoItem: + case MenuItemType::onTopItem: + case MenuItemType::moveItem: + case MenuItemType::switchItem: + case MenuItemType::controllerItem: + case MenuItemType::hostKeyboardItem: + case MenuItemType::shellItem: + case MenuItemType::controlPanelItem: + case MenuItemType::screenShotItem: + case MenuItemType::aboutItem: + case MenuItemType::systemResetItem: + case MenuItemType::forceCloseItem: + /* fall through */ + case MenuItemType::closeItem: + item = parseGeneralMenuItem(xml, depth + 1, menuType); + break; + default: QWARN_INDENT(depth + 1) << "undefined element: " << tokenName; + item = NULL; + break; } if (item != NULL) { diff --git a/tizen/src/ui/xmllayoutparser.h b/tizen/src/ui/xmllayoutparser.h index 16213e0a64..e6bcf80b94 100644 --- a/tizen/src/ui/xmllayoutparser.h +++ b/tizen/src/ui/xmllayoutparser.h @@ -5,7 +5,8 @@ * * Contact: * GiWoong Kim <giwoong.kim@samsung.com> - * Sangho Park <sangho1206.park@samsung.com> + * SeokYeon Hwang <syeon.hwang@samsung.com> + * Sangho Park <sangho.p@samsung.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -81,6 +82,7 @@ private: QString xmlPath; UiInformation *uiInfo; + QHash<QString, int> menuItems; }; #endif // XMLLAYOUTPARSER_H |