Adds API method ContainerWidget::isSectionContentVisible.

Updates demo project with example.
This commit is contained in:
mfreiholz 2016-04-21 07:51:26 +02:00
parent 1fb78aa873
commit 3a5cd2118a
4 changed files with 38 additions and 0 deletions

View File

@ -77,6 +77,11 @@ public:
*/ */
bool raiseSectionContent(const SectionContent::RefPtr& sc); bool raiseSectionContent(const SectionContent::RefPtr& sc);
/*!
* Indicates whether the SectionContent <em>sc</em> is visible.
*/
bool isSectionContentVisible(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

@ -278,6 +278,35 @@ bool ContainerWidget::raiseSectionContent(const SectionContent::RefPtr& sc)
return false; return false;
} }
bool ContainerWidget::isSectionContentVisible(const SectionContent::RefPtr& sc)
{
// Search SC in floatings
for (int i = 0; i < _floatings.count(); ++i)
{
const bool found = _floatings.at(i)->content()->uid() == sc->uid();
if (!found)
continue;
return _floatings.at(i)->isVisible();
}
// Search SC in sections
for (int i = 0; i < _sections.count(); ++i)
{
SectionWidget* sw = _sections.at(i);
const int index = sw->indexOfContent(sc);
if (index < 0)
continue;
return true;
}
// Search SC in hidden
if (_hiddenSectionContents.contains(sc->uid()))
return false;
qWarning() << "SectionContent is not a part of this ContainerWidget:" << sc->uniqueName();
return false;
}
QMenu* ContainerWidget::createContextMenu() const QMenu* ContainerWidget::createContextMenu() const
{ {
// Fill map with actions (sorted by key!) // Fill map with actions (sorted by key!)

View File

@ -6,6 +6,7 @@ SectionContentListModel::SectionContentListModel(QObject* parent) :
_headers.insert(UidColumn, "UID"); _headers.insert(UidColumn, "UID");
_headers.insert(UniqueNameColumn, "Unique Name"); _headers.insert(UniqueNameColumn, "Unique Name");
_headers.insert(TitleColumn, "Title"); _headers.insert(TitleColumn, "Title");
_headers.insert(VisibleColumn, "Visible");
} }
SectionContentListModel::~SectionContentListModel() SectionContentListModel::~SectionContentListModel()
@ -66,6 +67,8 @@ QVariant SectionContentListModel::data(const QModelIndex& index, int role) const
return sc->uniqueName(); return sc->uniqueName();
case TitleColumn: case TitleColumn:
return sc->title(); return sc->title();
case VisibleColumn:
return _cw->isSectionContentVisible(sc);
} }
} }
} }

View File

@ -23,6 +23,7 @@ public:
UidColumn, UidColumn,
UniqueNameColumn, UniqueNameColumn,
TitleColumn, TitleColumn,
VisibleColumn
}; };
SectionContentListModel(QObject* parent); SectionContentListModel(QObject* parent);