Made a few corrections according to Sami's suggestions
authorPekka Nissinen <pekka.nissinen@ixonos.com>
Mon, 16 Aug 2010 12:04:34 +0000 (15:04 +0300)
committerPekka Nissinen <pekka.nissinen@ixonos.com>
Mon, 16 Aug 2010 12:04:34 +0000 (15:04 +0300)
src/ui/panelbar.cpp
src/ui/panelbar.h
src/ui/panelbase.cpp
src/ui/panelbase.h
src/ui/panelcontent.cpp
src/ui/paneltab.cpp
src/ui/paneltab.h
src/ui/paneltabbar.cpp
src/ui/tabbedpanel.cpp
src/ui/tabbedpanel.h

index c219ae5..7044eed 100644 (file)
@@ -28,8 +28,6 @@
 
 #include "panelcommon.h"
 
-///< @todo requires clean-up, there is some commented code
-
 PanelBar::PanelBar(QWidget *parent)
     : QWidget(parent)
 {
@@ -37,16 +35,18 @@ PanelBar::PanelBar(QWidget *parent)
 
     m_barTile.load(":/res/images/sliding_bar_tile.png");
     m_menuDropShadowTile.load(":/res/images/menu_bar_drop_shadow.png");
-
+    ///< @todo magic
     m_barRect.setRect(0, 0, PANEL_BAR_WIDTH, PANEL_HEIGHT);
 
     this->resize(PANEL_BAR_WIDTH, PANEL_HEIGHT);
 }
 
-void PanelBar::paintEvent(QPaintEvent *)
+void PanelBar::paintEvent(QPaintEvent *event)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    Q_UNUSED(event);
+
     QPainter painter(this);
 
     painter.drawTiledPixmap(m_barRect, m_barTile);
index 8520e51..9da3f7b 100644 (file)
@@ -25,9 +25,8 @@
 
 #include <QWidget>
 
-///< @todo Comment does not tell what this class is actually for (=draws the vertical line between panel contents and tab buttons)
 /**
- * @brief Generic class for panel bars
+ * @brief Class for for drawing a vertical line between panel content and tab bar
  *
  * @author Kaj Wallin - kaj.wallin (at) ixonos.com
  * @author Pekka Nissinen - pekka.nissinen@ixonos.com
@@ -48,13 +47,12 @@ public:
  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
  ******************************************************************************/
 protected:
-    ///< @todo parameter name missing (also in .cpp)
     /**
      * @brief Draws the bar
      *
-     * @param * QPaintEvent unused
+     * @param event Paint event
      */
-    void paintEvent(QPaintEvent *);
+    void paintEvent(QPaintEvent *event);
 
 /*******************************************************************************
  * MEMBER FUNCTIONS AND SLOTS
index 3771888..5186828 100644 (file)
@@ -39,10 +39,12 @@ PanelBase::PanelBase(QWidget *parent)
     setAutoFillBackground(true);
 }
 
-void PanelBase::paintEvent(QPaintEvent *)
+void PanelBase::paintEvent(QPaintEvent *event)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    Q_UNUSED(event);
+
     QPainter painter(this);
 
     QRect shadowRect = QRect(0, 0, this->rect().width(), m_menuDropShadowTile.height());
index b75a7ab..f0a7db2 100644 (file)
@@ -49,13 +49,12 @@ public:
  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
  ******************************************************************************/
 protected:
-    ///< @todo parameter name (also in .cpp)
     /**
      * @brief Draws the panel content base
      *
-     * @param * QPaintEvent unused
+     * @param event Paint event
      */
-    void paintEvent(QPaintEvent *);
+    void paintEvent(QPaintEvent *event);
 
 /*******************************************************************************
  * DATA MEMBERS
index b8d320b..ec65575 100644 (file)
@@ -34,7 +34,7 @@ PanelContent::PanelContent(QWidget *parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    this->resize(PANEL_WIDTH, PANEL_HEIGHT);
+    resize(PANEL_WIDTH, PANEL_HEIGHT);
 
     m_panelVBox = new QVBoxLayout(this);
     m_panelVBox->setMargin(0);
@@ -56,7 +56,7 @@ void PanelContent::resizePanelContent(const QSize &size)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    this->resize(PANEL_WIDTH, size.height() - PANEL_TOP_PADDING - PANEL_BOTTOM_PADDING);
+    resize(PANEL_WIDTH, size.height() - PANEL_TOP_PADDING - PANEL_BOTTOM_PADDING);
 
     m_panelBase->resize(this->size());
 }
index 9d393c7..68a74c0 100644 (file)
@@ -26,8 +26,6 @@
 
 #include "paneltab.h"
 
-///< @todo TAB_WIDTH not global? move into paintEvent()
-const int TAB_WIDTH = 66;
 const int TAB_WIDTH_ACTIVE = 74;
 const int TAB_HEIGHT = 66;
 
@@ -38,10 +36,9 @@ PanelTab::PanelTab(QWidget *parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    ///< @todo magic, use enum, check also .h todo comment, fix everywhere
-    m_tabPixmaps[0].load(":/res/images/tab_inactive.png");
-    m_tabPixmaps[1].load(":/res/images/tab_inactive2.png");
-    m_tabPixmaps[2].load(":/res/images/tab_active.png");
+    m_tabActiveImage.load(":/res/images/tab_active.png");
+    m_tabInactiveImage.load(":/res/images/tab_inactive.png");
+    m_tabInactiveImage2.load(":/res/images/tab_inactive2.png");
 
     setCheckable(true);
 
@@ -74,33 +71,37 @@ void PanelTab::mouseReleaseEvent(QMouseEvent *event)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    ///< @todo mouse button is not checked, add check here or remove from mousePressEvent
+    if (event->button() == Qt::LeftButton) {
+        if(this->rect().contains(event->pos())) {
+            click();
 
-    if(this->rect().contains(event->pos())) {
-        click();
+            if(isChecked())
+                setChecked(false);
+            else
+                setChecked(true);
+        }
 
-        if(isChecked())
-            setChecked(false);
-        else
-            setChecked(true);
+        setDown(false);
+        m_tabSelected = false;
     }
-
-    setDown(false);
-    m_tabSelected = false;
 }
 
-void PanelTab::paintEvent(QPaintEvent *)
+void PanelTab::paintEvent(QPaintEvent *event)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    Q_UNUSED(event);
+
+    const int TAB_WIDTH = 66;
+
     QPainter painter(this);
 
     if(isChecked()) {
         m_tabRect.setRect(0, 0, TAB_WIDTH_ACTIVE, TAB_HEIGHT);
-        painter.drawPixmap(m_tabRect, m_tabPixmaps[2]);
+        painter.drawPixmap(m_tabRect, m_tabActiveImage);
     } else {
         m_tabRect.setRect(TAB_WIDTH_ACTIVE - TAB_WIDTH, 0, TAB_WIDTH, TAB_HEIGHT);
-        painter.drawPixmap(m_tabRect, m_tabPixmaps[0]);
+        painter.drawPixmap(m_tabRect, m_tabInactiveImage);
     }
 
     if(isDown())
@@ -110,14 +111,3 @@ void PanelTab::paintEvent(QPaintEvent *)
     else
         icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Disabled);
 }
-
-///< @todo setActive() method is not used
-void PanelTab::setActive(bool state)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    if(state)
-        setChecked(true);
-    else
-        setChecked(false);
-}
index f4fe610..a5e3e13 100644 (file)
@@ -68,22 +68,12 @@ protected:
      */
     void mouseReleaseEvent(QMouseEvent *event);
 
-///< @todo parameter name missing (also in .cpp)
     /**
      * @brief Draws the tab button
      *
-     * @param * QPaintEvent unused
+     * @param event Paint event
      */
-    void paintEvent(QPaintEvent *);
-
-/*******************************************************************************
- * MEMBER FUNCTIONS AND SLOTS
- ******************************************************************************/
-public:
-    /**
-     * @brief This slot is used to change tab button state
-     */
-    void setActive(bool state);
+    void paintEvent(QPaintEvent *event);
 
 /*******************************************************************************
  * DATA MEMBERS
@@ -92,10 +82,11 @@ private:
     bool m_tabActive;   ///< Boolean used to track whether the tab button is active or not
     bool m_tabSelected; ///< Boolean used to track whether the tab button is selected or not
 
-    ///< @todo magic, replace with enum?
-    QPixmap m_tabPixmaps[3];    ///< Pixmap table for tab button images
+    QPixmap m_tabActiveImage;    ///< Pixmap for active tab button
+    QPixmap m_tabInactiveImage;  ///< Pixmap for inactive tab button
+    QPixmap m_tabInactiveImage2; ///< Pixmap for inactive tab button below active tab button
 
-    QRect m_tabRect;            ///< Rect for the tab button
+    QRect m_tabRect;        ///< Rect for the tab button
 };
 
 #endif // PANELTAB_H
index e911645..c2be73c 100644 (file)
@@ -42,7 +42,9 @@ int PanelTabBar::addTab(const QIcon& icon)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    return insertTab(-1, icon);
+    const int APPEND_INDEX = -1;
+
+    return insertTab(APPEND_INDEX, icon);
 }
 
 void PanelTabBar::deselectTabs()
index 89c979c..9f0e1de 100644 (file)
@@ -38,9 +38,8 @@ TabbedPanel::TabbedPanel(QWidget *parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    ///< @todo Do not use this, REMOVE ALL OCCURENCES IN ALL FILES!
-    this->resize(PANEL_BAR_TABBED_WIDTH + PANEL_WIDTH, PANEL_HEIGHT);
-    this->move(PANEL_CLOSED_X, PANEL_TOP_PADDING);
+    resize(PANEL_BAR_TABBED_WIDTH + PANEL_WIDTH, PANEL_HEIGHT);
+    move(PANEL_CLOSED_X, PANEL_TOP_PADDING);
 
     // --- TABS ---
     m_panelWidgetStack = new QStackedWidget(this);
@@ -98,17 +97,22 @@ int TabbedPanel::addTab(QWidget *widget, const QIcon& icon)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    ///< @todo magic
-    return insertTab(-1, widget, icon);
+    const int APPEND_INDEX = -1;
+
+    return insertTab(APPEND_INDEX, widget, icon);
 }
 
-int TabbedPanel::insertTab(int index, QWidget *widget, const QIcon& icon)
+void TabbedPanel::closePanel()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    ///< @todo callers responsibility to call with right parameters
-    if(!widget)
-        return -1;
+    if(m_isOpen)
+        emit toggleState();
+}
+
+int TabbedPanel::insertTab(int index, QWidget *widget, const QIcon& icon)
+{
+    qDebug() << __PRETTY_FUNCTION__;
 
     index = m_panelWidgetStack->insertWidget(index, widget);
     m_panelTabBar->insertTab(index, icon);
@@ -126,13 +130,30 @@ void TabbedPanel::removeTab(int index)
     }
 }
 
-///< @todo sort alphabetically (other methods too)
-void TabbedPanel::closePanel()
+void TabbedPanel::resizePanel(const QSize &size)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    if(m_isOpen)
-        emit toggleState();
+    this->resize(PANEL_BAR_TABBED_WIDTH + PANEL_WIDTH,
+                 size.height() - PANEL_TOP_PADDING - PANEL_BOTTOM_PADDING);
+
+    if (!m_isOpen) {
+        move(size.width() - PANEL_TAB_WIDTH - PANEL_BAR_WIDTH, PANEL_TOP_PADDING);
+    } else {
+        move(size.width() - PANEL_TAB_WIDTH - PANEL_BAR_WIDTH - PANEL_WIDTH,
+                   PANEL_TOP_PADDING);
+    }
+
+    m_panelBar->resizeBar(size);
+
+    m_panelContent->resizePanelContent(size);
+
+    m_panelStateClosed->assignProperty(this, "pos",
+                        QPoint(size.width() - PANEL_TAB_WIDTH - PANEL_BAR_WIDTH,
+                               PANEL_TOP_PADDING));
+    m_panelStateOpened->assignProperty(this, "pos",
+                        QPoint(size.width() - PANEL_TAB_WIDTH - PANEL_BAR_WIDTH - PANEL_WIDTH,
+                               PANEL_TOP_PADDING));
 }
 
 void TabbedPanel::showPanel(QWidget *widget)
@@ -146,8 +167,7 @@ void TabbedPanel::setCurrentIndex(int index)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-///< @todo if ((first) && (second)) {
-    if (index < m_panelWidgetStack->count() && index >= 0) {
+    if ((index < m_panelWidgetStack->count()) && (index >= 0)) {
         m_panelWidgetStack->setCurrentIndex(index);
 
         if(!m_isOpen)
@@ -157,32 +177,6 @@ void TabbedPanel::setCurrentIndex(int index)
     }
 }
 
-void TabbedPanel::resizePanel(const QSize &size)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    this->resize(PANEL_BAR_TABBED_WIDTH + PANEL_WIDTH,
-                 size.height() - PANEL_TOP_PADDING - PANEL_BOTTOM_PADDING);
-
-    if (!m_isOpen) {
-        this->move(size.width() - PANEL_TAB_WIDTH - PANEL_BAR_WIDTH, PANEL_TOP_PADDING);
-    } else {
-        this->move(size.width() - PANEL_TAB_WIDTH - PANEL_BAR_WIDTH - PANEL_WIDTH,
-                   PANEL_TOP_PADDING);
-    }
-
-    m_panelBar->resizeBar(size);
-
-    m_panelContent->resizePanelContent(size);
-
-    ///< @todo alignment
-    m_panelStateClosed->assignProperty(this, "pos",
-                        QPoint(size.width() - PANEL_TAB_WIDTH - PANEL_BAR_WIDTH, PANEL_TOP_PADDING));
-    m_panelStateOpened->assignProperty(this, "pos",
-                        QPoint(size.width() - PANEL_TAB_WIDTH - PANEL_BAR_WIDTH - PANEL_WIDTH,
-                               PANEL_TOP_PADDING));
-}
-
 void TabbedPanel::stateChanged()
 {
     qDebug() << __PRETTY_FUNCTION__;
index af441c3..7357229 100644 (file)
@@ -70,7 +70,6 @@ public:
      */
     int addTab(QWidget *widget, const QIcon& icon);
 
-    ///< @todo define "out of range"
     /**
      * @brief Inserts a tab to the panel
      *