Merge branch 'new_panels' into locationlistview
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Mon, 16 Aug 2010 13:05:32 +0000 (16:05 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Mon, 16 Aug 2010 13:05:32 +0000 (16:05 +0300)
Conflicts:
src/src.pro
src/ui/friendlistpanel.h

20 files changed:
doc/testing/functionality-tests.doc
src/src.pro
src/ui/friendlistpanel.cpp
src/ui/friendlistpanel.h
src/ui/indicatorbuttonpanel.cpp
src/ui/indicatorbuttonpanel.h
src/ui/mainwindow.cpp
src/ui/panelbar.cpp
src/ui/panelbar.h
src/ui/panelbase.cpp
src/ui/panelbase.h
src/ui/panelcontent.cpp
src/ui/panelcontent.h
src/ui/paneltab.cpp
src/ui/paneltab.h
src/ui/paneltabbar.cpp
src/ui/paneltabbar.h
src/ui/tabbedpanel.cpp
src/ui/tabbedpanel.h
tests/ui/tabbedpanel/testtabbedpanel.cpp

index 5799763..1a5b902 100644 (file)
Binary files a/doc/testing/functionality-tests.doc and b/doc/testing/functionality-tests.doc differ
index 81399d9..bb9d204 100644 (file)
@@ -70,19 +70,22 @@ SOURCES += main.cpp \
     ui/zoombutton.cpp \
     ui/zoombuttonpanel.cpp \
     ui/searchdialog.cpp \
-    ui/paneltab.cpp \
-    ui/tabbedpanel.cpp \
+    ui/panelbase.cpp \    
     ui/panelbar.cpp \
     ui/panelcontent.cpp \
-    ui/panelbase.cpp \
+    ui/paneltab.cpp \
     ui/paneltabbar.cpp \
-    user/user.cpp \
+    ui/tabbedpanel.cpp \
     ui/routingpanel.cpp \
+    ui/routewaypointlistitem.cpp \
     ui/routewaypointlistview.cpp \
-    ui/routewaypointlistitem.cpp
+    user/user.cpp
 HEADERS += application.h \
     common.h \
+    coordinates/geocoordinate.h \
+    coordinates/scenecoordinate.h \
     engine/engine.h \
+    engine/mce.h \
     error.h \
     facebookservice/facebookauthentication.h \
     facebookservice/facebookcommon.h \
@@ -97,16 +100,24 @@ HEADERS += application.h \
     map/mapcommon.h \
     map/mapengine.h \
     map/mapfetcher.h \
+    map/maprouteitem.h \
     map/mapscene.h \
     map/mapscroller.h \
     map/maptile.h \
     map/maptilerequest.h \
     map/mapview.h \
+    map/osm.h \
     map/ownlocationitem.h \
     network/networkaccessmanager.h \
     network/networkcookiejar.h \
     network/networkhandler.h \
     network/networkreply.h \
+    routing/geocodingservice.h \
+    routing/location.h \
+    routing/route.h \
+    routing/routesegment.h \
+    routing/routingcommon.h \    
+    routing/routingservice.h \
     situareservice/imagefetcher.h \
     situareservice/situarecommon.h \
     situareservice/situareservice.h \
@@ -114,54 +125,38 @@ HEADERS += application.h \
     ui/updatelocation/updatelocationdialog.h \
     ui/avatarimage.h \
     ui/friendlistitem.h \
+    ui/friendlistitemdelegate.h \
     ui/friendlistpanel.h \
+    ui/friendlistview.h \
+    ui/fullscreenbutton.h \
     ui/imagebutton.h \
+    ui/indicatorbutton.h \
+    ui/indicatorbuttonpanel.h \
     ui/logindialog.h \
+    ui/locationlistview.h \
     ui/mainwindow.h \
     ui/mapscale.h \
-    ui/panelcommon.h \
     ui/settingsdialog.h \
     ui/userinfo.h \
     ui/userinfopanel.h \
     ui/zoombutton.h \
     ui/zoombuttonpanel.h \
-    user/user.h \
-    ui/fullscreenbutton.h \
-    engine/mce.h \
-    ui/indicatorbutton.h \
-    ui/indicatorbuttonpanel.h \
-    routing/geocodingservice.h \
-    routing/routingservice.h \
-    routing/routingcommon.h \
-    routing/routesegment.h \
-    routing/route.h \
-    routing/location.h \
-    map/maprouteitem.h \
-    map/osm.h \
-    coordinates/scenecoordinate.h \
-    coordinates/geocoordinate.h \
+    ui/listcommon.h \    
     ui/listview.h \
     ui/listitem.h \
     ui/listitemdelegate.h \
-    ui/friendlistitemdelegate.h \
-    ui/listcommon.h \
     ui/searchdialog.h \
-    ui/locationlistitem.h \
-    ui/extendedlistitem.h \
-    ui/extendedlistitemstore.h \
-    ui/extendedlistitemdelegate.h \
-    ui/locationlistview.h \
-    ui/friendlistview.h \
-    error.h \
-    ui/paneltab.h \
-    ui/tabbedpanel.h \
+    ui/panelbase.h \    
     ui/panelbar.h \
     ui/panelcontent.h \
-    ui/panelbase.h \
+    ui/panelcommon.h \
+    ui/paneltab.h \
     ui/paneltabbar.h \
+    ui/tabbedpanel.h \
     ui/routingpanel.h \
+    ui/routewaypointlistitem.h \
     ui/routewaypointlistview.h \
-    ui/routewaypointlistitem.h
+    user/user.h
 QT += network \
     webkit
 
index 1788f48..50b0f2c 100644 (file)
@@ -150,4 +150,6 @@ void FriendListPanel::showFriendsInList(const QList<QString> &userIDs)
 
     m_friendListHeaderWidget->show();
     m_friendListView->filter(userIDs);
+
+    emit showPanelRequested(this);
 }
index dc83e0b..855bb9c 100644 (file)
@@ -75,7 +75,7 @@ public slots:
 
 private slots:
     /**
-     * @brief Slot to clear friend list filter.
+     * @brief Slot to clear friend list filter
      */
     void clearFriendListFilter();
 
@@ -87,9 +87,9 @@ private slots:
     void routeToSelectedFriend();
 
     /**
-     * @brief Slot to show friends in list.
+     * @brief Slot to show friends in list
      *
-     * Shows only friends that are on userIDs list.
+     * Shows only friends that are on userIDs list
      * @param userIDs list of user ID's
      */
     void showFriendsInList(const QList<QString> &userIDs);
@@ -99,7 +99,7 @@ private slots:
  ******************************************************************************/
 signals:
     /**
-     * @brief Signal for friend finding.
+     * @brief Signal for friend finding
      *
      * @param coordinates Target coordinate
      */
@@ -112,6 +112,13 @@ signals:
     */
     void routeToFriend(const GeoCoordinate &coordinates);
 
+    /**
+     * @brief Signal for requesting a panel to be opened
+     *
+     * @param widget Pointer to the widget that emitted the signal
+     */
+    void showPanelRequested(QWidget *widget);
+
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
index 55b53a5..d535782 100644 (file)
@@ -109,6 +109,13 @@ IndicatorButtonPanel::IndicatorButtonPanel(QWidget *parent)
             this, SIGNAL(autoCenteringTriggered(bool)));
 }
 
+IndicatorButtonPanel::~IndicatorButtonPanel()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    delete m_normalColor;
+}
+
 void IndicatorButtonPanel::forceMouseRelease()
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -296,8 +303,7 @@ void IndicatorButtonPanel::updateValues(qreal direction, qreal distance, bool dr
 
     m_distance = distance;
 
-    if (m_distance < MIN_TO_METERS)
-    {
+    if (m_distance < MIN_TO_METERS) {
         m_distanceText.setNum(10);
         m_distanceText.prepend("< ");
         m_distanceText.append(UNIT_METER);
index 3dcaecf..2fc9f9f 100644 (file)
@@ -52,6 +52,12 @@ public:
      */
     IndicatorButtonPanel(QWidget *parent = 0);
 
+    /**
+     * @brief Desctructor
+     * Destroys m_normalColor
+     */
+    ~IndicatorButtonPanel();
+
 /*******************************************************************************
  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
  ******************************************************************************/
index 2b7acce..120a47e 100644 (file)
@@ -333,6 +333,9 @@ void MainWindow::buildPanels()
 
     connect(m_mapView, SIGNAL(viewResized(QSize)),
             m_tabbedPanel, SLOT(resizePanel(QSize)));
+
+    connect(m_friendsListPanel, SIGNAL(showPanelRequested(QWidget*)),
+            m_tabbedPanel, SLOT(showPanel(QWidget*)));
 }
 
 void MainWindow::buildRoutingPanel()
index 5de1679..7044eed 100644 (file)
@@ -35,22 +35,22 @@ 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);
 
-//    m_sliderRegion = QRegion(m_buttonRect).united(QRegion(m_topRect).united(QRegion(m_bottomRect)));
-//    setMask(m_sliderRegion);
-
     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);
+    ///< @todo magic
     painter.drawTiledPixmap(0, 0, PANEL_BAR_WIDTH, m_menuDropShadowTile.height(),
                             m_menuDropShadowTile);
 }
@@ -59,10 +59,8 @@ void PanelBar::resizeBar(const QSize &size)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    ///< @todo magic
     m_barRect.setRect(0, 0, PANEL_BAR_WIDTH, size.height());
 
-//    m_sliderRegion = QRegion(m_buttonRect).united(QRegion(m_topRect).united(QRegion(m_bottomRect)));
-//    setMask(m_sliderRegion);
-
     this->resize(PANEL_BAR_WIDTH, size.height() - PANEL_TOP_PADDING - PANEL_BOTTOM_PADDING);
 }
index 06cb618..9da3f7b 100644 (file)
@@ -26,7 +26,7 @@
 #include <QWidget>
 
 /**
- * @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
@@ -50,9 +50,9 @@ protected:
     /**
      * @brief Draws the bar
      *
-     * @param * QPaintEvent unused
+     * @param event Paint event
      */
-    void paintEvent(QPaintEvent *);
+    void paintEvent(QPaintEvent *event);
 
 /*******************************************************************************
  * MEMBER FUNCTIONS AND SLOTS
@@ -73,7 +73,5 @@ private:
     QPixmap m_barTile;              ///< Pixmap for panel bar
 
     QRect m_barRect;                ///< Rect for the panel bar
-
-//    QRegion m_sliderRegion;             ///< Region of the slider bar
 };
 #endif // PANELBAR_H
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 91200a1..f0a7db2 100644 (file)
@@ -26,6 +26,8 @@
 #include <QPixmap>
 #include <QWidget>
 
+///< @todo Base class? Might be misleading comment and does not tell about what this class does
+///< @todo Why not directly inheriting QStackedWidget?
 /**
  * @brief Base class for panel inner content
  *
@@ -50,9 +52,9 @@ protected:
     /**
      * @brief Draws the panel content base
      *
-     * @param * QPaintEvent unused
+     * @param event Paint event
      */
-    void paintEvent(QPaintEvent *);
+    void paintEvent(QPaintEvent *event);
 
 /*******************************************************************************
  * DATA MEMBERS
index eb1753c..ec65575 100644 (file)
@@ -24,8 +24,8 @@
 #include <QDebug>
 #include <QVBoxLayout>
 
-#include "panelcommon.h"
 #include "panelbase.h"
+#include "panelcommon.h"
 
 #include "panelcontent.h"
 
@@ -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 b54f114..74fabd3 100644 (file)
@@ -29,6 +29,7 @@ class QVBoxLayout;
 
 class PanelBase;
 
+///< @todo Base class? Might be misleading comment and does not tell about what this class does
 /**
  * @brief Base class for panel content area
  *
index 92ad68a..68a74c0 100644 (file)
@@ -26,7 +26,6 @@
 
 #include "paneltab.h"
 
-const int TAB_WIDTH = 66;
 const int TAB_WIDTH_ACTIVE = 74;
 const int TAB_HEIGHT = 66;
 
@@ -37,9 +36,9 @@ PanelTab::PanelTab(QWidget *parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    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);
 
@@ -72,31 +71,37 @@ void PanelTab::mouseReleaseEvent(QMouseEvent *event)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    if(this->rect().contains(event->pos())) {
-        click();
+    if (event->button() == Qt::LeftButton) {
+        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())
@@ -106,13 +111,3 @@ void PanelTab::paintEvent(QPaintEvent *)
     else
         icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Disabled);
 }
-
-void PanelTab::setActive(bool state)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    if(state)
-        setChecked(true);
-    else
-        setChecked(false);
-}
index 6742ec0..a5e3e13 100644 (file)
@@ -71,18 +71,9 @@ protected:
     /**
      * @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
@@ -91,9 +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
 
-    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 99c2776..4a43ba2 100644 (file)
@@ -28,7 +28,7 @@
 
 PanelTabBar::PanelTabBar(QWidget *parent)
     : QWidget(parent),
-      m_activeTab(-1)
+      m_activeTab(-1) ///< @todo magic
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -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()
@@ -63,7 +65,7 @@ int PanelTabBar::insertTab(int index, const QIcon& icon)
     m_tabButtonGroup->addButton(new PanelTab(this), index);
     m_tabButtonGroup->button(index)->setIcon(icon);
 
-    // [BEGIN]: Purkkaa (to be removed ASAP!!!)
+    ///< @todo  [BEGIN]: Purkkaa (to be removed ASAP!!!)
     if(index > 0)
         verticalStartPoint += 65 * index;
 
@@ -83,11 +85,20 @@ void PanelTabBar::removeTab(int index)
     }
 }
 
+void PanelTabBar::selectTab(int index)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    if (!m_tabButtonGroup->button(index)->isChecked())
+        m_tabButtonGroup->button(index)->click();
+}
+
 void PanelTabBar::setCurrentIndex(int index)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
     if(m_activeTab == index) {
+        ///< @todo magic
         m_activeTab = -1;
         emit tabCloseRequested(index);
     } else {
index 3c2d4cf..6714abd 100644 (file)
@@ -85,6 +85,12 @@ public slots:
     void deselectTabs();
 
     /**
+     * @brief This slot selects a tab at given index
+     */
+    void selectTab(int index);
+
+private slots:
+    /**
      * @brief Sets the tab at current index active
      *
      * @param index Index of the tab
index 2321ceb..424496a 100644 (file)
@@ -38,8 +38,8 @@ TabbedPanel::TabbedPanel(QWidget *parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    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);
@@ -47,7 +47,7 @@ TabbedPanel::TabbedPanel(QWidget *parent)
     m_panelTabBar = new PanelTabBar(this);
 
     connect(m_panelTabBar, SIGNAL(currentChanged(int)),
-            this, SLOT(showTab(int)));
+            this, SLOT(setCurrentIndex(int)));
 
     connect(m_panelTabBar, SIGNAL(tabCloseRequested(int)),
              this, SLOT(closePanel()));
@@ -97,15 +97,23 @@ int TabbedPanel::addTab(QWidget *widget, const QIcon& icon)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    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__;
 
-    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);
@@ -123,55 +131,50 @@ void TabbedPanel::removeTab(int index)
     }
 }
 
-void TabbedPanel::closePanel()
+void TabbedPanel::resizePanel(const QSize &size)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    if(m_isOpen)
-        emit toggleState();
-}
+    resize(PANEL_BAR_TABBED_WIDTH + PANEL_WIDTH,
+           size.height() - PANEL_TOP_PADDING - PANEL_BOTTOM_PADDING);
 
-void TabbedPanel::openPanel()
-{
-    qDebug() << __PRETTY_FUNCTION__;
+    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);
+
+    QPoint closedPosition(size.width() - PANEL_TAB_WIDTH - PANEL_BAR_WIDTH, PANEL_TOP_PADDING);
+    m_panelStateClosed->assignProperty(this, "pos", closedPosition);
+
+    QPoint openedPosition(size.width() - PANEL_TAB_WIDTH - PANEL_BAR_WIDTH - PANEL_WIDTH,
+                          PANEL_TOP_PADDING);
+    m_panelStateOpened->assignProperty(this, "pos", openedPosition);
 
-    if(!m_isOpen)
-        emit toggleState();
 }
 
-void TabbedPanel::showTab(int index)
+void TabbedPanel::showPanel(QWidget *widget)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    if (index < m_panelWidgetStack->count() && index >= 0) {
-        m_panelWidgetStack->setCurrentIndex(index);
-        openPanel();
-        emit currentChanged(index);
-    }
+    m_panelTabBar->selectTab(m_panelWidgetStack->indexOf(widget));
 }
 
-void TabbedPanel::resizePanel(const QSize &size)
+void TabbedPanel::setCurrentIndex(int index)
 {
     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);
+    if ((index < m_panelWidgetStack->count()) && (index >= 0)) {
+        m_panelWidgetStack->setCurrentIndex(index);
 
-    m_panelContent->resizePanelContent(size);
+        if(!m_isOpen)
+            emit toggleState();
 
-    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));
+        emit currentChanged(index);
+    }
 }
 
 void TabbedPanel::stateChanged()
index 5c9398a..7357229 100644 (file)
@@ -97,14 +97,16 @@ public:
 
 public slots:
     /**
-     * @brief Public slot that will close the panel unless already closed
+     * @brief Slot that closes the panel
      */
     void closePanel();
 
     /**
-     * @brief Public slot that will open the panel unless already open
+     * @brief Slot that shows the tab (and opens it if closed) with the desired widget
+     *
+     * @param widget Widget
      */
-    void openPanel();
+    void showPanel(QWidget *widget);
 
     /**
      * @brief Slot to redraw the panel after window resize event
@@ -113,14 +115,14 @@ public slots:
      */
     void resizePanel(const QSize &size);
 
+private slots:
     /**
-     * @brief Shows the tab at given index active
+     * @brief Sets the panel at current index active
      *
-     * @param index Index of the tab
+     * @param index Index of the panel
      */
-    void showTab(int index);
+    void setCurrentIndex(int index);
 
-private slots:
     /**
      * @brief Internal slot used to track statemachine state
      */
index 6dc7345..9f8325a 100644 (file)
@@ -3,6 +3,7 @@
     Copyright (C) 2010  Ixonos Plc. Authors:
 
         Kaj Wallin - kaj.wallin@ixonos.com
+        Pekka Nissinen - pekka.nissinen@ixonos.com
 
     Situare is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License
@@ -33,6 +34,8 @@ private slots:
     void testPanelToggling();
 };
 
+///< @todo Remove commented code. Add failing test case if there should be a unit test but it is not yet implemented
+
 //void TestTabbedPanel::testPanelTypes()
 //{
 //    SidePanel *testPanel = new SidePanel();
@@ -74,7 +77,10 @@ void TestTabbedPanel::testPanelToggling()
     testPanel->closePanel();
     QTest::qWait(1);
     QCOMPARE(toggleSpy.count(), 2);
+
     delete testPanel;
 }
+
 QTEST_MAIN(TestTabbedPanel)
+
 #include "testtabbedpanel.moc"