# HG changeset patch # User Chris Cannam # Date 1327328920 0 # Node ID a7a89ebe4b0202f254c96631cb1e9a9d6d74d740 # Parent afed40a40d1d5ab42c59fd8249cd5fe74f30ccec Show current-pane indicator and close-pane button only if there is more than one pane diff -r afed40a40d1d -r a7a89ebe4b02 view/PaneStack.cpp --- a/view/PaneStack.cpp Fri Jan 13 17:43:06 2012 +0000 +++ b/view/PaneStack.cpp Mon Jan 23 14:28:40 2012 +0000 @@ -104,8 +104,6 @@ layout->addWidget(pane, 0, 1, 2, 1); layout->setColumnStretch(1, 20); - m_xButtonMap[xButton] = pane; - QWidget *properties = 0; if (suppressPropertyBox) { properties = new QFrame(); @@ -129,6 +127,7 @@ PaneRec rec; rec.pane = pane; rec.propertyStack = properties; + rec.xButton = xButton; rec.currentIndicator = currentIndicator; rec.frame = frame; rec.layout = layout; @@ -157,6 +156,8 @@ setCurrentPane(pane); } + showOrHidePaneAccessories(); + return pane; } @@ -263,15 +264,6 @@ emit paneAboutToBeDeleted(pane); - for (std::map::iterator i = m_xButtonMap.begin(); - i != m_xButtonMap.end(); ++i) { - - if (i->second == pane) { - m_xButtonMap.erase(i); - break; - } - } - delete pane->parent(); if (m_currentPane == pane) { @@ -282,9 +274,24 @@ } } + showOrHidePaneAccessories(); + emit paneDeleted(); } +void +PaneStack::showOrHidePaneAccessories() +{ + std::cerr << "PaneStack::showOrHidePaneAccessories: count == " << getPaneCount() << std::endl; + + bool multi = (getPaneCount() > 1); + for (std::vector::iterator i = m_panes.begin(); + i != m_panes.end(); ++i) { + i->xButton->setVisible(multi); + i->currentIndicator->setVisible(multi); + } +} + int PaneStack::getPaneCount() const { @@ -319,14 +326,15 @@ } } + showOrHidePaneAccessories(); + emit paneHidden(pane); + emit paneHidden(); return; } ++i; } std::cerr << "WARNING: PaneStack::hidePane(" << pane << "): Pane not found in visible panes" << std::endl; - emit paneHidden(pane); - emit paneHidden(); } void @@ -343,6 +351,8 @@ //!!! update current pane + showOrHidePaneAccessories(); + return; } ++i; @@ -541,11 +551,9 @@ PaneStack::paneDeleteButtonClicked() { QObject *s = sender(); - QWidget *w = dynamic_cast(s); - if (w) { - if (m_xButtonMap.find(w) != m_xButtonMap.end()) { - Pane *p = m_xButtonMap[w]; - emit paneDeleteButtonClicked(p); + for (size_t i = 0; i < m_panes.size(); ++i) { + if (m_panes[i].xButton == s) { + emit paneDeleteButtonClicked(m_panes[i].pane); } } } diff -r afed40a40d1d -r a7a89ebe4b02 view/PaneStack.h --- a/view/PaneStack.h Fri Jan 13 17:43:06 2012 +0000 +++ b/view/PaneStack.h Mon Jan 23 14:28:40 2012 +0000 @@ -25,6 +25,7 @@ class QStackedWidget; class QSplitter; class QGridLayout; +class QPushButton; class View; class Pane; class Layer; @@ -109,6 +110,7 @@ { Pane *pane; QWidget *propertyStack; + QPushButton *xButton; QLabel *currentIndicator; QFrame *frame; QGridLayout *layout; @@ -117,8 +119,6 @@ std::vector m_panes; std::vector m_hiddenPanes; - std::map m_xButtonMap; - QSplitter *m_splitter; QStackedWidget *m_propertyStackStack; @@ -126,6 +126,8 @@ int m_propertyStackMinWidth; void sizePropertyStacks(); + void showOrHidePaneAccessories(); + LayoutStyle m_layoutStyle; };