layout: remove duplicated members between MainForm and ControllerForm
authorGiWoong Kim <giwoong.kim@samsung.com>
Mon, 24 Aug 2015 07:20:36 +0000 (16:20 +0900)
committerSangho Park <sangho.p@samsung.com>
Wed, 26 Aug 2015 04:24:47 +0000 (13:24 +0900)
move member variables/functions which are related HW keys and
skin images to LayoutForm(parent) class.

Change-Id: Ieae51159c1c51d9e726a7b7d726b71c1702b9507
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
18 files changed:
tizen/src/ui/controller/dockingconview.cpp
tizen/src/ui/controller/dockingconview.h
tizen/src/ui/controller/floatingcontroller.cpp
tizen/src/ui/controller/floatingconview.cpp
tizen/src/ui/controller/floatingconview.h
tizen/src/ui/input/keyboardshortcut.cpp
tizen/src/ui/input/keyboardshortcut.h
tizen/src/ui/layout/controllerform.h
tizen/src/ui/layout/layoutform.cpp
tizen/src/ui/layout/layoutform.h
tizen/src/ui/layout/mainform.cpp
tizen/src/ui/layout/mainform.h
tizen/src/ui/mainwindow.cpp
tizen/src/ui/menu/detailedinfodialog.cpp
tizen/src/ui/menu/detailedinfodialog.h
tizen/src/ui/skinview.cpp
tizen/src/ui/uiinformation.cpp
tizen/src/ui/xmllayoutparser.cpp

index e8d4625..514534c 100644 (file)
@@ -55,11 +55,11 @@ DockingConView::DockingConView(ControllerForm *conForm, QGraphicsScene *scene, Q
 void DockingConView::createItems(ControllerForm *conForm)
 {
     /* bezel */
-    bezelItem = new SkinBezelItem(conForm->conImg[ControllerForm::normal]);
+    bezelItem = new SkinBezelItem(conForm->skinImg[LayoutForm::normal]);
     scene()->addItem(bezelItem);
 
     /* HW keys */
-    keyList = conForm->keyList;
+    QList<HardwareKey *> &keyList = conForm->getKeyList();
 
     if (conForm->isGeneralPurpose() == false) {
         HardwareKey *hwKey = NULL;
@@ -67,7 +67,7 @@ void DockingConView::createItems(ControllerForm *conForm)
             hwKey = keyList.at(i);
             if (hwKey != NULL) {
                 new SkinKeyItem(bezelItem, hwKey,
-                    conForm->conImg[ControllerForm::pressed].copy(hwKey->getRegion()),
+                    conForm->skinImg[LayoutForm::pressed].copy(hwKey->getRegion()),
                     conForm->getHoverType());
             }
         }
@@ -189,11 +189,6 @@ int DockingConView::getConViewStatus()
     return conViewStat;
 }
 
-QList<HardwareKey *> DockingConView::getKeyList()
-{
-    return keyList;
-}
-
 DockingConView::~DockingConView()
 {
     qDebug("destroy docking controller view");
index 4c0659d..937ae6a 100644 (file)
@@ -45,7 +45,6 @@ class DockingConView : public QGraphicsView
 public:
     DockingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent = 0);
     ~DockingConView();
-    QList<HardwareKey *> getKeyList();
 
     enum conViewStatus {
         CONVIEW_PRESSED,
@@ -74,7 +73,6 @@ private:
     DockingController *parent;
     SkinBezelItem *bezelItem;
     QRubberBand *rubberBand;
-    QList<HardwareKey *> keyList;
 
     conViewStatus conViewStat;
 };
index ace2b18..eacdb77 100644 (file)
@@ -71,7 +71,7 @@ void FloatingController::showEvent(QShowEvent *event)
         menu->setChecked(true);
     }
 
-    QImage *baseImage = &(conForm->conImg[ControllerForm::normal]);
+    QImage *baseImage = &(conForm->skinImg[LayoutForm::normal]);
     if (baseImage->isNull() == true) {
         qWarning("invalid image for region");
     } else {
index 048d425..6d201e1 100644 (file)
@@ -56,11 +56,11 @@ FloatingConView::FloatingConView(ControllerForm *conForm, QGraphicsScene *scene,
 void FloatingConView::createItems(ControllerForm *conForm)
 {
     /* bezel */
-    bezelItem = new SkinBezelItem(conForm->conImg[ControllerForm::normal]);
+    bezelItem = new SkinBezelItem(conForm->skinImg[LayoutForm::normal]);
     scene()->addItem(bezelItem);
 
     /* HW keys */
-    keyList = conForm->keyList;
+    QList<HardwareKey *> &keyList = conForm->getKeyList();
 
     if (conForm->isGeneralPurpose() == false) {
         HardwareKey *hwKey = NULL;
@@ -68,7 +68,7 @@ void FloatingConView::createItems(ControllerForm *conForm)
             hwKey = keyList.at(i);
             if (hwKey != NULL) {
                 new SkinKeyItem(bezelItem, hwKey,
-                    conForm->conImg[ControllerForm::pressed].copy(hwKey->getRegion()),
+                    conForm->skinImg[LayoutForm::pressed].copy(hwKey->getRegion()),
                     conForm->getHoverType());
             }
         }
@@ -236,11 +236,6 @@ void FloatingConView::focusInEvent(QFocusEvent *event)
     win->activateWindow();
 }
 
-QList<HardwareKey *> FloatingConView::getKeyList()
-{
-    return keyList;
-}
-
 FloatingConView::~FloatingConView()
 {
     qDebug("destroy floating controller view");
index 5b39c72..1043364 100644 (file)
@@ -43,7 +43,6 @@ class FloatingConView : public QGraphicsView
 public:
     FloatingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent = 0);
     ~FloatingConView();
-    QList<HardwareKey *> getKeyList();
 
 protected:
     void resizeEvent(QResizeEvent *event);
@@ -63,7 +62,6 @@ private:
     FloatingController *parent;
     SkinBezelItem *bezelItem;
     QRubberBand *rubberBand;
-    QList<HardwareKey *> keyList;
 };
 
 #endif // FLOATINGCONVIEW_H
index 934cc49..3081e49 100644 (file)
@@ -45,15 +45,15 @@ KeyboardShortcut::KeyboardShortcut(QWidget *parent) : QWidget(parent)
 
     hide();
 
-    registerHwKeyShortcuts(win->uiInfo->getMainForm()->keyList);
+    registerHwKeyShortcuts(win->uiInfo->getMainForm()->getKeyList());
 }
 
-QMap<HardwareKey *, QShortcut *> KeyboardShortcut::getHwKeyShortcutMap()
+QMap<HardwareKey *, QShortcut *> &KeyboardShortcut::getHwKeyShortcutMap()
 {
     return hwKeyShortcutMap;
 }
 
-void KeyboardShortcut::registerHwKeyShortcuts(QList<HardwareKey *> list)
+void KeyboardShortcut::registerHwKeyShortcuts(QList<HardwareKey *> &list)
 {
     for (int index = 0; index < list.count(); index++) {
         HardwareKey *hwKey = list.at(index);
@@ -70,7 +70,7 @@ void KeyboardShortcut::registerHwKeyShortcuts(QList<HardwareKey *> list)
     qDebug() << hwKeyShortcutMap.count() << "shortcuts have been registered";
 }
 
-void KeyboardShortcut::cancelHwKeyShortcuts(QList<HardwareKey *> list)
+void KeyboardShortcut::cancelHwKeyShortcuts(QList<HardwareKey *> &list)
 {
     for (int index = 0; index < list.count(); index++) {
         delete hwKeyShortcutMap.value(list.at(index));
index bd7902b..e17d9f2 100644 (file)
@@ -45,9 +45,9 @@ public:
     KeyboardShortcut(QWidget *parent = 0);
     ~KeyboardShortcut();
 
-    void registerHwKeyShortcuts(QList<HardwareKey *> list);
-    void cancelHwKeyShortcuts(QList<HardwareKey *> list);
-    QMap<HardwareKey *, QShortcut *> getHwKeyShortcutMap();
+    void registerHwKeyShortcuts(QList<HardwareKey *> &list);
+    void cancelHwKeyShortcuts(QList<HardwareKey *> &list);
+    QMap<HardwareKey *, QShortcut *> &getHwKeyShortcutMap();
 
 public slots:
     void slotHwKeyShortcut(int keycode);
index 79f5537..8210ec7 100644 (file)
@@ -33,7 +33,6 @@
 #include <QWidget>
 
 #include "layoutform.h"
-#include "hardwarekey.h"
 
 class ControllerForm : public LayoutForm
 {
@@ -43,14 +42,7 @@ public:
     ControllerForm(const QString &name);
     ~ControllerForm();
 
-    QImage conImg[2];
-    QList<HardwareKey *> keyList;
     QRect centerRect;
-
-    enum ConImgType {
-        normal = 0,
-        pressed = 1
-    };
 };
 
 #endif // CONTROLLERFORM_H
index 2fcfd7b..6bf1066 100644 (file)
@@ -53,6 +53,11 @@ bool LayoutForm::isGeneralPurpose()
     return generalPurpose;
 }
 
+QList<HardwareKey *> &LayoutForm::getKeyList()
+{
+    return keyList;
+}
+
 void LayoutForm::setHoverType(HoverType *hover)
 {
     hoverType = hover;
@@ -65,6 +70,11 @@ HoverType *LayoutForm::getHoverType()
 
 LayoutForm::~LayoutForm()
 {
+    for (int i = 0; i < keyList.count(); i++) {
+        delete keyList.at(i);
+    }
+    keyList.clear();
+
     if (hoverType != NULL) {
         delete hoverType;
     }
index 0e22566..3a0e601 100644 (file)
 
 #include <QWidget>
 
+#include "hardwarekey.h"
 #include "hovertype.h"
 
 class LayoutForm
 {
+    Q_ENUMS(SkinImgType)
+
 public:
     LayoutForm(const QString &name);
     ~LayoutForm();
@@ -43,12 +46,22 @@ public:
     QString getName();
     void setGeneralPurpose(bool general);
     bool isGeneralPurpose();
+
+    QList<HardwareKey *> &getKeyList();
     void setHoverType(HoverType *hover);
     HoverType *getHoverType();
 
+    QImage skinImg[2];
+    enum SkinImgType {
+        normal = 0,
+        pressed = 1
+    };
+
 private:
     QString name;
     bool generalPurpose;
+
+    QList<HardwareKey *> keyList;
     HoverType *hoverType;
 };
 
index 68ff468..1ccaf6a 100644 (file)
@@ -56,9 +56,4 @@ MainForm::~MainForm()
     if (rotaryImg != NULL) {
         delete rotaryImg;
     }
-
-    for (int i = 0; i < keyList.count(); i++) {
-        delete keyList.at(i);
-    }
-    keyList.clear();
 }
index 9e0e288..e74d2e4 100644 (file)
 
 #include "layoutform.h"
 #include "displaytype.h"
-#include "hardwarekey.h"
 
 class MainForm : public LayoutForm
 {
-    Q_ENUMS(SkinImgType)
-
 public:
     MainForm(const QString &name);
     ~MainForm();
@@ -48,13 +45,6 @@ public:
     QPixmap *getRotaryImage();
 
     DisplayType *displayType;
-    QImage skinImg[2];
-    QList<HardwareKey *> keyList;
-
-    enum SkinImgType {
-        normal = 0,
-        pressed = 1
-    };
 
 private:
     QPixmap *rotaryImg;
index 24189fe..3705eca 100644 (file)
@@ -294,7 +294,7 @@ void MainWindow::openController(int index, int dockPos)
     }
 
     /* register controller's HW key shortcuts */
-    keyboardShortcut->registerHwKeyShortcuts(conForm->keyList);
+    keyboardShortcut->registerHwKeyShortcuts(conForm->getKeyList());
 
     /* update layout */
     resize(uiInfo->getUiSize());
@@ -330,7 +330,7 @@ void MainWindow::closeController()
 
         /* cancel controller's HW key shortcuts */
         keyboardShortcut->cancelHwKeyShortcuts(
-            getDockingCon()->getConForm()->keyList);
+            getDockingCon()->getConForm()->getKeyList());
         getDockingCon()->close();
 
         getUIState()->conState.dockingCon = NULL;
@@ -345,7 +345,7 @@ void MainWindow::closeController()
 
         /* cancel controller's HW key shortcuts */
         keyboardShortcut->cancelHwKeyShortcuts(
-            getFloatingCon()->getConForm()->keyList);
+            getFloatingCon()->getConForm()->getKeyList());
         getFloatingCon()->close();
 
         getUIState()->conState.floatingCon = NULL;
@@ -406,13 +406,13 @@ void MainWindow::switchForm(int index)
     qDebug("window switch: %d", index);
 
     /* cancel HW key shortcuts */
-    keyboardShortcut->cancelHwKeyShortcuts(uiInfo->getMainForm()->keyList);
+    keyboardShortcut->cancelHwKeyShortcuts(uiInfo->getMainForm()->getKeyList());
 
     /* layout switching */
     getUIState()->mainFormIndex = index;
 
     /* register new HW key shortcuts */
-    keyboardShortcut->registerHwKeyShortcuts(uiInfo->getMainForm()->keyList);
+    keyboardShortcut->registerHwKeyShortcuts(uiInfo->getMainForm()->getKeyList());
 
     updateDisplayMatrix();
 
index 0299444..9d0e56d 100644 (file)
@@ -204,19 +204,19 @@ void DetailedInfoDialog::updateShortcutTableItems()
 
     // TODO: consider getHwKeyShortcutMap()
     /* insert HW key shortcut info */
-    insertHwKeyShortcutInfo(win->uiInfo->getMainForm()->keyList);
+    insertHwKeyShortcutInfo(win->uiInfo->getMainForm()->getKeyList());
 
     /* insert Controller's HW key shortcut info */
     ControllerForm *conForm = win->uiInfo->getConForm();
     if (conForm != NULL) {
-        insertHwKeyShortcutInfo(win->uiInfo->getConForm()->keyList,
+        insertHwKeyShortcutInfo(win->uiInfo->getConForm()->getKeyList(),
             QString(" (controller)"));
     }
 
     qDebug() << shortcutInfoTable->rowCount() << "shortcut items have been inserted";
 }
 
-void DetailedInfoDialog::insertMenuShortcutInfo(QList<MenuItem *> list)
+void DetailedInfoDialog::insertMenuShortcutInfo(QList<MenuItem *> &list)
 {
     MenuItem *item = NULL;
 
@@ -251,7 +251,7 @@ void DetailedInfoDialog::insertMenuShortcutInfo(QList<MenuItem *> list)
 }
 
 void DetailedInfoDialog::insertHwKeyShortcutInfo(
-    QList<HardwareKey *> list, QString source)
+    QList<HardwareKey *> &list, QString source)
 {
     HardwareKey *hwKey = NULL;
 
index 7e718dc..e06dbf0 100644 (file)
@@ -64,8 +64,8 @@ private:
             const QString& value);
     void removeTableRows(QTableWidget *table, int startIndex, int lastIndex);
 
-    void insertMenuShortcutInfo(QList<MenuItem *> list);
-    void insertHwKeyShortcutInfo(QList<HardwareKey *> list, QString source = "");
+    void insertMenuShortcutInfo(QList<MenuItem *> &list);
+    void insertHwKeyShortcutInfo(QList<HardwareKey *> &list, QString source = "");
 
     MainWindow *win;
     QVBoxLayout *baseLayout;
index aacbfc2..70cd4ce 100644 (file)
@@ -52,18 +52,18 @@ SkinView::SkinView(QGraphicsScene *scene, QWidget *parent) :
 void SkinView::createItems(MainForm *form)
 {
     /* bezel */
-    SkinBezelItem *bezelItem = new SkinBezelItem(form->skinImg[MainForm::normal]);
+    SkinBezelItem *bezelItem = new SkinBezelItem(form->skinImg[LayoutForm::normal]);
     scene()->addItem(bezelItem);
 
     /* HW keys */
-    QList<HardwareKey *> keyList = form->keyList;
+    QList<HardwareKey *> &keyList = form->getKeyList();
 
     HardwareKey *hwKey = NULL;
     for (int i = 0; i < keyList.count(); i++) {
         hwKey = keyList.at(i);
         if (hwKey != NULL) {
             new SkinKeyItem(bezelItem, hwKey,
-                form->skinImg[MainForm::pressed].copy(hwKey->getRegion()),
+                form->skinImg[LayoutForm::pressed].copy(hwKey->getRegion()),
                 form->getHoverType());
         }
     }
index 32547c5..f0774ab 100644 (file)
@@ -105,7 +105,7 @@ QSize UIInformation::getMainSize()
         qFatal(MSG_INVALID_MAIN_FORM);
     }
 
-    return mainForm->skinImg[MainForm::normal].size() * uiState.getScaleFactor();
+    return mainForm->skinImg[LayoutForm::normal].size() * uiState.getScaleFactor();
 }
 
 QSize UIInformation::getConSize()
@@ -116,7 +116,7 @@ QSize UIInformation::getConSize()
         return QSize(0, 0);
     }
 
-    return conForm->conImg[ControllerForm::normal].size();
+    return conForm->skinImg[LayoutForm::normal].size();
 }
 
 QSize UIInformation::getUiSize()
@@ -142,7 +142,7 @@ QRegion UIInformation::getMainRegion()
         return QRegion(0, 0, 0, 0);
     }
 
-    QImage *mainImage = &(mainForm->skinImg[MainForm::normal]);
+    QImage *mainImage = &(mainForm->skinImg[LayoutForm::normal]);
     QImage regionImage = mainImage->scaled(
         mainImage->width() * uiState.getScaleFactor(),
         mainImage->height() * uiState.getScaleFactor()).createAlphaMask();
@@ -158,7 +158,7 @@ QRegion UIInformation::getConRegion()
         return QRegion(0, 0, 0, 0);
     }
 
-    QImage *conImage = &(conForm->conImg[ControllerForm::normal]);
+    QImage *conImage = &(conForm->skinImg[LayoutForm::normal]);
 
     return QRegion(QBitmap::fromImage(conImage->createAlphaMask()));
 }
index b8b324b..77fe26e 100644 (file)
@@ -52,15 +52,12 @@ QColor XmlLayoutParser::parseColor(QXmlStreamReader &xml)
 
         if (attributes.hasAttribute(COLOR_RED_ATTR_KEYWORD)) {
             red = attributes.value(COLOR_RED_ATTR_KEYWORD).toString().toInt();
-            qDebug() << red;
         }
         if (attributes.hasAttribute(COLOR_GREEN_ATTR_KEYWORD)) {
             green = attributes.value(COLOR_GREEN_ATTR_KEYWORD).toString().toInt();
-            qDebug() << green;
         }
         if (attributes.hasAttribute(COLOR_BLUE_ATTR_KEYWORD)) {
             blue = attributes.value(COLOR_BLUE_ATTR_KEYWORD).toString().toUInt();
-            qDebug() << blue;
         }
     }
 
@@ -254,7 +251,7 @@ MainForm *XmlLayoutParser::parseMainForm(QXmlStreamReader &xml)
                 QString normalImageFileName = xml.readElementText();
                 qDebug() << "-" << NORMAL_IMG_KEYWORD << ":" << normalImageFileName;
 
-                if (form->skinImg[MainForm::normal].load(
+                if (form->skinImg[LayoutForm::normal].load(
                     xmlPath + QDir::separator() + normalImageFileName) == false) {
                     qWarning() << "failed to load normal image";
                 }
@@ -263,7 +260,7 @@ MainForm *XmlLayoutParser::parseMainForm(QXmlStreamReader &xml)
                 QString pressedImageFileName = xml.readElementText();
                 qDebug() << "-" << PRESSED_IMG_KEYWORD << ":" << pressedImageFileName;
 
-                if (form->skinImg[MainForm::pressed].load(
+                if (form->skinImg[LayoutForm::pressed].load(
                     xmlPath + QDir::separator() + pressedImageFileName) == false) {
                     qWarning() << "failed to load pressed image";
                 }
@@ -279,7 +276,7 @@ MainForm *XmlLayoutParser::parseMainForm(QXmlStreamReader &xml)
                 }
             } else if (xml.name() == KEYLIST_KEYWORD) {
                 /* HW keys */
-                int cnt = parseKeyList(xml, form->keyList);
+                int cnt = parseKeyList(xml, form->getKeyList());
                 qDebug() << "-" << KEYLIST_KEYWORD << ":" << cnt;
             } else {
                 qWarning() << "undefined element :" << xml.name();
@@ -308,7 +305,7 @@ int XmlLayoutParser::parseMainFormList(
                 form = parseMainForm(xml);
                 if (form != NULL) {
                     /* image validation */
-                    if (form->skinImg[MainForm::normal].size() == QSize(0, 0)) {
+                    if (form->skinImg[LayoutForm::normal].size() == QSize(0, 0)) {
                         qDebug("- general purpose skin form");
 
                         SkinPainter painter("main-skin",
@@ -316,7 +313,7 @@ int XmlLayoutParser::parseMainFormList(
                             QPoint(30, 16), uiInfo->getVMColor());
                         form->setGeneralPurpose(true);
 
-                        form->skinImg[MainForm::normal] = painter.getSkinImage();
+                        form->skinImg[LayoutForm::normal] = painter.getSkinImage();
                         form->displayType->setRect(painter.getCenterRect());
                     }
 
@@ -591,7 +588,7 @@ ControllerForm *XmlLayoutParser::parseControllerForm(QXmlStreamReader &xml)
                 QString normalImageFileName = xml.readElementText();
                 qDebug() << "-" << NORMAL_IMG_KEYWORD << ":" <<  normalImageFileName;
 
-                if (form->conImg[ControllerForm::normal].load(
+                if (form->skinImg[LayoutForm::normal].load(
                     xmlPath + QDir::separator() + normalImageFileName) == false) {
                     qWarning() << "failed to load normal image";
                 }
@@ -600,13 +597,13 @@ ControllerForm *XmlLayoutParser::parseControllerForm(QXmlStreamReader &xml)
                 QString pressedImageFileName = xml.readElementText();
                 qDebug() << "-" << PRESSED_IMG_KEYWORD << ":" << pressedImageFileName;
 
-                if (form->conImg[ControllerForm::pressed].load(
+                if (form->skinImg[LayoutForm::pressed].load(
                     xmlPath + QDir::separator() + pressedImageFileName) == false) {
                     qWarning() << "failed to load pressed image";
                 }
             } else if (xml.name() == KEYLIST_KEYWORD) {
                 /* HW keys */
-                int cnt = parseKeyList(xml, form->keyList);
+                int cnt = parseKeyList(xml, form->getKeyList());
                 qDebug() << "-" << KEYLIST_KEYWORD << ":" << cnt;
             } else if (xml.name() == HOVER_KEYWORD) {
                 /* hover */
@@ -650,10 +647,10 @@ QString XmlLayoutParser::parseControllerUI(QXmlStreamReader &xml)
                 form = parseControllerForm(xml);
                 if (form != NULL) {
                     /* image validation */
-                    if (form->conImg[ControllerForm::normal].size() == QSize(0, 0)) {
+                    if (form->skinImg[LayoutForm::normal].size() == QSize(0, 0)) {
                         qDebug("- general purpose con form");
 
-                        int keyCount = form->keyList.count();
+                        int keyCount = form->getKeyList().count();
 
                         int width = GPC_KEYBUTTON_WIDTH;
                         int height = GPC_HEAD_SPACING;
@@ -674,7 +671,7 @@ QString XmlLayoutParser::parseControllerUI(QXmlStreamReader &xml)
                             uiInfo->getVMColor());
                         form->setGeneralPurpose(true);
 
-                        form->conImg[ControllerForm::normal] = painter.getSkinImage();
+                        form->skinImg[LayoutForm::normal] = painter.getSkinImage();
                         form->centerRect = painter.getCenterRect();
                     }