From: GiWoong Kim Date: Tue, 3 Nov 2015 07:21:27 +0000 (+0900) Subject: XML: minor cleanup X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~40^2~79 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9f3075afffc360d0e695ee92621f76140cabba51;p=sdk%2Femulator%2Fqemu.git XML: minor cleanup - declare a makeGeneralCon function - call by reference - add some logs Change-Id: Ic14a41b222be25ff8e3c9b773ded17c8e6cc7dda Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/ui/layout/controllerform.cpp b/tizen/src/ui/layout/controllerform.cpp index 7151e2abc9..0cc8380a02 100644 --- a/tizen/src/ui/layout/controllerform.cpp +++ b/tizen/src/ui/layout/controllerform.cpp @@ -34,7 +34,7 @@ ControllerForm::ControllerForm(const QString &name) : LayoutForm(name) /* do nothing */ } -void ControllerForm::setCenteralRect(QRect rect) +void ControllerForm::setCenteralRect(const QRect &rect) { centeralRect = rect; } diff --git a/tizen/src/ui/layout/controllerform.h b/tizen/src/ui/layout/controllerform.h index 4ee4ffdfd5..45482b687a 100644 --- a/tizen/src/ui/layout/controllerform.h +++ b/tizen/src/ui/layout/controllerform.h @@ -42,7 +42,7 @@ public: ControllerForm(const QString &name); ~ControllerForm(); - void setCenteralRect(QRect rect); + void setCenteralRect(const QRect &rect); QRect getCenteralRect(); private: diff --git a/tizen/src/ui/layout/hovertype.cpp b/tizen/src/ui/layout/hovertype.cpp index 028832bf18..764ebb8f35 100644 --- a/tizen/src/ui/layout/hovertype.cpp +++ b/tizen/src/ui/layout/hovertype.cpp @@ -29,7 +29,7 @@ #include "hovertype.h" -HoverType::HoverType(QColor color) +HoverType::HoverType(const QColor &color) { this->color = color; this->fill = false; diff --git a/tizen/src/ui/layout/hovertype.h b/tizen/src/ui/layout/hovertype.h index 1798f86f0a..b54d764f1d 100644 --- a/tizen/src/ui/layout/hovertype.h +++ b/tizen/src/ui/layout/hovertype.h @@ -35,7 +35,7 @@ class HoverType { public: - HoverType(QColor color); + HoverType(const QColor &color); ~HoverType(); QColor getColor(); diff --git a/tizen/src/ui/qt5_supplement.cpp b/tizen/src/ui/qt5_supplement.cpp index cce567c7b6..6a79bad00c 100644 --- a/tizen/src/ui/qt5_supplement.cpp +++ b/tizen/src/ui/qt5_supplement.cpp @@ -483,7 +483,7 @@ void loadMainFormFromXML(QString xmlPath, UiInformation *uiInfo/* out */) QFileInfo fileInfo(xmlPath); XmlLayoutParser parser(fileInfo.absolutePath(), uiInfo); QString version = parser.parseEmulatorUI(xml); - qDebug() << "layout version:" << version; + qDebug() << "* main layout version:" << version; const bool hasError = xml.hasError(); xml.clear(); @@ -514,7 +514,7 @@ void loadConFormFromXML(QFile *file, UiInformation *uiInfo/* out */) QFileInfo fileInfo(*file); XmlLayoutParser parser(fileInfo.absolutePath(), uiInfo); QString version = parser.parseControllerUI(xml); - qDebug() << "layout version:" << version; + qDebug() << "* con layout version:" << version; const bool hasError = xml.hasError(); xml.clear(); diff --git a/tizen/src/ui/skinpainter.cpp b/tizen/src/ui/skinpainter.cpp index 57ce10a7b8..0dac529d34 100644 --- a/tizen/src/ui/skinpainter.cpp +++ b/tizen/src/ui/skinpainter.cpp @@ -35,8 +35,8 @@ #define COLOR_TAG_SIZE (4) -SkinPainter::SkinPainter(QString patchPath, QSize centerPatch, int degree, - QPoint tagLeftTop, QColor tagColor) +SkinPainter::SkinPainter(const QString &patchPath, + QSize centerPatch, int degree, QPoint tagLeftTop, QColor tagColor) { QString path = ":/images/" + patchPath + "/"; @@ -96,7 +96,7 @@ void SkinPainter::drawSkin(QString patchPath, QSize center, int degree, centeralRect0.topLeft(), matrix.mapRect(centeralRect0).size()); } -QImage SkinPainter::getSkinImage() +QImage SkinPainter::getSkinImage() const { return skin->toImage(); } diff --git a/tizen/src/ui/skinpainter.h b/tizen/src/ui/skinpainter.h index 653e1204c9..ad9be008ea 100644 --- a/tizen/src/ui/skinpainter.h +++ b/tizen/src/ui/skinpainter.h @@ -37,11 +37,11 @@ class SkinPainter { public: - SkinPainter(QString patchPath, QSize centerPatch, int degree, + SkinPainter(const QString &patchPath, QSize centerPatch, int degree, QPoint tagLeftTop, QColor tagColor); ~SkinPainter(); - QImage getSkinImage(); + QImage getSkinImage() const; QRect getCenteralRect(); private: diff --git a/tizen/src/ui/xmllayoutparser.cpp b/tizen/src/ui/xmllayoutparser.cpp index 485d6dc993..ee44618805 100644 --- a/tizen/src/ui/xmllayoutparser.cpp +++ b/tizen/src/ui/xmllayoutparser.cpp @@ -32,11 +32,12 @@ #include "skinpainter.h" #include "layout/keycodetype.h" #include "controller/generalpurposecon.h" +#include "resource/ui_strings.h" /* Qt Qlayout has a minimum size */ #define QT_LAYOUT_MINIMUM (73) -XmlLayoutParser::XmlLayoutParser(QString path, UiInformation *uiInfo) +XmlLayoutParser::XmlLayoutParser(const QString &path, UiInformation *uiInfo) { this->xmlPath = path; this->uiInfo = uiInfo; @@ -66,7 +67,7 @@ QColor XmlLayoutParser::parseColor(QXmlStreamReader &xml) HoverType *XmlLayoutParser::parseHover(QXmlStreamReader &xml) { - QColor color; + QColor color(255, 255, 255); QXmlStreamReader::TokenType token = xml.readNext(); @@ -78,6 +79,8 @@ HoverType *XmlLayoutParser::parseHover(QXmlStreamReader &xml) /* color */ color = parseColor(xml); qDebug() << "hover color:" << color.name(); + } else { + qWarning() << "undefined element:" << xml.name(); } } @@ -145,6 +148,8 @@ DisplayType *XmlLayoutParser::parseDisplay(QXmlStreamReader &xml) xmlPath + QDir::separator() + maskImageFileName) == false) { qWarning() << "failed to load mask image"; } + } else { + qWarning() << "undefined element:" << xml.name(); } } @@ -196,6 +201,8 @@ HardwareKey *XmlLayoutParser::parseKey(QXmlStreamReader &xml) } else if (xml.name() == SHORTCUT_KEYWORD) { /* shortcut */ keySequence = QKeySequence::fromString(xml.readElementText()); + } else { + qWarning() << "undefined element:" << xml.name(); } } @@ -220,6 +227,8 @@ int XmlLayoutParser::parseKeyList( if (hwKey != NULL) { list.append(hwKey); } + } else { + qWarning() << "undefined element:" << xml.name(); } } @@ -322,6 +331,8 @@ int XmlLayoutParser::parseMainFormList( list.append(form); } + } else { + qWarning() << "undefined element:" << xml.name(); } } @@ -347,6 +358,8 @@ int XmlLayoutParser::parseFactorList( if (xml.name() == FACTOR_KEYWORD) { QString value = xml.attributes().value(NAME_ATTR_KEYWORD).toString(); map.insert(xml.readElementText().toInt(), value); + } else { + qWarning() << "undefined element:" << xml.name(); } } @@ -382,6 +395,8 @@ AdvancedMenuItem *XmlLayoutParser::parseAdvancedMenuItem(QXmlStreamReader &xml) } else if (xml.name() == MENULIST_KEYWORD) { int cnt = parseMenuList(xml, item->getMenuList()); qDebug("- advanced menuList: %d", cnt); + } else { + qWarning() << "undefined element:" << xml.name(); } } @@ -411,6 +426,8 @@ ScaleMenuItem *XmlLayoutParser::parseScaleMenuItem(QXmlStreamReader &xml) qDebug("- scale factorList: %d", cnt); item->setDefaultScaleFactor(defaultFactor); + } else { + qWarning() << "undefined element:" << xml.name(); } } @@ -438,6 +455,8 @@ MenuItem *XmlLayoutParser::parseGeneralMenuItem( if (token == QXmlStreamReader::StartElement) { if (xml.name() == SHORTCUT_KEYWORD) { parseShortcuts(xml, item->getShortcutMap()); + } else { + qWarning() << "undefined element:" << xml.name(); } } @@ -487,6 +506,8 @@ int XmlLayoutParser::parseMenuList( item = parseGeneralMenuItem(xml, MenuItemType::forceCloseItem); } else if (xml.name() == CLOSE_MENU_KEYWORD) { item = parseGeneralMenuItem(xml, MenuItemType::closeItem); + } else { + qWarning() << "undefined element:" << xml.name(); } if (item != NULL) { @@ -502,13 +523,14 @@ int XmlLayoutParser::parseMenuList( QString XmlLayoutParser::parseEmulatorUI(QXmlStreamReader &xml) { - QString layoutVersion = "undefined"; + QString layoutVersion = GENERIC_TEXT_UNDEFINED; QXmlStreamReader::TokenType token; while (xml.atEnd() == false && xml.hasError() == false) { token = xml.readNext(); - /* If token is just StartDocument, go to next.*/ + + /* If token is just StartDocument, go to next. */ if (token == QXmlStreamReader::StartDocument) { continue; } @@ -527,6 +549,8 @@ QString XmlLayoutParser::parseEmulatorUI(QXmlStreamReader &xml) } else if (xml.name() == MENULIST_KEYWORD) { int cnt = parseMenuList(xml, uiInfo->getMenuList()); qDebug() << MENULIST_KEYWORD << ":" << cnt; + } else { + qWarning() << "undefined element:" << xml.name(); } } } @@ -590,14 +614,15 @@ ControllerForm *XmlLayoutParser::parseControllerForm(QXmlStreamReader &xml) QString XmlLayoutParser::parseControllerUI(QXmlStreamReader &xml) { - QString layoutVersion = "undefined"; + QString layoutVersion = GENERIC_TEXT_UNDEFINED; ControllerForm *form = NULL; QXmlStreamReader::TokenType token; while (xml.atEnd() == false && xml.hasError() == false) { token = xml.readNext(); - /* If token is just StartDocument, go to next.*/ + + /* If token is just StartDocument, go to next. */ if (token == QXmlStreamReader::StartDocument) { continue; } @@ -616,37 +641,41 @@ QString XmlLayoutParser::parseControllerUI(QXmlStreamReader &xml) /* image validation */ if (form->skinImg[LayoutForm::normal].size() == QSize(0, 0)) { qDebug("- general purpose con form"); - - int keyCount = form->getKeyList().count(); - - int width = GPC_KEYBUTTON_WIDTH; - int height = GPC_HEAD_SPACING; - if (keyCount < GPC_KEYBUTTON_DEFAULT_CNT) { - height += (GPC_KEYBUTTON_HEIGHT * keyCount) + - (GPC_KEYBUTTON_VSPACING * (keyCount - 1)) + - GPC_TAIL_SPACING; - } else { - width += (GPC_SCROLLBAR_WIDTH + GPC_SCROLLBAR_HSPACING); - height += (GPC_KEYBUTTON_HEIGHT * GPC_KEYBUTTON_DEFAULT_CNT) + - (GPC_KEYBUTTON_VSPACING * (GPC_KEYBUTTON_DEFAULT_CNT - 1)) + - GPC_TAIL_SPACING; - } - - SkinPainter painter("controller-skin", - QSize(width, qMax(height, QT_LAYOUT_MINIMUM - 20)), - 0, QPoint(14, GPC_HEAD_SPACING - 1), - uiInfo->getVMColor()); - form->setGeneralPurpose(true); - - form->skinImg[LayoutForm::normal] = painter.getSkinImage(); - form->setCenteralRect(painter.getCenteralRect()); + makeGeneralCon(form); } uiInfo->getConFormList().append(form); } + } else { + qWarning() << "undefined element:" << xml.name(); } } } return layoutVersion; } + +void XmlLayoutParser::makeGeneralCon(ControllerForm *form) +{ + const int keyCount = form->getKeyList().count(); + + int width = GPC_KEYBUTTON_WIDTH; + int height = GPC_HEAD_SPACING; + if (keyCount < GPC_KEYBUTTON_DEFAULT_CNT) { + height += (GPC_KEYBUTTON_HEIGHT * keyCount) + + (GPC_KEYBUTTON_VSPACING * (keyCount - 1)) + GPC_TAIL_SPACING; + } else { + width += (GPC_SCROLLBAR_WIDTH + GPC_SCROLLBAR_HSPACING); + height += (GPC_KEYBUTTON_HEIGHT * GPC_KEYBUTTON_DEFAULT_CNT) + + (GPC_KEYBUTTON_VSPACING * (GPC_KEYBUTTON_DEFAULT_CNT - 1)) + + GPC_TAIL_SPACING; + } + + SkinPainter painter("controller-skin", + QSize(width, qMax(height, QT_LAYOUT_MINIMUM - 20)), 0, + QPoint(14, GPC_HEAD_SPACING - 1), uiInfo->getVMColor()); + + form->skinImg[LayoutForm::normal] = painter.getSkinImage(); + form->setCenteralRect(painter.getCenteralRect()); + form->setGeneralPurpose(true); +} diff --git a/tizen/src/ui/xmllayoutparser.h b/tizen/src/ui/xmllayoutparser.h index 4b8d4dd79a..804ce41573 100644 --- a/tizen/src/ui/xmllayoutparser.h +++ b/tizen/src/ui/xmllayoutparser.h @@ -44,7 +44,7 @@ class XmlLayoutParser { public: - XmlLayoutParser(QString path, UiInformation *uiInfo /* out */); + XmlLayoutParser(const QString &path, UiInformation *uiInfo /* out */); QString parseEmulatorUI(QXmlStreamReader &xml); QString parseControllerUI(QXmlStreamReader &xml); @@ -68,6 +68,7 @@ private: int parseMenuList(QXmlStreamReader &xml, QList &list); ControllerForm *parseControllerForm(QXmlStreamReader &xml); + void makeGeneralCon(ControllerForm *form); QString xmlPath; UiInformation *uiInfo;