Fixed the last remaining magic numbers
authorPekka Nissinen <pekka.nissinen@ixonos.com>
Tue, 17 Aug 2010 08:10:04 +0000 (11:10 +0300)
committerPekka Nissinen <pekka.nissinen@ixonos.com>
Tue, 17 Aug 2010 08:10:04 +0000 (11:10 +0300)
Reviewed by: Jussi Laitinen

src/ui/friendlistpanel.cpp
src/ui/panelcontentstack.cpp
src/ui/paneltab.cpp
src/ui/paneltabbar.cpp
src/ui/tabbedpanel.cpp
src/ui/userinfopanel.cpp

index a1bd15e..063f39f 100644 (file)
@@ -39,19 +39,20 @@ FriendListPanel::FriendListPanel(QWidget *parent)
     qDebug() << __PRETTY_FUNCTION__;
 
     const int FRIENDPANEL_FILTER_MARGIN_LEFT = PANEL_MARGIN_LEFT + 4;
+    const int FRIENDPANEL_FILTER_MARGIN_TOP = 0;
     const int FRIENDPANEL_FILTER_MARGIN_RIGHT = PANEL_MARGIN_RIGHT + MAEMO5_SCROLLBAR_WIDTH + 4;
+    const int FRIENDPANEL_FILTER_MARGIN_BOTTOM = 0;
 
     QVBoxLayout *friendListPanelLayout = new QVBoxLayout();
     friendListPanelLayout->setMargin(0);
     friendListPanelLayout->setSpacing(0);
-///< @todo magic
-    friendListPanelLayout->setContentsMargins(PANEL_MARGIN_LEFT, 0, PANEL_MARGIN_RIGHT, 0);
+    friendListPanelLayout->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP,
+                                              PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
     setLayout(friendListPanelLayout);
 
     QHBoxLayout *filterLayout = new QHBoxLayout();
-///< @todo magic
-    filterLayout->setContentsMargins(FRIENDPANEL_FILTER_MARGIN_LEFT, 0,
-                                     FRIENDPANEL_FILTER_MARGIN_RIGHT, 0);
+    filterLayout->setContentsMargins(FRIENDPANEL_FILTER_MARGIN_LEFT, FRIENDPANEL_FILTER_MARGIN_TOP,
+                                     FRIENDPANEL_FILTER_MARGIN_RIGHT, FRIENDPANEL_FILTER_MARGIN_BOTTOM);
 
     m_friendListHeaderWidget = new QWidget();
     m_friendListHeaderWidget->setLayout(filterLayout);
index e0a2cd7..ff7f5a0 100644 (file)
@@ -32,7 +32,7 @@ PanelContentStack::PanelContentStack(QWidget *parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    const QColor SEMI_TRANSPARENT_BLACK = QColor(0, 0, 0, 128);
+    const QColor SEMI_TRANSPARENT_BLACK(0, 0, 0, 128);
 
     resize(PANEL_WIDTH, PANEL_HEIGHT);
 
@@ -50,9 +50,12 @@ void PanelContentStack::paintEvent(QPaintEvent *event)
 
     Q_UNUSED(event);
 
+    const int SHADOW_RECT_X = 0;
+    const int SHADOW_RECT_Y = 0;
+
     QPainter painter(this);
-///< @todo magic
-    QRect shadowRect = QRect(0, 0, rect().width(), m_menuDropShadowTile.height());
+    QRect shadowRect = QRect(SHADOW_RECT_X, SHADOW_RECT_Y,
+                             rect().width(), m_menuDropShadowTile.height());
     painter.drawTiledPixmap(shadowRect, m_menuDropShadowTile);
 }
 
index 5ae77d8..db1101f 100644 (file)
@@ -93,16 +93,16 @@ void PanelTab::paintEvent(QPaintEvent *event)
     Q_UNUSED(event);
 
     const int TAB_WIDTH = 66;
+    const int TAB_RECT_X = 0;
+    const int TAB_RECT_Y = 0;
 
     QPainter painter(this);
 
     if (isChecked()) {
-///< @todo magic
-        m_tabRect.setRect(0, 0, TAB_WIDTH_ACTIVE, TAB_HEIGHT);
+        m_tabRect.setRect(TAB_RECT_X, TAB_RECT_Y, TAB_WIDTH_ACTIVE, TAB_HEIGHT);
         painter.drawPixmap(m_tabRect, m_tabActiveImage);
     } else {
-///< @todo magic
-        m_tabRect.setRect(TAB_WIDTH_ACTIVE - TAB_WIDTH, 0, TAB_WIDTH, TAB_HEIGHT);
+        m_tabRect.setRect(TAB_WIDTH_ACTIVE - TAB_WIDTH, TAB_RECT_Y, TAB_WIDTH, TAB_HEIGHT);
         painter.drawPixmap(m_tabRect, m_tabInactiveImage);
     }
 
index e21d63f..124fd77 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "paneltabbar.h"
 
+const int APPEND_INDEX = -1;
 const int NO_ACTIVE_TABS = -1;
 
 PanelTabBar::PanelTabBar(QWidget *parent)
@@ -44,8 +45,6 @@ int PanelTabBar::addTab(const QIcon& icon)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    const int APPEND_INDEX = -1;
-
     return insertTab(APPEND_INDEX, icon);
 }
 
@@ -62,7 +61,11 @@ int PanelTabBar::insertTab(int index, const QIcon& icon)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_tabButtonGroup->addButton(new PanelTab(this), index);
+    if (index == APPEND_INDEX)
+        m_tabButtonGroup->addButton(new PanelTab(this));
+    else
+        m_tabButtonGroup->addButton(new PanelTab(this), index);
+
     m_tabButtonGroup->button(index)->setIcon(icon);
 
     setUpTabLayout();
index 8ab6331..7da73c4 100644 (file)
@@ -38,6 +38,8 @@ TabbedPanel::TabbedPanel(QWidget *parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    const int PANEL_LEFT_X = 0;
+    const int PANEL_TOP_Y = 0;
     const int TAB_BAR_TOP_SPACING = 8;
 
     resize(PANEL_BAR_TABBED_WIDTH + PANEL_WIDTH, PANEL_HEIGHT);
@@ -45,7 +47,7 @@ TabbedPanel::TabbedPanel(QWidget *parent)
 
     // --- TABS ---
     m_panelTabBar = new PanelTabBar(this);
-    m_panelTabBar->move(0, TAB_BAR_TOP_SPACING);
+    m_panelTabBar->move(PANEL_LEFT_X, TAB_BAR_TOP_SPACING);
 
     connect(m_panelTabBar, SIGNAL(currentChanged(int)),
             this, SLOT(setCurrentIndex(int)));
@@ -58,13 +60,11 @@ TabbedPanel::TabbedPanel(QWidget *parent)
 
     // --- BAR ---
     m_panelBar = new PanelBar(this);
-///< @todo magic
-    m_panelBar->move(PANEL_TAB_WIDTH, 0);
+    m_panelBar->move(PANEL_TAB_WIDTH, PANEL_TOP_Y);
 
     // --- PANEL CONTENT ---
     m_panelContentStack = new PanelContentStack(this);
-///< @todo magic
-    m_panelContentStack->move(PANEL_TAB_WIDTH + PANEL_BAR_WIDTH, 0);
+    m_panelContentStack->move(PANEL_TAB_WIDTH + PANEL_BAR_WIDTH, PANEL_TOP_Y);
 
     // --- PANEL ANIMATION ---
     m_panelStateMachine = new QStateMachine(this);
index 726cc40..e68f390 100644 (file)
@@ -37,8 +37,8 @@ UserInfoPanel::UserInfoPanel(QWidget *parent)
     QVBoxLayout *userInfoPanelLayout = new QVBoxLayout;
     userInfoPanelLayout->setMargin(0);
     userInfoPanelLayout->setSpacing(0);
-///< @todo magic
-    userInfoPanelLayout->setContentsMargins(PANEL_MARGIN_LEFT, 0, PANEL_MARGIN_RIGHT, 0);
+    userInfoPanelLayout->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP,
+                                            PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
     setLayout(userInfoPanelLayout);
 
     m_userInfo = new UserInfo(this);