mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-24 23:31:32 +08:00
Adds API method ContainerWidget::isSectionContentVisible.
Updates demo project with example.
This commit is contained in:
parent
1fb78aa873
commit
3a5cd2118a
@ -77,6 +77,11 @@ public:
|
||||
*/
|
||||
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.
|
||||
* The caller is responsible to delete the menu.
|
||||
|
@ -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!)
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ public:
|
||||
UidColumn,
|
||||
UniqueNameColumn,
|
||||
TitleColumn,
|
||||
VisibleColumn
|
||||
};
|
||||
|
||||
SectionContentListModel(QObject* parent);
|
||||
|
Loading…
Reference in New Issue
Block a user