summaryrefslogtreecommitdiff
path: root/tizen
diff options
context:
space:
mode:
authorGiWoong Kim <giwoong.kim@samsung.com>2015-12-04 19:13:50 +0900
committerGiWoong Kim <giwoong.kim@samsung.com>2015-12-08 14:32:22 +0900
commit1ea27884373ee071b9eb382b7d6faf738db7a2b8 (patch)
tree668b1c90f95ad5c372cf9c49c6f4d28c2711525e /tizen
parent8d02f26a53514bf35eb1d4e1687394944fad3967 (diff)
downloadqemu-1ea27884373ee071b9eb382b7d6faf738db7a2b8.tar.gz
qemu-1ea27884373ee071b9eb382b7d6faf738db7a2b8.tar.bz2
qemu-1ea27884373ee071b9eb382b7d6faf738db7a2b8.zip
layout: minor improvements for XML parser
- use const type variables - delete an unnecessary error popup call - add some logs Change-Id: I3662284c0b329f683a4ca0e5f9a3e0748b70f336 Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
Diffstat (limited to 'tizen')
-rw-r--r--tizen/src/ui/xmllayoutparser.cpp106
-rw-r--r--tizen/src/ui/xmllayoutparser.h35
2 files changed, 84 insertions, 57 deletions
diff --git a/tizen/src/ui/xmllayoutparser.cpp b/tizen/src/ui/xmllayoutparser.cpp
index a37e2bb216..5e87848108 100644
--- a/tizen/src/ui/xmllayoutparser.cpp
+++ b/tizen/src/ui/xmllayoutparser.cpp
@@ -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
@@ -62,7 +63,7 @@ QString XmlLayoutParser::getIndenting(int depth) {
return indenting;
}
-QColor XmlLayoutParser::parseColor(QXmlStreamReader &xml, int depth)
+QColor XmlLayoutParser::parseColor(QXmlStreamReader &xml, const int depth)
{
int red = 0, green = 0, blue = 0;
@@ -84,7 +85,7 @@ QColor XmlLayoutParser::parseColor(QXmlStreamReader &xml, int depth)
return QColor(red, green, blue, 255);
}
-HoverType XmlLayoutParser::parseHover(QXmlStreamReader &xml, int depth)
+HoverType XmlLayoutParser::parseHover(QXmlStreamReader &xml, const int depth)
{
QColor color(255, 255, 255);
@@ -113,7 +114,7 @@ HoverType XmlLayoutParser::parseHover(QXmlStreamReader &xml, int depth)
return HoverType(color);
}
-QRect XmlLayoutParser::parseRegion(QXmlStreamReader &xml, int depth)
+QRect XmlLayoutParser::parseRegion(QXmlStreamReader &xml, const int depth)
{
int left = 0, top = 0;
unsigned int width = 0, height = 0;
@@ -139,9 +140,9 @@ QRect XmlLayoutParser::parseRegion(QXmlStreamReader &xml, int depth)
return QRect(left, top, width, height);
}
-DisplayType *XmlLayoutParser::parseDisplay(QXmlStreamReader &xml, int depth)
+DisplayType *XmlLayoutParser::parseDisplay(QXmlStreamReader &xml, const int depth)
{
- QRect displayRect;
+ QRect displayRect(0, 0, 0, 0);
int angle = 0;
QPixmap maskImage;
@@ -185,7 +186,7 @@ DisplayType *XmlLayoutParser::parseDisplay(QXmlStreamReader &xml, int depth)
return new DisplayType(displayRect, angle, maskImage);
}
-KeycodeType XmlLayoutParser::parseKeycode(QXmlStreamReader &xml, int depth)
+KeycodeType XmlLayoutParser::parseKeycode(QXmlStreamReader &xml, const int depth)
{
int longPress = -1, shortPress = 0;
@@ -197,7 +198,7 @@ KeycodeType XmlLayoutParser::parseKeycode(QXmlStreamReader &xml, int depth)
return KeycodeType(shortPress, longPress);
}
-HardwareKey *XmlLayoutParser::parseKey(QXmlStreamReader &xml, int depth)
+HardwareKey *XmlLayoutParser::parseKey(QXmlStreamReader &xml, const int depth)
{
QRect keyRegion;
KeycodeType keycodeType;
@@ -237,7 +238,7 @@ HardwareKey *XmlLayoutParser::parseKey(QXmlStreamReader &xml, int depth)
}
int XmlLayoutParser::parseKeyList(QXmlStreamReader &xml,
- int depth, QList<HardwareKey *> &list)
+ const int depth, QList<HardwareKey *> &list)
{
HardwareKey *hwKey = NULL;
@@ -263,7 +264,7 @@ int XmlLayoutParser::parseKeyList(QXmlStreamReader &xml,
return list.count();
}
-MainForm *XmlLayoutParser::parseMainForm(QXmlStreamReader &xml, int depth)
+MainForm *XmlLayoutParser::parseMainForm(QXmlStreamReader &xml, const int depth)
{
/* attribute */
QString formName = xml.attributes().value(NAME_ATTR_KEYWORD).toString();
@@ -333,7 +334,7 @@ MainForm *XmlLayoutParser::parseMainForm(QXmlStreamReader &xml, int depth)
}
int XmlLayoutParser::parseMainFormList(QXmlStreamReader &xml,
- int depth, QList<MainForm *> &list)
+ const int depth, QList<MainForm *> &list)
{
MainForm *form = NULL;
@@ -378,7 +379,7 @@ int XmlLayoutParser::parseMainFormList(QXmlStreamReader &xml,
/* menu */
int XmlLayoutParser::parseFactorList(QXmlStreamReader &xml,
- int depth, QMap<int, QString> &map, int *defaultFactor)
+ const int depth, QMap<int, QString> &map, int *defaultFactor)
{
QString defaultValue = xml.attributes().value(DEFAULT_ATTR_KEYWORD).toString();
*defaultFactor = defaultValue.toInt();
@@ -404,7 +405,7 @@ int XmlLayoutParser::parseFactorList(QXmlStreamReader &xml,
}
int XmlLayoutParser::parseShortcuts(QXmlStreamReader &xml,
- int depth, QMap<QString, QKeySequence> &map)
+ const int depth, QMap<QString, QKeySequence> &map)
{
QString key = xml.attributes().value(PROP_ATTR_KEYWORD).toString();
map.insert(key, QKeySequence::fromString(xml.readElementText()));
@@ -412,7 +413,8 @@ int XmlLayoutParser::parseShortcuts(QXmlStreamReader &xml,
return map.count();
}
-AdvancedMenuItem *XmlLayoutParser::parseAdvancedMenuItem(QXmlStreamReader &xml, int depth)
+AdvancedMenuItem *XmlLayoutParser::parseAdvancedMenuItem(
+ QXmlStreamReader &xml, const int depth)
{
/* attribute */
QString menuName = xml.attributes().value(NAME_ATTR_KEYWORD).toString();
@@ -444,7 +446,8 @@ AdvancedMenuItem *XmlLayoutParser::parseAdvancedMenuItem(QXmlStreamReader &xml,
return item;
}
-ScaleMenuItem *XmlLayoutParser::parseScaleMenuItem(QXmlStreamReader &xml, int depth)
+ScaleMenuItem *XmlLayoutParser::parseScaleMenuItem(
+ QXmlStreamReader &xml, const int depth)
{
/* attribute */
QString menuName = xml.attributes().value(NAME_ATTR_KEYWORD).toString();
@@ -481,7 +484,7 @@ ScaleMenuItem *XmlLayoutParser::parseScaleMenuItem(QXmlStreamReader &xml, int de
}
MenuItem *XmlLayoutParser::parseGeneralMenuItem(
- QXmlStreamReader &xml, int depth, int menuType)
+ QXmlStreamReader &xml, const int depth, int menuType)
{
QString itemKeyword = xml.name().toString();
@@ -510,7 +513,7 @@ MenuItem *XmlLayoutParser::parseGeneralMenuItem(
}
int XmlLayoutParser::parseMenuList(QXmlStreamReader &xml,
- int depth, QList<MenuItem *> &list)
+ const int depth, QList<MenuItem *> &list)
{
MenuItem *item = NULL;
@@ -518,58 +521,77 @@ int XmlLayoutParser::parseMenuList(QXmlStreamReader &xml,
QDEBUG_INDENT(depth) << MENULIST_KEYWORD << " {";
QXmlStreamReader::TokenType token = xml.readNext();
+ QString tokenName = xml.name().toString();
- while (xml.atEnd() == false && (xml.name() == MENULIST_KEYWORD &&
+ while (xml.atEnd() == false && (tokenName == MENULIST_KEYWORD &&
token == QXmlStreamReader::EndElement) == false) /* ~ </menuList> */
{
if (token == QXmlStreamReader::StartElement) {
- if (xml.name() == SEPARATOR_MENU_KEYWORD) {
+ if (tokenName == SEPARATOR_MENU_KEYWORD) {
+ /* separator */
item = new MenuItem(MenuItemType::separator, NULL);
- } else if (xml.name() == ADVANCED_MENU_KEYWORD) {
- item = (MenuItem *)parseAdvancedMenuItem(xml, depth + 1);
- } else if (xml.name() == INFO_MENU_KEYWORD) {
+ } else if (tokenName == ADVANCED_MENU_KEYWORD) {
+ /* 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 (xml.name() == ONTOP_MENU_KEYWORD) {
+ } else if (tokenName == ONTOP_MENU_KEYWORD) {
+ /* Always on Top */
item = parseGeneralMenuItem(
xml, depth + 1, MenuItemType::onTopItem);
- } else if (xml.name() == MOVE_MENU_KEYWORD) {
+ } else if (tokenName == MOVE_MENU_KEYWORD) {
+ /* Move */
item = parseGeneralMenuItem(
xml, depth + 1, MenuItemType::moveItem);
- } else if (xml.name() == SWITCH_MENU_KEYWORD) {
+ } else if (tokenName == SWITCH_MENU_KEYWORD) {
+ /* Rotate */
item = parseGeneralMenuItem(
xml, depth + 1, MenuItemType::switchItem);
- } else if (xml.name() == SCALE_MENU_KEYWORD) {
- item = (MenuItem *)parseScaleMenuItem(xml, depth + 1);
- } else if (xml.name() == CONTROLLER_MENU_KEYWORD) {
+ } else if (tokenName == SCALE_MENU_KEYWORD) {
+ /* 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 (xml.name() == HOSTKBD_MENU_KEYWORD) {
+ } else if (tokenName == HOSTKBD_MENU_KEYWORD) {
+ /* Host Keyboard */
item = parseGeneralMenuItem(
xml, depth + 1, MenuItemType::hostKeyboardItem);
- } else if (xml.name() == SHELL_MENU_KEYWORD) {
+ } else if (tokenName == SHELL_MENU_KEYWORD) {
+ /* Shell */
item = parseGeneralMenuItem(
xml, depth + 1, MenuItemType::shellItem);
- } else if (xml.name() == ECP_MENU_KEYWORD) {
+ } else if (tokenName == ECP_MENU_KEYWORD) {
+ /* Control Panel */
item = parseGeneralMenuItem(
xml, depth + 1, MenuItemType::controlPanelItem);
- } else if (xml.name() == SCREENSHOT_MENU_KEYWORD) {
+ } else if (tokenName == SCREENSHOT_MENU_KEYWORD) {
+ /* Screen Shot */
item = parseGeneralMenuItem(
xml, depth + 1, MenuItemType::screenShotItem);
- } else if (xml.name() == ABOUT_MENU_KEYWORD) {
+ } else if (tokenName == ABOUT_MENU_KEYWORD) {
+ /* About */
item = parseGeneralMenuItem(
xml, depth + 1, MenuItemType::aboutItem);
- } else if (xml.name() == SYSTEM_RESET_MENU_KEYWORD) {
+ } else if (tokenName == SYSTEM_RESET_MENU_KEYWORD) {
+ /* Reboot */
item = parseGeneralMenuItem(
xml, depth + 1, MenuItemType::systemResetItem);
- } else if (xml.name() == FORCECLOSE_MENU_KEYWORD) {
+ } else if (tokenName == FORCECLOSE_MENU_KEYWORD) {
+ /* Force Close */
item = parseGeneralMenuItem(
xml, depth + 1, MenuItemType::forceCloseItem);
- } else if (xml.name() == CLOSE_MENU_KEYWORD) {
+ } else if (tokenName == CLOSE_MENU_KEYWORD) {
+ /* Close */
item = parseGeneralMenuItem(
xml, depth + 1, MenuItemType::closeItem);
} else {
- QWARN_INDENT(depth + 1) << "undefined element: " << xml.name();
+ QWARN_INDENT(depth + 1) << "undefined element: " << tokenName;
}
if (item != NULL) {
@@ -578,6 +600,7 @@ int XmlLayoutParser::parseMenuList(QXmlStreamReader &xml,
}
token = xml.readNext();
+ tokenName = xml.name().toString();
}
QDEBUG_INDENT(depth) << "}";
@@ -588,7 +611,7 @@ int XmlLayoutParser::parseMenuList(QXmlStreamReader &xml,
QString XmlLayoutParser::parseEmulatorUI(QXmlStreamReader &xml)
{
QString layoutVersion = GENERIC_TEXT_UNDEFINED;
- int depth = 0;
+ const int depth = 0;
qDebug(LOG_LINE_HEAD_CHAR);
QDEBUG_INDENT(depth) << EMULATOR_UI_KEYWORD << " {";
@@ -637,7 +660,8 @@ QString XmlLayoutParser::parseEmulatorUI(QXmlStreamReader &xml)
}
/* controller */
-ControllerForm *XmlLayoutParser::parseControllerForm(QXmlStreamReader &xml, int depth)
+ControllerForm *XmlLayoutParser::parseControllerForm(
+ QXmlStreamReader &xml, const int depth)
{
/* attribute */
QString formName = xml.attributes().value(NAME_ATTR_KEYWORD).toString();
@@ -695,7 +719,7 @@ ControllerForm *XmlLayoutParser::parseControllerForm(QXmlStreamReader &xml, int
QString XmlLayoutParser::parseControllerUI(QXmlStreamReader &xml)
{
QString layoutVersion = GENERIC_TEXT_UNDEFINED;
- int depth = 0;
+ const int depth = 0;
qDebug(LOG_LINE_HEAD_CHAR);
QDEBUG_INDENT(depth) << CONTROLLER_UI_KEYWORD << " {";
@@ -789,7 +813,7 @@ void XmlLayoutParser::printError(QXmlStreamReader::Error err)
qCritical("The input stream ended before a well-formed XML document was parsed.");
break;
default:
- qFatal("invalid error type");
+ qCritical("Unexpected error type was returned.");
break;
}
}
diff --git a/tizen/src/ui/xmllayoutparser.h b/tizen/src/ui/xmllayoutparser.h
index 96f1cdf054..16213e0a64 100644
--- a/tizen/src/ui/xmllayoutparser.h
+++ b/tizen/src/ui/xmllayoutparser.h
@@ -51,27 +51,30 @@ public:
QString parseControllerUI(QXmlStreamReader &xml);
private:
- QColor parseColor(QXmlStreamReader &xml, int depth);
- HoverType parseHover(QXmlStreamReader &xml, int depth);
- QRect parseRegion(QXmlStreamReader &xml, int depth);
- DisplayType *parseDisplay(QXmlStreamReader &xml, int depth);
- KeycodeType parseKeycode(QXmlStreamReader &xml, int depth);
- HardwareKey *parseKey(QXmlStreamReader &xml, int depth);
- int parseKeyList(QXmlStreamReader &xml, int depth, QList<HardwareKey *> &list);
- MainForm *parseMainForm(QXmlStreamReader &xml, int depth);
+ QColor parseColor(QXmlStreamReader &xml, const int depth);
+ HoverType parseHover(QXmlStreamReader &xml, const int depth);
+ QRect parseRegion(QXmlStreamReader &xml, const int depth);
+ DisplayType *parseDisplay(QXmlStreamReader &xml, const int depth);
+ KeycodeType parseKeycode(QXmlStreamReader &xml, const int depth);
+ HardwareKey *parseKey(QXmlStreamReader &xml, const int depth);
+ int parseKeyList(QXmlStreamReader &xml,
+ const int depth, QList<HardwareKey *> &list);
+ MainForm *parseMainForm(QXmlStreamReader &xml, const int depth);
int parseMainFormList(QXmlStreamReader &xml,
- int depth, QList<MainForm *> &list);
+ const int depth, QList<MainForm *> &list);
int parseFactorList(QXmlStreamReader &xml,
- int depth, QMap<int, QString> &map, int *defaultFactor);
+ const int depth, QMap<int, QString> &map, int *defaultFactor);
int parseShortcuts(QXmlStreamReader &xml,
- int depth, QMap<QString, QKeySequence> &map);
- AdvancedMenuItem *parseAdvancedMenuItem(QXmlStreamReader &xml, int depth);
- ScaleMenuItem *parseScaleMenuItem(QXmlStreamReader &xml, int depth);
- MenuItem *parseGeneralMenuItem(QXmlStreamReader &xml, int depth, int menuType);
- int parseMenuList(QXmlStreamReader &xml, int depth, QList<MenuItem *> &list);
+ const int depth, QMap<QString, QKeySequence> &map);
+ AdvancedMenuItem *parseAdvancedMenuItem(QXmlStreamReader &xml, const int depth);
+ ScaleMenuItem *parseScaleMenuItem(QXmlStreamReader &xml, const int depth);
+ MenuItem *parseGeneralMenuItem(QXmlStreamReader &xml,
+ const int depth, int menuType);
+ int parseMenuList(QXmlStreamReader &xml,
+ const int depth, QList<MenuItem *> &list);
- ControllerForm *parseControllerForm(QXmlStreamReader &xml, int depth);
+ ControllerForm *parseControllerForm(QXmlStreamReader &xml, const int depth);
void makeGeneralCon(ControllerForm *form);
void printError(QXmlStreamReader::Error err);