diff --git a/AdvancedDockingSystem/include/ads/ContainerWidget.h b/AdvancedDockingSystem/include/ads/ContainerWidget.h index d8e2262..3c8b383 100644 --- a/AdvancedDockingSystem/include/ads/ContainerWidget.h +++ b/AdvancedDockingSystem/include/ads/ContainerWidget.h @@ -63,6 +63,12 @@ public: */ bool hideSectionContent(const SectionContent::RefPtr& sc); + /*! + * Selects the specific SectionContent as current, if it is part of a SectionWidget. + * If SC is floating, it does nothing (or should we show it?) + */ + bool raiseSectionContent(const SectionContent::RefPtr& sc); + /*! * Creates a QMenu based on available SectionContents. * The caller is responsible to delete the menu. diff --git a/AdvancedDockingSystem/src/ContainerWidget.cpp b/AdvancedDockingSystem/src/ContainerWidget.cpp index 2c6591a..7f4de13 100644 --- a/AdvancedDockingSystem/src/ContainerWidget.cpp +++ b/AdvancedDockingSystem/src/ContainerWidget.cpp @@ -112,7 +112,10 @@ bool ContainerWidget::showSectionContent(const SectionContent::RefPtr& sc) return true; } } - qFatal("Unable to show SectionContent, don't know where 8-/"); + + // Already visible? + // TODO + qDebug("Unable to show SectionContent, don't know where 8-/ (already visible?)"); return false; } @@ -158,10 +161,46 @@ bool ContainerWidget::hideSectionContent(const SectionContent::RefPtr& sc) } return true; } + + // Search SC in hidden elements + // The content may already be hidden + if (_hiddenSectionContents.contains(sc->uid())) + return true; + qFatal("Unable to hide SectionContent, don't know this one 8-/"); return false; } +bool ContainerWidget::raiseSectionContent(const SectionContent::RefPtr& sc) +{ + // Search SC in sections + for (int i = 0; i < _sections.count(); ++i) + { + SectionWidget* sw = _sections.at(i); + int index = sw->indexOfContent(sc); + if (index < 0) + continue; + sw->setCurrentIndex(index); + return true; + } + + // Search SC in floatings + for (int i = 0; i < _floatings.size(); ++i) + { + FloatingWidget* fw = _floatings.at(i); + if (fw->content()->uid() != sc->uid()) + continue; + fw->setVisible(true); + fw->raise(); + return true; + } + + // Search SC in hidden + // TODO + + return false; +} + QMenu* ContainerWidget::createContextMenu() const { // Fill map with actions (sorted by key!)