bool ContainerWidget::hideSectionContent(const SectionContent::RefPtr& sc) { // Search SC in floatings // We can simply hide floatings, nothing else required. for (int i = 0; i < _floatings.count(); ++i) { const bool found = _floatings.at(i)->content()->uid() == sc->uid(); if (!found) continue; _floatings.at(i)->setVisible(false); emit sectionContentVisibilityChanged(sc, false); return true; } // Search SC in sections // It's required to remove the SC from SW completely and hold it in a // separate list as long as a "showSectionContent" gets called for the SC again. // In case that the SW does not have any other SCs, we need to delete it. for (int i = 0; i < _sections.count(); ++i) { SectionWidget* sw = _sections.at(i); const bool found = sw->indexOfContent(sc) >= 0; if (!found) continue; HiddenSectionItem hsi; hsi.preferredSectionId = sw->uid(); hsi.preferredSectionIndex = sw->indexOfContent(sc); if (!sw->takeContent(sc->uid(), hsi.data)) return false; hsi.data.titleWidget->setVisible(false); hsi.data.contentWidget->setVisible(false); _hiddenSectionContents.insert(sc->uid(), hsi); if (sw->contents().isEmpty()) { delete sw; sw = NULL; deleteEmptySplitter(this); } emit sectionContentVisibilityChanged(sc, false); 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 if (_hiddenSectionContents.contains(sc->uid())) return showSectionContent(sc); qFatal("Unable to hide SectionContent, don't know this one 8-/"); return false; }