コード例 #1
0
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;
}
コード例 #2
0
bool ContainerWidget::showSectionContent(const SectionContent::RefPtr& sc)
{
	// Search SC in floatings
	for (int i = 0; i < _floatings.count(); ++i)
	{
		FloatingWidget* fw = _floatings.at(i);
		const bool found = fw->content()->uid() == sc->uid();
		if (!found)
			continue;
		fw->setVisible(true);
		fw->_titleWidget->setVisible(true);
		fw->_contentWidget->setVisible(true);
		emit sectionContentVisibilityChanged(sc, true);
		return true;
	}

	// Search SC in hidden sections
	// Try to show them in the last position, otherwise simply append
	// it to the first section (or create a new section?)
	if (_hiddenSectionContents.contains(sc->uid()))
	{
		const HiddenSectionItem hsi = _hiddenSectionContents.take(sc->uid());
		hsi.data.titleWidget->setVisible(true);
		hsi.data.contentWidget->setVisible(true);
		SectionWidget* sw = NULL;
		if (hsi.preferredSectionId > 0 && (sw = SWLookupMapById(this).value(hsi.preferredSectionId)) != NULL)
		{
			sw->addContent(hsi.data, true);
			emit sectionContentVisibilityChanged(sc, true);
			return true;
		}
		else if (_sections.size() > 0 && (sw = _sections.first()) != NULL)
		{
			sw->addContent(hsi.data, true);
			emit sectionContentVisibilityChanged(sc, true);
			return true;
		}
		else
		{
			sw = newSectionWidget();
			addSection(sw);
			sw->addContent(hsi.data, true);
			emit sectionContentVisibilityChanged(sc, true);
			return true;
		}
	}

	// Already visible?
	// TODO
	qWarning("Unable to show SectionContent, don't know where 8-/ (already visible?)");
	return false;
}