Tuning the ListItemContextButtonBar look
[situare] / src / ui / tabbedpanel.cpp
index 15b87da..3f130fc 100644 (file)
@@ -29,6 +29,7 @@
 #include <QStackedWidget>
 #include <QStateMachine>
 
+#include "listitemcontextbuttonbar.h"
 #include "panelbar.h"
 #include "panelbase.h"
 #include "panelcontentstack.h"
@@ -73,7 +74,7 @@ TabbedPanel::TabbedPanel(QWidget *parent)
     m_panelBar = new PanelBar(this);
     m_panelBar->move(PANEL_TAB_BAR_WIDTH, PANEL_TOP_Y);
 
-    // --- CONTEXT BUTTON BAR ---
+    // --- GENERIC PANEL CONTEXT BUTTON BAR ---
     m_panelContextButtonBar = new PanelContextButtonBar(this);
     m_panelContextButtonBar->move(PANEL_CONTEXT_BUTTON_BAR_LEFT_X, PANEL_HEIGHT);
 
@@ -83,9 +84,17 @@ TabbedPanel::TabbedPanel(QWidget *parent)
     connect(m_panelContextButtonBar, SIGNAL(positionChangeRequested()),
             this, SLOT(repositionContextButtonBar()));
 
+    // --- LIST ITEM RELATED CONTEXT BUTTONS BAR ---
+    m_itemContextButtonBar = new ListItemContextButtonBar(this);
+    m_itemContextButtonBar->hide();
+
+    connect(this, SIGNAL(listItemSelectionChanged(bool)),
+            m_itemContextButtonBar, SLOT(onListItemSelectionChanged(bool)));
+
     // --- PANEL CONTENT ---
     m_panelContentStack = new PanelContentStack(this);
     m_panelContentStack->move(PANEL_TAB_BAR_WIDTH + PANEL_BAR_WIDTH, PANEL_TOP_Y);
+    m_panelContentStack->stackUnder(m_itemContextButtonBar);
 
     // --- PANEL ANIMATION ---
     QStateMachine *panelStateMachine = new QStateMachine(this);
@@ -209,7 +218,7 @@ void TabbedPanel::repositionContextButtonBar()
     qDebug() << __PRETTY_FUNCTION__;
 
     m_panelContextButtonBar->move(PANEL_CONTEXT_BUTTON_BAR_LEFT_X, height());
-    
+
     calculateMask();
 }
 
@@ -252,7 +261,10 @@ void TabbedPanel::setCurrentIndex(int index)
             openPanel();
 
         m_panelContextButtonBar->setContextButtons(
-                static_cast<PanelBase *>(m_panelContentStack->widget(index))->contextButtons());
+                static_cast<PanelBase *>(m_panelContentStack->widget(index))->genericPanelButtons());
+
+        QWidget *itemContextButtons = static_cast<PanelBase *>(m_panelContentStack->widget(index))->itemButtons();
+        m_itemContextButtonBar->setContextButtons(itemContextButtons);
 
         emit currentChanged(index);
     }
@@ -265,11 +277,14 @@ void TabbedPanel::setTabsEnabled(const QList<int> &tabIndexes, bool enabled)
     QButtonGroup *tabs = m_panelTabBar->tabs();
 
     foreach (int tabIndex, tabIndexes) {
-
         QAbstractButton *tabButton = tabs->button(tabIndex);
 
-        if (tabButton)
+        if (tabButton) {
+            if (tabButton->isChecked())
+                closePanel();
+
             tabButton->setEnabled(enabled);
+        }
     }
 }