Added method to disable tabs.
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Wed, 1 Sep 2010 11:18:51 +0000 (14:18 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Wed, 1 Sep 2010 11:18:51 +0000 (14:18 +0300)
src/engine/engine.cpp
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/paneltab.cpp
src/ui/paneltabbar.cpp
src/ui/paneltabbar.h
src/ui/tabbedpanel.cpp
src/ui/tabbedpanel.h

index 8b0ac3c..e36f76b 100644 (file)
@@ -793,7 +793,6 @@ void SituareEngine::userDataChanged(User *user, QList<User *> &friendsList)
     qDebug() << __PRETTY_FUNCTION__;
 
     m_ui->toggleProgressIndicator(false);
-    m_ui->showPanels();
 
     emit userLocationReady(user);
     emit friendsLocationsReady(friendsList);
index 0d4c574..3766c2c 100644 (file)
@@ -324,8 +324,10 @@ void MainWindow::buildPanels()
     buildRoutingPanel();
 
     m_tabbedPanel = new TabbedPanel(this);
-    m_tabbedPanel->addTab(m_userInfoPanel, QIcon(":/res/images/user_info.png"));
-    m_tabbedPanel->addTab(m_friendsListPanel, QIcon(":/res/images/friend_list.png"));
+    m_situareTabsIndexes.append(
+            m_tabbedPanel->addTab(m_userInfoPanel, QIcon(":/res/images/user_info.png")));
+    m_situareTabsIndexes.append(
+            m_tabbedPanel->addTab(m_friendsListPanel, QIcon(":/res/images/friend_list.png")));
     m_tabbedPanel->addTab(m_routingPanel, QIcon(":/res/images/routing.png"));
 
     connect(m_mapView, SIGNAL(viewResized(QSize)),
@@ -952,25 +954,6 @@ void MainWindow::showInformationBox()
     }
 }
 
-void MainWindow::showPanels()
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-///< @todo check how this is called and can this method be removed
-
-//    if(m_loggedIn) {
-//        if(!m_friendsListPanel->isVisible()) {
-//            m_friendsListPanel->show();
-//            m_friendsListPanelSidebar->show();
-//        }
-
-//        if(!m_userPanel->isVisible()) {
-//            m_userPanel->show();
-//            m_userPanelSidebar->show();
-//        }
-//    }
-}
-
 void MainWindow::startLocationSearch()
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -1029,17 +1012,10 @@ void MainWindow::updateItemVisibility()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-///< @todo can this be removed?
-
-//    if(!m_loggedIn) {
-//        m_friendsListPanel->closePanel();
-//        m_friendsListPanel->hide();
-//        m_friendsListPanelSidebar->hide();
+    if (!m_loggedIn)
+        m_tabbedPanel->closePanel();
 
-//        m_userPanel->closePanel();
-//        m_userPanel->hide();
-//        m_userPanelSidebar->hide();
-//    }
+    m_tabbedPanel->setTabsEnabled(m_situareTabsIndexes, m_loggedIn);
 }
 
 const QString MainWindow::username()
index 044a1c4..5111c9e 100644 (file)
@@ -198,11 +198,6 @@ public slots:
     void setUsername(const QString &username);
 
     /**
-     * @brief Method to show panels
-     */
-    void showPanels();
-
-    /**
      * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
      *        doesn't exist yet
      */
@@ -674,6 +669,7 @@ private:
     QLabel *m_crosshair;                    ///< Label for center point crosshair
     QLabel *m_osmLicense;                   ///< Label for Open Street Map license
 
+    QList<int> m_situareTabsIndexes;        ///< List of Situare tab indexes
     QList<QDialog *> m_error_queue;         ///< QList type error dialog queue
     QList<QDialog *> m_queue;               ///< QList type dialog queue
 
index 19b1240..b048f51 100644 (file)
@@ -111,6 +111,8 @@ void PanelTab::paintEvent(QPaintEvent *event)
         icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Selected);
     else if (isChecked())
         icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Normal);
-    else
+    else if (!isEnabled())
         icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Disabled);
+    else
+        icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Normal);
 }
index 7b7cdd5..2560886 100644 (file)
@@ -128,3 +128,10 @@ void PanelTabBar::setUpTabLayout()
 
     emit sizeChangeRequested();
 }
+
+QButtonGroup *PanelTabBar::tabs() const
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    return m_tabButtonGroup;
+}
index 35ed793..ddf170e 100644 (file)
@@ -78,6 +78,13 @@ public:
      */
     void removeTab(int index);
 
+    /**
+    * @brief Returns all tabs.
+    *
+    * @return All tabs
+    */
+    QButtonGroup *tabs() const;
+
 private:
     /**
      * @brief Initializes and formats tab buttons layout
index 50f0344..15b87da 100644 (file)
@@ -20,6 +20,8 @@
     USA.
 */
 
+#include <QAbstractButton>
+#include <QButtonGroup>
 #include <QDebug>
 #include <QPropertyAnimation>
 #include <QRegion>
@@ -256,6 +258,21 @@ void TabbedPanel::setCurrentIndex(int index)
     }
 }
 
+void TabbedPanel::setTabsEnabled(const QList<int> &tabIndexes, bool enabled)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    QButtonGroup *tabs = m_panelTabBar->tabs();
+
+    foreach (int tabIndex, tabIndexes) {
+
+        QAbstractButton *tabButton = tabs->button(tabIndex);
+
+        if (tabButton)
+            tabButton->setEnabled(enabled);
+    }
+}
+
 void TabbedPanel::stateChanged()
 {
     qDebug() << __PRETTY_FUNCTION__;
index d3e1f16..c65dbbc 100644 (file)
@@ -95,6 +95,14 @@ public:
      */
     void removeTab(int index);
 
+    /**
+    * @brief Sets tabs enabled.
+    *
+    * @param tabIndexes tab indexes to set
+    * @param enabled true if should be enabled, false otherwise
+    */
+    void setTabsEnabled(const QList<int> &tabIndexes, bool enabled);
+
 public slots:
     /**
      * @brief Slot that closes the panel