XML: minor cleanup
authorGiWoong Kim <giwoong.kim@samsung.com>
Tue, 3 Nov 2015 07:21:27 +0000 (16:21 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Wed, 11 Nov 2015 04:30:12 +0000 (13:30 +0900)
- declare a makeGeneralCon function
- call by reference
- add some logs

Change-Id: Ic14a41b222be25ff8e3c9b773ded17c8e6cc7dda
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/ui/layout/controllerform.cpp
tizen/src/ui/layout/controllerform.h
tizen/src/ui/layout/hovertype.cpp
tizen/src/ui/layout/hovertype.h
tizen/src/ui/qt5_supplement.cpp
tizen/src/ui/skinpainter.cpp
tizen/src/ui/skinpainter.h
tizen/src/ui/xmllayoutparser.cpp
tizen/src/ui/xmllayoutparser.h

index 7151e2abc9a470a658e710999d2dd816c65b9bcb..0cc8380a0241d7b85a51d1efc3f37597b4a7de0a 100644 (file)
@@ -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;
 }
index 4ee4ffdfd53b42e55c7678baa54e047f09ae08e7..45482b687af52c33784d5e5396d85a16b840c006 100644 (file)
@@ -42,7 +42,7 @@ public:
     ControllerForm(const QString &name);
     ~ControllerForm();
 
-    void setCenteralRect(QRect rect);
+    void setCenteralRect(const QRect &rect);
     QRect getCenteralRect();
 
 private:
index 028832bf1843df771f27eabc1eb03b7895279144..764ebb8f359cec4b66d62dd3401f14bbb0e24091 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "hovertype.h"
 
-HoverType::HoverType(QColor color)
+HoverType::HoverType(const QColor &color)
 {
     this->color = color;
     this->fill = false;
index 1798f86f0a7771c2a821205bae20675b509f61a2..b54d764f1d337ba6a76f457aaf144dad0312cd67 100644 (file)
@@ -35,7 +35,7 @@
 class HoverType
 {
 public:
-    HoverType(QColor color);
+    HoverType(const QColor &color);
     ~HoverType();
 
     QColor getColor();
index cce567c7b6030be77a53e10e8911fca3de825c04..6a79bad00cf952c380322634a57e07009f67b06c 100644 (file)
@@ -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();
index 57ce10a7b8f8e425a1f61cba08d8d0597c2b8018..0dac529d34eb71fcd67def6516b8d4f65980f832 100644 (file)
@@ -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();
 }
index 653e1204c916431425779e88b9296b26bee3410b..ad9be008eaf908bc1f8aa0793917d3efae29635f 100644 (file)
 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:
index 485d6dc993ba940e1b9b34b8b536055fa91c3542..ee44618805f6c88b30f7c8f889cedbd8dcfc2cbc 100644 (file)
 #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);
+}
index 4b8d4dd79a07f138730e8ab1b8ab5e8ceea5b007..804ce41573e0a9463b9e4f4a5fa9c8ac56ff115e 100644 (file)
@@ -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<MenuItem *> &list);
 
     ControllerForm *parseControllerForm(QXmlStreamReader &xml);
+    void makeGeneralCon(ControllerForm *form);
 
     QString xmlPath;
     UiInformation *uiInfo;