Adds function to raise a section-content.

This commit is contained in:
mfreiholz 2016-02-24 11:45:19 +01:00
parent 747874b1e5
commit 7e41d18a6d
2 changed files with 46 additions and 1 deletions

View File

@ -63,6 +63,12 @@ public:
*/ */
bool hideSectionContent(const SectionContent::RefPtr& sc); 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. * Creates a QMenu based on available SectionContents.
* The caller is responsible to delete the menu. * The caller is responsible to delete the menu.

View File

@ -112,7 +112,10 @@ bool ContainerWidget::showSectionContent(const SectionContent::RefPtr& sc)
return true; 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; return false;
} }
@ -158,10 +161,46 @@ bool ContainerWidget::hideSectionContent(const SectionContent::RefPtr& sc)
} }
return true; 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-/"); qFatal("Unable to hide SectionContent, don't know this one 8-/");
return false; 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 QMenu* ContainerWidget::createContextMenu() const
{ {
// Fill map with actions (sorted by key!) // Fill map with actions (sorted by key!)