diff --git a/AdvancedDockingSystem/include/ads/ContainerWidget.h b/AdvancedDockingSystem/include/ads/ContainerWidget.h index b1c142c..a32bb72 100644 --- a/AdvancedDockingSystem/include/ads/ContainerWidget.h +++ b/AdvancedDockingSystem/include/ads/ContainerWidget.h @@ -77,6 +77,11 @@ public: */ bool raiseSectionContent(const SectionContent::RefPtr& sc); + /*! + * Indicates whether the SectionContent sc is visible. + */ + bool isSectionContentVisible(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 22aa00b..7be5df4 100644 --- a/AdvancedDockingSystem/src/ContainerWidget.cpp +++ b/AdvancedDockingSystem/src/ContainerWidget.cpp @@ -278,6 +278,35 @@ bool ContainerWidget::raiseSectionContent(const SectionContent::RefPtr& sc) 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 { // Fill map with actions (sorted by key!) diff --git a/AdvancedDockingSystemDemo/src/dialogs/SectionContentListModel.cpp b/AdvancedDockingSystemDemo/src/dialogs/SectionContentListModel.cpp index 4e64381..11885fb 100644 --- a/AdvancedDockingSystemDemo/src/dialogs/SectionContentListModel.cpp +++ b/AdvancedDockingSystemDemo/src/dialogs/SectionContentListModel.cpp @@ -6,6 +6,7 @@ SectionContentListModel::SectionContentListModel(QObject* parent) : _headers.insert(UidColumn, "UID"); _headers.insert(UniqueNameColumn, "Unique Name"); _headers.insert(TitleColumn, "Title"); + _headers.insert(VisibleColumn, "Visible"); } SectionContentListModel::~SectionContentListModel() @@ -66,6 +67,8 @@ QVariant SectionContentListModel::data(const QModelIndex& index, int role) const return sc->uniqueName(); case TitleColumn: return sc->title(); + case VisibleColumn: + return _cw->isSectionContentVisible(sc); } } } diff --git a/AdvancedDockingSystemDemo/src/dialogs/SectionContentListModel.h b/AdvancedDockingSystemDemo/src/dialogs/SectionContentListModel.h index 95a6c60..2f0bcaf 100644 --- a/AdvancedDockingSystemDemo/src/dialogs/SectionContentListModel.h +++ b/AdvancedDockingSystemDemo/src/dialogs/SectionContentListModel.h @@ -23,6 +23,7 @@ public: UidColumn, UniqueNameColumn, TitleColumn, + VisibleColumn }; SectionContentListModel(QObject* parent);